diff --git a/lib/PhpParser/Autoloader.php b/lib/PhpParser/Autoloader.php index 809a06ed8d..d68f01669d 100644 --- a/lib/PhpParser/Autoloader.php +++ b/lib/PhpParser/Autoloader.php @@ -15,7 +15,7 @@ class Autoloader * * @param bool $prepend Whether to prepend the autoloader instead of appending */ - static public function register($prepend = false) { + static public function register(bool $prepend = false) { if (self::$registered === true) { return; } @@ -29,7 +29,7 @@ static public function register($prepend = false) { * * @param string $class A class name. */ - static public function autoload($class) { + static public function autoload(string $class) { if (0 === strpos($class, 'PhpParser\\')) { $fileName = __DIR__ . strtr(substr($class, 9), '\\', '/') . '.php'; if (file_exists($fileName)) { diff --git a/lib/PhpParser/Builder.php b/lib/PhpParser/Builder.php index 95655e8200..02fd198ed2 100644 --- a/lib/PhpParser/Builder.php +++ b/lib/PhpParser/Builder.php @@ -9,5 +9,5 @@ interface Builder * * @return Node The built node */ - public function getNode(); + public function getNode() : Node; } \ No newline at end of file diff --git a/lib/PhpParser/Builder/Class_.php b/lib/PhpParser/Builder/Class_.php index b1400ca0a9..5bb65a449c 100644 --- a/lib/PhpParser/Builder/Class_.php +++ b/lib/PhpParser/Builder/Class_.php @@ -25,7 +25,7 @@ class Class_ extends Declaration * * @param string $name Name of the class */ - public function __construct($name) { + public function __construct(string $name) { $this->name = $name; } @@ -111,7 +111,7 @@ public function addStmt($stmt) { * * @return Stmt\Class_ The built class node */ - public function getNode() { + public function getNode() : PhpParser\Node { return new Stmt\Class_($this->name, array( 'flags' => $this->flags, 'extends' => $this->extends, diff --git a/lib/PhpParser/Builder/Function_.php b/lib/PhpParser/Builder/Function_.php index 3b694ed744..d341413d61 100644 --- a/lib/PhpParser/Builder/Function_.php +++ b/lib/PhpParser/Builder/Function_.php @@ -17,7 +17,7 @@ class Function_ extends FunctionLike * * @param string $name Name of the function */ - public function __construct($name) { + public function __construct(string $name) { $this->name = $name; } @@ -39,7 +39,7 @@ public function addStmt($stmt) { * * @return Stmt\Function_ The built function node */ - public function getNode() { + public function getNode() : Node { return new Stmt\Function_($this->name, array( 'byRef' => $this->returnByRef, 'params' => $this->params, diff --git a/lib/PhpParser/Builder/Interface_.php b/lib/PhpParser/Builder/Interface_.php index f6c3fc9308..908c9ca8e6 100644 --- a/lib/PhpParser/Builder/Interface_.php +++ b/lib/PhpParser/Builder/Interface_.php @@ -19,7 +19,7 @@ class Interface_ extends Declaration * * @param string $name Name of the interface */ - public function __construct($name) { + public function __construct(string $name) { $this->name = $name; } @@ -72,7 +72,7 @@ public function addStmt($stmt) { * * @return Stmt\Interface_ The built interface node */ - public function getNode() { + public function getNode() : PhpParser\Node { return new Stmt\Interface_($this->name, array( 'extends' => $this->extends, 'stmts' => array_merge($this->constants, $this->methods), diff --git a/lib/PhpParser/Builder/Method.php b/lib/PhpParser/Builder/Method.php index ef7280476b..a89f02f53c 100644 --- a/lib/PhpParser/Builder/Method.php +++ b/lib/PhpParser/Builder/Method.php @@ -20,7 +20,7 @@ class Method extends FunctionLike * * @param string $name Name of the method */ - public function __construct($name) { + public function __construct(string $name) { $this->name = $name; } @@ -117,7 +117,7 @@ public function addStmt($stmt) { * * @return Stmt\ClassMethod The built method node */ - public function getNode() { + public function getNode() : Node { return new Stmt\ClassMethod($this->name, array( 'flags' => $this->flags, 'byRef' => $this->returnByRef, diff --git a/lib/PhpParser/Builder/Namespace_.php b/lib/PhpParser/Builder/Namespace_.php index 605ca9534a..8504e99aeb 100644 --- a/lib/PhpParser/Builder/Namespace_.php +++ b/lib/PhpParser/Builder/Namespace_.php @@ -54,7 +54,7 @@ public function addStmts(array $stmts) { * * @return Node The built node */ - public function getNode() { + public function getNode() : Node { return new Stmt\Namespace_($this->name, $this->stmts); } } diff --git a/lib/PhpParser/Builder/Param.php b/lib/PhpParser/Builder/Param.php index 9ac1d30770..53d16e08e2 100644 --- a/lib/PhpParser/Builder/Param.php +++ b/lib/PhpParser/Builder/Param.php @@ -24,7 +24,7 @@ class Param implements PhpParser\Builder * * @param string $name Name of the parameter */ - public function __construct($name) { + public function __construct(string $name) { $this->name = $name; } @@ -84,7 +84,7 @@ public function makeVariadic() { * * @return Node\Param The built parameter node */ - public function getNode() { + public function getNode() : Node { return new Node\Param( new Node\Expr\Variable($this->name), $this->default, $this->type, $this->byRef, $this->variadic diff --git a/lib/PhpParser/Builder/Property.php b/lib/PhpParser/Builder/Property.php index 0a0ad17837..b7f88fc0d9 100644 --- a/lib/PhpParser/Builder/Property.php +++ b/lib/PhpParser/Builder/Property.php @@ -19,7 +19,7 @@ class Property implements PhpParser\Builder * * @param string $name Name of the property */ - public function __construct($name) { + public function __construct(string $name) { $this->name = $name; } @@ -100,7 +100,7 @@ public function setDocComment($docComment) { * * @return Stmt\Property The built property node */ - public function getNode() { + public function getNode() : PhpParser\Node { return new Stmt\Property( $this->flags !== 0 ? $this->flags : Stmt\Class_::MODIFIER_PUBLIC, array( diff --git a/lib/PhpParser/Builder/Trait_.php b/lib/PhpParser/Builder/Trait_.php index 350f97de09..5096dfb5ea 100644 --- a/lib/PhpParser/Builder/Trait_.php +++ b/lib/PhpParser/Builder/Trait_.php @@ -17,7 +17,7 @@ class Trait_ extends Declaration * * @param string $name Name of the interface */ - public function __construct($name) { + public function __construct(string $name) { $this->name = $name; } @@ -47,7 +47,7 @@ public function addStmt($stmt) { * * @return Stmt\Trait_ The built interface node */ - public function getNode() { + public function getNode() : PhpParser\Node { return new Stmt\Trait_( $this->name, array( 'stmts' => array_merge($this->properties, $this->methods) diff --git a/lib/PhpParser/Builder/Use_.php b/lib/PhpParser/Builder/Use_.php index 59850c9bc6..c25e78f7d8 100644 --- a/lib/PhpParser/Builder/Use_.php +++ b/lib/PhpParser/Builder/Use_.php @@ -21,7 +21,7 @@ class Use_ implements Builder { * @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias * @param int $type One of the Stmt\Use_::TYPE_* constants */ - public function __construct($name, $type) { + public function __construct($name, int $type) { $this->name = BuilderHelpers::normalizeName($name); $this->type = $type; } @@ -33,7 +33,7 @@ public function __construct($name, $type) { * * @return $this The builder instance (for fluid interface) */ - protected function as_($alias) { + protected function as_(string $alias) { $this->alias = $alias; return $this; } @@ -50,7 +50,7 @@ public function __call($name, $args) { * * @return Node The built node */ - public function getNode() { + public function getNode() : Node { return new Stmt\Use_(array( new Stmt\UseUse($this->name, $this->alias) ), $this->type); diff --git a/lib/PhpParser/BuilderFactory.php b/lib/PhpParser/BuilderFactory.php index 488a333890..e07630bbdb 100644 --- a/lib/PhpParser/BuilderFactory.php +++ b/lib/PhpParser/BuilderFactory.php @@ -29,7 +29,7 @@ class BuilderFactory * * @return Builder\Namespace_ The created namespace builder */ - protected function _namespace($name) { + protected function _namespace($name) : Builder\Namespace_ { return new Builder\Namespace_($name); } @@ -40,7 +40,7 @@ protected function _namespace($name) { * * @return Builder\Class_ The created class builder */ - protected function _class($name) { + protected function _class(string $name) : Builder\Class_ { return new Builder\Class_($name); } @@ -51,7 +51,7 @@ protected function _class($name) { * * @return Builder\Interface_ The created interface builder */ - protected function _interface($name) { + protected function _interface(string $name) : Builder\Interface_ { return new Builder\Interface_($name); } @@ -62,7 +62,7 @@ protected function _interface($name) { * * @return Builder\Trait_ The created trait builder */ - protected function _trait($name) { + protected function _trait(string $name) : Builder\Trait_ { return new Builder\Trait_($name); } @@ -73,7 +73,7 @@ protected function _trait($name) { * * @return Builder\Method The created method builder */ - public function method($name) { + public function method(string $name) : Builder\Method { return new Builder\Method($name); } @@ -84,7 +84,7 @@ public function method($name) { * * @return Builder\Param The created parameter builder */ - public function param($name) { + public function param(string $name) : Builder\Param { return new Builder\Param($name); } @@ -95,7 +95,7 @@ public function param($name) { * * @return Builder\Property The created property builder */ - public function property($name) { + public function property(string $name) : Builder\Property { return new Builder\Property($name); } @@ -106,7 +106,7 @@ public function property($name) { * * @return Builder\Function_ The created function builder */ - protected function _function($name) { + protected function _function(string $name) : Builder\Function_ { return new Builder\Function_($name); } @@ -117,7 +117,7 @@ protected function _function($name) { * * @return Builder\Use_ The create use builder */ - protected function _use($name) { + protected function _use($name) : Builder\Use_ { return new Builder\Use_($name, Use_::TYPE_NORMAL); } @@ -128,7 +128,7 @@ protected function _use($name) { * * @return Expr */ - public function val($value) { + public function val($value) : Expr { return BuilderHelpers::normalizeValue($value); } @@ -141,7 +141,7 @@ public function val($value) { * * @return Arg[] */ - public function args(array $args) { + public function args(array $args) : array { $normalizedArgs = []; foreach ($args as $arg) { if ($arg instanceof Arg) { @@ -160,7 +160,7 @@ public function args(array $args) { * * @return Concat */ - public function concat(...$exprs) { + public function concat(...$exprs) : Concat { $numExprs = count($exprs); if ($numExprs < 2) { throw new \LogicException('Expected at least two expressions'); diff --git a/lib/PhpParser/BuilderHelpers.php b/lib/PhpParser/BuilderHelpers.php index 85108733d3..eddd700eab 100644 --- a/lib/PhpParser/BuilderHelpers.php +++ b/lib/PhpParser/BuilderHelpers.php @@ -23,7 +23,7 @@ final class BuilderHelpers { * * @return Node The normalized node */ - public static function normalizeNode($node) { + public static function normalizeNode($node) : Node { if ($node instanceof Builder) { return $node->getNode(); } elseif ($node instanceof Node) { @@ -42,7 +42,7 @@ public static function normalizeNode($node) { * * @return Stmt The normalized statement node */ - public static function normalizeStmt($node) { + public static function normalizeStmt($node) : Stmt { $node = self::normalizeNode($node); if ($node instanceof Stmt) { return $node; @@ -62,7 +62,7 @@ public static function normalizeStmt($node) { * * @return Name The normalized name */ - public static function normalizeName($name) { + public static function normalizeName($name) : Name { if ($name instanceof Name) { return $name; } elseif (is_string($name)) { @@ -134,7 +134,7 @@ public static function normalizeType($type) { * * @return Expr The normalized value */ - public static function normalizeValue($value) { + public static function normalizeValue($value) : Expr { if ($value instanceof Node\Expr) { return $value; } elseif (is_null($value)) { @@ -182,7 +182,7 @@ public static function normalizeValue($value) { * * @return Comment\Doc The normalized doc comment */ - public static function normalizeDocComment($docComment) { + public static function normalizeDocComment($docComment) : Comment\Doc { if ($docComment instanceof Comment\Doc) { return $docComment; } else if (is_string($docComment)) { @@ -200,7 +200,7 @@ public static function normalizeDocComment($docComment) { * * @return int New modifiers */ - public static function addModifier($modifiers, $modifier) { + public static function addModifier(int $modifiers, int $modifier) : int { Stmt\Class_::verifyModifier($modifiers, $modifier); return $modifiers | $modifier; } diff --git a/lib/PhpParser/Comment.php b/lib/PhpParser/Comment.php index 9408d4cf85..aec4acfae0 100644 --- a/lib/PhpParser/Comment.php +++ b/lib/PhpParser/Comment.php @@ -15,7 +15,7 @@ class Comment implements \JsonSerializable * @param int $startLine Line number the comment started on * @param int $startFilePos File offset the comment started on */ - public function __construct($text, $startLine = -1, $startFilePos = -1) { + public function __construct(string $text, int $startLine = -1, int $startFilePos = -1) { $this->text = $text; $this->line = $startLine; $this->filePos = $startFilePos; @@ -26,7 +26,7 @@ public function __construct($text, $startLine = -1, $startFilePos = -1) { * * @return string The comment text (including comment delimiters like /*) */ - public function getText() { + public function getText() : string { return $this->text; } @@ -35,7 +35,7 @@ public function getText() { * * @return int Line number */ - public function getLine() { + public function getLine() : int { return $this->line; } @@ -44,7 +44,7 @@ public function getLine() { * * @return int File offset */ - public function getFilePos() { + public function getFilePos() : int { return $this->filePos; } @@ -53,7 +53,7 @@ public function getFilePos() { * * @return string The comment text (including comment delimiters like /*) */ - public function __toString() { + public function __toString() : string { return $this->text; } @@ -122,7 +122,7 @@ public function getReformattedText() { * @param string $str String to check * @return int Length in characters. Tabs count as single characters. */ - private function getShortestWhitespacePrefixLen($str) { + private function getShortestWhitespacePrefixLen(string $str) : int { $lines = explode("\n", $str); $shortestPrefixLen = INF; foreach ($lines as $line) { @@ -139,7 +139,7 @@ private function getShortestWhitespacePrefixLen($str) { * @return array * @psalm-return array{nodeType:string, text:mixed, line:mixed, filePos:mixed} */ - public function jsonSerialize() { + public function jsonSerialize() : array { // Technically not a node, but we make it look like one anyway $type = $this instanceof Comment\Doc ? 'Comment_Doc' : 'Comment'; return [ diff --git a/lib/PhpParser/Error.php b/lib/PhpParser/Error.php index b455a5ce72..e9d2eb9e2c 100644 --- a/lib/PhpParser/Error.php +++ b/lib/PhpParser/Error.php @@ -14,7 +14,7 @@ class Error extends \RuntimeException * @param array|int $attributes Attributes of node/token where error occurred * (or start line of error -- deprecated) */ - public function __construct($message, $attributes = array()) { + public function __construct(string $message, $attributes = array()) { $this->rawMessage = (string) $message; if (is_array($attributes)) { $this->attributes = $attributes; @@ -29,7 +29,7 @@ public function __construct($message, $attributes = array()) { * * @return string Error message */ - public function getRawMessage() { + public function getRawMessage() : string { return $this->rawMessage; } @@ -38,7 +38,7 @@ public function getRawMessage() { * * @return int Error start line */ - public function getStartLine() { + public function getStartLine() : int { return $this->attributes['startLine'] ?? -1; } @@ -47,7 +47,7 @@ public function getStartLine() { * * @return int Error end line */ - public function getEndLine() { + public function getEndLine() : int { return $this->attributes['endLine'] ?? -1; } @@ -57,7 +57,7 @@ public function getEndLine() { * * @return array */ - public function getAttributes() { + public function getAttributes() : array { return $this->attributes; } @@ -76,7 +76,7 @@ public function setAttributes(array $attributes) { * * @param string $message Error message */ - public function setRawMessage($message) { + public function setRawMessage(string $message) { $this->rawMessage = (string) $message; $this->updateMessage(); } @@ -86,7 +86,7 @@ public function setRawMessage($message) { * * @param int $line Error start line */ - public function setStartLine($line) { + public function setStartLine(int $line) { $this->attributes['startLine'] = (int) $line; $this->updateMessage(); } @@ -98,7 +98,7 @@ public function setStartLine($line) { * * @return bool */ - public function hasColumnInfo() { + public function hasColumnInfo() : bool { return isset($this->attributes['startFilePos']) && isset($this->attributes['endFilePos']); } @@ -108,7 +108,7 @@ public function hasColumnInfo() { * @param string $code Source code of the file * @return int */ - public function getStartColumn($code) { + public function getStartColumn(string $code) : int { if (!$this->hasColumnInfo()) { throw new \RuntimeException('Error does not have column information'); } @@ -122,7 +122,7 @@ public function getStartColumn($code) { * @param string $code Source code of the file * @return int */ - public function getEndColumn($code) { + public function getEndColumn(string $code) : int { if (!$this->hasColumnInfo()) { throw new \RuntimeException('Error does not have column information'); } @@ -137,7 +137,7 @@ public function getEndColumn($code) { * * @return string Formatted message */ - public function getMessageWithColumnInfo($code) { + public function getMessageWithColumnInfo(string $code) : string { return sprintf( '%s from %d:%d to %d:%d', $this->getRawMessage(), $this->getStartLine(), $this->getStartColumn($code), @@ -153,7 +153,7 @@ public function getMessageWithColumnInfo($code) { * * @return int 1-based column (relative to start of line) */ - private function toColumn($code, $pos) { + private function toColumn(string $code, int $pos) : int { if ($pos > strlen($code)) { throw new \RuntimeException('Invalid position information'); } diff --git a/lib/PhpParser/ErrorHandler/Collecting.php b/lib/PhpParser/ErrorHandler/Collecting.php index 99290f0466..b6fdf11ea7 100644 --- a/lib/PhpParser/ErrorHandler/Collecting.php +++ b/lib/PhpParser/ErrorHandler/Collecting.php @@ -24,7 +24,7 @@ public function handleError(Error $error) { * * @return Error[] */ - public function getErrors() { + public function getErrors() : array { return $this->errors; } @@ -33,7 +33,7 @@ public function getErrors() { * * @return bool */ - public function hasErrors() { + public function hasErrors() : bool { return !empty($this->errors); } diff --git a/lib/PhpParser/Lexer.php b/lib/PhpParser/Lexer.php index f89ef8ac56..32788e136f 100644 --- a/lib/PhpParser/Lexer.php +++ b/lib/PhpParser/Lexer.php @@ -55,7 +55,7 @@ public function __construct(array $options = array()) { * @param ErrorHandler|null $errorHandler Error handler to use for lexing errors. Defaults to * ErrorHandler\Throwing */ - public function startLexing($code, ErrorHandler $errorHandler = null) { + public function startLexing(string $code, ErrorHandler $errorHandler = null) { if (null === $errorHandler) { $errorHandler = new ErrorHandler\Throwing(); } @@ -122,7 +122,7 @@ private function handleInvalidCharacterRange($start, $end, $line, ErrorHandler $ * * @return bool */ - private function isUnterminatedComment($token) { + private function isUnterminatedComment($token) : bool { return ($token[0] === T_COMMENT || $token[0] === T_DOC_COMMENT) && substr($token[1], 0, 2) === '/*' && substr($token[1], -2) !== '*/'; @@ -133,7 +133,7 @@ private function isUnterminatedComment($token) { * * @return bool */ - private function errorMayHaveOccurred() { + private function errorMayHaveOccurred() : bool { if (defined('HHVM_VERSION')) { // In HHVM token_get_all() does not throw warnings, so we need to conservatively // assume that an error occurred @@ -229,7 +229,7 @@ protected function handleErrors(ErrorHandler $errorHandler) { * * @return int Token id */ - public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) { + public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) : int { $startAttributes = array(); $endAttributes = array(); @@ -313,7 +313,7 @@ public function getNextToken(&$value = null, &$startAttributes = null, &$endAttr * * @return array Array of tokens in token_get_all() format */ - public function getTokens() { + public function getTokens() : array { return $this->tokens; } @@ -322,7 +322,7 @@ public function getTokens() { * * @return string Remaining text */ - public function handleHaltCompiler() { + public function handleHaltCompiler() : string { // text after T_HALT_COMPILER, still including (); $textAfter = substr($this->code, $this->filePos); @@ -349,7 +349,7 @@ public function handleHaltCompiler() { * * @return array The token map */ - protected function createTokenMap() { + protected function createTokenMap() : array { $tokenMap = array(); // 256 is the minimum possible token number, as everything below diff --git a/lib/PhpParser/NameContext.php b/lib/PhpParser/NameContext.php index 2f6e19d2f1..ce9a9a4a02 100644 --- a/lib/PhpParser/NameContext.php +++ b/lib/PhpParser/NameContext.php @@ -53,7 +53,7 @@ public function startNamespace(Name $namespace = null) { * @param int $type One of Stmt\Use_::TYPE_* * @param array $errorAttrs Attributes to use to report an error */ - public function addAlias(Name $name, $aliasName, $type, array $errorAttrs = []) { + public function addAlias(Name $name, string $aliasName, int $type, array $errorAttrs = []) { // Constant names are case sensitive, everything else case insensitive if ($type === Stmt\Use_::TYPE_CONSTANT) { $aliasLookupName = $aliasName; @@ -99,7 +99,7 @@ public function getNamespace() { * * @return null|Name Resolved name, or null if static resolution is not possible */ - public function getResolvedName(Name $name, $type) { + public function getResolvedName(Name $name, int $type) { // don't resolve special class names if ($type === Stmt\Use_::TYPE_NORMAL && in_array(strtolower($name->toString()), array('self', 'parent', 'static'))) { @@ -143,7 +143,7 @@ public function getResolvedName(Name $name, $type) { * * @return Name Resolved name */ - public function getResolvedClassName(Name $name) { + public function getResolvedClassName(Name $name) : Name { return $this->getResolvedName($name, Stmt\Use_::TYPE_NORMAL); } @@ -155,7 +155,7 @@ public function getResolvedClassName(Name $name) { * * @return Name[] Possible representations of the name */ - public function getPossibleNames(FullyQualified $name, $type) { + public function getPossibleNames(FullyQualified $name, int $type) : array { $nameStr = (string) $name; $lcName = strtolower($name); @@ -204,7 +204,7 @@ public function getPossibleNames(FullyQualified $name, $type) { * * @return Name Shortest representation */ - public function getShortName(Name\FullyQualified $name, $type) { + public function getShortName(Name\FullyQualified $name, int $type) : Name { $possibleNames = $this->getPossibleNames($name, $type); // Find shortest name diff --git a/lib/PhpParser/Node.php b/lib/PhpParser/Node.php index 9da9245078..b471209cbb 100644 --- a/lib/PhpParser/Node.php +++ b/lib/PhpParser/Node.php @@ -9,28 +9,28 @@ interface Node * * @return string Type of the node */ - public function getType(); + public function getType() : string; /** * Gets the names of the sub nodes. * * @return array Names of sub nodes */ - public function getSubNodeNames(); + public function getSubNodeNames() : array; /** * Gets line the node started in. * * @return int Line */ - public function getLine(); + public function getLine() : int; /** * Sets line the node started in. * * @param int $line Line */ - public function setLine($line); + public function setLine(int $line); /** * Gets the doc comment of the node. @@ -56,7 +56,7 @@ public function setDocComment(Comment\Doc $docComment); * @param string $key * @param mixed $value */ - public function setAttribute($key, $value); + public function setAttribute(string $key, $value); /** * Returns whether an attribute exists. @@ -65,7 +65,7 @@ public function setAttribute($key, $value); * * @return bool */ - public function hasAttribute($key); + public function hasAttribute(string $key) : bool; /** * Returns the value of an attribute. @@ -75,12 +75,12 @@ public function hasAttribute($key); * * @return mixed */ - public function &getAttribute($key, $default = null); + public function &getAttribute(string $key, $default = null); /** * Returns all attributes for the given node. * * @return array */ - public function getAttributes(); + public function getAttributes() : array; } \ No newline at end of file diff --git a/lib/PhpParser/Node/Arg.php b/lib/PhpParser/Node/Arg.php index 0887669438..a0d361486c 100644 --- a/lib/PhpParser/Node/Arg.php +++ b/lib/PhpParser/Node/Arg.php @@ -21,14 +21,14 @@ class Arg extends NodeAbstract * @param bool $unpack Whether to unpack the argument * @param array $attributes Additional attributes */ - public function __construct(Expr $value, $byRef = false, $unpack = false, array $attributes = array()) { + public function __construct(Expr $value, bool $byRef = false, bool $unpack = false, array $attributes = array()) { parent::__construct($attributes); $this->value = $value; $this->byRef = $byRef; $this->unpack = $unpack; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('value', 'byRef', 'unpack'); } } diff --git a/lib/PhpParser/Node/Const_.php b/lib/PhpParser/Node/Const_.php index 581b3f7125..8428bbfc18 100644 --- a/lib/PhpParser/Node/Const_.php +++ b/lib/PhpParser/Node/Const_.php @@ -27,7 +27,7 @@ public function __construct($name, Expr $value, array $attributes = array()) { $this->value = $value; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('name', 'value'); } } diff --git a/lib/PhpParser/Node/Expr/ArrayDimFetch.php b/lib/PhpParser/Node/Expr/ArrayDimFetch.php index b8e4818fa3..0e08b524af 100644 --- a/lib/PhpParser/Node/Expr/ArrayDimFetch.php +++ b/lib/PhpParser/Node/Expr/ArrayDimFetch.php @@ -24,7 +24,7 @@ public function __construct(Expr $var, Expr $dim = null, array $attributes = arr $this->dim = $dim; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var', 'dim'); } } diff --git a/lib/PhpParser/Node/Expr/ArrayItem.php b/lib/PhpParser/Node/Expr/ArrayItem.php index de73ef467e..9bc5ac8bf4 100644 --- a/lib/PhpParser/Node/Expr/ArrayItem.php +++ b/lib/PhpParser/Node/Expr/ArrayItem.php @@ -21,14 +21,14 @@ class ArrayItem extends Expr * @param bool $byRef Whether to assign by reference * @param array $attributes Additional attributes */ - public function __construct(Expr $value, Expr $key = null, $byRef = false, array $attributes = array()) { + public function __construct(Expr $value, Expr $key = null, bool $byRef = false, array $attributes = array()) { parent::__construct($attributes); $this->key = $key; $this->value = $value; $this->byRef = $byRef; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('key', 'value', 'byRef'); } } diff --git a/lib/PhpParser/Node/Expr/Array_.php b/lib/PhpParser/Node/Expr/Array_.php index 9151f27d83..87674f062e 100644 --- a/lib/PhpParser/Node/Expr/Array_.php +++ b/lib/PhpParser/Node/Expr/Array_.php @@ -24,7 +24,7 @@ public function __construct(array $items = array(), array $attributes = array()) $this->items = $items; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('items'); } } diff --git a/lib/PhpParser/Node/Expr/Assign.php b/lib/PhpParser/Node/Expr/Assign.php index 1f280ff0c7..48ca6fa3a0 100644 --- a/lib/PhpParser/Node/Expr/Assign.php +++ b/lib/PhpParser/Node/Expr/Assign.php @@ -24,7 +24,7 @@ public function __construct(Expr $var, Expr $expr, array $attributes = array()) $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var', 'expr'); } } diff --git a/lib/PhpParser/Node/Expr/AssignOp.php b/lib/PhpParser/Node/Expr/AssignOp.php index 83540a0726..e026b2d514 100644 --- a/lib/PhpParser/Node/Expr/AssignOp.php +++ b/lib/PhpParser/Node/Expr/AssignOp.php @@ -24,7 +24,7 @@ public function __construct(Expr $var, Expr $expr, array $attributes = array()) $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var', 'expr'); } } diff --git a/lib/PhpParser/Node/Expr/AssignRef.php b/lib/PhpParser/Node/Expr/AssignRef.php index 7578df3ff2..d99ef3d54c 100644 --- a/lib/PhpParser/Node/Expr/AssignRef.php +++ b/lib/PhpParser/Node/Expr/AssignRef.php @@ -24,7 +24,7 @@ public function __construct(Expr $var, Expr $expr, array $attributes = array()) $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var', 'expr'); } } diff --git a/lib/PhpParser/Node/Expr/BinaryOp.php b/lib/PhpParser/Node/Expr/BinaryOp.php index 6f87e23505..1da009ed09 100644 --- a/lib/PhpParser/Node/Expr/BinaryOp.php +++ b/lib/PhpParser/Node/Expr/BinaryOp.php @@ -24,7 +24,7 @@ public function __construct(Expr $left, Expr $right, array $attributes = array() $this->right = $right; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('left', 'right'); } } diff --git a/lib/PhpParser/Node/Expr/BitwiseNot.php b/lib/PhpParser/Node/Expr/BitwiseNot.php index 1d92264107..2e5f046e6b 100644 --- a/lib/PhpParser/Node/Expr/BitwiseNot.php +++ b/lib/PhpParser/Node/Expr/BitwiseNot.php @@ -20,7 +20,7 @@ public function __construct(Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/BooleanNot.php b/lib/PhpParser/Node/Expr/BooleanNot.php index 8f543b822f..bb2491ca10 100644 --- a/lib/PhpParser/Node/Expr/BooleanNot.php +++ b/lib/PhpParser/Node/Expr/BooleanNot.php @@ -20,7 +20,7 @@ public function __construct(Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/Cast.php b/lib/PhpParser/Node/Expr/Cast.php index bf850dc522..c13318ba0a 100644 --- a/lib/PhpParser/Node/Expr/Cast.php +++ b/lib/PhpParser/Node/Expr/Cast.php @@ -20,7 +20,7 @@ public function __construct(Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/ClassConstFetch.php b/lib/PhpParser/Node/Expr/ClassConstFetch.php index 89f1ab6b5d..9c21d56cd7 100644 --- a/lib/PhpParser/Node/Expr/ClassConstFetch.php +++ b/lib/PhpParser/Node/Expr/ClassConstFetch.php @@ -26,7 +26,7 @@ public function __construct($class, $name, array $attributes = array()) { $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('class', 'name'); } } diff --git a/lib/PhpParser/Node/Expr/Clone_.php b/lib/PhpParser/Node/Expr/Clone_.php index 198ec4d891..85f3525847 100644 --- a/lib/PhpParser/Node/Expr/Clone_.php +++ b/lib/PhpParser/Node/Expr/Clone_.php @@ -20,7 +20,7 @@ public function __construct(Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/Closure.php b/lib/PhpParser/Node/Expr/Closure.php index a9513ec40a..e2f730fb01 100644 --- a/lib/PhpParser/Node/Expr/Closure.php +++ b/lib/PhpParser/Node/Expr/Closure.php @@ -44,15 +44,15 @@ public function __construct(array $subNodes = array(), array $attributes = array $this->stmts = $subNodes['stmts'] ?? array(); } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('static', 'byRef', 'params', 'uses', 'returnType', 'stmts'); } - public function returnsByRef() { + public function returnsByRef() : bool { return $this->byRef; } - public function getParams() { + public function getParams() : array { return $this->params; } @@ -60,7 +60,7 @@ public function getReturnType() { return $this->returnType; } - public function getStmts() { + public function getStmts() : array { return $this->stmts; } } diff --git a/lib/PhpParser/Node/Expr/ClosureUse.php b/lib/PhpParser/Node/Expr/ClosureUse.php index 155afa1a70..ecee160533 100644 --- a/lib/PhpParser/Node/Expr/ClosureUse.php +++ b/lib/PhpParser/Node/Expr/ClosureUse.php @@ -18,13 +18,13 @@ class ClosureUse extends Expr * @param bool $byRef Whether to use by reference * @param array $attributes Additional attributes */ - public function __construct(Expr\Variable $var, $byRef = false, array $attributes = array()) { + public function __construct(Expr\Variable $var, bool $byRef = false, array $attributes = array()) { parent::__construct($attributes); $this->var = $var; $this->byRef = $byRef; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var', 'byRef'); } } diff --git a/lib/PhpParser/Node/Expr/ConstFetch.php b/lib/PhpParser/Node/Expr/ConstFetch.php index 98e51d5273..4dd1d30679 100644 --- a/lib/PhpParser/Node/Expr/ConstFetch.php +++ b/lib/PhpParser/Node/Expr/ConstFetch.php @@ -21,7 +21,7 @@ public function __construct(Name $name, array $attributes = array()) { $this->name = $name; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('name'); } } diff --git a/lib/PhpParser/Node/Expr/Empty_.php b/lib/PhpParser/Node/Expr/Empty_.php index 0c0509efbb..d6f73e9182 100644 --- a/lib/PhpParser/Node/Expr/Empty_.php +++ b/lib/PhpParser/Node/Expr/Empty_.php @@ -20,7 +20,7 @@ public function __construct(Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/Error.php b/lib/PhpParser/Node/Expr/Error.php index 5ab8fd4450..a499d01136 100644 --- a/lib/PhpParser/Node/Expr/Error.php +++ b/lib/PhpParser/Node/Expr/Error.php @@ -21,7 +21,7 @@ public function __construct(array $attributes = array()) { parent::__construct($attributes); } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array(); } } diff --git a/lib/PhpParser/Node/Expr/ErrorSuppress.php b/lib/PhpParser/Node/Expr/ErrorSuppress.php index 750c814c75..863bd84d17 100644 --- a/lib/PhpParser/Node/Expr/ErrorSuppress.php +++ b/lib/PhpParser/Node/Expr/ErrorSuppress.php @@ -20,7 +20,7 @@ public function __construct(Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/Eval_.php b/lib/PhpParser/Node/Expr/Eval_.php index eadffd008f..fac88fae4a 100644 --- a/lib/PhpParser/Node/Expr/Eval_.php +++ b/lib/PhpParser/Node/Expr/Eval_.php @@ -20,7 +20,7 @@ public function __construct(Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/Exit_.php b/lib/PhpParser/Node/Expr/Exit_.php index b0b94cf7b1..8c627cc28b 100644 --- a/lib/PhpParser/Node/Expr/Exit_.php +++ b/lib/PhpParser/Node/Expr/Exit_.php @@ -24,7 +24,7 @@ public function __construct(Expr $expr = null, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/FuncCall.php b/lib/PhpParser/Node/Expr/FuncCall.php index 60d00507d1..74b20f3b3e 100644 --- a/lib/PhpParser/Node/Expr/FuncCall.php +++ b/lib/PhpParser/Node/Expr/FuncCall.php @@ -25,7 +25,7 @@ public function __construct($name, array $args = array(), array $attributes = ar $this->args = $args; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('name', 'args'); } } diff --git a/lib/PhpParser/Node/Expr/Include_.php b/lib/PhpParser/Node/Expr/Include_.php index b27f3af18f..8c1b3feef4 100644 --- a/lib/PhpParser/Node/Expr/Include_.php +++ b/lib/PhpParser/Node/Expr/Include_.php @@ -23,13 +23,13 @@ class Include_ extends Expr * @param int $type Type of include * @param array $attributes Additional attributes */ - public function __construct(Expr $expr, $type, array $attributes = array()) { + public function __construct(Expr $expr, int $type, array $attributes = array()) { parent::__construct($attributes); $this->expr = $expr; $this->type = $type; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr', 'type'); } } diff --git a/lib/PhpParser/Node/Expr/Instanceof_.php b/lib/PhpParser/Node/Expr/Instanceof_.php index 69573d865d..c21749f083 100644 --- a/lib/PhpParser/Node/Expr/Instanceof_.php +++ b/lib/PhpParser/Node/Expr/Instanceof_.php @@ -25,7 +25,7 @@ public function __construct(Expr $expr, $class, array $attributes = array()) { $this->class = $class; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr', 'class'); } } diff --git a/lib/PhpParser/Node/Expr/Isset_.php b/lib/PhpParser/Node/Expr/Isset_.php index 4ec1d025a5..91c6d6b98e 100644 --- a/lib/PhpParser/Node/Expr/Isset_.php +++ b/lib/PhpParser/Node/Expr/Isset_.php @@ -20,7 +20,7 @@ public function __construct(array $vars, array $attributes = array()) { $this->vars = $vars; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('vars'); } } diff --git a/lib/PhpParser/Node/Expr/List_.php b/lib/PhpParser/Node/Expr/List_.php index 30f3dc1652..b122468a4d 100644 --- a/lib/PhpParser/Node/Expr/List_.php +++ b/lib/PhpParser/Node/Expr/List_.php @@ -20,7 +20,7 @@ public function __construct(array $items, array $attributes = array()) { $this->items = $items; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('items'); } } diff --git a/lib/PhpParser/Node/Expr/MethodCall.php b/lib/PhpParser/Node/Expr/MethodCall.php index 909f7ef225..6101e74da9 100644 --- a/lib/PhpParser/Node/Expr/MethodCall.php +++ b/lib/PhpParser/Node/Expr/MethodCall.php @@ -30,7 +30,7 @@ public function __construct(Expr $var, $name, array $args = array(), array $attr $this->args = $args; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var', 'name', 'args'); } } diff --git a/lib/PhpParser/Node/Expr/New_.php b/lib/PhpParser/Node/Expr/New_.php index a8c87794db..7b71904d12 100644 --- a/lib/PhpParser/Node/Expr/New_.php +++ b/lib/PhpParser/Node/Expr/New_.php @@ -25,7 +25,7 @@ public function __construct($class, array $args = array(), array $attributes = a $this->args = $args; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('class', 'args'); } } diff --git a/lib/PhpParser/Node/Expr/PostDec.php b/lib/PhpParser/Node/Expr/PostDec.php index 06ce5470eb..e35b05751a 100644 --- a/lib/PhpParser/Node/Expr/PostDec.php +++ b/lib/PhpParser/Node/Expr/PostDec.php @@ -20,7 +20,7 @@ public function __construct(Expr $var, array $attributes = array()) { $this->var = $var; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var'); } } diff --git a/lib/PhpParser/Node/Expr/PostInc.php b/lib/PhpParser/Node/Expr/PostInc.php index 54865ba12c..419df8ca2b 100644 --- a/lib/PhpParser/Node/Expr/PostInc.php +++ b/lib/PhpParser/Node/Expr/PostInc.php @@ -20,7 +20,7 @@ public function __construct(Expr $var, array $attributes = array()) { $this->var = $var; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var'); } } diff --git a/lib/PhpParser/Node/Expr/PreDec.php b/lib/PhpParser/Node/Expr/PreDec.php index db30f51026..94972124d2 100644 --- a/lib/PhpParser/Node/Expr/PreDec.php +++ b/lib/PhpParser/Node/Expr/PreDec.php @@ -20,7 +20,7 @@ public function __construct(Expr $var, array $attributes = array()) { $this->var = $var; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var'); } } diff --git a/lib/PhpParser/Node/Expr/PreInc.php b/lib/PhpParser/Node/Expr/PreInc.php index 06356028ce..2efdf2f3d9 100644 --- a/lib/PhpParser/Node/Expr/PreInc.php +++ b/lib/PhpParser/Node/Expr/PreInc.php @@ -20,7 +20,7 @@ public function __construct(Expr $var, array $attributes = array()) { $this->var = $var; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var'); } } diff --git a/lib/PhpParser/Node/Expr/Print_.php b/lib/PhpParser/Node/Expr/Print_.php index 0666ab84d7..16ffbdcc50 100644 --- a/lib/PhpParser/Node/Expr/Print_.php +++ b/lib/PhpParser/Node/Expr/Print_.php @@ -20,7 +20,7 @@ public function __construct(Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/PropertyFetch.php b/lib/PhpParser/Node/Expr/PropertyFetch.php index 3fb660ea30..116071566b 100644 --- a/lib/PhpParser/Node/Expr/PropertyFetch.php +++ b/lib/PhpParser/Node/Expr/PropertyFetch.php @@ -25,7 +25,7 @@ public function __construct(Expr $var, $name, array $attributes = array()) { $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var', 'name'); } } diff --git a/lib/PhpParser/Node/Expr/ShellExec.php b/lib/PhpParser/Node/Expr/ShellExec.php index 9516a32f49..34d1d6faaf 100644 --- a/lib/PhpParser/Node/Expr/ShellExec.php +++ b/lib/PhpParser/Node/Expr/ShellExec.php @@ -20,7 +20,7 @@ public function __construct(array $parts, array $attributes = array()) { $this->parts = $parts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('parts'); } } diff --git a/lib/PhpParser/Node/Expr/StaticCall.php b/lib/PhpParser/Node/Expr/StaticCall.php index 34595c2b5d..e702eda321 100644 --- a/lib/PhpParser/Node/Expr/StaticCall.php +++ b/lib/PhpParser/Node/Expr/StaticCall.php @@ -30,7 +30,7 @@ public function __construct($class, $name, array $args = array(), array $attribu $this->args = $args; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('class', 'name', 'args'); } } diff --git a/lib/PhpParser/Node/Expr/StaticPropertyFetch.php b/lib/PhpParser/Node/Expr/StaticPropertyFetch.php index f41798f7b7..4af433dbc8 100644 --- a/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +++ b/lib/PhpParser/Node/Expr/StaticPropertyFetch.php @@ -26,7 +26,7 @@ public function __construct($class, $name, array $attributes = array()) { $this->name = \is_string($name) ? new VarLikeIdentifier($name) : $name; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('class', 'name'); } } diff --git a/lib/PhpParser/Node/Expr/Ternary.php b/lib/PhpParser/Node/Expr/Ternary.php index 57301390fe..87ebdc15ce 100644 --- a/lib/PhpParser/Node/Expr/Ternary.php +++ b/lib/PhpParser/Node/Expr/Ternary.php @@ -28,7 +28,7 @@ public function __construct(Expr $cond, $if, Expr $else, array $attributes = arr $this->else = $else; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('cond', 'if', 'else'); } } diff --git a/lib/PhpParser/Node/Expr/UnaryMinus.php b/lib/PhpParser/Node/Expr/UnaryMinus.php index 94635d6383..7e47827aad 100644 --- a/lib/PhpParser/Node/Expr/UnaryMinus.php +++ b/lib/PhpParser/Node/Expr/UnaryMinus.php @@ -20,7 +20,7 @@ public function __construct(Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/UnaryPlus.php b/lib/PhpParser/Node/Expr/UnaryPlus.php index 651412003b..d869cfe9ba 100644 --- a/lib/PhpParser/Node/Expr/UnaryPlus.php +++ b/lib/PhpParser/Node/Expr/UnaryPlus.php @@ -20,7 +20,7 @@ public function __construct(Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/Variable.php b/lib/PhpParser/Node/Expr/Variable.php index 3ae3ecd9b2..96f2df2d52 100644 --- a/lib/PhpParser/Node/Expr/Variable.php +++ b/lib/PhpParser/Node/Expr/Variable.php @@ -20,7 +20,7 @@ public function __construct($name, array $attributes = array()) { $this->name = $name; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('name'); } } diff --git a/lib/PhpParser/Node/Expr/YieldFrom.php b/lib/PhpParser/Node/Expr/YieldFrom.php index 993c82c20a..d48426e077 100644 --- a/lib/PhpParser/Node/Expr/YieldFrom.php +++ b/lib/PhpParser/Node/Expr/YieldFrom.php @@ -20,7 +20,7 @@ public function __construct(Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Expr/Yield_.php b/lib/PhpParser/Node/Expr/Yield_.php index f3ca88e05b..639c9a385a 100644 --- a/lib/PhpParser/Node/Expr/Yield_.php +++ b/lib/PhpParser/Node/Expr/Yield_.php @@ -24,7 +24,7 @@ public function __construct(Expr $value = null, Expr $key = null, array $attribu $this->value = $value; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('key', 'value'); } } diff --git a/lib/PhpParser/Node/FunctionLike.php b/lib/PhpParser/Node/FunctionLike.php index d8d36bbf04..6acbd8b26c 100644 --- a/lib/PhpParser/Node/FunctionLike.php +++ b/lib/PhpParser/Node/FunctionLike.php @@ -11,14 +11,14 @@ interface FunctionLike extends Node * * @return bool */ - public function returnsByRef(); + public function returnsByRef() : bool; /** * List of parameters * * @return Node\Param[] */ - public function getParams(); + public function getParams() : array; /** * Get the declared return type or null @@ -32,5 +32,5 @@ public function getReturnType(); * * @return Node\Stmt[] */ - public function getStmts(); + public function getStmts() : array; } diff --git a/lib/PhpParser/Node/Identifier.php b/lib/PhpParser/Node/Identifier.php index 4af1a65c33..35c79f5eeb 100644 --- a/lib/PhpParser/Node/Identifier.php +++ b/lib/PhpParser/Node/Identifier.php @@ -18,12 +18,12 @@ class Identifier extends NodeAbstract * @param string $name Identifier as string * @param array $attributes Additional attributes */ - public function __construct($name, array $attributes = array()) { + public function __construct(string $name, array $attributes = array()) { parent::__construct($attributes); $this->name = $name; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('name'); } @@ -32,7 +32,7 @@ public function getSubNodeNames() { * * @return string Identifier as string. */ - public function __toString() { + public function __toString() : string { return $this->name; } } diff --git a/lib/PhpParser/Node/Name.php b/lib/PhpParser/Node/Name.php index f8d46ea5fe..0e79a887a2 100644 --- a/lib/PhpParser/Node/Name.php +++ b/lib/PhpParser/Node/Name.php @@ -23,7 +23,7 @@ public function __construct($name, array $attributes = array()) { $this->parts = self::prepareName($name); } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('parts'); } @@ -32,7 +32,7 @@ public function getSubNodeNames() { * * @return string First part of the name */ - public function getFirst() { + public function getFirst() : string { return $this->parts[0]; } @@ -41,7 +41,7 @@ public function getFirst() { * * @return string Last part of the name */ - public function getLast() { + public function getLast() : string { return $this->parts[count($this->parts) - 1]; } @@ -50,7 +50,7 @@ public function getLast() { * * @return bool Whether the name is unqualified */ - public function isUnqualified() { + public function isUnqualified() : bool { return 1 == count($this->parts); } @@ -59,7 +59,7 @@ public function isUnqualified() { * * @return bool Whether the name is qualified */ - public function isQualified() { + public function isQualified() : bool { return 1 < count($this->parts); } @@ -68,7 +68,7 @@ public function isQualified() { * * @return bool Whether the name is fully qualified */ - public function isFullyQualified() { + public function isFullyQualified() : bool { return false; } @@ -77,7 +77,7 @@ public function isFullyQualified() { * * @return bool Whether the name is relative */ - public function isRelative() { + public function isRelative() : bool { return false; } @@ -87,7 +87,7 @@ public function isRelative() { * * @return string String representation */ - public function toString() { + public function toString() : string { return implode('\\', $this->parts); } @@ -97,7 +97,7 @@ public function toString() { * * @return string String representation */ - public function toCodeString() { + public function toCodeString() : string { return $this->toString(); } @@ -107,7 +107,7 @@ public function toCodeString() { * * @return string String representation */ - public function __toString() { + public function __toString() : string { return implode('\\', $this->parts); } @@ -127,7 +127,7 @@ public function __toString() { * * @return static|null Sliced name */ - public function slice($offset, $length = null) { + public function slice(int $offset, int $length = null) { $numParts = count($this->parts); $realOffset = $offset < 0 ? $offset + $numParts : $offset; @@ -191,7 +191,7 @@ public static function concat($name1, $name2, array $attributes = []) { * * @return string[] Prepared name */ - private static function prepareName($name) { + private static function prepareName($name) : array { if (\is_string($name)) { return explode('\\', $name); } elseif (\is_array($name)) { diff --git a/lib/PhpParser/Node/Name/FullyQualified.php b/lib/PhpParser/Node/Name/FullyQualified.php index b50a0350b5..568dec705a 100644 --- a/lib/PhpParser/Node/Name/FullyQualified.php +++ b/lib/PhpParser/Node/Name/FullyQualified.php @@ -9,7 +9,7 @@ class FullyQualified extends \PhpParser\Node\Name * * @return bool Whether the name is unqualified */ - public function isUnqualified() { + public function isUnqualified() : bool { return false; } @@ -18,7 +18,7 @@ public function isUnqualified() { * * @return bool Whether the name is qualified */ - public function isQualified() { + public function isQualified() : bool { return false; } @@ -27,7 +27,7 @@ public function isQualified() { * * @return bool Whether the name is fully qualified */ - public function isFullyQualified() { + public function isFullyQualified() : bool { return true; } @@ -36,11 +36,11 @@ public function isFullyQualified() { * * @return bool Whether the name is relative */ - public function isRelative() { + public function isRelative() : bool { return false; } - public function toCodeString() { + public function toCodeString() : string { return '\\' . $this->toString(); } } \ No newline at end of file diff --git a/lib/PhpParser/Node/Name/Relative.php b/lib/PhpParser/Node/Name/Relative.php index 3ad3296dc1..2e5a8ab04d 100644 --- a/lib/PhpParser/Node/Name/Relative.php +++ b/lib/PhpParser/Node/Name/Relative.php @@ -9,7 +9,7 @@ class Relative extends \PhpParser\Node\Name * * @return bool Whether the name is unqualified */ - public function isUnqualified() { + public function isUnqualified() : bool { return false; } @@ -18,7 +18,7 @@ public function isUnqualified() { * * @return bool Whether the name is qualified */ - public function isQualified() { + public function isQualified() : bool { return false; } @@ -27,7 +27,7 @@ public function isQualified() { * * @return bool Whether the name is fully qualified */ - public function isFullyQualified() { + public function isFullyQualified() : bool { return false; } @@ -36,11 +36,11 @@ public function isFullyQualified() { * * @return bool Whether the name is relative */ - public function isRelative() { + public function isRelative() : bool { return true; } - public function toCodeString() { + public function toCodeString() : string { return 'namespace\\' . $this->toString(); } } \ No newline at end of file diff --git a/lib/PhpParser/Node/NullableType.php b/lib/PhpParser/Node/NullableType.php index d4a30f19e1..ca3c0aa4d5 100644 --- a/lib/PhpParser/Node/NullableType.php +++ b/lib/PhpParser/Node/NullableType.php @@ -20,7 +20,7 @@ public function __construct($type, array $attributes = array()) { $this->type = \is_string($type) ? new Identifier($type) : $type; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('type'); } } diff --git a/lib/PhpParser/Node/Param.php b/lib/PhpParser/Node/Param.php index fcf5cc130b..85471d5e7c 100644 --- a/lib/PhpParser/Node/Param.php +++ b/lib/PhpParser/Node/Param.php @@ -29,7 +29,7 @@ class Param extends NodeAbstract */ public function __construct( Expr\Variable $var, Expr $default = null, $type = null, - $byRef = false, $variadic = false, array $attributes = array() + bool $byRef = false, bool $variadic = false, array $attributes = array() ) { parent::__construct($attributes); $this->type = \is_string($type) ? new Identifier($type) : $type; @@ -39,7 +39,7 @@ public function __construct( $this->default = $default; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('type', 'byRef', 'variadic', 'var', 'default'); } } diff --git a/lib/PhpParser/Node/Scalar/DNumber.php b/lib/PhpParser/Node/Scalar/DNumber.php index 84ef75d34b..b406f2ccca 100644 --- a/lib/PhpParser/Node/Scalar/DNumber.php +++ b/lib/PhpParser/Node/Scalar/DNumber.php @@ -15,12 +15,12 @@ class DNumber extends Scalar * @param float $value Value of the number * @param array $attributes Additional attributes */ - public function __construct($value, array $attributes = array()) { + public function __construct(float $value, array $attributes = array()) { parent::__construct($attributes); $this->value = $value; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('value'); } @@ -33,7 +33,7 @@ public function getSubNodeNames() { * * @return float The parsed number */ - public static function parse($str) { + public static function parse(string $str) : float { // if string contains any of .eE just cast it to float if (false !== strpbrk($str, '.eE')) { return (float) $str; diff --git a/lib/PhpParser/Node/Scalar/Encapsed.php b/lib/PhpParser/Node/Scalar/Encapsed.php index fbf3998ed0..535a0bc8e0 100644 --- a/lib/PhpParser/Node/Scalar/Encapsed.php +++ b/lib/PhpParser/Node/Scalar/Encapsed.php @@ -21,7 +21,7 @@ public function __construct(array $parts, array $attributes = array()) { $this->parts = $parts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('parts'); } } diff --git a/lib/PhpParser/Node/Scalar/EncapsedStringPart.php b/lib/PhpParser/Node/Scalar/EncapsedStringPart.php index 50cb1afe6c..7de7504421 100644 --- a/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +++ b/lib/PhpParser/Node/Scalar/EncapsedStringPart.php @@ -15,12 +15,12 @@ class EncapsedStringPart extends Scalar * @param string $value String value * @param array $attributes Additional attributes */ - public function __construct($value, array $attributes = array()) { + public function __construct(string $value, array $attributes = array()) { parent::__construct($attributes); $this->value = $value; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('value'); } } diff --git a/lib/PhpParser/Node/Scalar/LNumber.php b/lib/PhpParser/Node/Scalar/LNumber.php index 3559b982c3..f9f493e452 100644 --- a/lib/PhpParser/Node/Scalar/LNumber.php +++ b/lib/PhpParser/Node/Scalar/LNumber.php @@ -22,12 +22,12 @@ class LNumber extends Scalar * @param int $value Value of the number * @param array $attributes Additional attributes */ - public function __construct($value, array $attributes = array()) { + public function __construct(int $value, array $attributes = array()) { parent::__construct($attributes); $this->value = $value; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('value'); } @@ -40,7 +40,7 @@ public function getSubNodeNames() { * * @return LNumber The constructed LNumber, including kind attribute */ - public static function fromString($str, array $attributes = array(), $allowInvalidOctal = false) { + public static function fromString(string $str, array $attributes = array(), bool $allowInvalidOctal = false) : LNumber { if ('0' !== $str[0] || '0' === $str) { $attributes['kind'] = LNumber::KIND_DEC; return new LNumber((int) $str, $attributes); diff --git a/lib/PhpParser/Node/Scalar/MagicConst.php b/lib/PhpParser/Node/Scalar/MagicConst.php index a50d68f3d0..3a1e57dbe2 100644 --- a/lib/PhpParser/Node/Scalar/MagicConst.php +++ b/lib/PhpParser/Node/Scalar/MagicConst.php @@ -15,7 +15,7 @@ public function __construct(array $attributes = array()) { parent::__construct($attributes); } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array(); } @@ -24,5 +24,5 @@ public function getSubNodeNames() { * * @return string Name of magic constant */ - abstract public function getName(); + abstract public function getName() : string; } diff --git a/lib/PhpParser/Node/Scalar/MagicConst/Class_.php b/lib/PhpParser/Node/Scalar/MagicConst/Class_.php index 3466b21a13..d3343c9e44 100644 --- a/lib/PhpParser/Node/Scalar/MagicConst/Class_.php +++ b/lib/PhpParser/Node/Scalar/MagicConst/Class_.php @@ -6,7 +6,7 @@ class Class_ extends MagicConst { - public function getName() { + public function getName() : string { return '__CLASS__'; } } \ No newline at end of file diff --git a/lib/PhpParser/Node/Scalar/MagicConst/Dir.php b/lib/PhpParser/Node/Scalar/MagicConst/Dir.php index 9a86ae9c03..fa8538c998 100644 --- a/lib/PhpParser/Node/Scalar/MagicConst/Dir.php +++ b/lib/PhpParser/Node/Scalar/MagicConst/Dir.php @@ -6,7 +6,7 @@ class Dir extends MagicConst { - public function getName() { + public function getName() : string { return '__DIR__'; } } \ No newline at end of file diff --git a/lib/PhpParser/Node/Scalar/MagicConst/File.php b/lib/PhpParser/Node/Scalar/MagicConst/File.php index db293ef537..a6a6306ad6 100644 --- a/lib/PhpParser/Node/Scalar/MagicConst/File.php +++ b/lib/PhpParser/Node/Scalar/MagicConst/File.php @@ -6,7 +6,7 @@ class File extends MagicConst { - public function getName() { + public function getName() : string { return '__FILE__'; } } \ No newline at end of file diff --git a/lib/PhpParser/Node/Scalar/MagicConst/Function_.php b/lib/PhpParser/Node/Scalar/MagicConst/Function_.php index 435a8aec08..902721246b 100644 --- a/lib/PhpParser/Node/Scalar/MagicConst/Function_.php +++ b/lib/PhpParser/Node/Scalar/MagicConst/Function_.php @@ -6,7 +6,7 @@ class Function_ extends MagicConst { - public function getName() { + public function getName() : string { return '__FUNCTION__'; } } \ No newline at end of file diff --git a/lib/PhpParser/Node/Scalar/MagicConst/Line.php b/lib/PhpParser/Node/Scalar/MagicConst/Line.php index 35f89bc726..2ed898e570 100644 --- a/lib/PhpParser/Node/Scalar/MagicConst/Line.php +++ b/lib/PhpParser/Node/Scalar/MagicConst/Line.php @@ -6,7 +6,7 @@ class Line extends MagicConst { - public function getName() { + public function getName() : string { return '__LINE__'; } } \ No newline at end of file diff --git a/lib/PhpParser/Node/Scalar/MagicConst/Method.php b/lib/PhpParser/Node/Scalar/MagicConst/Method.php index 7791b9d6c5..a444c1b25e 100644 --- a/lib/PhpParser/Node/Scalar/MagicConst/Method.php +++ b/lib/PhpParser/Node/Scalar/MagicConst/Method.php @@ -6,7 +6,7 @@ class Method extends MagicConst { - public function getName() { + public function getName() : string { return '__METHOD__'; } } \ No newline at end of file diff --git a/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php b/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php index 07f5affb6c..38502871a5 100644 --- a/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php +++ b/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php @@ -6,7 +6,7 @@ class Namespace_ extends MagicConst { - public function getName() { + public function getName() : string { return '__NAMESPACE__'; } } \ No newline at end of file diff --git a/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php b/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php index 1ac3f784d1..46a04817d8 100644 --- a/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php +++ b/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php @@ -6,7 +6,7 @@ class Trait_ extends MagicConst { - public function getName() { + public function getName() : string { return '__TRAIT__'; } } \ No newline at end of file diff --git a/lib/PhpParser/Node/Scalar/String_.php b/lib/PhpParser/Node/Scalar/String_.php index d5cf5f4d73..f274c4002d 100644 --- a/lib/PhpParser/Node/Scalar/String_.php +++ b/lib/PhpParser/Node/Scalar/String_.php @@ -33,12 +33,12 @@ class String_ extends Scalar * @param string $value Value of the string * @param array $attributes Additional attributes */ - public function __construct($value, array $attributes = array()) { + public function __construct(string $value, array $attributes = array()) { parent::__construct($attributes); $this->value = $value; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('value'); } @@ -52,7 +52,7 @@ public function getSubNodeNames() { * * @return string The parsed string */ - public static function parse($str, $parseUnicodeEscape = true) { + public static function parse(string $str, bool $parseUnicodeEscape = true) : string { $bLength = 0; if ('b' === $str[0] || 'B' === $str[0]) { $bLength = 1; @@ -82,7 +82,7 @@ public static function parse($str, $parseUnicodeEscape = true) { * * @return string String with escape sequences parsed */ - public static function parseEscapeSequences($str, $quote, $parseUnicodeEscape = true) { + public static function parseEscapeSequences(string $str, $quote, bool $parseUnicodeEscape = true) : string { if (null !== $quote) { $str = str_replace('\\' . $quote, $quote, $str); } @@ -118,7 +118,7 @@ function($matches) { * * @return string UTF-8 representation of code point */ - private static function codePointToUtf8($num) { + private static function codePointToUtf8(int $num) : string { if ($num <= 0x7F) { return chr($num); } @@ -146,7 +146,7 @@ private static function codePointToUtf8($num) { * * @return string Parsed string */ - public static function parseDocString($startToken, $str, $parseUnicodeEscape = true) { + public static function parseDocString(string $startToken, string $str, bool $parseUnicodeEscape = true) : string { // strip last newline (thanks tokenizer for sticking it into the string!) $str = preg_replace('~(\r\n|\n|\r)\z~', '', $str); diff --git a/lib/PhpParser/Node/Stmt/Break_.php b/lib/PhpParser/Node/Stmt/Break_.php index c177c9a07f..23e70724d5 100644 --- a/lib/PhpParser/Node/Stmt/Break_.php +++ b/lib/PhpParser/Node/Stmt/Break_.php @@ -20,7 +20,7 @@ public function __construct(Node\Expr $num = null, array $attributes = array()) $this->num = $num; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('num'); } } diff --git a/lib/PhpParser/Node/Stmt/Case_.php b/lib/PhpParser/Node/Stmt/Case_.php index 63f56b8cf6..39aac73fb3 100644 --- a/lib/PhpParser/Node/Stmt/Case_.php +++ b/lib/PhpParser/Node/Stmt/Case_.php @@ -24,7 +24,7 @@ public function __construct($cond, array $stmts = array(), array $attributes = a $this->stmts = $stmts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('cond', 'stmts'); } } diff --git a/lib/PhpParser/Node/Stmt/Catch_.php b/lib/PhpParser/Node/Stmt/Catch_.php index d8e76acb85..b166bbab33 100644 --- a/lib/PhpParser/Node/Stmt/Catch_.php +++ b/lib/PhpParser/Node/Stmt/Catch_.php @@ -31,7 +31,7 @@ public function __construct( $this->stmts = $stmts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('types', 'var', 'stmts'); } } diff --git a/lib/PhpParser/Node/Stmt/ClassConst.php b/lib/PhpParser/Node/Stmt/ClassConst.php index a440cb33bb..fa575c943e 100644 --- a/lib/PhpParser/Node/Stmt/ClassConst.php +++ b/lib/PhpParser/Node/Stmt/ClassConst.php @@ -18,13 +18,13 @@ class ClassConst extends Node\Stmt * @param int $flags Modifiers * @param array $attributes Additional attributes */ - public function __construct(array $consts, $flags = 0, array $attributes = array()) { + public function __construct(array $consts, int $flags = 0, array $attributes = array()) { parent::__construct($attributes); $this->flags = $flags; $this->consts = $consts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('flags', 'consts'); } @@ -33,7 +33,7 @@ public function getSubNodeNames() { * * @return bool */ - public function isPublic() { + public function isPublic() : bool { return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; } @@ -43,7 +43,7 @@ public function isPublic() { * * @return bool */ - public function isProtected() { + public function isProtected() : bool { return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); } @@ -52,7 +52,7 @@ public function isProtected() { * * @return bool */ - public function isPrivate() { + public function isPrivate() : bool { return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); } } diff --git a/lib/PhpParser/Node/Stmt/ClassLike.php b/lib/PhpParser/Node/Stmt/ClassLike.php index fcb310e7cc..5d0c83e8c5 100644 --- a/lib/PhpParser/Node/Stmt/ClassLike.php +++ b/lib/PhpParser/Node/Stmt/ClassLike.php @@ -18,7 +18,7 @@ abstract class ClassLike extends Node\Stmt { * * @return ClassMethod[] */ - public function getMethods() { + public function getMethods() : array { $methods = array(); foreach ($this->stmts as $stmt) { if ($stmt instanceof ClassMethod) { @@ -35,7 +35,7 @@ public function getMethods() { * * @return ClassMethod|null Method node or null if the method does not exist */ - public function getMethod($name) { + public function getMethod(string $name) { $lowerName = strtolower($name); foreach ($this->stmts as $stmt) { if ($stmt instanceof ClassMethod && $lowerName === strtolower($stmt->name)) { diff --git a/lib/PhpParser/Node/Stmt/ClassMethod.php b/lib/PhpParser/Node/Stmt/ClassMethod.php index 0a1ff8653f..da4f2bf51b 100644 --- a/lib/PhpParser/Node/Stmt/ClassMethod.php +++ b/lib/PhpParser/Node/Stmt/ClassMethod.php @@ -61,15 +61,15 @@ public function __construct($name, array $subNodes = array(), array $attributes $this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : array(); } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('flags', 'byRef', 'name', 'params', 'returnType', 'stmts'); } - public function returnsByRef() { + public function returnsByRef() : bool { return $this->byRef; } - public function getParams() { + public function getParams() : array { return $this->params; } @@ -77,7 +77,7 @@ public function getReturnType() { return $this->returnType; } - public function getStmts() { + public function getStmts() : array { return $this->stmts; } @@ -86,7 +86,7 @@ public function getStmts() { * * @return bool */ - public function isPublic() { + public function isPublic() : bool { return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; } @@ -96,7 +96,7 @@ public function isPublic() { * * @return bool */ - public function isProtected() { + public function isProtected() : bool { return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); } @@ -105,7 +105,7 @@ public function isProtected() { * * @return bool */ - public function isPrivate() { + public function isPrivate() : bool { return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); } @@ -114,7 +114,7 @@ public function isPrivate() { * * @return bool */ - public function isAbstract() { + public function isAbstract() : bool { return (bool) ($this->flags & Class_::MODIFIER_ABSTRACT); } @@ -123,7 +123,7 @@ public function isAbstract() { * # * @return bool */ - public function isFinal() { + public function isFinal() : bool { return (bool) ($this->flags & Class_::MODIFIER_FINAL); } @@ -132,7 +132,7 @@ public function isFinal() { * * @return bool */ - public function isStatic() { + public function isStatic() : bool { return (bool) ($this->flags & Class_::MODIFIER_STATIC); } @@ -141,7 +141,7 @@ public function isStatic() { * * @return bool */ - public function isMagic() { + public function isMagic() : bool { return isset(self::$magicNames[strtolower($this->name)]); } } diff --git a/lib/PhpParser/Node/Stmt/Class_.php b/lib/PhpParser/Node/Stmt/Class_.php index 087937a3af..b30c6650ef 100644 --- a/lib/PhpParser/Node/Stmt/Class_.php +++ b/lib/PhpParser/Node/Stmt/Class_.php @@ -49,7 +49,7 @@ public function __construct($name, array $subNodes = array(), array $attributes $this->stmts = $subNodes['stmts'] ?? array(); } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('flags', 'name', 'extends', 'implements', 'stmts'); } @@ -58,7 +58,7 @@ public function getSubNodeNames() { * * @return bool */ - public function isAbstract() { + public function isAbstract() : bool { return (bool) ($this->flags & self::MODIFIER_ABSTRACT); } @@ -67,7 +67,7 @@ public function isAbstract() { * * @return bool */ - public function isFinal() { + public function isFinal() : bool { return (bool) ($this->flags & self::MODIFIER_FINAL); } @@ -76,7 +76,7 @@ public function isFinal() { * * @return bool */ - public function isAnonymous() { + public function isAnonymous() : bool { return null === $this->name; } diff --git a/lib/PhpParser/Node/Stmt/Const_.php b/lib/PhpParser/Node/Stmt/Const_.php index 8b2eecd51d..f5bf7812e8 100644 --- a/lib/PhpParser/Node/Stmt/Const_.php +++ b/lib/PhpParser/Node/Stmt/Const_.php @@ -20,7 +20,7 @@ public function __construct(array $consts, array $attributes = array()) { $this->consts = $consts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('consts'); } } diff --git a/lib/PhpParser/Node/Stmt/Continue_.php b/lib/PhpParser/Node/Stmt/Continue_.php index f78e19a2aa..06c7b6bd3a 100644 --- a/lib/PhpParser/Node/Stmt/Continue_.php +++ b/lib/PhpParser/Node/Stmt/Continue_.php @@ -20,7 +20,7 @@ public function __construct(Node\Expr $num = null, array $attributes = array()) $this->num = $num; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('num'); } } diff --git a/lib/PhpParser/Node/Stmt/DeclareDeclare.php b/lib/PhpParser/Node/Stmt/DeclareDeclare.php index f8c4c14b59..8562e2c8b4 100644 --- a/lib/PhpParser/Node/Stmt/DeclareDeclare.php +++ b/lib/PhpParser/Node/Stmt/DeclareDeclare.php @@ -24,7 +24,7 @@ public function __construct($key, Node\Expr $value, array $attributes = array()) $this->value = $value; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('key', 'value'); } } diff --git a/lib/PhpParser/Node/Stmt/Declare_.php b/lib/PhpParser/Node/Stmt/Declare_.php index 797f547cc9..b9457e0874 100644 --- a/lib/PhpParser/Node/Stmt/Declare_.php +++ b/lib/PhpParser/Node/Stmt/Declare_.php @@ -24,7 +24,7 @@ public function __construct(array $declares, array $stmts = null, array $attribu $this->stmts = $stmts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('declares', 'stmts'); } } diff --git a/lib/PhpParser/Node/Stmt/Do_.php b/lib/PhpParser/Node/Stmt/Do_.php index 94c7e2df9f..5c719a3f14 100644 --- a/lib/PhpParser/Node/Stmt/Do_.php +++ b/lib/PhpParser/Node/Stmt/Do_.php @@ -24,7 +24,7 @@ public function __construct(Node\Expr $cond, array $stmts = array(), array $attr $this->stmts = $stmts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('stmts', 'cond'); } } diff --git a/lib/PhpParser/Node/Stmt/Echo_.php b/lib/PhpParser/Node/Stmt/Echo_.php index 11e1070725..9535abd29f 100644 --- a/lib/PhpParser/Node/Stmt/Echo_.php +++ b/lib/PhpParser/Node/Stmt/Echo_.php @@ -20,7 +20,7 @@ public function __construct(array $exprs, array $attributes = array()) { $this->exprs = $exprs; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('exprs'); } } diff --git a/lib/PhpParser/Node/Stmt/ElseIf_.php b/lib/PhpParser/Node/Stmt/ElseIf_.php index babcbe4335..3cb8b03221 100644 --- a/lib/PhpParser/Node/Stmt/ElseIf_.php +++ b/lib/PhpParser/Node/Stmt/ElseIf_.php @@ -24,7 +24,7 @@ public function __construct(Node\Expr $cond, array $stmts = array(), array $attr $this->stmts = $stmts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('cond', 'stmts'); } } diff --git a/lib/PhpParser/Node/Stmt/Else_.php b/lib/PhpParser/Node/Stmt/Else_.php index 7c840b722f..bb1824de93 100644 --- a/lib/PhpParser/Node/Stmt/Else_.php +++ b/lib/PhpParser/Node/Stmt/Else_.php @@ -20,7 +20,7 @@ public function __construct(array $stmts = array(), array $attributes = array()) $this->stmts = $stmts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('stmts'); } } diff --git a/lib/PhpParser/Node/Stmt/Expression.php b/lib/PhpParser/Node/Stmt/Expression.php index d7d002b2ad..22e671f8db 100644 --- a/lib/PhpParser/Node/Stmt/Expression.php +++ b/lib/PhpParser/Node/Stmt/Expression.php @@ -23,7 +23,7 @@ public function __construct(Node\Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Stmt/Finally_.php b/lib/PhpParser/Node/Stmt/Finally_.php index 0ae25d6738..beaa4b9927 100644 --- a/lib/PhpParser/Node/Stmt/Finally_.php +++ b/lib/PhpParser/Node/Stmt/Finally_.php @@ -20,7 +20,7 @@ public function __construct(array $stmts = array(), array $attributes = array()) $this->stmts = $stmts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('stmts'); } } diff --git a/lib/PhpParser/Node/Stmt/For_.php b/lib/PhpParser/Node/Stmt/For_.php index 0a01099441..116b00dd66 100644 --- a/lib/PhpParser/Node/Stmt/For_.php +++ b/lib/PhpParser/Node/Stmt/For_.php @@ -33,7 +33,7 @@ public function __construct(array $subNodes = array(), array $attributes = array $this->stmts = $subNodes['stmts'] ?? array(); } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('init', 'cond', 'loop', 'stmts'); } } diff --git a/lib/PhpParser/Node/Stmt/Foreach_.php b/lib/PhpParser/Node/Stmt/Foreach_.php index 8af47a644d..9ce2c15d73 100644 --- a/lib/PhpParser/Node/Stmt/Foreach_.php +++ b/lib/PhpParser/Node/Stmt/Foreach_.php @@ -37,7 +37,7 @@ public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNode $this->stmts = $subNodes['stmts'] ?? array(); } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr', 'keyVar', 'byRef', 'valueVar', 'stmts'); } } diff --git a/lib/PhpParser/Node/Stmt/Function_.php b/lib/PhpParser/Node/Stmt/Function_.php index d695512aea..ccf4b9a96e 100644 --- a/lib/PhpParser/Node/Stmt/Function_.php +++ b/lib/PhpParser/Node/Stmt/Function_.php @@ -42,15 +42,15 @@ public function __construct($name, array $subNodes = array(), array $attributes $this->stmts = $subNodes['stmts'] ?? array(); } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('byRef', 'name', 'params', 'returnType', 'stmts'); } - public function returnsByRef() { + public function returnsByRef() : bool { return $this->byRef; } - public function getParams() { + public function getParams() : array { return $this->params; } @@ -58,7 +58,7 @@ public function getReturnType() { return $this->returnType; } - public function getStmts() { + public function getStmts() : array { return $this->stmts; } } diff --git a/lib/PhpParser/Node/Stmt/Global_.php b/lib/PhpParser/Node/Stmt/Global_.php index 29fbc488ee..caadefff1e 100644 --- a/lib/PhpParser/Node/Stmt/Global_.php +++ b/lib/PhpParser/Node/Stmt/Global_.php @@ -20,7 +20,7 @@ public function __construct(array $vars, array $attributes = array()) { $this->vars = $vars; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('vars'); } } diff --git a/lib/PhpParser/Node/Stmt/Goto_.php b/lib/PhpParser/Node/Stmt/Goto_.php index 21b32e188e..e19bfa5cf8 100644 --- a/lib/PhpParser/Node/Stmt/Goto_.php +++ b/lib/PhpParser/Node/Stmt/Goto_.php @@ -21,7 +21,7 @@ public function __construct($name, array $attributes = array()) { $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('name'); } } diff --git a/lib/PhpParser/Node/Stmt/GroupUse.php b/lib/PhpParser/Node/Stmt/GroupUse.php index 30837dd6bb..37866faf57 100644 --- a/lib/PhpParser/Node/Stmt/GroupUse.php +++ b/lib/PhpParser/Node/Stmt/GroupUse.php @@ -22,14 +22,14 @@ class GroupUse extends Stmt * @param int $type Type of group use * @param array $attributes Additional attributes */ - public function __construct(Name $prefix, array $uses, $type = Use_::TYPE_NORMAL, array $attributes = array()) { + public function __construct(Name $prefix, array $uses, int $type = Use_::TYPE_NORMAL, array $attributes = array()) { parent::__construct($attributes); $this->type = $type; $this->prefix = $prefix; $this->uses = $uses; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('type', 'prefix', 'uses'); } } diff --git a/lib/PhpParser/Node/Stmt/HaltCompiler.php b/lib/PhpParser/Node/Stmt/HaltCompiler.php index c33ec9f1da..28533451d6 100644 --- a/lib/PhpParser/Node/Stmt/HaltCompiler.php +++ b/lib/PhpParser/Node/Stmt/HaltCompiler.php @@ -15,12 +15,12 @@ class HaltCompiler extends Stmt * @param string $remaining Remaining text after halt compiler statement. * @param array $attributes Additional attributes */ - public function __construct($remaining, array $attributes = array()) { + public function __construct(string $remaining, array $attributes = array()) { parent::__construct($attributes); $this->remaining = $remaining; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('remaining'); } } diff --git a/lib/PhpParser/Node/Stmt/If_.php b/lib/PhpParser/Node/Stmt/If_.php index d69be6f6f4..220352b3a8 100644 --- a/lib/PhpParser/Node/Stmt/If_.php +++ b/lib/PhpParser/Node/Stmt/If_.php @@ -33,7 +33,7 @@ public function __construct(Node\Expr $cond, array $subNodes = array(), array $a $this->else = $subNodes['else'] ?? null; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('cond', 'stmts', 'elseifs', 'else'); } } diff --git a/lib/PhpParser/Node/Stmt/InlineHTML.php b/lib/PhpParser/Node/Stmt/InlineHTML.php index accebe61ea..8e02038dec 100644 --- a/lib/PhpParser/Node/Stmt/InlineHTML.php +++ b/lib/PhpParser/Node/Stmt/InlineHTML.php @@ -15,12 +15,12 @@ class InlineHTML extends Stmt * @param string $value String * @param array $attributes Additional attributes */ - public function __construct($value, array $attributes = array()) { + public function __construct(string $value, array $attributes = array()) { parent::__construct($attributes); $this->value = $value; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('value'); } } diff --git a/lib/PhpParser/Node/Stmt/Interface_.php b/lib/PhpParser/Node/Stmt/Interface_.php index b7edcfe6fd..d9942dafa9 100644 --- a/lib/PhpParser/Node/Stmt/Interface_.php +++ b/lib/PhpParser/Node/Stmt/Interface_.php @@ -25,7 +25,7 @@ public function __construct($name, array $subNodes = array(), array $attributes $this->stmts = $subNodes['stmts'] ?? array(); } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('name', 'extends', 'stmts'); } } diff --git a/lib/PhpParser/Node/Stmt/Label.php b/lib/PhpParser/Node/Stmt/Label.php index 4d91f8f619..9ba7235f75 100644 --- a/lib/PhpParser/Node/Stmt/Label.php +++ b/lib/PhpParser/Node/Stmt/Label.php @@ -21,7 +21,7 @@ public function __construct($name, array $attributes = array()) { $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('name'); } } diff --git a/lib/PhpParser/Node/Stmt/Namespace_.php b/lib/PhpParser/Node/Stmt/Namespace_.php index e585d727d9..050e6d4537 100644 --- a/lib/PhpParser/Node/Stmt/Namespace_.php +++ b/lib/PhpParser/Node/Stmt/Namespace_.php @@ -24,7 +24,7 @@ public function __construct(Node\Name $name = null, $stmts = array(), array $att $this->stmts = $stmts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('name', 'stmts'); } } diff --git a/lib/PhpParser/Node/Stmt/Nop.php b/lib/PhpParser/Node/Stmt/Nop.php index 270dd0995a..6dce539fb7 100644 --- a/lib/PhpParser/Node/Stmt/Nop.php +++ b/lib/PhpParser/Node/Stmt/Nop.php @@ -7,7 +7,7 @@ /** Nop/empty statement (;). */ class Nop extends Node\Stmt { - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array(); } } diff --git a/lib/PhpParser/Node/Stmt/Property.php b/lib/PhpParser/Node/Stmt/Property.php index 5bd7652d19..b12db034fd 100644 --- a/lib/PhpParser/Node/Stmt/Property.php +++ b/lib/PhpParser/Node/Stmt/Property.php @@ -18,13 +18,13 @@ class Property extends Node\Stmt * @param PropertyProperty[] $props Properties * @param array $attributes Additional attributes */ - public function __construct($flags, array $props, array $attributes = array()) { + public function __construct(int $flags, array $props, array $attributes = array()) { parent::__construct($attributes); $this->flags = $flags; $this->props = $props; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('flags', 'props'); } @@ -33,7 +33,7 @@ public function getSubNodeNames() { * * @return bool */ - public function isPublic() { + public function isPublic() : bool { return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; } @@ -43,7 +43,7 @@ public function isPublic() { * * @return bool */ - public function isProtected() { + public function isProtected() : bool { return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); } @@ -52,7 +52,7 @@ public function isProtected() { * * @return bool */ - public function isPrivate() { + public function isPrivate() : bool { return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); } @@ -61,7 +61,7 @@ public function isPrivate() { * * @return bool */ - public function isStatic() { + public function isStatic() : bool { return (bool) ($this->flags & Class_::MODIFIER_STATIC); } } diff --git a/lib/PhpParser/Node/Stmt/PropertyProperty.php b/lib/PhpParser/Node/Stmt/PropertyProperty.php index da9a17a17f..e2074001e7 100644 --- a/lib/PhpParser/Node/Stmt/PropertyProperty.php +++ b/lib/PhpParser/Node/Stmt/PropertyProperty.php @@ -24,7 +24,7 @@ public function __construct($name, Node\Expr $default = null, array $attributes $this->default = $default; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('name', 'default'); } } diff --git a/lib/PhpParser/Node/Stmt/Return_.php b/lib/PhpParser/Node/Stmt/Return_.php index b64284114a..8df1dba3a0 100644 --- a/lib/PhpParser/Node/Stmt/Return_.php +++ b/lib/PhpParser/Node/Stmt/Return_.php @@ -20,7 +20,7 @@ public function __construct(Node\Expr $expr = null, array $attributes = array()) $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Stmt/StaticVar.php b/lib/PhpParser/Node/Stmt/StaticVar.php index 09b8315fad..4a6445dbad 100644 --- a/lib/PhpParser/Node/Stmt/StaticVar.php +++ b/lib/PhpParser/Node/Stmt/StaticVar.php @@ -27,7 +27,7 @@ public function __construct( $this->default = $default; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('var', 'default'); } } diff --git a/lib/PhpParser/Node/Stmt/Static_.php b/lib/PhpParser/Node/Stmt/Static_.php index 37cc0b36f3..6729f629fb 100644 --- a/lib/PhpParser/Node/Stmt/Static_.php +++ b/lib/PhpParser/Node/Stmt/Static_.php @@ -20,7 +20,7 @@ public function __construct(array $vars, array $attributes = array()) { $this->vars = $vars; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('vars'); } } diff --git a/lib/PhpParser/Node/Stmt/Switch_.php b/lib/PhpParser/Node/Stmt/Switch_.php index 72d667b1e3..e5356b3c68 100644 --- a/lib/PhpParser/Node/Stmt/Switch_.php +++ b/lib/PhpParser/Node/Stmt/Switch_.php @@ -24,7 +24,7 @@ public function __construct(Node\Expr $cond, array $cases, array $attributes = a $this->cases = $cases; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('cond', 'cases'); } } diff --git a/lib/PhpParser/Node/Stmt/Throw_.php b/lib/PhpParser/Node/Stmt/Throw_.php index f8ff6aa383..01cb4a1a7c 100644 --- a/lib/PhpParser/Node/Stmt/Throw_.php +++ b/lib/PhpParser/Node/Stmt/Throw_.php @@ -20,7 +20,7 @@ public function __construct(Node\Expr $expr, array $attributes = array()) { $this->expr = $expr; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('expr'); } } diff --git a/lib/PhpParser/Node/Stmt/TraitUse.php b/lib/PhpParser/Node/Stmt/TraitUse.php index a29874bea4..22b29ea2fc 100644 --- a/lib/PhpParser/Node/Stmt/TraitUse.php +++ b/lib/PhpParser/Node/Stmt/TraitUse.php @@ -25,7 +25,7 @@ public function __construct(array $traits, array $adaptations = array(), array $ $this->adaptations = $adaptations; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('traits', 'adaptations'); } } diff --git a/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php b/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php index 5a017007a6..83abf56534 100644 --- a/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +++ b/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php @@ -28,7 +28,7 @@ public function __construct($trait, $method, $newModifier, $newName, array $attr $this->newName = \is_string($newName) ? new Node\Identifier($newName) : $newName; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('trait', 'method', 'newModifier', 'newName'); } } diff --git a/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php b/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php index 4b243f9419..e4e86f8e00 100644 --- a/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +++ b/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php @@ -24,7 +24,7 @@ public function __construct(Node\Name $trait, $method, array $insteadof, array $ $this->insteadof = $insteadof; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('trait', 'method', 'insteadof'); } } diff --git a/lib/PhpParser/Node/Stmt/Trait_.php b/lib/PhpParser/Node/Stmt/Trait_.php index 9b9449102b..6170489eac 100644 --- a/lib/PhpParser/Node/Stmt/Trait_.php +++ b/lib/PhpParser/Node/Stmt/Trait_.php @@ -20,7 +20,7 @@ public function __construct($name, array $subNodes = array(), array $attributes $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('name', 'stmts'); } } diff --git a/lib/PhpParser/Node/Stmt/TryCatch.php b/lib/PhpParser/Node/Stmt/TryCatch.php index eb44c46b0a..f342276056 100644 --- a/lib/PhpParser/Node/Stmt/TryCatch.php +++ b/lib/PhpParser/Node/Stmt/TryCatch.php @@ -28,7 +28,7 @@ public function __construct(array $stmts, array $catches, Finally_ $finally = nu $this->finally = $finally; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('stmts', 'catches', 'finally'); } } diff --git a/lib/PhpParser/Node/Stmt/Unset_.php b/lib/PhpParser/Node/Stmt/Unset_.php index 0f00fe9415..6df28f252e 100644 --- a/lib/PhpParser/Node/Stmt/Unset_.php +++ b/lib/PhpParser/Node/Stmt/Unset_.php @@ -20,7 +20,7 @@ public function __construct(array $vars, array $attributes = array()) { $this->vars = $vars; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('vars'); } } diff --git a/lib/PhpParser/Node/Stmt/UseUse.php b/lib/PhpParser/Node/Stmt/UseUse.php index 34417f3c5a..efd964a897 100644 --- a/lib/PhpParser/Node/Stmt/UseUse.php +++ b/lib/PhpParser/Node/Stmt/UseUse.php @@ -22,14 +22,14 @@ class UseUse extends Node\Stmt * @param int $type Type of the use element (for mixed group use only) * @param array $attributes Additional attributes */ - public function __construct(Node\Name $name, $alias = null, $type = Use_::TYPE_UNKNOWN, array $attributes = array()) { + public function __construct(Node\Name $name, $alias = null, int $type = Use_::TYPE_UNKNOWN, array $attributes = array()) { parent::__construct($attributes); $this->type = $type; $this->name = $name; $this->alias = \is_string($alias) ? new Identifier($alias) : $alias; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('type', 'name', 'alias'); } @@ -38,7 +38,7 @@ public function getSubNodeNames() { * * @return Identifier */ - public function getAlias() { + public function getAlias() : Identifier { if (null !== $this->alias) { return $this->alias; } diff --git a/lib/PhpParser/Node/Stmt/Use_.php b/lib/PhpParser/Node/Stmt/Use_.php index 6c89ebb1be..e179bc0f46 100644 --- a/lib/PhpParser/Node/Stmt/Use_.php +++ b/lib/PhpParser/Node/Stmt/Use_.php @@ -31,13 +31,13 @@ class Use_ extends Stmt * @param int $type Type of alias * @param array $attributes Additional attributes */ - public function __construct(array $uses, $type = self::TYPE_NORMAL, array $attributes = array()) { + public function __construct(array $uses, int $type = self::TYPE_NORMAL, array $attributes = array()) { parent::__construct($attributes); $this->type = $type; $this->uses = $uses; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('type', 'uses'); } } diff --git a/lib/PhpParser/Node/Stmt/While_.php b/lib/PhpParser/Node/Stmt/While_.php index a36a8cfd7b..d35498cc17 100644 --- a/lib/PhpParser/Node/Stmt/While_.php +++ b/lib/PhpParser/Node/Stmt/While_.php @@ -24,7 +24,7 @@ public function __construct(Node\Expr $cond, array $stmts = array(), array $attr $this->stmts = $stmts; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('cond', 'stmts'); } } diff --git a/lib/PhpParser/NodeAbstract.php b/lib/PhpParser/NodeAbstract.php index a691c073e7..29a63c9304 100644 --- a/lib/PhpParser/NodeAbstract.php +++ b/lib/PhpParser/NodeAbstract.php @@ -20,7 +20,7 @@ public function __construct(array $attributes = array()) { * * @return string Type of the node */ - public function getType() { + public function getType() : string { return strtr(substr(rtrim(get_class($this), '_'), 15), '\\', '_'); } @@ -29,7 +29,7 @@ public function getType() { * * @return int Line */ - public function getLine() { + public function getLine() : int { return $this->getAttribute('startLine', -1); } @@ -38,7 +38,7 @@ public function getLine() { * * @param int $line Line */ - public function setLine($line) { + public function setLine(int $line) { $this->setAttribute('startLine', (int) $line); } @@ -85,15 +85,15 @@ public function setDocComment(Comment\Doc $docComment) { $this->setAttribute('comments', $comments); } - public function setAttribute($key, $value) { + public function setAttribute(string $key, $value) { $this->attributes[$key] = $value; } - public function hasAttribute($key) { + public function hasAttribute(string $key) : bool { return array_key_exists($key, $this->attributes); } - public function &getAttribute($key, $default = null) { + public function &getAttribute(string $key, $default = null) { if (!array_key_exists($key, $this->attributes)) { return $default; } else { @@ -101,7 +101,7 @@ public function &getAttribute($key, $default = null) { } } - public function getAttributes() { + public function getAttributes() : array { return $this->attributes; } @@ -112,7 +112,7 @@ public function setAttributes(array $attributes) { /** * @return array */ - public function jsonSerialize() { + public function jsonSerialize() : array { return ['nodeType' => $this->getType()] + get_object_vars($this); } } diff --git a/lib/PhpParser/NodeDumper.php b/lib/PhpParser/NodeDumper.php index 385e58a2ab..9b058c0bb7 100644 --- a/lib/PhpParser/NodeDumper.php +++ b/lib/PhpParser/NodeDumper.php @@ -39,7 +39,7 @@ public function __construct(array $options = []) { * * @return string Dumped value */ - public function dump($node, $code = null) { + public function dump($node, string $code = null) : string { $this->code = $code; return $this->dumpRecursive($node); } diff --git a/lib/PhpParser/NodeFinder.php b/lib/PhpParser/NodeFinder.php index cc82978a7e..c7589ee88a 100644 --- a/lib/PhpParser/NodeFinder.php +++ b/lib/PhpParser/NodeFinder.php @@ -14,7 +14,7 @@ class NodeFinder { * * @return Node[] Found nodes satisfying the filter callback */ - public function find($nodes, callable $filter) { + public function find($nodes, callable $filter) : array { if (!is_array($nodes)) { $nodes = [$nodes]; } @@ -36,7 +36,7 @@ public function find($nodes, callable $filter) { * * @return Node[] Found nodes (all instances of $class) */ - public function findInstanceOf($nodes, $class) { + public function findInstanceOf($nodes, string $class) : array { return $this->find($nodes, function ($node) use ($class) { return $node instanceof $class; }); @@ -72,7 +72,7 @@ public function findFirst($nodes, callable $filter) { * * @return null|Node Found node, which is an instance of $class (or null if none found) */ - public function findFirstInstanceOf($nodes, $class) { + public function findFirstInstanceOf($nodes, string $class) { return $this->findFirst($nodes, function ($node) use ($class) { return $node instanceof $class; }); diff --git a/lib/PhpParser/NodeTraverser.php b/lib/PhpParser/NodeTraverser.php index fd257b3505..6016563a8b 100644 --- a/lib/PhpParser/NodeTraverser.php +++ b/lib/PhpParser/NodeTraverser.php @@ -73,7 +73,7 @@ public function removeVisitor(NodeVisitor $visitor) { * * @return Node[] Traversed array of nodes */ - public function traverse(array $nodes) { + public function traverse(array $nodes) : array { $this->stopTraversal = false; foreach ($this->visitors as $visitor) { @@ -100,7 +100,7 @@ public function traverse(array $nodes) { * * @return Node Result of traversal (may be original node or new one) */ - protected function traverseNode(Node $node) { + protected function traverseNode(Node $node) : Node { foreach ($node->getSubNodeNames() as $name) { $subNode =& $node->$name; @@ -169,7 +169,7 @@ protected function traverseNode(Node $node) { * * @return array Result of traversal (may be original array or changed one) */ - protected function traverseArray(array $nodes) { + protected function traverseArray(array $nodes) : array { $doNodes = array(); foreach ($nodes as $i => &$node) { diff --git a/lib/PhpParser/NodeTraverserInterface.php b/lib/PhpParser/NodeTraverserInterface.php index 0f88e4671d..405657423d 100644 --- a/lib/PhpParser/NodeTraverserInterface.php +++ b/lib/PhpParser/NodeTraverserInterface.php @@ -25,6 +25,6 @@ function removeVisitor(NodeVisitor $visitor); * * @return Node[] Traversed array of nodes */ - function traverse(array $nodes); + function traverse(array $nodes) : array; } diff --git a/lib/PhpParser/NodeVisitor/FindingVisitor.php b/lib/PhpParser/NodeVisitor/FindingVisitor.php index dc152fead2..445c8d384e 100644 --- a/lib/PhpParser/NodeVisitor/FindingVisitor.php +++ b/lib/PhpParser/NodeVisitor/FindingVisitor.php @@ -26,7 +26,7 @@ public function __construct(callable $filterCallback) { * * @return Node[] Found nodes */ - public function getFoundNodes() { + public function getFoundNodes() : array { return $this->foundNodes; } diff --git a/lib/PhpParser/NodeVisitor/NameResolver.php b/lib/PhpParser/NodeVisitor/NameResolver.php index 18942cc620..ba4a5bad7c 100644 --- a/lib/PhpParser/NodeVisitor/NameResolver.php +++ b/lib/PhpParser/NodeVisitor/NameResolver.php @@ -47,7 +47,7 @@ public function __construct(ErrorHandler $errorHandler = null, array $options = * * @return NameContext */ - public function getNameContext() { + public function getNameContext() : NameContext { return $this->nameContext; } @@ -176,7 +176,7 @@ private function resolveType($node) { * * @return Name Resolved name, or original name with attribute */ - protected function resolveName(Name $name, $type) { + protected function resolveName(Name $name, int $type) : Name { if (!$this->replaceNodes) { $resolvedName = $this->nameContext->getResolvedName($name, $type); if (null !== $resolvedName) { diff --git a/lib/PhpParser/Parser.php b/lib/PhpParser/Parser.php index 717a24f61a..b2734ff690 100644 --- a/lib/PhpParser/Parser.php +++ b/lib/PhpParser/Parser.php @@ -13,5 +13,5 @@ interface Parser { * @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and * the parser was unable to recover from an error). */ - public function parse($code, ErrorHandler $errorHandler = null); + public function parse(string $code, ErrorHandler $errorHandler = null); } diff --git a/lib/PhpParser/Parser/Multiple.php b/lib/PhpParser/Parser/Multiple.php index 25296a4ef6..0527fa11e8 100644 --- a/lib/PhpParser/Parser/Multiple.php +++ b/lib/PhpParser/Parser/Multiple.php @@ -23,7 +23,7 @@ public function __construct(array $parsers) { $this->parsers = $parsers; } - public function parse($code, ErrorHandler $errorHandler = null) { + public function parse(string $code, ErrorHandler $errorHandler = null) { if (null === $errorHandler) { $errorHandler = new ErrorHandler\Throwing; } diff --git a/lib/PhpParser/ParserAbstract.php b/lib/PhpParser/ParserAbstract.php index c639d53f32..835780a87e 100644 --- a/lib/PhpParser/ParserAbstract.php +++ b/lib/PhpParser/ParserAbstract.php @@ -150,7 +150,7 @@ public function __construct(Lexer $lexer, array $options = array()) { * @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and * the parser was unable to recover from an error). */ - public function parse($code, ErrorHandler $errorHandler = null) { + public function parse(string $code, ErrorHandler $errorHandler = null) { $this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing; // Initialize the lexer @@ -368,7 +368,7 @@ protected function emitError(Error $error) { * * @return string Formatted error message */ - protected function getErrorMessage($symbol, $state) { + protected function getErrorMessage(int $symbol, int $state) : string { $expectedString = ''; if ($expected = $this->getExpectedTokens($state)) { $expectedString = ', expecting ' . implode(' or ', $expected); @@ -384,7 +384,7 @@ protected function getErrorMessage($symbol, $state) { * * @return string[] Expected tokens. If too many, an empty array is returned. */ - protected function getExpectedTokens($state) { + protected function getExpectedTokens(int $state) : array { $expected = array(); $base = $this->actionBase[$state]; @@ -457,7 +457,7 @@ protected function traceDiscard($symbol) { * @param Node\Stmt[] $stmts * @return Node\Stmt[] */ - protected function handleNamespaces(array $stmts) { + protected function handleNamespaces(array $stmts) : array { $hasErrored = false; $style = $this->getNamespacingStyle($stmts); if (null === $style) { @@ -593,7 +593,7 @@ private function getNamespacingStyle(array $stmts) { * * @return Expr\StaticCall */ - protected function fixupPhp5StaticPropCall($prop, array $args, array $attributes) { + protected function fixupPhp5StaticPropCall($prop, array $args, array $attributes) : Expr\StaticCall { if ($prop instanceof Node\Expr\StaticPropertyFetch) { $var = new Expr\Variable($prop->name, $prop->name->getAttributes()); return new Expr\StaticCall($prop->class, $var, $args, $attributes); @@ -666,7 +666,7 @@ protected function handleBuiltinTypes(Name $name) { * * @return array Combined start and end attributes */ - protected function getAttributesAt($pos) { + protected function getAttributesAt(int $pos) : array { return $this->startAttributeStack[$pos] + $this->endAttributeStack[$pos]; } @@ -688,7 +688,7 @@ protected function parseLNumber($str, $attributes, $allowInvalidOctal = false) { * * @return LNumber|String_ Integer or string node. */ - protected function parseNumString($str, array $attributes) { + protected function parseNumString(string $str, array $attributes) { if (!preg_match('/^(?:0|-?[1-9][0-9]*)$/', $str)) { return new String_($str, $attributes); } diff --git a/lib/PhpParser/ParserFactory.php b/lib/PhpParser/ParserFactory.php index 28b9070d40..8721fce4c2 100644 --- a/lib/PhpParser/ParserFactory.php +++ b/lib/PhpParser/ParserFactory.php @@ -17,7 +17,7 @@ class ParserFactory { * * @return Parser The parser instance */ - public function create($kind, Lexer $lexer = null, array $parserOptions = array()) { + public function create(int $kind, Lexer $lexer = null, array $parserOptions = array()) : Parser { if (null === $lexer) { $lexer = new Lexer\Emulative(); } diff --git a/lib/PhpParser/PrettyPrinterAbstract.php b/lib/PhpParser/PrettyPrinterAbstract.php index 7fc900eabd..97927bb773 100644 --- a/lib/PhpParser/PrettyPrinterAbstract.php +++ b/lib/PhpParser/PrettyPrinterAbstract.php @@ -136,7 +136,7 @@ public function __construct(array $options = []) { * * @return string Pretty printed statements */ - public function prettyPrint(array $stmts) { + public function prettyPrint(array $stmts) : string { $this->preprocessNodes($stmts); return ltrim($this->handleMagicTokens($this->pStmts($stmts, false))); @@ -149,7 +149,7 @@ public function prettyPrint(array $stmts) { * * @return string Pretty printed node */ - public function prettyPrintExpr(Expr $node) { + public function prettyPrintExpr(Expr $node) : string { return $this->handleMagicTokens($this->p($node)); } @@ -160,7 +160,7 @@ public function prettyPrintExpr(Expr $node) { * * @return string Pretty printed statements */ - public function prettyPrintFile(array $stmts) { + public function prettyPrintFile(array $stmts) : string { if (!$stmts) { return "noIndentToken, '', $str); @@ -217,7 +217,7 @@ protected function handleMagicTokens($str) { * * @return string Pretty printed statements */ - protected function pStmts(array $nodes, $indent = true) { + protected function pStmts(array $nodes, bool $indent = true) : string { $result = ''; foreach ($nodes as $node) { $comments = $node->getAttribute('comments', array()); @@ -248,7 +248,7 @@ protected function pStmts(array $nodes, $indent = true) { * * @return string Pretty printed infix operation */ - protected function pInfixOp($type, Node $leftNode, $operatorString, Node $rightNode) { + protected function pInfixOp(string $type, Node $leftNode, string $operatorString, Node $rightNode) : string { list($precedence, $associativity) = $this->precedenceMap[$type]; return $this->pPrec($leftNode, $precedence, $associativity, -1) @@ -265,7 +265,7 @@ protected function pInfixOp($type, Node $leftNode, $operatorString, Node $rightN * * @return string Pretty printed prefix operation */ - protected function pPrefixOp($type, $operatorString, Node $node) { + protected function pPrefixOp(string $type, string $operatorString, Node $node) : string { list($precedence, $associativity) = $this->precedenceMap[$type]; return $operatorString . $this->pPrec($node, $precedence, $associativity, 1); } @@ -279,7 +279,7 @@ protected function pPrefixOp($type, $operatorString, Node $node) { * * @return string Pretty printed postfix operation */ - protected function pPostfixOp($type, Node $node, $operatorString) { + protected function pPostfixOp(string $type, Node $node, string $operatorString) : string { list($precedence, $associativity) = $this->precedenceMap[$type]; return $this->pPrec($node, $precedence, $associativity, -1) . $operatorString; } @@ -296,7 +296,7 @@ protected function pPostfixOp($type, Node $node, $operatorString) { * * @return string The pretty printed node */ - protected function pPrec(Node $node, $parentPrecedence, $parentAssociativity, $childPosition) { + protected function pPrec(Node $node, int $parentPrecedence, int $parentAssociativity, int $childPosition) : string { $type = $node->getType(); if (isset($this->precedenceMap[$type])) { $childPrecedence = $this->precedenceMap[$type][0]; @@ -318,7 +318,7 @@ protected function pPrec(Node $node, $parentPrecedence, $parentAssociativity, $c * * @return string Imploded pretty printed nodes */ - protected function pImplode(array $nodes, $glue = '') { + protected function pImplode(array $nodes, string $glue = '') : string { $pNodes = array(); foreach ($nodes as $node) { if (null === $node) { @@ -338,7 +338,7 @@ protected function pImplode(array $nodes, $glue = '') { * * @return string Comma separated pretty printed nodes */ - protected function pCommaSeparated(array $nodes) { + protected function pCommaSeparated(array $nodes) : string { return $this->pImplode($nodes, ', '); } @@ -352,7 +352,7 @@ protected function pCommaSeparated(array $nodes) { * * @return string Comma separated pretty printed nodes in multiline style */ - protected function pCommaSeparatedMultiline(array $nodes, $trailingComma) { + protected function pCommaSeparatedMultiline(array $nodes, bool $trailingComma) : string { $result = ''; $lastIdx = count($nodes) - 1; foreach ($nodes as $idx => $node) { @@ -381,7 +381,7 @@ protected function pCommaSeparatedMultiline(array $nodes, $trailingComma) { * * @return string String marked with $this->noIndentToken's. */ - protected function pNoIndent($string) { + protected function pNoIndent(string $string) : string { return str_replace("\n", "\n" . $this->noIndentToken, $string); } @@ -392,7 +392,7 @@ protected function pNoIndent($string) { * * @return string Reformatted text of comments */ - protected function pComments(array $comments) { + protected function pComments(array $comments) : string { $formattedComments = []; foreach ($comments as $comment) { @@ -419,7 +419,7 @@ protected function pComments(array $comments) { * * @return string */ - public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens) { + public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens) : string { $this->initializeLabelCharMap(); $this->initializeFixupMap(); $this->initializeRemovalMap(); @@ -456,7 +456,7 @@ protected function pFallback(Node $node) { * * @return string Pretty printed node */ - protected function p(Node $node) { + protected function p(Node $node) : string { // No orig tokens means this is a normal pretty print without preservation of formatting if (!$this->origTokens) { return $this->{'p' . $node->getType()}($node); @@ -620,7 +620,7 @@ protected function p(Node $node) { * * @return null|string Result of pretty print or null if cannot preserve formatting */ - protected function pArray(array $nodes, array $origNodes, &$pos, $indentAdjustment, $fixup) { + protected function pArray(array $nodes, array $origNodes, int &$pos, int $indentAdjustment, $fixup) { $len = count($nodes); $origLen = count($origNodes); if ($len !== $origLen) { @@ -688,7 +688,7 @@ protected function pArray(array $nodes, array $origNodes, &$pos, $indentAdjustme * * @return string Result of fixed-up print of subnode */ - protected function pFixup($fixup, Node $subNode, $parentType, $subStartPos, $subEndPos) { + protected function pFixup(int $fixup, Node $subNode, $parentType, int $subStartPos, int $subEndPos) : string { switch ($fixup) { case self::FIXUP_PREC_LEFT: case self::FIXUP_PREC_RIGHT: @@ -745,7 +745,7 @@ protected function pFixup($fixup, Node $subNode, $parentType, $subStartPos, $sub * @param string $str * @param string $append */ - protected function safeAppend(&$str, $append) { + protected function safeAppend(string &$str, string $append) { // $append must not be empty in this function if ($str === "") { $str = $append; @@ -767,7 +767,7 @@ protected function safeAppend(&$str, $append) { * * @return int Indentation depth (in spaces) */ - protected function getIndentationBefore($pos) { + protected function getIndentationBefore(int $pos) : int { $tokens = $this->origTokens; $indent = 0; $pos--; @@ -796,7 +796,7 @@ protected function getIndentationBefore($pos) { * * @return bool */ - protected function haveParens($startPos, $endPos) { + protected function haveParens(int $startPos, int $endPos) : bool { return $this->haveTokenImmediativelyBefore($startPos, '(') && $this->haveTokenImmediatelyAfter($endPos, ')'); } @@ -809,7 +809,7 @@ protected function haveParens($startPos, $endPos) { * * @return bool */ - protected function haveBraces($startPos, $endPos) { + protected function haveBraces(int $startPos, int $endPos) : bool { return $this->haveTokenImmediativelyBefore($startPos, '{') && $this->haveTokenImmediatelyAfter($endPos, '}'); } @@ -824,7 +824,7 @@ protected function haveBraces($startPos, $endPos) { * * @return bool Whether the expected token was found */ - protected function haveTokenImmediativelyBefore($pos, $expectedTokenType) { + protected function haveTokenImmediativelyBefore(int $pos, $expectedTokenType) : bool { $tokens = $this->origTokens; $pos--; for (; $pos >= 0; $pos--) { @@ -850,7 +850,7 @@ protected function haveTokenImmediativelyBefore($pos, $expectedTokenType) { * * @return bool Whether the expected token was found */ - protected function haveTokenImmediatelyAfter($pos, $expectedTokenType) { + protected function haveTokenImmediatelyAfter(int $pos, $expectedTokenType) : bool { $tokens = $this->origTokens; $pos++; for (; $pos < \count($tokens); $pos++) { @@ -875,7 +875,7 @@ protected function haveTokenImmediatelyAfter($pos, $expectedTokenType) { * * @return string Code corresponding to token range, adjusted for indentation */ - protected function getTokenCode($from, $to, $indent) { + protected function getTokenCode(int $from, int $to, int $indent) : string { $tokens = $this->origTokens; $result = ''; for ($pos = $from; $pos < $to; $pos++) { @@ -976,7 +976,7 @@ protected function findRight($pos, $findTokenType) { * * @return bool Whether parentheses are required */ - protected function callLhsRequiresParens(Node $node) { + protected function callLhsRequiresParens(Node $node) : bool { return !($node instanceof Node\Name || $node instanceof Expr\Variable || $node instanceof Expr\ArrayDimFetch @@ -993,7 +993,7 @@ protected function callLhsRequiresParens(Node $node) { * * @return bool Whether parentheses are required */ - protected function dereferenceLhsRequiresParens(Node $node) { + protected function dereferenceLhsRequiresParens(Node $node) : bool { return !($node instanceof Expr\Variable || $node instanceof Node\Name || $node instanceof Expr\ArrayDimFetch diff --git a/test/PhpParser/Node/Stmt/ClassMethodTest.php b/test/PhpParser/Node/Stmt/ClassMethodTest.php index dda99fefc1..75c409f45c 100644 --- a/test/PhpParser/Node/Stmt/ClassMethodTest.php +++ b/test/PhpParser/Node/Stmt/ClassMethodTest.php @@ -47,7 +47,7 @@ public function provideModifiers() { * * @param string $modifier Node type modifier */ - public function testImplicitPublic($modifier) + public function testImplicitPublic(string $modifier) { $node = new ClassMethod('foo', array( 'type' => constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier)) @@ -69,7 +69,7 @@ public function implicitPublicModifiers() { * * @param string $name Node name */ - public function testMagic($name) { + public function testMagic(string $name) { $node = new ClassMethod($name); $this->assertTrue($node->isMagic(), 'Method should be magic'); } diff --git a/test/PhpParser/NodeAbstractTest.php b/test/PhpParser/NodeAbstractTest.php index d8426bde3f..48e0ca5b1b 100644 --- a/test/PhpParser/NodeAbstractTest.php +++ b/test/PhpParser/NodeAbstractTest.php @@ -14,12 +14,12 @@ public function __construct($subNode1, $subNode2, $attributes) { $this->subNode2 = $subNode2; } - public function getSubNodeNames() { + public function getSubNodeNames() : array { return array('subNode1', 'subNode2'); } // This method is only overwritten because the node is located in an unusual namespace - public function getType() { + public function getType() : string { return 'Dummy'; } } diff --git a/test/PhpParser/ParserTest.php b/test/PhpParser/ParserTest.php index ada41912cc..9ccef4b8e0 100644 --- a/test/PhpParser/ParserTest.php +++ b/test/PhpParser/ParserTest.php @@ -176,7 +176,7 @@ public function provideTestExtraAttributes() { } class InvalidTokenLexer extends Lexer { - public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) { + public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) : int { $value = 'foobar'; return 999; }