From 9bbee0d60343b84c3010cef74b3967cd7cdb0309 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Mon, 9 Aug 2021 14:58:06 +0200 Subject: [PATCH] =?UTF-8?q?:arrow=5Fup:=20N=C2=B03867=20Upgrade=20php-pars?= =?UTF-8?q?er=20from=203.1.5=20to=20latest=20version=204.12.0=20The=203.1.?= =?UTF-8?q?5=20version=20wasn't=20maintained=20anymore=20and=20was=20compa?= =?UTF-8?q?tible=20with=20PHP=207.2=20maximum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 2 +- composer.lock | 23 +- lib/composer/ClassLoader.php | 34 + lib/composer/InstalledVersions.php | 10 +- lib/composer/autoload_classmap.php | 11 +- lib/composer/autoload_real.php | 2 +- lib/composer/autoload_static.php | 11 +- lib/composer/installed.json | 23 +- lib/composer/installed.php | 10 +- lib/nikic/php-parser/.editorconfig | 9 + .../php-parser/.github/workflows/main.yml | 86 - lib/nikic/php-parser/.gitignore | 4 - lib/nikic/php-parser/.travis.yml | 31 - lib/nikic/php-parser/CHANGELOG.md | 422 -- lib/nikic/php-parser/LICENSE | 44 +- lib/nikic/php-parser/README.md | 238 +- lib/nikic/php-parser/UPGRADE-1.0.md | 121 - lib/nikic/php-parser/UPGRADE-2.0.md | 74 - lib/nikic/php-parser/UPGRADE-3.0.md | 160 - lib/nikic/php-parser/bin/php-parse | 55 +- lib/nikic/php-parser/composer.json | 29 +- .../php-parser/doc/0_Introduction.markdown | 80 - .../doc/2_Usage_of_basic_components.markdown | 438 -- ...3_Other_node_tree_representations.markdown | 330 - .../php-parser/doc/4_Code_generation.markdown | 84 - .../doc/component/Error_handling.markdown | 75 - .../php-parser/doc/component/Lexer.markdown | 152 - lib/nikic/php-parser/grammar/README.md | 12 +- lib/nikic/php-parser/grammar/parser.template | 27 +- lib/nikic/php-parser/grammar/php5.y | 245 +- lib/nikic/php-parser/grammar/php7.y | 541 +- lib/nikic/php-parser/grammar/phpyLang.php | 192 + .../php-parser/grammar/rebuildParsers.php | 218 +- lib/nikic/php-parser/grammar/tokens.y | 24 +- .../php-parser/lib/PhpParser/Autoloader.php | 40 - .../php-parser/lib/PhpParser/Builder.php | 6 +- .../lib/PhpParser/Builder/ClassConst.php | 132 + .../lib/PhpParser/Builder/Class_.php | 75 +- .../lib/PhpParser/Builder/Declaration.php | 15 +- .../lib/PhpParser/Builder/FunctionLike.php | 17 +- .../lib/PhpParser/Builder/Function_.php | 32 +- .../lib/PhpParser/Builder/Interface_.php | 67 +- .../lib/PhpParser/Builder/Method.php | 44 +- .../lib/PhpParser/Builder/Namespace_.php | 13 +- .../lib/PhpParser/Builder/Param.php | 55 +- .../lib/PhpParser/Builder/Property.php | 84 +- .../lib/PhpParser/Builder/Trait_.php | 43 +- .../php-parser/lib/PhpParser/Builder/Use_.php | 35 +- .../lib/PhpParser/BuilderAbstract.php | 175 - .../lib/PhpParser/BuilderFactory.php | 306 +- .../lib/PhpParser/BuilderHelpers.php | 93 +- .../php-parser/lib/PhpParser/Comment.php | 143 +- .../php-parser/lib/PhpParser/Comment/Doc.php | 4 +- lib/nikic/php-parser/lib/PhpParser/Error.php | 58 +- .../php-parser/lib/PhpParser/ErrorHandler.php | 4 +- .../lib/PhpParser/ErrorHandler/Collecting.php | 8 +- .../lib/PhpParser/ErrorHandler/Throwing.php | 4 +- lib/nikic/php-parser/lib/PhpParser/Lexer.php | 349 +- .../lib/PhpParser/Lexer/Emulative.php | 352 +- .../Lexer/TokenEmulator/EnumTokenEmulator.php | 31 + .../Lexer/TokenEmulator/KeywordEmulator.php | 14 +- .../TokenEmulator/ReadonlyTokenEmulator.php | 23 + lib/nikic/php-parser/lib/PhpParser/Node.php | 97 +- .../php-parser/lib/PhpParser/Node/Arg.php | 21 +- .../php-parser/lib/PhpParser/Node/Const_.php | 27 +- .../php-parser/lib/PhpParser/Node/Expr.php | 4 +- .../lib/PhpParser/Node/Expr/ArrayDimFetch.php | 14 +- .../lib/PhpParser/Node/Expr/ArrayItem.php | 17 +- .../lib/PhpParser/Node/Expr/Array_.php | 18 +- .../lib/PhpParser/Node/Expr/Assign.php | 14 +- .../lib/PhpParser/Node/Expr/AssignOp.php | 10 +- .../Node/Expr/AssignOp/BitwiseAnd.php | 7 +- .../Node/Expr/AssignOp/BitwiseOr.php | 7 +- .../Node/Expr/AssignOp/BitwiseXor.php | 7 +- .../PhpParser/Node/Expr/AssignOp/Concat.php | 7 +- .../lib/PhpParser/Node/Expr/AssignOp/Div.php | 7 +- .../PhpParser/Node/Expr/AssignOp/Minus.php | 7 +- .../lib/PhpParser/Node/Expr/AssignOp/Mod.php | 7 +- .../lib/PhpParser/Node/Expr/AssignOp/Mul.php | 7 +- .../lib/PhpParser/Node/Expr/AssignOp/Plus.php | 7 +- .../lib/PhpParser/Node/Expr/AssignOp/Pow.php | 7 +- .../Node/Expr/AssignOp/ShiftLeft.php | 7 +- .../Node/Expr/AssignOp/ShiftRight.php | 7 +- .../lib/PhpParser/Node/Expr/AssignRef.php | 14 +- .../lib/PhpParser/Node/Expr/BinaryOp.php | 22 +- .../Node/Expr/BinaryOp/BitwiseAnd.php | 11 +- .../Node/Expr/BinaryOp/BitwiseOr.php | 11 +- .../Node/Expr/BinaryOp/BitwiseXor.php | 11 +- .../Node/Expr/BinaryOp/BooleanAnd.php | 11 +- .../Node/Expr/BinaryOp/BooleanOr.php | 11 +- .../PhpParser/Node/Expr/BinaryOp/Coalesce.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Concat.php | 11 +- .../lib/PhpParser/Node/Expr/BinaryOp/Div.php | 11 +- .../PhpParser/Node/Expr/BinaryOp/Equal.php | 11 +- .../PhpParser/Node/Expr/BinaryOp/Greater.php | 11 +- .../Node/Expr/BinaryOp/GreaterOrEqual.php | 11 +- .../Node/Expr/BinaryOp/Identical.php | 11 +- .../Node/Expr/BinaryOp/LogicalAnd.php | 11 +- .../Node/Expr/BinaryOp/LogicalOr.php | 11 +- .../Node/Expr/BinaryOp/LogicalXor.php | 11 +- .../PhpParser/Node/Expr/BinaryOp/Minus.php | 11 +- .../lib/PhpParser/Node/Expr/BinaryOp/Mod.php | 11 +- .../lib/PhpParser/Node/Expr/BinaryOp/Mul.php | 11 +- .../PhpParser/Node/Expr/BinaryOp/NotEqual.php | 11 +- .../Node/Expr/BinaryOp/NotIdentical.php | 11 +- .../lib/PhpParser/Node/Expr/BinaryOp/Plus.php | 11 +- .../lib/PhpParser/Node/Expr/BinaryOp/Pow.php | 11 +- .../Node/Expr/BinaryOp/ShiftLeft.php | 11 +- .../Node/Expr/BinaryOp/ShiftRight.php | 11 +- .../PhpParser/Node/Expr/BinaryOp/Smaller.php | 11 +- .../Node/Expr/BinaryOp/SmallerOrEqual.php | 11 +- .../Node/Expr/BinaryOp/Spaceship.php | 9 +- .../lib/PhpParser/Node/Expr/BitwiseNot.php | 14 +- .../lib/PhpParser/Node/Expr/BooleanNot.php | 14 +- .../lib/PhpParser/Node/Expr/Cast.php | 10 +- .../lib/PhpParser/Node/Expr/Cast/Array_.php | 7 +- .../lib/PhpParser/Node/Expr/Cast/Bool_.php | 5 +- .../lib/PhpParser/Node/Expr/Cast/Double.php | 10 +- .../lib/PhpParser/Node/Expr/Cast/Int_.php | 5 +- .../lib/PhpParser/Node/Expr/Cast/Object_.php | 5 +- .../lib/PhpParser/Node/Expr/Cast/String_.php | 5 +- .../lib/PhpParser/Node/Expr/Cast/Unset_.php | 7 +- .../PhpParser/Node/Expr/ClassConstFetch.php | 25 +- .../lib/PhpParser/Node/Expr/Clone_.php | 14 +- .../lib/PhpParser/Node/Expr/Closure.php | 46 +- .../lib/PhpParser/Node/Expr/ClosureUse.php | 22 +- .../lib/PhpParser/Node/Expr/ConstFetch.php | 14 +- .../lib/PhpParser/Node/Expr/Empty_.php | 14 +- .../lib/PhpParser/Node/Expr/Error.php | 14 +- .../lib/PhpParser/Node/Expr/ErrorSuppress.php | 14 +- .../lib/PhpParser/Node/Expr/Eval_.php | 14 +- .../lib/PhpParser/Node/Expr/Exit_.php | 14 +- .../lib/PhpParser/Node/Expr/FuncCall.php | 18 +- .../lib/PhpParser/Node/Expr/Include_.php | 14 +- .../lib/PhpParser/Node/Expr/Instanceof_.php | 14 +- .../lib/PhpParser/Node/Expr/Isset_.php | 14 +- .../lib/PhpParser/Node/Expr/List_.php | 20 +- .../lib/PhpParser/Node/Expr/MethodCall.php | 27 +- .../lib/PhpParser/Node/Expr/New_.php | 14 +- .../lib/PhpParser/Node/Expr/PostDec.php | 14 +- .../lib/PhpParser/Node/Expr/PostInc.php | 14 +- .../lib/PhpParser/Node/Expr/PreDec.php | 14 +- .../lib/PhpParser/Node/Expr/PreInc.php | 14 +- .../lib/PhpParser/Node/Expr/Print_.php | 14 +- .../lib/PhpParser/Node/Expr/PropertyFetch.php | 25 +- .../lib/PhpParser/Node/Expr/ShellExec.php | 14 +- .../lib/PhpParser/Node/Expr/StaticCall.php | 27 +- .../Node/Expr/StaticPropertyFetch.php | 25 +- .../lib/PhpParser/Node/Expr/Ternary.php | 14 +- .../lib/PhpParser/Node/Expr/UnaryMinus.php | 14 +- .../lib/PhpParser/Node/Expr/UnaryPlus.php | 14 +- .../lib/PhpParser/Node/Expr/Variable.php | 16 +- .../lib/PhpParser/Node/Expr/YieldFrom.php | 14 +- .../lib/PhpParser/Node/Expr/Yield_.php | 14 +- .../lib/PhpParser/Node/FunctionLike.php | 21 +- .../php-parser/lib/PhpParser/Node/Name.php | 104 +- .../PhpParser/Node/Name/FullyQualified.php | 20 +- .../lib/PhpParser/Node/Name/Relative.php | 20 +- .../lib/PhpParser/Node/NullableType.php | 22 +- .../php-parser/lib/PhpParser/Node/Param.php | 50 +- .../php-parser/lib/PhpParser/Node/Scalar.php | 4 +- .../lib/PhpParser/Node/Scalar/DNumber.php | 18 +- .../lib/PhpParser/Node/Scalar/Encapsed.php | 18 +- .../Node/Scalar/EncapsedStringPart.php | 14 +- .../lib/PhpParser/Node/Scalar/LNumber.php | 18 +- .../lib/PhpParser/Node/Scalar/MagicConst.php | 12 +- .../Node/Scalar/MagicConst/Class_.php | 10 +- .../PhpParser/Node/Scalar/MagicConst/Dir.php | 10 +- .../PhpParser/Node/Scalar/MagicConst/File.php | 10 +- .../Node/Scalar/MagicConst/Function_.php | 10 +- .../PhpParser/Node/Scalar/MagicConst/Line.php | 10 +- .../Node/Scalar/MagicConst/Method.php | 10 +- .../Node/Scalar/MagicConst/Namespace_.php | 10 +- .../Node/Scalar/MagicConst/Trait_.php | 10 +- .../lib/PhpParser/Node/Scalar/String_.php | 56 +- .../php-parser/lib/PhpParser/Node/Stmt.php | 4 +- .../lib/PhpParser/Node/Stmt/Break_.php | 14 +- .../lib/PhpParser/Node/Stmt/Case_.php | 20 +- .../lib/PhpParser/Node/Stmt/Catch_.php | 29 +- .../lib/PhpParser/Node/Stmt/ClassConst.php | 59 +- .../lib/PhpParser/Node/Stmt/ClassLike.php | 81 +- .../lib/PhpParser/Node/Stmt/ClassMethod.php | 133 +- .../lib/PhpParser/Node/Stmt/Class_.php | 75 +- .../lib/PhpParser/Node/Stmt/Const_.php | 14 +- .../lib/PhpParser/Node/Stmt/Continue_.php | 14 +- .../PhpParser/Node/Stmt/DeclareDeclare.php | 24 +- .../lib/PhpParser/Node/Stmt/Declare_.php | 18 +- .../lib/PhpParser/Node/Stmt/Do_.php | 24 +- .../lib/PhpParser/Node/Stmt/Echo_.php | 14 +- .../lib/PhpParser/Node/Stmt/ElseIf_.php | 22 +- .../lib/PhpParser/Node/Stmt/Else_.php | 20 +- .../lib/PhpParser/Node/Stmt/EnumCase.php | 37 + .../lib/PhpParser/Node/Stmt/Enum_.php | 40 + .../lib/PhpParser/Node/Stmt/Finally_.php | 20 +- .../lib/PhpParser/Node/Stmt/For_.php | 24 +- .../lib/PhpParser/Node/Stmt/Foreach_.php | 22 +- .../lib/PhpParser/Node/Stmt/Function_.php | 51 +- .../lib/PhpParser/Node/Stmt/Global_.php | 14 +- .../lib/PhpParser/Node/Stmt/Goto_.php | 23 +- .../lib/PhpParser/Node/Stmt/GroupUse.php | 14 +- .../lib/PhpParser/Node/Stmt/HaltCompiler.php | 14 +- .../lib/PhpParser/Node/Stmt/If_.php | 22 +- .../lib/PhpParser/Node/Stmt/InlineHTML.php | 14 +- .../lib/PhpParser/Node/Stmt/Interface_.php | 28 +- .../lib/PhpParser/Node/Stmt/Label.php | 23 +- .../lib/PhpParser/Node/Stmt/Namespace_.php | 22 +- .../lib/PhpParser/Node/Stmt/Nop.php | 10 +- .../lib/PhpParser/Node/Stmt/Property.php | 71 +- .../PhpParser/Node/Stmt/PropertyProperty.php | 24 +- .../lib/PhpParser/Node/Stmt/Return_.php | 14 +- .../lib/PhpParser/Node/Stmt/StaticVar.php | 25 +- .../lib/PhpParser/Node/Stmt/Static_.php | 14 +- .../lib/PhpParser/Node/Stmt/Switch_.php | 14 +- .../lib/PhpParser/Node/Stmt/Throw_.php | 16 +- .../lib/PhpParser/Node/Stmt/TraitUse.php | 15 +- .../Node/Stmt/TraitUseAdaptation.php | 6 +- .../Node/Stmt/TraitUseAdaptation/Alias.php | 30 +- .../Stmt/TraitUseAdaptation/Precedence.php | 24 +- .../lib/PhpParser/Node/Stmt/Trait_.php | 24 +- .../lib/PhpParser/Node/Stmt/TryCatch.php | 22 +- .../lib/PhpParser/Node/Stmt/Unset_.php | 14 +- .../lib/PhpParser/Node/Stmt/UseUse.php | 44 +- .../lib/PhpParser/Node/Stmt/Use_.php | 14 +- .../lib/PhpParser/Node/Stmt/While_.php | 22 +- .../php-parser/lib/PhpParser/NodeAbstract.php | 156 +- .../php-parser/lib/PhpParser/NodeDumper.php | 30 +- .../lib/PhpParser/NodeTraverser.php | 191 +- .../lib/PhpParser/NodeTraverserInterface.php | 9 +- .../php-parser/lib/PhpParser/NodeVisitor.php | 8 +- .../PhpParser/NodeVisitor/NameResolver.php | 237 +- .../lib/PhpParser/NodeVisitorAbstract.php | 23 +- lib/nikic/php-parser/lib/PhpParser/Parser.php | 11 +- .../lib/PhpParser/Parser/Multiple.php | 7 +- .../php-parser/lib/PhpParser/Parser/Php5.php | 5301 ++++++++--------- .../php-parser/lib/PhpParser/Parser/Php7.php | 5122 ++++++++-------- .../lib/PhpParser/Parser/Tokens.php | 254 +- .../lib/PhpParser/ParserAbstract.php | 572 +- .../lib/PhpParser/ParserFactory.php | 7 +- .../lib/PhpParser/PrettyPrinter/Standard.php | 472 +- .../lib/PhpParser/PrettyPrinterAbstract.php | 1401 ++++- .../php-parser/lib/PhpParser/Serializer.php | 18 - .../lib/PhpParser/Serializer/XML.php | 89 - .../php-parser/lib/PhpParser/Unserializer.php | 18 - .../lib/PhpParser/Unserializer/XML.php | 155 - lib/nikic/php-parser/lib/bootstrap.php | 6 - lib/nikic/php-parser/phpunit.xml.dist | 24 - lib/nikic/php-parser/test_old/run-php-src.sh | 4 - lib/nikic/php-parser/test_old/run.php | 220 - 248 files changed, 12185 insertions(+), 11258 deletions(-) create mode 100644 lib/nikic/php-parser/.editorconfig delete mode 100644 lib/nikic/php-parser/.github/workflows/main.yml delete mode 100644 lib/nikic/php-parser/.gitignore delete mode 100644 lib/nikic/php-parser/.travis.yml delete mode 100644 lib/nikic/php-parser/CHANGELOG.md delete mode 100644 lib/nikic/php-parser/UPGRADE-1.0.md delete mode 100644 lib/nikic/php-parser/UPGRADE-2.0.md delete mode 100644 lib/nikic/php-parser/UPGRADE-3.0.md delete mode 100644 lib/nikic/php-parser/doc/0_Introduction.markdown delete mode 100644 lib/nikic/php-parser/doc/2_Usage_of_basic_components.markdown delete mode 100644 lib/nikic/php-parser/doc/3_Other_node_tree_representations.markdown delete mode 100644 lib/nikic/php-parser/doc/4_Code_generation.markdown delete mode 100644 lib/nikic/php-parser/doc/component/Error_handling.markdown delete mode 100644 lib/nikic/php-parser/doc/component/Lexer.markdown create mode 100644 lib/nikic/php-parser/grammar/phpyLang.php delete mode 100644 lib/nikic/php-parser/lib/PhpParser/Autoloader.php create mode 100644 lib/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php delete mode 100644 lib/nikic/php-parser/lib/PhpParser/BuilderAbstract.php create mode 100644 lib/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php create mode 100644 lib/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php create mode 100644 lib/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php create mode 100644 lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php delete mode 100644 lib/nikic/php-parser/lib/PhpParser/Serializer.php delete mode 100644 lib/nikic/php-parser/lib/PhpParser/Serializer/XML.php delete mode 100644 lib/nikic/php-parser/lib/PhpParser/Unserializer.php delete mode 100644 lib/nikic/php-parser/lib/PhpParser/Unserializer/XML.php delete mode 100644 lib/nikic/php-parser/lib/bootstrap.php delete mode 100644 lib/nikic/php-parser/phpunit.xml.dist delete mode 100644 lib/nikic/php-parser/test_old/run-php-src.sh delete mode 100644 lib/nikic/php-parser/test_old/run.php diff --git a/composer.json b/composer.json index ffd7696b6..f2dba2a27 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "ext-mysqli": "*", "ext-soap": "*", "combodo/tcpdf": "6.3.5", - "nikic/php-parser": "^3.1", + "nikic/php-parser": "^4.12.0", "pear/archive_tar": "1.4.13", "pelago/emogrifier": "2.1.0", "scssphp/scssphp": "1.0.6", diff --git a/composer.lock b/composer.lock index 143cf807f..5ea702aec 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "62e394b1ef30b4e716e3e3e519de11dd", + "content-hash": "75f17b71005971207815906ec7e9cf67", "packages": [ { "name": "combodo/tcpdf", @@ -68,24 +68,25 @@ }, { "name": "nikic/php-parser", - "version": "v3.1.5", + "version": "v4.12.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce" + "reference": "6608f01670c3cc5079e18c1dab1104e002579143" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6608f01670c3cc5079e18c1dab1104e002579143", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.5" + "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "~4.0|~5.0" + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" }, "bin": [ "bin/php-parse" @@ -93,7 +94,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.9-dev" } }, "autoload": { @@ -115,7 +116,11 @@ "parser", "php" ], - "time": "2018-02-28T20:30:58+00:00" + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.12.0" + }, + "time": "2021-07-21T10:44:31+00:00" }, { "name": "paragonie/random_compat", diff --git a/lib/composer/ClassLoader.php b/lib/composer/ClassLoader.php index 1a58957d2..247294d66 100644 --- a/lib/composer/ClassLoader.php +++ b/lib/composer/ClassLoader.php @@ -42,6 +42,8 @@ namespace Composer\Autoload; */ class ClassLoader { + private $vendorDir; + // PSR-4 private $prefixLengthsPsr4 = array(); private $prefixDirsPsr4 = array(); @@ -57,6 +59,13 @@ class ClassLoader private $missingClasses = array(); private $apcuPrefix; + private static $registeredLoaders = array(); + + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + public function getPrefixes() { if (!empty($this->prefixesPsr0)) { @@ -300,6 +309,17 @@ class ClassLoader public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } } /** @@ -308,6 +328,10 @@ class ClassLoader public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } } /** @@ -367,6 +391,16 @@ class ClassLoader return $file; } + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + private function findFileWithExtension($class, $ext) { // PSR-4 lookup diff --git a/lib/composer/InstalledVersions.php b/lib/composer/InstalledVersions.php index a2f389016..53b8db9bb 100644 --- a/lib/composer/InstalledVersions.php +++ b/lib/composer/InstalledVersions.php @@ -32,7 +32,7 @@ private static $installed = array ( 'aliases' => array ( ), - 'reference' => '51e24a4e3527c8416bc14fe28284ff67152a36c9', + 'reference' => 'c8dd8c3806d92e19b5a67c16be9d64ceaa2e0524', 'name' => '__root__', ), 'versions' => @@ -44,7 +44,7 @@ private static $installed = array ( 'aliases' => array ( ), - 'reference' => '51e24a4e3527c8416bc14fe28284ff67152a36c9', + 'reference' => 'c8dd8c3806d92e19b5a67c16be9d64ceaa2e0524', ), 'combodo/tcpdf' => array ( @@ -57,12 +57,12 @@ private static $installed = array ( ), 'nikic/php-parser' => array ( - 'pretty_version' => 'v3.1.5', - 'version' => '3.1.5.0', + 'pretty_version' => 'v4.12.0', + 'version' => '4.12.0.0', 'aliases' => array ( ), - 'reference' => 'bb87e28e7d7b8d9a7fda231d37457c9210faf6ce', + 'reference' => '6608f01670c3cc5079e18c1dab1104e002579143', ), 'paragonie/random_compat' => array ( diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index 4afb1ff9a..c3fd41f44 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -571,11 +571,10 @@ return array( 'Pelago\\Emogrifier\\HtmlProcessor\\AbstractHtmlProcessor' => $vendorDir . '/pelago/emogrifier/src/Emogrifier/HtmlProcessor/AbstractHtmlProcessor.php', 'Pelago\\Emogrifier\\HtmlProcessor\\CssToAttributeConverter' => $vendorDir . '/pelago/emogrifier/src/Emogrifier/HtmlProcessor/CssToAttributeConverter.php', 'Pelago\\Emogrifier\\HtmlProcessor\\HtmlNormalizer' => $vendorDir . '/pelago/emogrifier/src/Emogrifier/HtmlProcessor/HtmlNormalizer.php', - 'PhpParser\\Autoloader' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Autoloader.php', 'PhpParser\\Builder' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Builder.php', - 'PhpParser\\BuilderAbstract' => $vendorDir . '/nikic/php-parser/lib/PhpParser/BuilderAbstract.php', 'PhpParser\\BuilderFactory' => $vendorDir . '/nikic/php-parser/lib/PhpParser/BuilderFactory.php', 'PhpParser\\BuilderHelpers' => $vendorDir . '/nikic/php-parser/lib/PhpParser/BuilderHelpers.php', + 'PhpParser\\Builder\\ClassConst' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php', 'PhpParser\\Builder\\Class_' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Builder/Class_.php', 'PhpParser\\Builder\\Declaration' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Builder/Declaration.php', 'PhpParser\\Builder\\FunctionLike' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php', @@ -606,12 +605,14 @@ return array( 'PhpParser\\Lexer\\Emulative' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php', 'PhpParser\\Lexer\\TokenEmulator\\AttributeEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\CoaleseEqualTokenEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php', + 'PhpParser\\Lexer\\TokenEmulator\\EnumTokenEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\FlexibleDocStringEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\FnTokenEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\KeywordEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\MatchTokenEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\NullsafeTokenEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\NumericLiteralSeparatorEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php', + 'PhpParser\\Lexer\\TokenEmulator\\ReadonlyTokenEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\ReverseEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\TokenEmulator' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php', 'PhpParser\\NameContext' => $vendorDir . '/nikic/php-parser/lib/PhpParser/NameContext.php', @@ -767,6 +768,8 @@ return array( 'PhpParser\\Node\\Stmt\\Echo_' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php', 'PhpParser\\Node\\Stmt\\ElseIf_' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php', 'PhpParser\\Node\\Stmt\\Else_' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php', + 'PhpParser\\Node\\Stmt\\EnumCase' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php', + 'PhpParser\\Node\\Stmt\\Enum_' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php', 'PhpParser\\Node\\Stmt\\Expression' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php', 'PhpParser\\Node\\Stmt\\Finally_' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php', 'PhpParser\\Node\\Stmt\\For_' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php', @@ -810,10 +813,6 @@ return array( 'PhpParser\\Parser\\Tokens' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Parser/Tokens.php', 'PhpParser\\PrettyPrinterAbstract' => $vendorDir . '/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php', 'PhpParser\\PrettyPrinter\\Standard' => $vendorDir . '/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php', - 'PhpParser\\Serializer' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Serializer.php', - 'PhpParser\\Serializer\\XML' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Serializer/XML.php', - 'PhpParser\\Unserializer' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Unserializer.php', - 'PhpParser\\Unserializer\\XML' => $vendorDir . '/nikic/php-parser/lib/PhpParser/Unserializer/XML.php', 'PluginInstanciationManager' => $baseDir . '/core/plugininstanciationmanager.class.inc.php', 'PluginManager' => $baseDir . '/core/pluginmanager.class.inc.php', 'PortalDispatcher' => $baseDir . '/application/portaldispatcher.class.inc.php', diff --git a/lib/composer/autoload_real.php b/lib/composer/autoload_real.php index 4f1c7e5ca..661cd2543 100644 --- a/lib/composer/autoload_real.php +++ b/lib/composer/autoload_real.php @@ -25,7 +25,7 @@ class ComposerAutoloaderInit0018331147de7601e7552f7da8e3bb8b require __DIR__ . '/platform_check.php'; spl_autoload_register(array('ComposerAutoloaderInit0018331147de7601e7552f7da8e3bb8b', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); spl_autoload_unregister(array('ComposerAutoloaderInit0018331147de7601e7552f7da8e3bb8b', 'loadClassLoader')); $includePaths = require __DIR__ . '/include_paths.php'; diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index 532085636..9a8a2d2b4 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -801,11 +801,10 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'Pelago\\Emogrifier\\HtmlProcessor\\AbstractHtmlProcessor' => __DIR__ . '/..' . '/pelago/emogrifier/src/Emogrifier/HtmlProcessor/AbstractHtmlProcessor.php', 'Pelago\\Emogrifier\\HtmlProcessor\\CssToAttributeConverter' => __DIR__ . '/..' . '/pelago/emogrifier/src/Emogrifier/HtmlProcessor/CssToAttributeConverter.php', 'Pelago\\Emogrifier\\HtmlProcessor\\HtmlNormalizer' => __DIR__ . '/..' . '/pelago/emogrifier/src/Emogrifier/HtmlProcessor/HtmlNormalizer.php', - 'PhpParser\\Autoloader' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Autoloader.php', 'PhpParser\\Builder' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Builder.php', - 'PhpParser\\BuilderAbstract' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/BuilderAbstract.php', 'PhpParser\\BuilderFactory' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/BuilderFactory.php', 'PhpParser\\BuilderHelpers' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/BuilderHelpers.php', + 'PhpParser\\Builder\\ClassConst' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php', 'PhpParser\\Builder\\Class_' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Builder/Class_.php', 'PhpParser\\Builder\\Declaration' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Builder/Declaration.php', 'PhpParser\\Builder\\FunctionLike' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php', @@ -836,12 +835,14 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'PhpParser\\Lexer\\Emulative' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php', 'PhpParser\\Lexer\\TokenEmulator\\AttributeEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\CoaleseEqualTokenEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php', + 'PhpParser\\Lexer\\TokenEmulator\\EnumTokenEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\FlexibleDocStringEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\FnTokenEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\KeywordEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\MatchTokenEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\NullsafeTokenEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\NumericLiteralSeparatorEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php', + 'PhpParser\\Lexer\\TokenEmulator\\ReadonlyTokenEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\ReverseEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php', 'PhpParser\\Lexer\\TokenEmulator\\TokenEmulator' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php', 'PhpParser\\NameContext' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/NameContext.php', @@ -997,6 +998,8 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'PhpParser\\Node\\Stmt\\Echo_' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php', 'PhpParser\\Node\\Stmt\\ElseIf_' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php', 'PhpParser\\Node\\Stmt\\Else_' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php', + 'PhpParser\\Node\\Stmt\\EnumCase' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php', + 'PhpParser\\Node\\Stmt\\Enum_' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php', 'PhpParser\\Node\\Stmt\\Expression' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php', 'PhpParser\\Node\\Stmt\\Finally_' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php', 'PhpParser\\Node\\Stmt\\For_' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php', @@ -1040,10 +1043,6 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'PhpParser\\Parser\\Tokens' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Parser/Tokens.php', 'PhpParser\\PrettyPrinterAbstract' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php', 'PhpParser\\PrettyPrinter\\Standard' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php', - 'PhpParser\\Serializer' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Serializer.php', - 'PhpParser\\Serializer\\XML' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Serializer/XML.php', - 'PhpParser\\Unserializer' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Unserializer.php', - 'PhpParser\\Unserializer\\XML' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/Unserializer/XML.php', 'PluginInstanciationManager' => __DIR__ . '/../..' . '/core/plugininstanciationmanager.class.inc.php', 'PluginManager' => __DIR__ . '/../..' . '/core/pluginmanager.class.inc.php', 'PortalDispatcher' => __DIR__ . '/../..' . '/application/portaldispatcher.class.inc.php', diff --git a/lib/composer/installed.json b/lib/composer/installed.json index 187997b38..77b2b3667 100644 --- a/lib/composer/installed.json +++ b/lib/composer/installed.json @@ -65,34 +65,35 @@ }, { "name": "nikic/php-parser", - "version": "v3.1.5", - "version_normalized": "3.1.5.0", + "version": "v4.12.0", + "version_normalized": "4.12.0.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce" + "reference": "6608f01670c3cc5079e18c1dab1104e002579143" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6608f01670c3cc5079e18c1dab1104e002579143", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.5" + "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "~4.0|~5.0" + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" }, - "time": "2018-02-28T20:30:58+00:00", + "time": "2021-07-21T10:44:31+00:00", "bin": [ "bin/php-parse" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.9-dev" } }, "installation-source": "dist", @@ -115,6 +116,10 @@ "parser", "php" ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.12.0" + }, "install-path": "../nikic/php-parser" }, { diff --git a/lib/composer/installed.php b/lib/composer/installed.php index ef3b8babd..22fdb170c 100644 --- a/lib/composer/installed.php +++ b/lib/composer/installed.php @@ -6,7 +6,7 @@ 'aliases' => array ( ), - 'reference' => '51e24a4e3527c8416bc14fe28284ff67152a36c9', + 'reference' => 'c8dd8c3806d92e19b5a67c16be9d64ceaa2e0524', 'name' => '__root__', ), 'versions' => @@ -18,7 +18,7 @@ 'aliases' => array ( ), - 'reference' => '51e24a4e3527c8416bc14fe28284ff67152a36c9', + 'reference' => 'c8dd8c3806d92e19b5a67c16be9d64ceaa2e0524', ), 'combodo/tcpdf' => array ( @@ -31,12 +31,12 @@ ), 'nikic/php-parser' => array ( - 'pretty_version' => 'v3.1.5', - 'version' => '3.1.5.0', + 'pretty_version' => 'v4.12.0', + 'version' => '4.12.0.0', 'aliases' => array ( ), - 'reference' => 'bb87e28e7d7b8d9a7fda231d37457c9210faf6ce', + 'reference' => '6608f01670c3cc5079e18c1dab1104e002579143', ), 'paragonie/random_compat' => array ( diff --git a/lib/nikic/php-parser/.editorconfig b/lib/nikic/php-parser/.editorconfig new file mode 100644 index 000000000..9c76d0708 --- /dev/null +++ b/lib/nikic/php-parser/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*.y] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 diff --git a/lib/nikic/php-parser/.github/workflows/main.yml b/lib/nikic/php-parser/.github/workflows/main.yml deleted file mode 100644 index 426d4c83d..000000000 --- a/lib/nikic/php-parser/.github/workflows/main.yml +++ /dev/null @@ -1,86 +0,0 @@ -# https://help.github.com/en/categories/automating-your-workflow-with-github-actions -name: Main -on: - push: - pull_request: - -jobs: - tests_70: - runs-on: "ubuntu-latest" - name: "PHP 7.0 Unit Tests" - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "xdebug" - php-version: "7.0" - tools: composer:v2 - - name: "Install dependencies" - run: | - composer require php-coveralls/php-coveralls:^2.2 --dev --no-update - composer update --no-progress --prefer-dist - - name: "Tests" - run: "php vendor/bin/phpunit --coverage-clover build/logs/clover.xml" - - name: Coveralls - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: "php vendor/bin/php-coveralls" - if: ${{ success() }} - tests: - runs-on: "ubuntu-latest" - name: "PHP ${{ matrix.php-version }} Unit Tests" - strategy: - matrix: - php-version: - - "7.1" - - "7.2" - - "7.3" - - "7.4" - - "8.0" - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "${{ matrix.php-version }}" - tools: composer:v2 - - name: "Install dependencies" - run: "composer update --no-progress --prefer-dist" - - name: "PHPUnit" - run: "php vendor/bin/phpunit" - test_old_73_80: - runs-on: "ubuntu-latest" - name: "PHP 7.3 Code on PHP 8.0 Integration Tests" - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "8.0" - tools: composer:v2 - - name: "Install PHP 8 dependencies" - run: "composer update --no-progress --prefer-dist" - - name: "Tests" - run: "test_old/run-php-src.sh 7.3.21" - test_old_80_70: - runs-on: "ubuntu-latest" - name: "PHP 8.0 Code on PHP 7.0 Integration Tests" - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "7.0" - tools: composer:v2 - - name: "Install PHP 8 dependencies" - run: "composer update --no-progress --prefer-dist" - - name: "Tests" - run: "test_old/run-php-src.sh 8.0.0" diff --git a/lib/nikic/php-parser/.gitignore b/lib/nikic/php-parser/.gitignore deleted file mode 100644 index 8c7db2a6e..000000000 --- a/lib/nikic/php-parser/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -vendor/ -composer.lock -grammar/kmyacc.exe -grammar/y.output diff --git a/lib/nikic/php-parser/.travis.yml b/lib/nikic/php-parser/.travis.yml deleted file mode 100644 index 9cd00253e..000000000 --- a/lib/nikic/php-parser/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: php -dist: trusty -sudo: false - -cache: - directories: - - $HOME/.composer/cache - -php: - - 5.5 - - 5.6 - - 7.0 - - nightly - - hhvm - -install: - - if [ $TRAVIS_PHP_VERSION = '5.6' ]; then composer require satooshi/php-coveralls '~1.0'; fi - - composer install --prefer-dist - -matrix: - allow_failures: - - php: nightly - fast_finish: true - -script: - - if [ $TRAVIS_PHP_VERSION = '5.6' ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; else vendor/bin/phpunit; fi - - if [ $TRAVIS_PHP_VERSION = '7.0' ]; then test_old/run-php-src.sh; fi - -after_success: - if [ $TRAVIS_PHP_VERSION = '5.6' ]; then php vendor/bin/coveralls; fi - diff --git a/lib/nikic/php-parser/CHANGELOG.md b/lib/nikic/php-parser/CHANGELOG.md deleted file mode 100644 index c2d953393..000000000 --- a/lib/nikic/php-parser/CHANGELOG.md +++ /dev/null @@ -1,422 +0,0 @@ -Version 3.1.6-dev ------------------ - -Nothing yet. - -Version 3.1.5 (2018-02-28) --------------------------- - -### Fixed - -* Fixed duplicate comment assignment in switch statements. (#469) -* Improve compatibility with PHP-Scoper. (#477) - -Version 3.1.4 (2018-01-25) --------------------------- - -### Fixed - -* Fixed pretty printing of `-(-$x)` and `+(+$x)`. (#459) - -Version 3.1.3 (2017-12-26) --------------------------- - -### Fixed - -* Improve compatibility with php-scoper, by supporting prefixed namespaces in - `NodeAbstract::getType()`. - -Version 3.1.2 (2017-11-04) --------------------------- - -### Fixed - -* Comments on empty blocks are now preserved on a `Stmt\Nop` node. (#382) - -### Added - -* Added `kind` attribute for `Stmt\Namespace_` node, which is one of `KIND_SEMICOLON` or - `KIND_BRACED`. (#417) -* Added `setDocComment()` method to namespace builder. (#437) - -Version 3.1.1 (2017-09-02) --------------------------- - -### Fixed - -* Fixed syntax error on comment after brace-style namespace declaration. (#412) -* Added support for TraitUse statements in trait builder. (#413) - -Version 3.1.0 (2017-07-28) --------------------------- - -### Added - -* [PHP 7.2] Added support for trailing comma in group use statements. -* [PHP 7.2] Added support for `object` type. This means `object` types will now be represented as a - builtin type (a simple `"object"` string), rather than a class `Name`. - -### Fixed - -* Floating-point numbers are now printed correctly if the LC_NUMERIC locale uses a comma as decimal - separator. - -### Changed - -* `Name::$parts` is no longer deprecated. - -Version 3.0.6 (2017-06-28) --------------------------- - -### Fixed - -* Fixed the spelling of `Class_::VISIBILITY_MODIFIER_MASK`. The previous spelling of - `Class_::VISIBILITY_MODIFER_MASK` is preserved for backwards compatibility. -* The pretty printing will now preserve comments inside array literals and function calls by - printing the array items / function arguments on separate lines. Array literals and functions that - do not contain comments are not affected. - -### Added - -* Added `Builder\Param::makeVariadic()`. - -### Deprecated - -* The `Node::setLine()` method has been deprecated. - -Version 3.0.5 (2017-03-05) --------------------------- - -### Fixed - -* Name resolution of `NullableType`s is now performed earlier, so that a fully resolved signature is - available when a function is entered. (#360) -* `Error` nodes are now considered empty, while previously they extended until the token where the - error occurred. This made some nodes larger than expected. (#359) -* Fixed notices being thrown during error recovery in some situations. (#362) - -Version 3.0.4 (2017-02-10) --------------------------- - -### Fixed - -* Fixed some extensibility issues in pretty printer (`pUseType()` is now public and `pPrec()` calls - into `p()`, instead of directly dispatching to the type-specific printing method). -* Fixed notice in `bin/php-parse` script. - -### Added - -* Error recovery from missing semicolons is now supported in more cases. -* Error recovery from trailing commas in positions where PHP does not support them is now supported. - -Version 3.0.3 (2017-02-03) --------------------------- - -### Fixed - -* In `"$foo[0]"` the `0` is now parsed as an `LNumber` rather than `String`. (#325) -* Ensure integers and floats are always pretty printed preserving semantics, even if the particular - value can only be manually constructed. -* Throw a `LogicException` when trying to pretty-print an `Error` node. Previously this resulted in - an undefined method exception or fatal error. - -### Added - -* [PHP 7.1] Added support for negative interpolated offsets: `"$foo[-1]"` -* Added `preserveOriginalNames` option to `NameResolver`. If this option is enabled, an - `originalName` attribute, containing the unresolved name, will be added to each resolved name. -* Added `php-parse --with-positions` option, which dumps nodes with position information. - -### Deprecated - -* The XML serializer has been deprecated. In particular, the classes `Serializer\XML`, - `Unserializer\XML`, as well as the interfaces `Serializer` and `Unserializer` are deprecated. - -Version 3.0.2 (2016-12-06) --------------------------- - -### Fixed - -* Fixed name resolution of nullable types. (#324) -* Fixed pretty-printing of nullable types. - -Version 3.0.1 (2016-12-01) --------------------------- - -### Fixed - -* Fixed handling of nested `list()`s: If the nested list was unkeyed, it was directly included in - the list items. If it was keyed, it was wrapped in `ArrayItem`. Now nested `List_` nodes are - always wrapped in `ArrayItem`s. (#321) - -Version 3.0.0 (2016-11-30) --------------------------- - -### Added - -* Added support for dumping node positions in the NodeDumper through the `dumpPositions` option. -* Added error recovery support for `$`, `new`, `Foo::`. - -Version 3.0.0-beta2 (2016-10-29) --------------------------------- - -This release primarily improves our support for error recovery. - -### Added - -* Added `Node::setDocComment()` method. -* Added `Error::getMessageWithColumnInfo()` method. -* Added support for recovery from lexer errors. -* Added support for recovering from "special" errors (i.e. non-syntax parse errors). -* Added precise location information for lexer errors. -* Added `ErrorHandler` interface, and `ErrorHandler\Throwing` and `ErrorHandler\Collecting` as - specific implementations. These provide a general mechanism for handling error recovery. -* Added optional `ErrorHandler` argument to `Parser::parse()`, `Lexer::startLexing()` and - `NameResolver::__construct()`. -* The `NameResolver` now adds a `namespacedName` attribute on name nodes that cannot be statically - resolved (unqualified unaliased function or constant names in namespaces). - -### Fixed - -* Fixed attribute assignment for `GroupUse` prefix and variables in interpolated strings. - -### Changed - -* The constants on `NameTraverserInterface` have been moved into the `NameTraverser` class. -* Due to the error handling changes, the `Parser` interface and `Lexer` API have changed. -* The emulative lexer now directly postprocesses tokens, instead of using `~__EMU__~` sequences. - This changes the protected API of the lexer. -* The `Name::slice()` method now returns `null` for empty slices, previously `new Name([])` was - used. `Name::concat()` now also supports concatenation with `null`. - -### Removed - -* Removed `Name::append()` and `Name::prepend()`. These mutable methods have been superseded by - the immutable `Name::concat()`. -* Removed `Error::getRawLine()` and `Error::setRawLine()`. These methods have been superseded by - `Error::getStartLine()` and `Error::setStartLine()`. -* Removed support for node cloning in the `NodeTraverser`. -* Removed `$separator` argument from `Name::toString()`. -* Removed `throw_on_error` parser option and `Parser::getErrors()` method. Use the `ErrorHandler` - mechanism instead. - -Version 3.0.0-beta1 (2016-09-16) --------------------------------- - -### Added - -* [7.1] Function/method and parameter builders now support PHP 7.1 type hints (void, iterable and - nullable types). -* Nodes and Comments now implement `JsonSerializable`. The node kind is stored in a `nodeType` - property. -* The `InlineHTML` node now has an `hasLeadingNewline` attribute, that specifies whether the - preceding closing tag contained a newline. The pretty printer honors this attribute. -* Partial parsing of `$obj->` (with missing property name) is now supported in error recovery mode. -* The error recovery mode is now exposed in the `php-parse` script through the `--with-recovery` - or `-r` flags. - -The following changes are also part of PHP-Parser 2.1.1: - -* The PHP 7 parser will now generate a parse error for `$var =& new Obj` assignments. -* Comments on free-standing code blocks will now be retained as comments on the first statement in - the code block. - -Version 3.0.0-alpha1 (2016-07-25) ---------------------------------- - -### Added - -* [7.1] Added support for `void` and `iterable` types. These will now be represented as strings - (instead of `Name` instances) similar to other builtin types. -* [7.1] Added support for class constant visibility. The `ClassConst` node now has a `flags` subnode - holding the visibility modifier, as well as `isPublic()`, `isProtected()` and `isPrivate()` - methods. The constructor changed to accept the additional subnode. -* [7.1] Added support for nullable types. These are represented using a new `NullableType` node - with a single `type` subnode. -* [7.1] Added support for short array destructuring syntax. This means that `Array` nodes may now - appear as the left-hand-side of assignments and foreach value targets. Additionally the array - items may now contain `null` values if elements are skipped. -* [7.1] Added support for keys in list() destructuring. The `List` subnode `vars` has been renamed - to `items` and now contains `ArrayItem`s instead of plain variables. -* [7.1] Added support for multi-catch. The `Catch` subnode `type` has been renamed to `types` and - is now an array of `Name`s. -* `Name::slice()` now supports lengths and negative offsets. This brings it in line with - `array_slice()` functionality. - -### Changed - -Due to PHP 7.1 support additions described above, the node structure changed as follows: - -* `void` and `iterable` types are now stored as strings if the PHP 7 parser is used. -* The `ClassConst` constructor changed to accept an additional `flags` subnode. -* The `Array` subnode `items` may now contain `null` elements (destructuring). -* The `List` subnode `vars` has been renamed to `items` and now contains `ArrayItem`s instead of - plain variables. -* The `Catch` subnode `type` has been renamed to `types` and is now an array of `Name`s. - -Additionally the following changes were made: - -* The `type` subnode on `Class`, `ClassMethod` and `Property` has been renamed to `flags`. The - `type` subnode has retained for backwards compatibility and is populated to the same value as - `flags`. However, writes to `type` will not update `flags`. -* The `TryCatch` subnode `finallyStmts` has been replaced with a `finally` subnode that holds an - explicit `Finally` node. This allows for more accurate attribute assignment. -* The `Trait` constructor now has the same form as the `Class` and `Interface` constructors: It - takes an array of subnodes. Unlike classes/interfaces, traits can only have a `stmts` subnode. -* The `NodeDumper` now prints class/method/property/constant modifiers, as well as the include and - use type in a textual representation, instead of only showing the number. -* All methods on `PrettyPrinter\Standard` are now protected. Previoulsy most of them were public. - -### Removed - -* Removed support for running on PHP 5.4. It is however still possible to parse PHP 5.2-5.4 code - while running on a newer version. -* The deprecated `Comment::setLine()` and `Comment::setText()` methods have been removed. -* The deprecated `Name::set()`, `Name::setFirst()` and `Name::setLast()` methods have been removed. - -Version 2.1.1 (2016-09-16) --------------------------- - -### Changed - -* The pretty printer will now escape all control characters in the range `\x00-\x1F` inside double - quoted strings. If no special escape sequence is available, an octal escape will be used. -* The quality of the error recovery has been improved. In particular unterminated expressions should - be handled more gracefully. -* The PHP 7 parser will now generate a parse error for `$var =& new Obj` assignments. -* Comments on free-standing code blocks will no be retained as comments on the first statement in - the code block. - -Version 2.1.0 (2016-04-19) --------------------------- - -### Fixed - -* Properly support `B""` strings (with uppercase `B`) in a number of places. -* Fixed reformatting of indented parts in a certain non-standard comment style. - -### Added - -* Added `dumpComments` option to node dumper, to enable dumping of comments associated with nodes. -* Added `Stmt\Nop` node, that is used to collect comments located at the end of a block or at the - end of a file (without a following node with which they could otherwise be associated). -* Added `kind` attribute to `Expr\Exit` to distinguish between `exit` and `die`. -* Added `kind` attribute to `Scalar\LNumber` to distinguish between decimal, binary, octal and - hexadecimal numbers. -* Added `kind` attribtue to `Expr\Array` to distinguish between `array()` and `[]`. -* Added `kind` attribute to `Scalar\String` and `Scalar\Encapsed` to distinguish between - single-quoted, double-quoted, heredoc and nowdoc string. -* Added `docLabel` attribute to `Scalar\String` and `Scalar\Encapsed`, if it is a heredoc or - nowdoc string. -* Added start file offset information to `Comment` nodes. -* Added `setReturnType()` method to function and method builders. -* Added `-h` and `--help` options to `php-parse` script. - -### Changed - -* Invalid octal literals now throw a parse error in PHP 7 mode. -* The pretty printer takes all the new attributes mentioned in the previous section into account. -* The protected `AbstractPrettyPrinter::pComments()` method no longer returns a trailing newline. -* The bundled autoloader supports library files being stored in a different directory than - `PhpParser` for easier downstream distribution. - -### Deprecated - -* The `Comment::setLine()` and `Comment::setText()` methods have been deprecated. Construct new - objects instead. - -### Removed - -* The internal (but public) method `Scalar\LNumber::parse()` has been removed. A non-internal - `LNumber::fromString()` method has been added instead. - -Version 2.0.1 (2016-02-28) --------------------------- - -### Fixed - -* `declare() {}` and `declare();` are not semantically equivalent and will now result in different - ASTs. The format case will have an empty `stmts` array, while the latter will set `stmts` to - `null`. -* Magic constants are now supported as semi-reserved keywords. -* A shebang line like `#!/usr/bin/env php` is now allowed at the start of a namespaced file. - Previously this generated an exception. -* The `prettyPrintFile()` method will not strip a trailing `?>` from the raw data that follows a - `__halt_compiler()` statement. -* The `prettyPrintFile()` method will not strip an opening `slice()` which takes a subslice of a name. - -### Changed - -* `PhpParser\Parser` is now an interface, implemented by `Parser\Php5`, `Parser\Php7` and - `Parser\Multiple`. The `Multiple` parser will try multiple parsers, until one succeeds. -* Token constants are now defined on `PhpParser\Parser\Tokens` rather than `PhpParser\Parser`. -* The `Name->set()`, `Name->append()`, `Name->prepend()` and `Name->setFirst()` methods are - deprecated in favor of `Name::concat()` and `Name->slice()`. -* The `NodeTraverser` no longer clones nodes by default. The old behavior can be restored by - passing `true` to the constructor. -* The constructor for `Scalar` nodes no longer has a default value. E.g. `new LNumber()` should now - be written as `new LNumber(0)`. - ---- - -**This changelog only includes changes from the 2.0 series. For older changes see the -[1.x series changelog](https://github.com/nikic/PHP-Parser/blob/1.x/CHANGELOG.md) and the -[0.9 series changelog](https://github.com/nikic/PHP-Parser/blob/0.9/CHANGELOG.md).** \ No newline at end of file diff --git a/lib/nikic/php-parser/LICENSE b/lib/nikic/php-parser/LICENSE index 920cc5b1f..2e5671835 100644 --- a/lib/nikic/php-parser/LICENSE +++ b/lib/nikic/php-parser/LICENSE @@ -1,31 +1,29 @@ -Copyright (c) 2011-2018 by Nikita Popov. +BSD 3-Clause License -Some rights reserved. +Copyright (c) 2011, Nikita Popov +All rights reserved. Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: +modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/nikic/php-parser/README.md b/lib/nikic/php-parser/README.md index 2f62754ce..e5b26bf5c 100644 --- a/lib/nikic/php-parser/README.md +++ b/lib/nikic/php-parser/README.md @@ -1,99 +1,225 @@ PHP Parser ========== -[![Build Status](https://travis-ci.org/nikic/PHP-Parser.svg?branch=master)](https://travis-ci.org/nikic/PHP-Parser) [![Coverage Status](https://coveralls.io/repos/github/nikic/PHP-Parser/badge.svg?branch=master)](https://coveralls.io/github/nikic/PHP-Parser?branch=master) +[![Coverage Status](https://coveralls.io/repos/github/nikic/PHP-Parser/badge.svg?branch=master)](https://coveralls.io/github/nikic/PHP-Parser?branch=master) -This is a PHP 5.2 to PHP 7.1 parser written in PHP. Its purpose is to simplify static code analysis and +This is a PHP 5.2 to PHP 8.0 parser written in PHP. Its purpose is to simplify static code analysis and manipulation. -[**Documentation for version 3.x**][doc_master] (stable; for running on PHP >= 5.5; for parsing PHP 5.2 to PHP 7.1). +[**Documentation for version 4.x**][doc_master] (stable; for running on PHP >= 7.0; for parsing PHP 5.2 to PHP 8.0). -[Documentation for version 2.x][doc_2_x] (stable; for running on PHP >= 5.4; for parsing PHP 5.2 to PHP 7.0). +[Documentation for version 3.x][doc_3_x] (unsupported; for running on PHP >= 5.5; for parsing PHP 5.2 to PHP 7.2). -[Documentation for version 1.x][doc_1_x] (unsupported; for running on PHP >= 5.3; for parsing PHP 5.2 to PHP 5.6). +Features +-------- -In a Nutshell -------------- +The main features provided by this library are: -The parser turns PHP source code into an abstract syntax tree. For example, if you pass the following code into the -parser: + * Parsing PHP 5, PHP 7, and PHP 8 code into an abstract syntax tree (AST). + * Invalid code can be parsed into a partial AST. + * The AST contains accurate location information. + * Dumping the AST in human-readable form. + * Converting an AST back to PHP code. + * Experimental: Formatting can be preserved for partially changed ASTs. + * Infrastructure to traverse and modify ASTs. + * Resolution of namespaced names. + * Evaluation of constant expressions. + * Builders to simplify AST construction for code generation. + * Converting an AST into JSON and back. + +Quick Start +----------- + +Install the library using [composer](https://getcomposer.org): + + php composer.phar require nikic/php-parser + +Parse some PHP code into an AST and dump the result in human-readable form: ```php create(ParserFactory::PREFER_PHP7); +try { + $ast = $parser->parse($code); +} catch (Error $error) { + echo "Parse error: {$error->getMessage()}\n"; + return; +} + +$dumper = new NodeDumper; +echo $dumper->dump($ast) . "\n"; ``` -You'll get a syntax tree looking roughly like this: +This dumps an AST looking something like this: -```php +``` array( - 0: Stmt_Echo( - exprs: array( - 0: Scalar_String( - value: Hi - ) - 1: Scalar_String( - value: World + 0: Stmt_Function( + byRef: false + name: Identifier( + name: test + ) + params: array( + 0: Param( + type: null + byRef: false + variadic: false + var: Expr_Variable( + name: foo + ) + default: null ) ) - ) - 1: Expr_FuncCall( - name: Name( - parts: array( - 0: hello - 1: world - ) - ) - args: array( - 0: Arg( - value: Scalar_String( - value: foo - ) - byRef: false - ) - 1: Arg( - value: Expr_Concat( - left: Scalar_String( - value: bar + returnType: null + stmts: array( + 0: Stmt_Expression( + expr: Expr_FuncCall( + name: Name( + parts: array( + 0: var_dump + ) ) - right: Scalar_String( - value: baz + args: array( + 0: Arg( + value: Expr_Variable( + name: foo + ) + byRef: false + unpack: false + ) ) ) - byRef: false ) ) ) ) ``` -You can then work with this syntax tree, for example to statically analyze the code (e.g. to find -programming errors or security issues). +Let's traverse the AST and perform some kind of modification. For example, drop all function bodies: -Additionally, you can convert a syntax tree back to PHP code. This allows you to do code preprocessing -(like automatedly porting code to older PHP versions). +```php +use PhpParser\Node; +use PhpParser\Node\Stmt\Function_; +use PhpParser\NodeTraverser; +use PhpParser\NodeVisitorAbstract; -Installation ------------- +$traverser = new NodeTraverser(); +$traverser->addVisitor(new class extends NodeVisitorAbstract { + public function enterNode(Node $node) { + if ($node instanceof Function_) { + // Clean out the function body + $node->stmts = []; + } + } +}); -The preferred installation method is [composer](https://getcomposer.org): +$ast = $traverser->traverse($ast); +echo $dumper->dump($ast) . "\n"; +``` - php composer.phar require nikic/php-parser +This gives us an AST where the `Function_::$stmts` are empty: + +``` +array( + 0: Stmt_Function( + byRef: false + name: Identifier( + name: test + ) + params: array( + 0: Param( + type: null + byRef: false + variadic: false + var: Expr_Variable( + name: foo + ) + default: null + ) + ) + returnType: null + stmts: array( + ) + ) +) +``` + +Finally, we can convert the new AST back to PHP code: + +```php +use PhpParser\PrettyPrinter; + +$prettyPrinter = new PrettyPrinter\Standard; +echo $prettyPrinter->prettyPrintFile($ast); +``` + +This gives us our original code, minus the `var_dump()` call inside the function: + +```php + Expr_AssignOp_BitwiseAnd -Expr_AssignBitwiseOr => Expr_AssignOp_BitwiseOr -Expr_AssignBitwiseXor => Expr_AssignOp_BitwiseXor -Expr_AssignConcat => Expr_AssignOp_Concat -Expr_AssignDiv => Expr_AssignOp_Div -Expr_AssignMinus => Expr_AssignOp_Minus -Expr_AssignMod => Expr_AssignOp_Mod -Expr_AssignMul => Expr_AssignOp_Mul -Expr_AssignPlus => Expr_AssignOp_Plus -Expr_AssignShiftLeft => Expr_AssignOp_ShiftLeft -Expr_AssignShiftRight => Expr_AssignOp_ShiftRight - -Expr_BitwiseAnd => Expr_BinaryOp_BitwiseAnd -Expr_BitwiseOr => Expr_BinaryOp_BitwiseOr -Expr_BitwiseXor => Expr_BinaryOp_BitwiseXor -Expr_BooleanAnd => Expr_BinaryOp_BooleanAnd -Expr_BooleanOr => Expr_BinaryOp_BooleanOr -Expr_Concat => Expr_BinaryOp_Concat -Expr_Div => Expr_BinaryOp_Div -Expr_Equal => Expr_BinaryOp_Equal -Expr_Greater => Expr_BinaryOp_Greater -Expr_GreaterOrEqual => Expr_BinaryOp_GreaterOrEqual -Expr_Identical => Expr_BinaryOp_Identical -Expr_LogicalAnd => Expr_BinaryOp_LogicalAnd -Expr_LogicalOr => Expr_BinaryOp_LogicalOr -Expr_LogicalXor => Expr_BinaryOp_LogicalXor -Expr_Minus => Expr_BinaryOp_Minus -Expr_Mod => Expr_BinaryOp_Mod -Expr_Mul => Expr_BinaryOp_Mul -Expr_NotEqual => Expr_BinaryOp_NotEqual -Expr_NotIdentical => Expr_BinaryOp_NotIdentical -Expr_Plus => Expr_BinaryOp_Plus -Expr_ShiftLeft => Expr_BinaryOp_ShiftLeft -Expr_ShiftRight => Expr_BinaryOp_ShiftRight -Expr_Smaller => Expr_BinaryOp_Smaller -Expr_SmallerOrEqual => Expr_BinaryOp_SmallerOrEqual - -Scalar_ClassConst => Scalar_MagicConst_Class -Scalar_DirConst => Scalar_MagicConst_Dir -Scalar_FileConst => Scalar_MagicConst_File -Scalar_FuncConst => Scalar_MagicConst_Function -Scalar_LineConst => Scalar_MagicConst_Line -Scalar_MethodConst => Scalar_MagicConst_Method -Scalar_NSConst => Scalar_MagicConst_Namespace -Scalar_TraitConst => Scalar_MagicConst_Trait -``` - -These changes may affect custom pretty printers and code comparing the return value of `Node::getType()` to specific -strings. - -### Miscellaneous - - * The classes `Template` and `TemplateLoader` have been removed. You should use some other [code generation][code_gen] - project built on top of PHP-Parser instead. - - * The `PrettyPrinterAbstract::pStmts()` method now emits a leading newline if the statement list is not empty. - Custom pretty printers should remove the explicit newline before `pStmts()` calls. - - Old: - - ```php - public function pStmt_Trait(PHPParser_Node_Stmt_Trait $node) { - return 'trait ' . $node->name - . "\n" . '{' . "\n" . $this->pStmts($node->stmts) . "\n" . '}'; - } - ``` - - New: - - ```php - public function pStmt_Trait(Stmt\Trait_ $node) { - return 'trait ' . $node->name - . "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}'; - } - ``` - - [code_gen]: https://github.com/nikic/PHP-Parser/wiki/Projects-using-the-PHP-Parser#code-generation \ No newline at end of file diff --git a/lib/nikic/php-parser/UPGRADE-2.0.md b/lib/nikic/php-parser/UPGRADE-2.0.md deleted file mode 100644 index 1c61de54f..000000000 --- a/lib/nikic/php-parser/UPGRADE-2.0.md +++ /dev/null @@ -1,74 +0,0 @@ -Upgrading from PHP-Parser 1.x to 2.0 -==================================== - -### PHP version requirements - -PHP-Parser now requires PHP 5.4 or newer to run. It is however still possible to *parse* PHP 5.2 and -PHP 5.3 source code, while running on a newer version. - -### Creating a parser instance - -Parser instances should now be created through the `ParserFactory`. Old direct instantiation code -will not work, because the parser class was renamed. - -Old: - -```php -use PhpParser\Parser, PhpParser\Lexer; -$parser = new Parser(new Lexer\Emulative); -``` - -New: - -```php -use PhpParser\ParserFactory; -$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7); -``` - -The first argument to `ParserFactory` determines how different PHP versions are handled. The -possible values are: - - * `ParserFactory::PREFER_PHP7`: Try to parse code as PHP 7. If this fails, try to parse it as PHP 5. - * `ParserFactory::PREFER_PHP5`: Try to parse code as PHP 5. If this fails, try to parse it as PHP 7. - * `ParserFactory::ONLY_PHP7`: Parse code as PHP 7. - * `ParserFactory::ONLY_PHP5`: Parse code as PHP 5. - -For most practical purposes the difference between `PREFER_PHP7` and `PREFER_PHP5` is mainly whether -a scalar type hint like `string` will be stored as `'string'` (PHP 7) or as `new Name('string')` -(PHP 5). - -To use a custom lexer, pass it as the second argument to the `create()` method: - -```php -use PhpParser\ParserFactory; -$lexer = new MyLexer; -$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7, $lexer); -``` - -### Rename of the `PhpParser\Parser` class - -`PhpParser\Parser` is now an interface, which is implemented by `Parser\Php5`, `Parser\Php7` and -`Parser\Multiple`. Parser tokens are now defined in `Parser\Tokens`. If you use the `ParserFactory` -described above to create your parser instance, these changes should have no further impact on you. - -### Removal of legacy aliases - -All legacy aliases for classes have been removed. This includes the old non-namespaced `PHPParser_` -classes, as well as the classes that had to be renamed for PHP 7 support. - -### Deprecations - -The `set()`, `setFirst()`, `append()` and `prepend()` methods of the `Node\Name` class have been -deprecated. Instead `Name::concat()` and `Name->slice()` should be used. - -### Miscellaneous - -* The `NodeTraverser` no longer clones nodes by default. If you want to restore the old behavior, - pass `true` to the constructor. -* The legacy node format has been removed. If you use custom nodes, they are now expected to - implement a `getSubNodeNames()` method. -* The default value for `Scalar` node constructors was removed. This means that something like - `new LNumber()` should be replaced by `new LNumber(0)`. -* String parts of encapsed strings are now represented using `Scalar\EncapsStringPart` nodes, while - previously raw strings were used. This affects the `parts` child of `Scalar\Encaps` and - `Expr\ShellExec`. \ No newline at end of file diff --git a/lib/nikic/php-parser/UPGRADE-3.0.md b/lib/nikic/php-parser/UPGRADE-3.0.md deleted file mode 100644 index 9e04f2afd..000000000 --- a/lib/nikic/php-parser/UPGRADE-3.0.md +++ /dev/null @@ -1,160 +0,0 @@ -Upgrading from PHP-Parser 2.x to 3.0 -==================================== - -The backwards-incompatible changes in this release may be summarized as follows: - - * The specific details of the node representation have changed in some cases, primarily to - accomodate new PHP 7.1 features. - * There have been significant changes to the error recovery implementation. This may affect you, - if you used the error recovery mode or have a custom lexer implementation. - * A number of deprecated methods were removed. - -### PHP version requirements - -PHP-Parser now requires PHP 5.5 or newer to run. It is however still possible to *parse* PHP 5.2, -5.3 and 5.4 source code, while running on a newer version. - -### Changes to the node structure - -The following changes are likely to require code changes if the respective nodes are used: - - * The `List` subnode `vars` has been renamed to `items` and now contains `ArrayItem`s instead of - plain variables. - * The `Catch` subnode `type` has been renamed to `types` and is now an array of `Name`s. - * The `TryCatch` subnode `finallyStmts` has been replaced with a `finally` subnode that holds an - explicit `Finally` node. - * The `type` subnode on `Class`, `ClassMethod` and `Property` has been renamed to `flags`. The - `type` subnode has retained for backwards compatibility and is populated to the same value as - `flags`. However, writes to `type` will not update `flags` and use of `type` is discouraged. - -The following changes are unlikely to require code changes: - - * The `ClassConst` constructor changed to accept an additional `flags` subnode. - * The `Trait` constructor now has the same form as the `Class` and `Interface` constructors: It - takes an array of subnodes. Unlike classes/interfaces, traits can only have a `stmts` subnode. - * The `Array` subnode `items` may now contain `null` elements (due to destructuring). - * `void` and `iterable` types are now stored as strings if the PHP 7 parser is used. Previously - these would have been represented as `Name` instances. - -### Changes to error recovery mode - -Previously, error recovery mode was enabled by setting the `throwOnError` option to `false` when -creating the parser, while collected errors were retrieved using the `getErrors()` method: - -```php -$lexer = ...; -$parser = (new ParserFactory)->create(ParserFactor::ONLY_PHP7, $lexer, [ - 'throwOnError' => true, -]); - -$stmts = $parser->parse($code); -$errors = $parser->getErrors(); -if ($errors) { - handleErrors($errors); -} -processAst($stmts); -``` - -Both the `throwOnError` option and the `getErrors()` method have been removed in PHP-Parser 3.0. -Instead an instance of `ErrorHandler\Collecting` should be passed to the `parse()` method: - -```php -$lexer = ...; -$parser = (new ParserFactory)->create(ParserFactor::ONLY_PHP7, $lexer); - -$errorHandler = new ErrorHandler\Collecting; -$stmts = $parser->parse($code, $errorHandler); -if ($errorHandler->hasErrors()) { - handleErrors($errorHandler->getErrors()); -} -processAst($stmts); -``` - -#### Multiple parser fallback in error recovery mode - -As a result of this change, if a `Multiple` parser is used (e.g. through the `ParserFactory` using -`PREFER_PHP7` or `PREFER_PHP5`), it will now return the result of the first *non-throwing* parse. As -parsing never throws in error recovery mode, the result from the first parser will always be -returned. - -The PHP 7 parser is a superset of the PHP 5 parser, with the exceptions that `=& new` and -`global $$foo->bar` are not supported (other differences are in representation only). The PHP 7 -parser will be able to recover from the error in both cases. For this reason, this change will -likely pass unnoticed if you do not specifically test for this syntax. - -It is possible to restore the precise previous behavior with the following code: - -```php -$lexer = ...; -$parser7 = new Parser\Php7($lexer); -$parser5 = new Parser\Php5($lexer); - -$errors7 = new ErrorHandler\Collecting(); -$stmts7 = $parser7->parse($code, $errors7); -if ($errors7->hasErrors()) { - $errors5 = new ErrorHandler\Collecting(); - $stmts5 = $parser5->parse($code, $errors5); - if (!$errors5->hasErrors()) { - // If PHP 7 parse has errors but PHP 5 parse has no errors, use PHP 5 result - return [$stmts5, $errors5]; - } -} -// If PHP 7 succeeds or both fail use PHP 7 result -return [$stmts7, $errors7]; -``` - -#### Error handling in the lexer - -In order to support recovery from lexer errors, the signature of the `startLexing()` method changed -to optionally accept an `ErrorHandler`: - -```php -// OLD -public function startLexing($code); -// NEW -public function startLexing($code, ErrorHandler $errorHandler = null); -``` - -If you use a custom lexer with overriden `startLexing()` method, it needs to be changed to accept -the extra parameter. The value should be passed on to the parent method. - -#### Error checks in node constructors - -The constructors of certain nodes used to contain additional checks for semantic errors, such as -creating a try block without either catch or finally. These checks have been moved from the node -constructors into the parser. This allows recovery from such errors, as well as representing the -resulting (invalid) AST. - -This means that certain error conditions are no longer checked for manually constructed nodes. - -### Removed methods, arguments, options - -The following methods, arguments or options have been removed: - - * `Comment::setLine()`, `Comment::setText()`: Create new `Comment` instances instead. - * `Name::set()`, `Name::setFirst()`, `Name::setLast()`, `Name::append()`, `Name::prepend()`: - Use `Name::concat()` in combination with `Name::slice()` instead. - * `Error::getRawLine()`, `Error::setRawLine()`. Use `Error::getStartLine()` and - `Error::setStartLine()` instead. - * `Parser::getErrors()`. Use `ErrorHandler\Collecting` instead. - * `$separator` argument of `Name::toString()`. Use `strtr()` instead, if you really need it. - * `$cloneNodes` argument of `NodeTraverser::__construct()`. Explicitly clone nodes in the visitor - instead. - * `throwOnError` parser option. Use `ErrorHandler\Collecting` instead. - -### Miscellaneous - - * The `NameResolver` will now resolve unqualified function and constant names in the global - namespace into fully qualified names. For example `foo()` in the global namespace resolves to - `\foo()`. For names where no static resolution is possible, a `namespacedName` attribute is - added now, containing the namespaced variant of the name. - * All methods on `PrettyPrinter\Standard` are now protected. Previoulsy most of them were public. - The pretty printer should only be invoked using the `prettyPrint()`, `prettyPrintFile()` and - `prettyPrintExpr()` methods. - * The node dumper now prints numeric values that act as enums/flags in a string representation. - If node dumper results are used in tests, updates may be needed to account for this. - * The constants on `NameTraverserInterface` have been moved into the `NameTraverser` class. - * The emulative lexer now directly postprocesses tokens, instead of using `~__EMU__~` sequences. - This changes the protected API of the emulative lexer. - * The `Name::slice()` method now returns `null` for empty slices, previously `new Name([])` was - used. `Name::concat()` now also supports concatenation with `null`. diff --git a/lib/nikic/php-parser/bin/php-parse b/lib/nikic/php-parser/bin/php-parse index 1760e758d..bb3e46df4 100755 --- a/lib/nikic/php-parser/bin/php-parse +++ b/lib/nikic/php-parser/bin/php-parse @@ -10,7 +10,7 @@ foreach ([__DIR__ . '/../../../autoload.php', __DIR__ . '/../vendor/autoload.php ini_set('xdebug.max_nesting_level', 3000); -// Disable XDebug var_dump() output truncation +// Disable Xdebug var_dump() output truncation ini_set('xdebug.var_display_max_children', -1); ini_set('xdebug.var_display_max_data', -1); ini_set('xdebug.var_display_max_depth', -1); @@ -26,9 +26,9 @@ if (empty($files)) { showHelp("Must specify at least one file."); } -$lexer = new PhpParser\Lexer\Emulative(array('usedAttributes' => array( +$lexer = new PhpParser\Lexer\Emulative(['usedAttributes' => [ 'startLine', 'endLine', 'startFilePos', 'endFilePos', 'comments' -))); +]]); $parser = (new PhpParser\ParserFactory)->create( PhpParser\ParserFactory::PREFER_PHP7, $lexer @@ -38,7 +38,6 @@ $dumper = new PhpParser\NodeDumper([ 'dumpPositions' => $attributes['with-positions'], ]); $prettyPrinter = new PhpParser\PrettyPrinter\Standard; -$serializer = new PhpParser\Serializer\XML; $traverser = new PhpParser\NodeTraverser(); $traverser->addVisitor(new PhpParser\NodeVisitor\NameResolver); @@ -46,14 +45,15 @@ $traverser->addVisitor(new PhpParser\NodeVisitor\NameResolver); foreach ($files as $file) { if (strpos($file, ' Code $code\n"; + fwrite(STDERR, "====> Code $code\n"); } else { if (!file_exists($file)) { - die("File $file does not exist.\n"); + fwrite(STDERR, "File $file does not exist.\n"); + exit(1); } $code = file_get_contents($file); - echo "====> File $file:\n"; + fwrite(STDERR, "====> File $file:\n"); } if ($attributes['with-recovery']) { @@ -61,7 +61,7 @@ foreach ($files as $file) { $stmts = $parser->parse($code, $errorHandler); foreach ($errorHandler->getErrors() as $error) { $message = formatErrorMessage($error, $code, $attributes['with-column-info']); - echo $message . "\n"; + fwrite(STDERR, $message . "\n"); } if (null === $stmts) { continue; @@ -71,25 +71,26 @@ foreach ($files as $file) { $stmts = $parser->parse($code); } catch (PhpParser\Error $error) { $message = formatErrorMessage($error, $code, $attributes['with-column-info']); - die($message . "\n"); + fwrite(STDERR, $message . "\n"); + exit(1); } } foreach ($operations as $operation) { if ('dump' === $operation) { - echo "==> Node dump:\n"; + fwrite(STDERR, "==> Node dump:\n"); echo $dumper->dump($stmts, $code), "\n"; } elseif ('pretty-print' === $operation) { - echo "==> Pretty print:\n"; + fwrite(STDERR, "==> Pretty print:\n"); echo $prettyPrinter->prettyPrintFile($stmts), "\n"; - } elseif ('serialize-xml' === $operation) { - echo "==> Serialized XML:\n"; - echo $serializer->serialize($stmts), "\n"; + } elseif ('json-dump' === $operation) { + fwrite(STDERR, "==> JSON dump:\n"); + echo json_encode($stmts, JSON_PRETTY_PRINT), "\n"; } elseif ('var-dump' === $operation) { - echo "==> var_dump():\n"; + fwrite(STDERR, "==> var_dump():\n"); var_dump($stmts); } elseif ('resolve-names' === $operation) { - echo "==> Resolved names.\n"; + fwrite(STDERR, "==> Resolved names.\n"); $stmts = $traverser->traverse($stmts); } } @@ -105,9 +106,9 @@ function formatErrorMessage(PhpParser\Error $e, $code, $withColumnInfo) { function showHelp($error = '') { if ($error) { - echo $error . "\n\n"; + fwrite(STDERR, $error . "\n\n"); } - die(<< false, 'with-positions' => false, 'with-recovery' => false, - ); + ]; array_shift($args); $parseOptions = true; @@ -160,8 +162,9 @@ function parseArgs($args) { case '-p': $operations[] = 'pretty-print'; break; - case '--serialize-xml': - $operations[] = 'serialize-xml'; + case '--json-dump': + case '-j': + $operations[] = 'json-dump'; break; case '--var-dump': $operations[] = 'var-dump'; @@ -198,5 +201,5 @@ function parseArgs($args) { } } - return array($operations, $files, $attributes); + return [$operations, $files, $attributes]; } diff --git a/lib/nikic/php-parser/composer.json b/lib/nikic/php-parser/composer.json index 66df90a8f..2fd064a21 100644 --- a/lib/nikic/php-parser/composer.json +++ b/lib/nikic/php-parser/composer.json @@ -1,8 +1,11 @@ { "name": "nikic/php-parser", - "description": "A PHP parser written in PHP", - "keywords": ["php", "parser"], "type": "library", + "description": "A PHP parser written in PHP", + "keywords": [ + "php", + "parser" + ], "license": "BSD-3-Clause", "authors": [ { @@ -10,21 +13,29 @@ } ], "require": { - "php": ">=5.5", + "php": ">=7.0", "ext-tokenizer": "*" }, "require-dev": { - "phpunit/phpunit": "~4.0|~5.0" + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0", + "ircmaxell/php-yacc": "^0.0.7" + }, + "extra": { + "branch-alias": { + "dev-master": "4.9-dev" + } }, "autoload": { "psr-4": { "PhpParser\\": "lib/PhpParser" } }, - "bin": ["bin/php-parse"], - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" + "autoload-dev": { + "psr-4": { + "PhpParser\\": "test/PhpParser/" } - } + }, + "bin": [ + "bin/php-parse" + ] } diff --git a/lib/nikic/php-parser/doc/0_Introduction.markdown b/lib/nikic/php-parser/doc/0_Introduction.markdown deleted file mode 100644 index ca1ceb2ec..000000000 --- a/lib/nikic/php-parser/doc/0_Introduction.markdown +++ /dev/null @@ -1,80 +0,0 @@ -Introduction -============ - -This project is a PHP 5.2 to PHP 7.1 parser **written in PHP itself**. - -What is this for? ------------------ - -A parser is useful for [static analysis][0], manipulation of code and basically any other -application dealing with code programmatically. A parser constructs an [Abstract Syntax Tree][1] -(AST) of the code and thus allows dealing with it in an abstract and robust way. - -There are other ways of processing source code. One that PHP supports natively is using the -token stream generated by [`token_get_all`][2]. The token stream is much more low level than -the AST and thus has different applications: It allows to also analyze the exact formatting of -a file. On the other hand the token stream is much harder to deal with for more complex analysis. -For example an AST abstracts away the fact that in PHP variables can be written as `$foo`, but also -as `$$bar`, `${'foobar'}` or even `${!${''}=barfoo()}`. You don't have to worry about recognizing -all the different syntaxes from a stream of tokens. - -Another question is: Why would I want to have a PHP parser *written in PHP*? Well, PHP might not be -a language especially suited for fast parsing, but processing the AST is much easier in PHP than it -would be in other, faster languages like C. Furthermore the people most probably wanting to do -programmatic PHP code analysis are incidentally PHP developers, not C developers. - -What can it parse? ------------------- - -The parser supports parsing PHP 5.2-5.6 and PHP 7. - -As the parser is based on the tokens returned by `token_get_all` (which is only able to lex the PHP -version it runs on), additionally a wrapper for emulating tokens from newer versions is provided. -This allows to parse PHP 7.1 source code running on PHP 5.5, for example. This emulation is somewhat -hacky and not perfect, but it should work well on any sane code. - -What output does it produce? ----------------------------- - -The parser produces an [Abstract Syntax Tree][1] (AST) also known as a node tree. How this looks like -can best be seen in an example. The program `create(ParserFactory::PREFER_PHP7); -``` - -The factory accepts a kind argument, that determines how different PHP versions are treated: - -Kind | Behavior ------|--------- -`ParserFactory::PREFER_PHP7` | Try to parse code as PHP 7. If this fails, try to parse it as PHP 5. -`ParserFactory::PREFER_PHP5` | Try to parse code as PHP 5. If this fails, try to parse it as PHP 7. -`ParserFactory::ONLY_PHP7` | Parse code as PHP 7. -`ParserFactory::ONLY_PHP5` | Parse code as PHP 5. - -Unless you have strong reason to use something else, `PREFER_PHP7` is a reasonable default. - -The `create()` method optionally accepts a `Lexer` instance as the second argument. Some use cases -that require customized lexers are discussed in the [lexer documentation](component/Lexer.markdown). - -Subsequently you can pass PHP code (including the opening `create(ParserFactory::PREFER_PHP7); - -try { - $stmts = $parser->parse($code); - // $stmts is an array of statement nodes -} catch (Error $e) { - echo 'Parse Error: ', $e->getMessage(); -} -``` - -A parser instance can be reused to parse multiple files. - -Node tree ---------- - -If you use the above code with `$code = "subNodeName`. The `Stmt\Echo_` node has only one subnode `exprs`. So in order to access it -in the above example you would write `$stmts[0]->exprs`. If you wanted to access the name of the function -call, you would write `$stmts[0]->exprs[1]->name`. - -All nodes also define a `getType()` method that returns the node type. The type is the class name -without the `PhpParser\Node\` prefix and `\` replaced with `_`. It also does not contain a trailing -`_` for reserved-keyword class names. - -It is possible to associate custom metadata with a node using the `setAttribute()` method. This data -can then be retrieved using `hasAttribute()`, `getAttribute()` and `getAttributes()`. - -By default the lexer adds the `startLine`, `endLine` and `comments` attributes. `comments` is an array -of `PhpParser\Comment[\Doc]` instances. - -The start line can also be accessed using `getLine()`/`setLine()` (instead of `getAttribute('startLine')`). -The last doc comment from the `comments` attribute can be obtained using `getDocComment()`. - -Pretty printer --------------- - -The pretty printer component compiles the AST back to PHP code. As the parser does not retain formatting -information the formatting is done using a specified scheme. Currently there is only one scheme available, -namely `PhpParser\PrettyPrinter\Standard`. - -```php -use PhpParser\Error; -use PhpParser\ParserFactory; -use PhpParser\PrettyPrinter; - -$code = "create(ParserFactory::PREFER_PHP7); -$prettyPrinter = new PrettyPrinter\Standard; - -try { - // parse - $stmts = $parser->parse($code); - - // change - $stmts[0] // the echo statement - ->exprs // sub expressions - [0] // the first of them (the string node) - ->value // it's value, i.e. 'Hi ' - = 'Hello '; // change to 'Hello ' - - // pretty print - $code = $prettyPrinter->prettyPrint($stmts); - - echo $code; -} catch (Error $e) { - echo 'Parse Error: ', $e->getMessage(); -} -``` - -The above code will output: - - parse()`, then changed and then -again converted to code using `PhpParser\PrettyPrinter\Standard->prettyPrint()`. - -The `prettyPrint()` method pretty prints a statements array. It is also possible to pretty print only a -single expression using `prettyPrintExpr()`. - -The `prettyPrintFile()` method can be used to print an entire file. This will include the opening `create(ParserFactory::PREFER_PHP7); -$traverser = new NodeTraverser; -$prettyPrinter = new PrettyPrinter\Standard; - -// add your visitor -$traverser->addVisitor(new MyNodeVisitor); - -try { - $code = file_get_contents($fileName); - - // parse - $stmts = $parser->parse($code); - - // traverse - $stmts = $traverser->traverse($stmts); - - // pretty print - $code = $prettyPrinter->prettyPrintFile($stmts); - - echo $code; -} catch (PhpParser\Error $e) { - echo 'Parse Error: ', $e->getMessage(); -} -``` - -The corresponding node visitor might look like this: - -```php -use PhpParser\Node; -use PhpParser\NodeVisitorAbstract; - -class MyNodeVisitor extends NodeVisitorAbstract -{ - public function leaveNode(Node $node) { - if ($node instanceof Node\Scalar\String_) { - $node->value = 'foo'; - } - } -} -``` - -The above node visitor would change all string literals in the program to `'foo'`. - -All visitors must implement the `PhpParser\NodeVisitor` interface, which defines the following four -methods: - -```php -public function beforeTraverse(array $nodes); -public function enterNode(\PhpParser\Node $node); -public function leaveNode(\PhpParser\Node $node); -public function afterTraverse(array $nodes); -``` - -The `beforeTraverse()` method is called once before the traversal begins and is passed the nodes the -traverser was called with. This method can be used for resetting values before traversation or -preparing the tree for traversal. - -The `afterTraverse()` method is similar to the `beforeTraverse()` method, with the only difference that -it is called once after the traversal. - -The `enterNode()` and `leaveNode()` methods are called on every node, the former when it is entered, -i.e. before its subnodes are traversed, the latter when it is left. - -All four methods can either return the changed node or not return at all (i.e. `null`) in which -case the current node is not changed. - -The `enterNode()` method can additionally return the value `NodeTraverser::DONT_TRAVERSE_CHILDREN`, -which instructs the traverser to skip all children of the current node. - -The `leaveNode()` method can additionally return the value `NodeTraverser::REMOVE_NODE`, in which -case the current node will be removed from the parent array. Furthermore it is possible to return -an array of nodes, which will be merged into the parent array at the offset of the current node. -I.e. if in `array(A, B, C)` the node `B` should be replaced with `array(X, Y, Z)` the result will -be `array(A, X, Y, Z, C)`. - -Instead of manually implementing the `NodeVisitor` interface you can also extend the `NodeVisitorAbstract` -class, which will define empty default implementations for all the above methods. - -The NameResolver node visitor ------------------------------ - -One visitor is already bundled with the package: `PhpParser\NodeVisitor\NameResolver`. This visitor -helps you work with namespaced code by trying to resolve most names to fully qualified ones. - -For example, consider the following code: - - use A as B; - new B\C(); - -In order to know that `B\C` really is `A\C` you would need to track aliases and namespaces yourself. -The `NameResolver` takes care of that and resolves names as far as possible. - -After running it most names will be fully qualified. The only names that will stay unqualified are -unqualified function and constant names. These are resolved at runtime and thus the visitor can't -know which function they are referring to. In most cases this is a non-issue as the global functions -are meant. - -Also the `NameResolver` adds a `namespacedName` subnode to class, function and constant declarations -that contains the namespaced name instead of only the shortname that is available via `name`. - -Example: Converting namespaced code to pseudo namespaces --------------------------------------------------------- - -A small example to understand the concept: We want to convert namespaced code to pseudo namespaces -so it works on 5.2, i.e. names like `A\\B` should be converted to `A_B`. Note that such conversions -are fairly complicated if you take PHP's dynamic features into account, so our conversion will -assume that no dynamic features are used. - -We start off with the following base code: - -```php -use PhpParser\ParserFactory; -use PhpParser\PrettyPrinter; -use PhpParser\NodeTraverser; -use PhpParser\NodeVisitor\NameResolver; - -$inDir = '/some/path'; -$outDir = '/some/other/path'; - -$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7); -$traverser = new NodeTraverser; -$prettyPrinter = new PrettyPrinter\Standard; - -$traverser->addVisitor(new NameResolver); // we will need resolved names -$traverser->addVisitor(new NamespaceConverter); // our own node visitor - -// iterate over all .php files in the directory -$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($inDir)); -$files = new \RegexIterator($files, '/\.php$/'); - -foreach ($files as $file) { - try { - // read the file that should be converted - $code = file_get_contents($file); - - // parse - $stmts = $parser->parse($code); - - // traverse - $stmts = $traverser->traverse($stmts); - - // pretty print - $code = $prettyPrinter->prettyPrintFile($stmts); - - // write the converted file to the target directory - file_put_contents( - substr_replace($file->getPathname(), $outDir, 0, strlen($inDir)), - $code - ); - } catch (PhpParser\Error $e) { - echo 'Parse Error: ', $e->getMessage(); - } -} -``` - -Now lets start with the main code, the `NodeVisitor\NamespaceConverter`. One thing it needs to do -is convert `A\\B` style names to `A_B` style ones. - -```php -use PhpParser\Node; - -class NamespaceConverter extends \PhpParser\NodeVisitorAbstract -{ - public function leaveNode(Node $node) { - if ($node instanceof Node\Name) { - return new Node\Name($node->toString('_')); - } - } -} -``` - -The above code profits from the fact that the `NameResolver` already resolved all names as far as -possible, so we don't need to do that. We only need to create a string with the name parts separated -by underscores instead of backslashes. This is what `$node->toString('_')` does. (If you want to -create a name with backslashes either write `$node->toString()` or `(string) $node`.) Then we create -a new name from the string and return it. Returning a new node replaces the old node. - -Another thing we need to do is change the class/function/const declarations. Currently they contain -only the shortname (i.e. the last part of the name), but they need to contain the complete name including -the namespace prefix: - -```php -use PhpParser\Node; -use PhpParser\Node\Stmt; - -class NodeVisitor_NamespaceConverter extends \PhpParser\NodeVisitorAbstract -{ - public function leaveNode(Node $node) { - if ($node instanceof Node\Name) { - return new Node\Name($node->toString('_')); - } elseif ($node instanceof Stmt\Class_ - || $node instanceof Stmt\Interface_ - || $node instanceof Stmt\Function_) { - $node->name = $node->namespacedName->toString('_'); - } elseif ($node instanceof Stmt\Const_) { - foreach ($node->consts as $const) { - $const->name = $const->namespacedName->toString('_'); - } - } - } -} -``` - -There is not much more to it than converting the namespaced name to string with `_` as separator. - -The last thing we need to do is remove the `namespace` and `use` statements: - -```php -use PhpParser\Node; -use PhpParser\Node\Stmt; - -class NodeVisitor_NamespaceConverter extends \PhpParser\NodeVisitorAbstract -{ - public function leaveNode(Node $node) { - if ($node instanceof Node\Name) { - return new Node\Name($node->toString('_')); - } elseif ($node instanceof Stmt\Class_ - || $node instanceof Stmt\Interface_ - || $node instanceof Stmt\Function_) { - $node->name = $node->namespacedName->toString('_'); - } elseif ($node instanceof Stmt\Const_) { - foreach ($node->consts as $const) { - $const->name = $const->namespacedName->toString('_'); - } - } elseif ($node instanceof Stmt\Namespace_) { - // returning an array merges is into the parent array - return $node->stmts; - } elseif ($node instanceof Stmt\Use_) { - // returning false removed the node altogether - return false; - } - } -} -``` - -That's all. diff --git a/lib/nikic/php-parser/doc/3_Other_node_tree_representations.markdown b/lib/nikic/php-parser/doc/3_Other_node_tree_representations.markdown deleted file mode 100644 index 0830f399c..000000000 --- a/lib/nikic/php-parser/doc/3_Other_node_tree_representations.markdown +++ /dev/null @@ -1,330 +0,0 @@ -Other node tree representations -=============================== - -It is possible to convert the AST into several textual representations, which serve different uses. - -Simple serialization --------------------- - -It is possible to serialize the node tree using `serialize()` and also unserialize it using -`unserialize()`. The output is not human readable and not easily processable from anything -but PHP, but it is compact and generates quickly. The main application thus is in caching. - -Human readable dumping ----------------------- - -Furthermore it is possible to dump nodes into a human readable format using the `dump` method of -`PhpParser\NodeDumper`. This can be used for debugging. - -```php -$code = <<<'CODE' -create(PhpParser\ParserFactory::PREFER_PHP7); -$nodeDumper = new PhpParser\NodeDumper; - -try { - $stmts = $parser->parse($code); - - echo $nodeDumper->dump($stmts), "\n"; -} catch (PhpParser\Error $e) { - echo 'Parse Error: ', $e->getMessage(); -} -``` - -The above script will have an output looking roughly like this: - -``` -array( - 0: Stmt_Function( - byRef: false - params: array( - 0: Param( - name: msg - default: null - type: null - byRef: false - ) - ) - stmts: array( - 0: Stmt_Echo( - exprs: array( - 0: Expr_Variable( - name: msg - ) - 1: Scalar_String( - value: - - ) - ) - ) - ) - name: printLine - ) - 1: Expr_FuncCall( - name: Name( - parts: array( - 0: printLine - ) - ) - args: array( - 0: Arg( - value: Scalar_String( - value: Hello World!!! - ) - byRef: false - ) - ) - ) -) -``` - -JSON encoding -------------- - -Nodes (and comments) implement the `JsonSerializable` interface. As such, it is possible to JSON -encode the AST directly using `json_encode()`: - -```php -$code = <<<'CODE' -create(PhpParser\ParserFactory::PREFER_PHP7); -$nodeDumper = new PhpParser\NodeDumper; - -try { - $stmts = $parser->parse($code); - - echo json_encode($stmts, JSON_PRETTY_PRINT), "\n"; -} catch (PhpParser\Error $e) { - echo 'Parse Error: ', $e->getMessage(); -} -``` - -This will result in the following output (which includes attributes): - -```json -[ - { - "nodeType": "Stmt_Function", - "byRef": false, - "name": "printLine", - "params": [ - { - "nodeType": "Param", - "type": null, - "byRef": false, - "variadic": false, - "name": "msg", - "default": null, - "attributes": { - "startLine": 3, - "endLine": 3 - } - } - ], - "returnType": null, - "stmts": [ - { - "nodeType": "Stmt_Echo", - "exprs": [ - { - "nodeType": "Expr_Variable", - "name": "msg", - "attributes": { - "startLine": 4, - "endLine": 4 - } - }, - { - "nodeType": "Scalar_String", - "value": "\n", - "attributes": { - "startLine": 4, - "endLine": 4, - "kind": 2 - } - } - ], - "attributes": { - "startLine": 4, - "endLine": 4 - } - } - ], - "attributes": { - "startLine": 3, - "endLine": 5 - } - }, - { - "nodeType": "Expr_FuncCall", - "name": { - "nodeType": "Name", - "parts": [ - "printLine" - ], - "attributes": { - "startLine": 7, - "endLine": 7 - } - }, - "args": [ - { - "nodeType": "Arg", - "value": { - "nodeType": "Scalar_String", - "value": "Hello World!!!", - "attributes": { - "startLine": 7, - "endLine": 7, - "kind": 1 - } - }, - "byRef": false, - "unpack": false, - "attributes": { - "startLine": 7, - "endLine": 7 - } - } - ], - "attributes": { - "startLine": 7, - "endLine": 7 - } - } -] -``` - -There is currently no mechanism to convert JSON back into a node tree. Furthermore, not all ASTs -can be JSON encoded. In particular, JSON only supports UTF-8 strings. - -Serialization to XML --------------------- - -It is also possible to serialize the node tree to XML using `PhpParser\Serializer\XML->serialize()` -and to unserialize it using `PhpParser\Unserializer\XML->unserialize()`. This is useful for -interfacing with other languages and applications or for doing transformation using XSLT. - -```php -create(PhpParser\ParserFactory::PREFER_PHP7); -$serializer = new PhpParser\Serializer\XML; - -try { - $stmts = $parser->parse($code); - - echo $serializer->serialize($stmts); -} catch (PhpParser\Error $e) { - echo 'Parse Error: ', $e->getMessage(); -} -``` - -Produces: - -```xml - - - - - - - - - - - - msg - - - - - - - - - - - - - - - - - - - - - msg - - - - - - - - - - - - - - - printLine - - - - - - - - printLine - - - - - - - - - - - Hello World!!! - - - - - - - - - - - - -``` \ No newline at end of file diff --git a/lib/nikic/php-parser/doc/4_Code_generation.markdown b/lib/nikic/php-parser/doc/4_Code_generation.markdown deleted file mode 100644 index 2c0aa0ede..000000000 --- a/lib/nikic/php-parser/doc/4_Code_generation.markdown +++ /dev/null @@ -1,84 +0,0 @@ -Code generation -=============== - -It is also possible to generate code using the parser, by first creating an Abstract Syntax Tree and then using the -pretty printer to convert it to PHP code. To simplify code generation, the project comes with builders which allow -creating node trees using a fluid interface, instead of instantiating all nodes manually. Builders are available for -the following syntactic elements: - - * namespaces and use statements - * classes, interfaces and traits - * methods, functions and parameters - * properties - -Here is an example: - -```php -use PhpParser\BuilderFactory; -use PhpParser\PrettyPrinter; -use PhpParser\Node; - -$factory = new BuilderFactory; -$node = $factory->namespace('Name\Space') - ->addStmt($factory->use('Some\Other\Thingy')->as('SomeOtherClass')) - ->addStmt($factory->class('SomeClass') - ->extend('SomeOtherClass') - ->implement('A\Few', '\Interfaces') - ->makeAbstract() // ->makeFinal() - - ->addStmt($factory->method('someMethod') - ->makePublic() - ->makeAbstract() // ->makeFinal() - ->setReturnType('bool') - ->addParam($factory->param('someParam')->setTypeHint('SomeClass')) - ->setDocComment('/** - * This method does something. - * - * @param SomeClass And takes a parameter - */') - ) - - ->addStmt($factory->method('anotherMethod') - ->makeProtected() // ->makePublic() [default], ->makePrivate() - ->addParam($factory->param('someParam')->setDefault('test')) - // it is possible to add manually created nodes - ->addStmt(new Node\Expr\Print_(new Node\Expr\Variable('someParam'))) - ) - - // properties will be correctly reordered above the methods - ->addStmt($factory->property('someProperty')->makeProtected()) - ->addStmt($factory->property('anotherProperty')->makePrivate()->setDefault(array(1, 2, 3))) - ) - - ->getNode() -; - -$stmts = array($node); -$prettyPrinter = new PrettyPrinter\Standard(); -echo $prettyPrinter->prettyPrintFile($stmts); -``` - -This will produce the following output with the standard pretty printer: - -```php - array('comments', 'startLine', 'endLine', 'startFilePos', 'endFilePos'), -)); -$parser = (new PhpParser\ParserFactory)->create(PhpParser\ParserFactory::PREFER_PHP7, $lexer); - -try { - $stmts = $parser->parse($code); - // ... -} catch (PhpParser\Error $e) { - // ... -} -``` - -Before using column information its availability needs to be checked with `$e->hasColumnInfo()`, as the precise -location of an error cannot always be determined. The methods for retrieving column information also have to be passed -the source code of the parsed file. An example for printing an error: - -```php -if ($e->hasColumnInfo()) { - echo $e->getRawMessage() . ' from ' . $e->getStartLine() . ':' . $e->getStartColumn($code) - . ' to ' . $e->getEndLine() . ':' . $e->getEndColumn($code); - // or: - echo $e->getMessageWithColumnInfo(); -} else { - echo $e->getMessage(); -} -``` - -Both line numbers and column numbers are 1-based. EOF errors will be located at the position one past the end of the -file. - -Error recovery --------------- - -The error behavior of the parser (and other components) is controlled by an `ErrorHandler`. Whenever an error is -encountered, `ErrorHandler::handleError()` is invoked. The default error handling strategy is `ErrorHandler\Throwing`, -which will immediately throw when an error is encountered. - -To instead collect all encountered errors into an array, while trying to continue parsing the rest of the source code, -an instance of `ErrorHandler\Collecting` can be passed to the `Parser::parse()` method. A usage example: - -```php -$parser = (new PhpParser\ParserFactory)->create(PhpParser\ParserFactory::ONLY_PHP7); -$errorHandler = new PhpParser\ErrorHandler\Collecting; - -$stmts = $parser->parse($code, $errorHandler); - -if ($errorHandler->hasErrors()) { - foreach ($errorHandler->getErrors() as $error) { - // $error is an ordinary PhpParser\Error - } -} - -if (null !== $stmts) { - // $stmts is a best-effort partial AST -} -``` - -The `NameResolver` visitor also accepts an `ErrorHandler` as a constructor argument. \ No newline at end of file diff --git a/lib/nikic/php-parser/doc/component/Lexer.markdown b/lib/nikic/php-parser/doc/component/Lexer.markdown deleted file mode 100644 index b22942dd1..000000000 --- a/lib/nikic/php-parser/doc/component/Lexer.markdown +++ /dev/null @@ -1,152 +0,0 @@ -Lexer component documentation -============================= - -The lexer is responsible for providing tokens to the parser. The project comes with two lexers: `PhpParser\Lexer` and -`PhpParser\Lexer\Emulative`. The latter is an extension of the former, which adds the ability to emulate tokens of -newer PHP versions and thus allows parsing of new code on older versions. - -This documentation discusses options available for the default lexers and explains how lexers can be extended. - -Lexer options -------------- - -The two default lexers accept an `$options` array in the constructor. Currently only the `'usedAttributes'` option is -supported, which allows you to specify which attributes will be added to the AST nodes. The attributes can then be -accessed using `$node->getAttribute()`, `$node->setAttribute()`, `$node->hasAttribute()` and `$node->getAttributes()` -methods. A sample options array: - -```php -$lexer = new PhpParser\Lexer(array( - 'usedAttributes' => array( - 'comments', 'startLine', 'endLine' - ) -)); -``` - -The attributes used in this example match the default behavior of the lexer. The following attributes are supported: - - * `comments`: Array of `PhpParser\Comment` or `PhpParser\Comment\Doc` instances, representing all comments that occurred - between the previous non-discarded token and the current one. Use of this attribute is required for the - `$node->getDocComment()` method to work. The attribute is also needed if you wish the pretty printer to retain - comments present in the original code. - * `startLine`: Line in which the node starts. This attribute is required for the `$node->getLine()` to work. It is also - required if syntax errors should contain line number information. - * `endLine`: Line in which the node ends. - * `startTokenPos`: Offset into the token array of the first token in the node. - * `endTokenPos`: Offset into the token array of the last token in the node. - * `startFilePos`: Offset into the code string of the first character that is part of the node. - * `endFilePos`: Offset into the code string of the last character that is part of the node. - -### Using token positions - -The token offset information is useful if you wish to examine the exact formatting used for a node. For example the AST -does not distinguish whether a property was declared using `public` or using `var`, but you can retrieve this -information based on the token position: - -```php -function isDeclaredUsingVar(array $tokens, PhpParser\Node\Stmt\Property $prop) { - $i = $prop->getAttribute('startTokenPos'); - return $tokens[$i][0] === T_VAR; -} -``` - -In order to make use of this function, you will have to provide the tokens from the lexer to your node visitor using -code similar to the following: - -```php -class MyNodeVisitor extends PhpParser\NodeVisitorAbstract { - private $tokens; - public function setTokens(array $tokens) { - $this->tokens = $tokens; - } - - public function leaveNode(PhpParser\Node $node) { - if ($node instanceof PhpParser\Node\Stmt\Property) { - var_dump(isDeclaredUsingVar($this->tokens, $node)); - } - } -} - -$lexer = new PhpParser\Lexer(array( - 'usedAttributes' => array( - 'comments', 'startLine', 'endLine', 'startTokenPos', 'endTokenPos' - ) -)); -$parser = (new PhpParser\ParserFactory)->create(PhpParser\ParserFactory::PREFER_PHP7, $lexer); - -$visitor = new MyNodeVisitor(); -$traverser = new PhpParser\NodeTraverser(); -$traverser->addVisitor($visitor); - -try { - $stmts = $parser->parse($code); - $visitor->setTokens($lexer->getTokens()); - $stmts = $traverser->traverse($stmts); -} catch (PhpParser\Error $e) { - echo 'Parse Error: ', $e->getMessage(); -} -``` - -The same approach can also be used to perform specific modifications in the code, without changing the formatting in -other places (which is the case when using the pretty printer). - -Lexer extension ---------------- - -A lexer has to define the following public interface: - - void startLexing(string $code, ErrorHandler $errorHandler = null); - array getTokens(); - string handleHaltCompiler(); - int getNextToken(string &$value = null, array &$startAttributes = null, array &$endAttributes = null); - -The `startLexing()` method is invoked with the source code that is to be lexed (including the opening tag) whenever the -`parse()` method of the parser is called. It can be used to reset state or preprocess the source code or tokens. The -passes `ErrorHandler` should be used to report lexing errors. - -The `getTokens()` method returns the current token array, in the usual `token_get_all()` format. This method is not -used by the parser (which uses `getNextToken()`), but is useful in combination with the token position attributes. - -The `handleHaltCompiler()` method is called whenever a `T_HALT_COMPILER` token is encountered. It has to return the -remaining string after the construct (not including `();`). - -The `getNextToken()` method returns the ID of the next token (as defined by the `Parser::T_*` constants). If no more -tokens are available it must return `0`, which is the ID of the `EOF` token. Furthermore the string content of the -token should be written into the by-reference `$value` parameter (which will then be available as `$n` in the parser). - -### Attribute handling - -The other two by-ref variables `$startAttributes` and `$endAttributes` define which attributes will eventually be -assigned to the generated nodes: The parser will take the `$startAttributes` from the first token which is part of the -node and the `$endAttributes` from the last token that is part of the node. - -E.g. if the tokens `T_FUNCTION T_STRING ... '{' ... '}'` constitute a node, then the `$startAttributes` from the -`T_FUNCTION` token will be taken and the `$endAttributes` from the `'}'` token. - -An application of custom attributes is storing the exact original formatting of literals: While the parser does retain -some information about the formatting of integers (like decimal vs. hexadecimal) or strings (like used quote type), it -does not preserve the exact original formatting (e.g. leading zeros for integers or escape sequences in strings). This -can be remedied by storing the original value in an attribute: - -```php -use PhpParser\Lexer; -use PhpParser\Parser\Tokens; - -class KeepOriginalValueLexer extends Lexer // or Lexer\Emulative -{ - public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) { - $tokenId = parent::getNextToken($value, $startAttributes, $endAttributes); - - if ($tokenId == Tokens::T_CONSTANT_ENCAPSED_STRING // non-interpolated string - || $tokenId == Tokens::T_ENCAPSED_AND_WHITESPACE // interpolated string - || $tokenId == Tokens::T_LNUMBER // integer - || $tokenId == Tokens::T_DNUMBER // floating point number - ) { - // could also use $startAttributes, doesn't really matter here - $endAttributes['originalValue'] = $value; - } - - return $tokenId; - } -} -``` diff --git a/lib/nikic/php-parser/grammar/README.md b/lib/nikic/php-parser/grammar/README.md index 3f1698a68..4bae11d82 100644 --- a/lib/nikic/php-parser/grammar/README.md +++ b/lib/nikic/php-parser/grammar/README.md @@ -11,7 +11,7 @@ What do all those files mean? .phpy pseudo language ===================== -The `.y` file is a normal grammer in `kmyacc` (`yacc`) style, with some transformations +The `.y` file is a normal grammar in `kmyacc` (`yacc`) style, with some transformations applied to it: * Nodes are created using the syntax `Name[..., ...]`. This is transformed into @@ -21,8 +21,10 @@ applied to it: Building the parser =================== -In order to rebuild the parser, you need [moriyoshi's fork of kmyacc](https://github.com/moriyoshi/kmyacc-forked). -After you compiled/installed it, run the `rebuildParsers.php` script. +Run `php grammar/rebuildParsers.php` to rebuild the parsers. Additional options: -By default only the `Parser.php` is built. If you want to additionally emit debug symbols and create `y.output`, run the -script with `--debug`. If you want to retain the preprocessed grammar pass `--keep-tmp-grammar`. + * The `KMYACC` environment variable can be used to specify an alternative `kmyacc` binary. + By default the `phpyacc` dev dependency will be used. To use the original `kmyacc`, you + need to compile [moriyoshi's fork](https://github.com/moriyoshi/kmyacc-forked). + * The `--debug` option enables emission of debug symbols and creates the `y.output` file. + * The `--keep-tmp-grammar` option preserves the preprocessed grammar file. diff --git a/lib/nikic/php-parser/grammar/parser.template b/lib/nikic/php-parser/grammar/parser.template index fff893ff4..6166607c9 100644 --- a/lib/nikic/php-parser/grammar/parser.template +++ b/lib/nikic/php-parser/grammar/parser.template @@ -2,8 +2,8 @@ $meta # #semval($) $this->semValue #semval($,%t) $this->semValue -#semval(%n) $this->stackPos-(%l-%n) -#semval(%n,%t) $this->stackPos-(%l-%n) +#semval(%n) $stackPos-(%l-%n) +#semval(%n,%t) $stackPos-(%l-%n) namespace PhpParser\Parser; @@ -32,8 +32,8 @@ class #(-p) extends \PhpParser\ParserAbstract protected $defaultAction = #(YYDEFAULT); protected $unexpectedTokenRule = #(YYUNEXPECTED); - protected $YY2TBLSTATE = #(YY2TBLSTATE); - protected $YYNLSTATES = #(YYNLSTATES); + protected $YY2TBLSTATE = #(YY2TBLSTATE); + protected $numNonLeafStates = #(YYNLSTATES); protected $symbolToName = array( #listvar terminals @@ -88,16 +88,19 @@ class #(-p) extends \PhpParser\ParserAbstract #production-strings; ); #endif + + protected function initReduceCallbacks() { + $this->reduceCallbacks = [ #reduce - - protected function reduceRule%n() { - %b - } + %n => function ($stackPos) { + %b + }, #noact - - protected function reduceRule%n() { - $this->semValue = $this->semStack[$this->stackPos]; - } + %n => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, #endreduce + ]; + } } #tailcode; diff --git a/lib/nikic/php-parser/grammar/php5.y b/lib/nikic/php-parser/grammar/php5.y index 79384381f..f9e7e7dd1 100644 --- a/lib/nikic/php-parser/grammar/php5.y +++ b/lib/nikic/php-parser/grammar/php5.y @@ -16,10 +16,15 @@ top_statement_list_ex: top_statement_list: top_statement_list_ex - { makeNop($nop, $this->lookaheadStartAttributes); + { makeZeroLengthNop($nop, $this->lookaheadStartAttributes); if ($nop !== null) { $1[] = $nop; } $$ = $1; } ; +ampersand: + T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG + | T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG +; + reserved_non_modifiers: T_INCLUDE | T_INCLUDE_ONCE | T_EVAL | T_REQUIRE | T_REQUIRE_ONCE | T_LOGICAL_OR | T_LOGICAL_XOR | T_LOGICAL_AND | T_INSTANCEOF | T_NEW | T_CLONE | T_EXIT | T_IF | T_ELSEIF | T_ELSE | T_ENDIF | T_ECHO | T_DO | T_WHILE @@ -27,7 +32,8 @@ reserved_non_modifiers: | T_FINALLY | T_THROW | T_USE | T_INSTEADOF | T_GLOBAL | T_VAR | T_UNSET | T_ISSET | T_EMPTY | T_CONTINUE | T_GOTO | T_FUNCTION | T_CONST | T_RETURN | T_PRINT | T_YIELD | T_LIST | T_SWITCH | T_ENDSWITCH | T_CASE | T_DEFAULT | T_BREAK | T_ARRAY | T_CALLABLE | T_EXTENDS | T_IMPLEMENTS | T_NAMESPACE | T_TRAIT | T_INTERFACE | T_CLASS - | T_CLASS_C | T_TRAIT_C | T_FUNC_C | T_METHOD_C | T_LINE | T_FILE | T_DIR | T_NS_C | T_HALT_COMPILER + | T_CLASS_C | T_TRAIT_C | T_FUNC_C | T_METHOD_C | T_LINE | T_FILE | T_DIR | T_NS_C | T_HALT_COMPILER | T_FN + | T_MATCH ; semi_reserved: @@ -35,18 +41,31 @@ semi_reserved: | T_STATIC | T_ABSTRACT | T_FINAL | T_PRIVATE | T_PROTECTED | T_PUBLIC ; -identifier: - T_STRING { $$ = $1; } - | semi_reserved { $$ = $1; } +identifier_ex: + T_STRING { $$ = Node\Identifier[$1]; } + | semi_reserved { $$ = Node\Identifier[$1]; } ; -namespace_name_parts: - T_STRING { init($1); } - | namespace_name_parts T_NS_SEPARATOR T_STRING { push($1, $3); } +identifier: + T_STRING { $$ = Node\Identifier[$1]; } +; + +reserved_non_modifiers_identifier: + reserved_non_modifiers { $$ = Node\Identifier[$1]; } ; namespace_name: - namespace_name_parts { $$ = Name[$1]; } + T_STRING { $$ = Name[$1]; } + | T_NAME_QUALIFIED { $$ = Name[$1]; } +; + +legacy_namespace_name: + namespace_name { $$ = $1; } + | T_NAME_FULLY_QUALIFIED { $$ = Name[substr($1, 1)]; } +; + +plain_variable: + T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } ; top_statement: @@ -78,16 +97,11 @@ use_type: | T_CONST { $$ = Stmt\Use_::TYPE_CONSTANT; } ; -/* Using namespace_name_parts here to avoid s/r conflict on T_NS_SEPARATOR */ group_use_declaration: - T_USE use_type namespace_name_parts T_NS_SEPARATOR '{' unprefixed_use_declarations '}' - { $$ = Stmt\GroupUse[new Name($3, stackAttributes(#3)), $6, $2]; } - | T_USE use_type T_NS_SEPARATOR namespace_name_parts T_NS_SEPARATOR '{' unprefixed_use_declarations '}' - { $$ = Stmt\GroupUse[new Name($4, stackAttributes(#4)), $7, $2]; } - | T_USE namespace_name_parts T_NS_SEPARATOR '{' inline_use_declarations '}' - { $$ = Stmt\GroupUse[new Name($2, stackAttributes(#2)), $5, Stmt\Use_::TYPE_UNKNOWN]; } - | T_USE T_NS_SEPARATOR namespace_name_parts T_NS_SEPARATOR '{' inline_use_declarations '}' - { $$ = Stmt\GroupUse[new Name($3, stackAttributes(#3)), $6, Stmt\Use_::TYPE_UNKNOWN]; } + T_USE use_type legacy_namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations '}' + { $$ = Stmt\GroupUse[$3, $6, $2]; } + | T_USE legacy_namespace_name T_NS_SEPARATOR '{' inline_use_declarations '}' + { $$ = Stmt\GroupUse[$2, $5, Stmt\Use_::TYPE_UNKNOWN]; } ; unprefixed_use_declarations: @@ -109,13 +123,15 @@ inline_use_declarations: unprefixed_use_declaration: namespace_name { $$ = Stmt\UseUse[$1, null, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #1); } - | namespace_name T_AS T_STRING + | namespace_name T_AS identifier { $$ = Stmt\UseUse[$1, $3, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #3); } ; use_declaration: - unprefixed_use_declaration { $$ = $1; } - | T_NS_SEPARATOR unprefixed_use_declaration { $$ = $2; } + legacy_namespace_name + { $$ = Stmt\UseUse[$1, null, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #1); } + | legacy_namespace_name T_AS identifier + { $$ = Stmt\UseUse[$1, $3, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #3); } ; inline_use_declaration: @@ -129,7 +145,7 @@ constant_declaration_list: ; constant_declaration: - T_STRING '=' static_scalar { $$ = Node\Const_[$1, $3]; } + identifier '=' static_scalar { $$ = Node\Const_[$1, $3]; } ; class_const_list: @@ -138,7 +154,7 @@ class_const_list: ; class_const: - identifier '=' static_scalar { $$ = Node\Const_[$1, $3]; } + identifier_ex '=' static_scalar { $$ = Node\Const_[$1, $3]; } ; inner_statement_list_ex: @@ -148,7 +164,7 @@ inner_statement_list_ex: inner_statement_list: inner_statement_list_ex - { makeNop($nop, $this->lookaheadStartAttributes); + { makeZeroLengthNop($nop, $this->lookaheadStartAttributes); if ($nop !== null) { $1[] = $nop; } $$ = $1; } ; @@ -166,7 +182,7 @@ non_empty_statement: if ($2) { $$ = $2; prependLeadingComments($$); } else { - makeNop($$, $this->startAttributeStack[#1]); + makeNop($$, $this->startAttributeStack[#1], $this->endAttributes); if (null === $$) { $$ = array(); } } } @@ -185,12 +201,12 @@ non_empty_statement: | T_CONTINUE expr ';' { $$ = Stmt\Continue_[$2]; } | T_RETURN ';' { $$ = Stmt\Return_[null]; } | T_RETURN expr ';' { $$ = Stmt\Return_[$2]; } - | yield_expr ';' { $$ = $1; } | T_GLOBAL global_var_list ';' { $$ = Stmt\Global_[$2]; } | T_STATIC static_var_list ';' { $$ = Stmt\Static_[$2]; } | T_ECHO expr_list ';' { $$ = Stmt\Echo_[$2]; } | T_INLINE_HTML { $$ = Stmt\InlineHTML[$1]; } - | expr ';' { $$ = $1; } + | yield_expr ';' { $$ = Stmt\Expression[$1]; } + | expr ';' { $$ = Stmt\Expression[$1]; } | T_UNSET '(' variables_list ')' ';' { $$ = Stmt\Unset_[$3]; } | T_FOREACH '(' expr T_AS foreach_variable ')' foreach_statement { $$ = Stmt\Foreach_[$3, $5[0], ['keyVar' => null, 'byRef' => $5[1], 'stmts' => $7]]; } @@ -200,16 +216,16 @@ non_empty_statement: | T_TRY '{' inner_statement_list '}' catches optional_finally { $$ = Stmt\TryCatch[$3, $5, $6]; $this->checkTryCatch($$); } | T_THROW expr ';' { $$ = Stmt\Throw_[$2]; } - | T_GOTO T_STRING ';' { $$ = Stmt\Goto_[$2]; } - | T_STRING ':' { $$ = Stmt\Label[$1]; } - | expr error { $$ = $1; } + | T_GOTO identifier ';' { $$ = Stmt\Goto_[$2]; } + | identifier ':' { $$ = Stmt\Label[$1]; } + | expr error { $$ = Stmt\Expression[$1]; } | error { $$ = array(); /* means: no statement */ } ; statement: non_empty_statement { $$ = $1; } | ';' - { makeNop($$, $this->startAttributeStack[#1]); + { makeNop($$, $this->startAttributeStack[#1], $this->endAttributes); if ($$ === null) $$ = array(); /* means: no statement */ } ; @@ -219,8 +235,8 @@ catches: ; catch: - T_CATCH '(' name T_VARIABLE ')' '{' inner_statement_list '}' - { $$ = Stmt\Catch_[array($3), parseVar($4), $7]; } + T_CATCH '(' name plain_variable ')' '{' inner_statement_list '}' + { $$ = Stmt\Catch_[array($3), $4, $7]; } ; optional_finally: @@ -235,7 +251,12 @@ variables_list: optional_ref: /* empty */ { $$ = false; } - | '&' { $$ = true; } + | ampersand { $$ = true; } +; + +optional_arg_ref: + /* empty */ { $$ = false; } + | T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG { $$ = true; } ; optional_ellipsis: @@ -244,18 +265,18 @@ optional_ellipsis: ; function_declaration_statement: - T_FUNCTION optional_ref T_STRING '(' parameter_list ')' optional_return_type '{' inner_statement_list '}' + T_FUNCTION optional_ref identifier '(' parameter_list ')' optional_return_type '{' inner_statement_list '}' { $$ = Stmt\Function_[$3, ['byRef' => $2, 'params' => $5, 'returnType' => $7, 'stmts' => $9]]; } ; class_declaration_statement: - class_entry_type T_STRING extends_from implements_list '{' class_statement_list '}' + class_entry_type identifier extends_from implements_list '{' class_statement_list '}' { $$ = Stmt\Class_[$2, ['type' => $1, 'extends' => $3, 'implements' => $4, 'stmts' => $6]]; $this->checkClass($$, #2); } - | T_INTERFACE T_STRING interface_extends_list '{' class_statement_list '}' + | T_INTERFACE identifier interface_extends_list '{' class_statement_list '}' { $$ = Stmt\Interface_[$2, ['extends' => $3, 'stmts' => $5]]; $this->checkInterface($$, #2); } - | T_TRAIT T_STRING '{' class_statement_list '}' + | T_TRAIT identifier '{' class_statement_list '}' { $$ = Stmt\Trait_[$2, ['stmts' => $4]]; } ; @@ -307,7 +328,7 @@ declare_list: ; declare_list_element: - T_STRING '=' static_scalar { $$ = Stmt\DeclareDeclare[$1, $3]; } + identifier '=' static_scalar { $$ = Stmt\DeclareDeclare[$1, $3]; } ; switch_case_list: @@ -367,7 +388,7 @@ new_else_single: foreach_variable: variable { $$ = array($1, false); } - | '&' variable { $$ = array($2, true); } + | ampersand variable { $$ = array($2, true); } | list_expr { $$ = array($1, false); } ; @@ -382,16 +403,16 @@ non_empty_parameter_list: ; parameter: - optional_param_type optional_ref optional_ellipsis T_VARIABLE - { $$ = Node\Param[parseVar($4), null, $1, $2, $3]; $this->checkParam($$); } - | optional_param_type optional_ref optional_ellipsis T_VARIABLE '=' static_scalar - { $$ = Node\Param[parseVar($4), $6, $1, $2, $3]; $this->checkParam($$); } + optional_param_type optional_arg_ref optional_ellipsis plain_variable + { $$ = Node\Param[$4, null, $1, $2, $3]; $this->checkParam($$); } + | optional_param_type optional_arg_ref optional_ellipsis plain_variable '=' static_scalar + { $$ = Node\Param[$4, $6, $1, $2, $3]; $this->checkParam($$); } ; type: name { $$ = $1; } - | T_ARRAY { $$ = 'array'; } - | T_CALLABLE { $$ = 'callable'; } + | T_ARRAY { $$ = Node\Identifier['array']; } + | T_CALLABLE { $$ = Node\Identifier['callable']; } ; optional_param_type: @@ -417,7 +438,7 @@ non_empty_argument_list: argument: expr { $$ = Node\Arg[$1, false, false]; } - | '&' variable { $$ = Node\Arg[$2, true, false]; } + | ampersand variable { $$ = Node\Arg[$2, true, false]; } | T_ELLIPSIS expr { $$ = Node\Arg[$2, false, true]; } ; @@ -427,7 +448,7 @@ global_var_list: ; global_var: - T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } + plain_variable { $$ = $1; } | '$' variable { $$ = Expr\Variable[$2]; } | '$' '{' expr '}' { $$ = Expr\Variable[$3]; } ; @@ -438,20 +459,26 @@ static_var_list: ; static_var: - T_VARIABLE { $$ = Stmt\StaticVar[parseVar($1), null]; } - | T_VARIABLE '=' static_scalar { $$ = Stmt\StaticVar[parseVar($1), $3]; } + plain_variable { $$ = Stmt\StaticVar[$1, null]; } + | plain_variable '=' static_scalar { $$ = Stmt\StaticVar[$1, $3]; } +; + +class_statement_list_ex: + class_statement_list_ex class_statement { if ($2 !== null) { push($1, $2); } } + | /* empty */ { init(); } ; class_statement_list: - class_statement_list class_statement { push($1, $2); } - | /* empty */ { init(); } + class_statement_list_ex + { makeZeroLengthNop($nop, $this->lookaheadStartAttributes); + if ($nop !== null) { $1[] = $nop; } $$ = $1; } ; class_statement: variable_modifiers property_declaration_list ';' { $$ = Stmt\Property[$1, $2]; $this->checkProperty($$, #1); } | T_CONST class_const_list ';' { $$ = Stmt\ClassConst[$2, 0]; } - | method_modifiers T_FUNCTION optional_ref identifier '(' parameter_list ')' optional_return_type method_body + | method_modifiers T_FUNCTION optional_ref identifier_ex '(' parameter_list ')' optional_return_type method_body { $$ = Stmt\ClassMethod[$4, ['type' => $1, 'byRef' => $3, 'params' => $6, 'returnType' => $8, 'stmts' => $9]]; $this->checkClassMethod($$, #1); } | T_USE class_name_list trait_adaptations { $$ = Stmt\TraitUse[$2, $3]; } @@ -470,22 +497,22 @@ trait_adaptation_list: trait_adaptation: trait_method_reference_fully_qualified T_INSTEADOF class_name_list ';' { $$ = Stmt\TraitUseAdaptation\Precedence[$1[0], $1[1], $3]; } - | trait_method_reference T_AS member_modifier identifier ';' + | trait_method_reference T_AS member_modifier identifier_ex ';' { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], $3, $4]; } | trait_method_reference T_AS member_modifier ';' { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], $3, null]; } - | trait_method_reference T_AS T_STRING ';' + | trait_method_reference T_AS identifier ';' { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; } - | trait_method_reference T_AS reserved_non_modifiers ';' + | trait_method_reference T_AS reserved_non_modifiers_identifier ';' { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; } ; trait_method_reference_fully_qualified: - name T_PAAMAYIM_NEKUDOTAYIM identifier { $$ = array($1, $3); } + name T_PAAMAYIM_NEKUDOTAYIM identifier_ex { $$ = array($1, $3); } ; trait_method_reference: trait_method_reference_fully_qualified { $$ = $1; } - | identifier { $$ = array(null, $1); } + | identifier_ex { $$ = array(null, $1); } ; method_body: @@ -522,9 +549,13 @@ property_declaration_list: | property_declaration_list ',' property_declaration { push($1, $3); } ; +property_decl_name: + T_VARIABLE { $$ = Node\VarLikeIdentifier[parseVar($1)]; } +; + property_declaration: - T_VARIABLE { $$ = Stmt\PropertyProperty[parseVar($1), null]; } - | T_VARIABLE '=' static_scalar { $$ = Stmt\PropertyProperty[parseVar($1), $3]; } + property_decl_name { $$ = Stmt\PropertyProperty[$1, null]; } + | property_decl_name '=' static_scalar { $$ = Stmt\PropertyProperty[$1, $3]; } ; expr_list: @@ -541,8 +572,8 @@ expr: variable { $$ = $1; } | list_expr '=' expr { $$ = Expr\Assign[$1, $3]; } | variable '=' expr { $$ = Expr\Assign[$1, $3]; } - | variable '=' '&' variable { $$ = Expr\AssignRef[$1, $4]; } - | variable '=' '&' new_expr { $$ = Expr\AssignRef[$1, $4]; } + | variable '=' ampersand variable { $$ = Expr\AssignRef[$1, $4]; } + | variable '=' ampersand new_expr { $$ = Expr\AssignRef[$1, $4]; } | new_expr { $$ = $1; } | T_CLONE expr { $$ = Expr\Clone_[$2]; } | variable T_PLUS_EQUAL expr { $$ = Expr\AssignOp\Plus [$1, $3]; } @@ -557,6 +588,7 @@ expr: | variable T_SL_EQUAL expr { $$ = Expr\AssignOp\ShiftLeft [$1, $3]; } | variable T_SR_EQUAL expr { $$ = Expr\AssignOp\ShiftRight[$1, $3]; } | variable T_POW_EQUAL expr { $$ = Expr\AssignOp\Pow [$1, $3]; } + | variable T_COALESCE_EQUAL expr { $$ = Expr\AssignOp\Coalesce [$1, $3]; } | variable T_INC { $$ = Expr\PostInc[$1]; } | T_INC variable { $$ = Expr\PreInc [$2]; } | variable T_DEC { $$ = Expr\PostDec[$1]; } @@ -567,7 +599,8 @@ expr: | expr T_LOGICAL_AND expr { $$ = Expr\BinaryOp\LogicalAnd[$1, $3]; } | expr T_LOGICAL_XOR expr { $$ = Expr\BinaryOp\LogicalXor[$1, $3]; } | expr '|' expr { $$ = Expr\BinaryOp\BitwiseOr [$1, $3]; } - | expr '&' expr { $$ = Expr\BinaryOp\BitwiseAnd[$1, $3]; } + | expr T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG expr { $$ = Expr\BinaryOp\BitwiseAnd[$1, $3]; } + | expr T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG expr { $$ = Expr\BinaryOp\BitwiseAnd[$1, $3]; } | expr '^' expr { $$ = Expr\BinaryOp\BitwiseXor[$1, $3]; } | expr '.' expr { $$ = Expr\BinaryOp\Concat [$1, $3]; } | expr '+' expr { $$ = Expr\BinaryOp\Plus [$1, $3]; } @@ -606,7 +639,10 @@ expr: | T_REQUIRE expr { $$ = Expr\Include_[$2, Expr\Include_::TYPE_REQUIRE]; } | T_REQUIRE_ONCE expr { $$ = Expr\Include_[$2, Expr\Include_::TYPE_REQUIRE_ONCE]; } | T_INT_CAST expr { $$ = Expr\Cast\Int_ [$2]; } - | T_DOUBLE_CAST expr { $$ = Expr\Cast\Double [$2]; } + | T_DOUBLE_CAST expr + { $attrs = attributes(); + $attrs['kind'] = $this->getFloatCastKind($1); + $$ = new Expr\Cast\Double($2, $attrs); } | T_STRING_CAST expr { $$ = Expr\Cast\String_ [$2]; } | T_ARRAY_CAST expr { $$ = Expr\Cast\Array_ [$2]; } | T_OBJECT_CAST expr { $$ = Expr\Cast\Object_ [$2]; } @@ -665,6 +701,7 @@ anonymous_class: T_CLASS ctor_arguments extends_from implements_list '{' class_statement_list '}' { $$ = array(Stmt\Class_[null, ['type' => 0, 'extends' => $3, 'implements' => $4, 'stmts' => $6]], $2); $this->checkClass($$[0], -1); } +; new_expr: T_NEW class_name_reference ctor_arguments { $$ = Expr\New_[$2, $3]; } @@ -683,30 +720,17 @@ lexical_var_list: ; lexical_var: - optional_ref T_VARIABLE { $$ = Expr\ClosureUse[parseVar($2), $1]; } + optional_ref plain_variable { $$ = Expr\ClosureUse[$2, $1]; } ; function_call: name argument_list { $$ = Expr\FuncCall[$1, $2]; } - | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier argument_list + | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier_ex argument_list { $$ = Expr\StaticCall[$1, $3, $4]; } | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '{' expr '}' argument_list { $$ = Expr\StaticCall[$1, $4, $6]; } - | static_property argument_list { - if ($1 instanceof Node\Expr\StaticPropertyFetch) { - $$ = Expr\StaticCall[$1->class, Expr\Variable[$1->name], $2]; - } elseif ($1 instanceof Node\Expr\ArrayDimFetch) { - $tmp = $1; - while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { - $tmp = $tmp->var; - } - - $$ = Expr\StaticCall[$tmp->var->class, $1, $2]; - $tmp->var = Expr\Variable[$tmp->var->name]; - } else { - throw new \Exception; - } - } + | static_property argument_list + { $$ = $this->fixupPhp5StaticPropCall($1, $2, attributes()); } | variable_without_objects argument_list { $$ = Expr\FuncCall[$1, $2]; } | function_call '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } @@ -719,9 +743,10 @@ class_name: ; name: - namespace_name_parts { $$ = Name[$1]; } - | T_NS_SEPARATOR namespace_name_parts { $$ = Name\FullyQualified[$2]; } - | T_NAMESPACE T_NS_SEPARATOR namespace_name_parts { $$ = Name\Relative[$3]; } + T_STRING { $$ = Name[$1]; } + | T_NAME_QUALIFIED { $$ = Name[$1]; } + | T_NAME_FULLY_QUALIFIED { $$ = Name\FullyQualified[substr($1, 1)]; } + | T_NAME_RELATIVE { $$ = Name\Relative[substr($1, 10)]; } ; class_name_reference: @@ -781,16 +806,14 @@ common_scalar: | T_FUNC_C { $$ = Scalar\MagicConst\Function_[]; } | T_NS_C { $$ = Scalar\MagicConst\Namespace_[]; } | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC - { $attrs = attributes(); setDocStringAttrs($attrs, $1); - $$ = new Scalar\String_(Scalar\String_::parseDocString($1, $2, false), $attrs); } + { $$ = $this->parseDocString($1, $2, $3, attributes(), stackAttributes(#3), false); } | T_START_HEREDOC T_END_HEREDOC - { $attrs = attributes(); setDocStringAttrs($attrs, $1); - $$ = new Scalar\String_('', $attrs); } + { $$ = $this->parseDocString($1, '', $2, attributes(), stackAttributes(#2), false); } ; static_scalar: common_scalar { $$ = $1; } - | class_name T_PAAMAYIM_NEKUDOTAYIM identifier { $$ = Expr\ClassConstFetch[$1, $3]; } + | class_name T_PAAMAYIM_NEKUDOTAYIM identifier_ex { $$ = Expr\ClassConstFetch[$1, $3]; } | name { $$ = Expr\ConstFetch[$1]; } | T_ARRAY '(' static_array_pair_list ')' { $$ = Expr\Array_[$3]; } | '[' static_array_pair_list ']' { $$ = Expr\Array_[$2]; } @@ -804,7 +827,10 @@ static_operation: | static_scalar T_LOGICAL_AND static_scalar { $$ = Expr\BinaryOp\LogicalAnd[$1, $3]; } | static_scalar T_LOGICAL_XOR static_scalar { $$ = Expr\BinaryOp\LogicalXor[$1, $3]; } | static_scalar '|' static_scalar { $$ = Expr\BinaryOp\BitwiseOr [$1, $3]; } - | static_scalar '&' static_scalar { $$ = Expr\BinaryOp\BitwiseAnd[$1, $3]; } + | static_scalar T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG static_scalar + { $$ = Expr\BinaryOp\BitwiseAnd[$1, $3]; } + | static_scalar T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG static_scalar + { $$ = Expr\BinaryOp\BitwiseAnd[$1, $3]; } | static_scalar '^' static_scalar { $$ = Expr\BinaryOp\BitwiseXor[$1, $3]; } | static_scalar '.' static_scalar { $$ = Expr\BinaryOp\Concat [$1, $3]; } | static_scalar '+' static_scalar { $$ = Expr\BinaryOp\Plus [$1, $3]; } @@ -835,7 +861,7 @@ static_operation: constant: name { $$ = Expr\ConstFetch[$1]; } - | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier + | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier_ex { $$ = Expr\ClassConstFetch[$1, $3]; } ; @@ -846,8 +872,7 @@ scalar: { $attrs = attributes(); $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; parseEncapsed($2, '"', true); $$ = new Scalar\Encapsed($2, $attrs); } | T_START_HEREDOC encaps_list T_END_HEREDOC - { $attrs = attributes(); setDocStringAttrs($attrs, $1); - parseEncapsedDoc($2, true); $$ = new Scalar\Encapsed($2, $attrs); } + { $$ = $this->parseDocString($1, $2, $3, attributes(), stackAttributes(#3), true); } ; static_array_pair_list: @@ -914,9 +939,14 @@ static_property: | static_property_with_arrays { $$ = $1; } ; +static_property_simple_name: + T_VARIABLE + { $var = parseVar($1); $$ = \is_string($var) ? Node\VarLikeIdentifier[$var] : $var; } +; + static_property_with_arrays: - class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE - { $$ = Expr\StaticPropertyFetch[$1, parseVar($3)]; } + class_name_or_var T_PAAMAYIM_NEKUDOTAYIM static_property_simple_name + { $$ = Expr\StaticPropertyFetch[$1, $3]; } | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}' { $$ = Expr\StaticPropertyFetch[$1, $5]; } | static_property_with_arrays '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } @@ -926,7 +956,7 @@ static_property_with_arrays: reference_variable: reference_variable '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } | reference_variable '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; } - | T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } + | plain_variable { $$ = $1; } | '$' '{' expr '}' { $$ = Expr\Variable[$3]; } ; @@ -936,7 +966,7 @@ dim_offset: ; object_property: - T_STRING { $$ = $1; } + identifier { $$ = $1; } | '{' expr '}' { $$ = $2; } | variable_without_objects { $$ = $1; } | error { $$ = Expr\Error[]; $this->errorState = 2; } @@ -970,8 +1000,9 @@ non_empty_array_pair_list: array_pair: expr T_DOUBLE_ARROW expr { $$ = Expr\ArrayItem[$3, $1, false]; } | expr { $$ = Expr\ArrayItem[$1, null, false]; } - | expr T_DOUBLE_ARROW '&' variable { $$ = Expr\ArrayItem[$4, $1, true]; } - | '&' variable { $$ = Expr\ArrayItem[$2, null, true]; } + | expr T_DOUBLE_ARROW ampersand variable { $$ = Expr\ArrayItem[$4, $1, true]; } + | ampersand variable { $$ = Expr\ArrayItem[$2, null, true]; } + | T_ELLIPSIS expr { $$ = Expr\ArrayItem[$2, null, false, attributes(), true]; } ; encaps_list: @@ -985,25 +1016,25 @@ encaps_string_part: T_ENCAPSED_AND_WHITESPACE { $$ = Scalar\EncapsedStringPart[$1]; } ; -encaps_base_var: - T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } +encaps_str_varname: + T_STRING_VARNAME { $$ = Expr\Variable[$1]; } ; encaps_var: - encaps_base_var { $$ = $1; } - | encaps_base_var '[' encaps_var_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } - | encaps_base_var T_OBJECT_OPERATOR T_STRING { $$ = Expr\PropertyFetch[$1, $3]; } + plain_variable { $$ = $1; } + | plain_variable '[' encaps_var_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } + | plain_variable T_OBJECT_OPERATOR identifier { $$ = Expr\PropertyFetch[$1, $3]; } | T_DOLLAR_OPEN_CURLY_BRACES expr '}' { $$ = Expr\Variable[$2]; } | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' { $$ = Expr\Variable[$2]; } - | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' - { $$ = Expr\ArrayDimFetch[Expr\Variable[$2], $4]; } + | T_DOLLAR_OPEN_CURLY_BRACES encaps_str_varname '[' expr ']' '}' + { $$ = Expr\ArrayDimFetch[$2, $4]; } | T_CURLY_OPEN variable '}' { $$ = $2; } ; encaps_var_offset: T_STRING { $$ = Scalar\String_[$1]; } | T_NUM_STRING { $$ = $this->parseNumString($1, attributes()); } - | T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } + | plain_variable { $$ = $1; } ; %% diff --git a/lib/nikic/php-parser/grammar/php7.y b/lib/nikic/php-parser/grammar/php7.y index f9b599b8d..d9a450379 100644 --- a/lib/nikic/php-parser/grammar/php7.y +++ b/lib/nikic/php-parser/grammar/php7.y @@ -16,10 +16,15 @@ top_statement_list_ex: top_statement_list: top_statement_list_ex - { makeNop($nop, $this->lookaheadStartAttributes); + { makeZeroLengthNop($nop, $this->lookaheadStartAttributes); if ($nop !== null) { $1[] = $nop; } $$ = $1; } ; +ampersand: + T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG + | T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG +; + reserved_non_modifiers: T_INCLUDE | T_INCLUDE_ONCE | T_EVAL | T_REQUIRE | T_REQUIRE_ONCE | T_LOGICAL_OR | T_LOGICAL_XOR | T_LOGICAL_AND | T_INSTANCEOF | T_NEW | T_CLONE | T_EXIT | T_IF | T_ELSEIF | T_ELSE | T_ENDIF | T_ECHO | T_DO | T_WHILE @@ -27,26 +32,46 @@ reserved_non_modifiers: | T_FINALLY | T_THROW | T_USE | T_INSTEADOF | T_GLOBAL | T_VAR | T_UNSET | T_ISSET | T_EMPTY | T_CONTINUE | T_GOTO | T_FUNCTION | T_CONST | T_RETURN | T_PRINT | T_YIELD | T_LIST | T_SWITCH | T_ENDSWITCH | T_CASE | T_DEFAULT | T_BREAK | T_ARRAY | T_CALLABLE | T_EXTENDS | T_IMPLEMENTS | T_NAMESPACE | T_TRAIT | T_INTERFACE | T_CLASS - | T_CLASS_C | T_TRAIT_C | T_FUNC_C | T_METHOD_C | T_LINE | T_FILE | T_DIR | T_NS_C | T_HALT_COMPILER + | T_CLASS_C | T_TRAIT_C | T_FUNC_C | T_METHOD_C | T_LINE | T_FILE | T_DIR | T_NS_C | T_HALT_COMPILER | T_FN + | T_MATCH | T_ENUM ; semi_reserved: reserved_non_modifiers - | T_STATIC | T_ABSTRACT | T_FINAL | T_PRIVATE | T_PROTECTED | T_PUBLIC + | T_STATIC | T_ABSTRACT | T_FINAL | T_PRIVATE | T_PROTECTED | T_PUBLIC | T_READONLY +; + +identifier_ex: + T_STRING { $$ = Node\Identifier[$1]; } + | semi_reserved { $$ = Node\Identifier[$1]; } ; identifier: - T_STRING { $$ = $1; } - | semi_reserved { $$ = $1; } + T_STRING { $$ = Node\Identifier[$1]; } ; -namespace_name_parts: - T_STRING { init($1); } - | namespace_name_parts T_NS_SEPARATOR T_STRING { push($1, $3); } +reserved_non_modifiers_identifier: + reserved_non_modifiers { $$ = Node\Identifier[$1]; } +; + +namespace_declaration_name: + T_STRING { $$ = Name[$1]; } + | semi_reserved { $$ = Name[$1]; } + | T_NAME_QUALIFIED { $$ = Name[$1]; } ; namespace_name: - namespace_name_parts { $$ = Name[$1]; } + T_STRING { $$ = Name[$1]; } + | T_NAME_QUALIFIED { $$ = Name[$1]; } +; + +legacy_namespace_name: + namespace_name { $$ = $1; } + | T_NAME_FULLY_QUALIFIED { $$ = Name[substr($1, 1)]; } +; + +plain_variable: + T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } ; semi: @@ -62,6 +87,31 @@ no_comma: optional_comma: /* empty */ | ',' +; + +attribute_decl: + class_name { $$ = Node\Attribute[$1, []]; } + | class_name argument_list { $$ = Node\Attribute[$1, $2]; } +; + +attribute_group: + attribute_decl { init($1); } + | attribute_group ',' attribute_decl { push($1, $3); } +; + +attribute: + T_ATTRIBUTE attribute_group optional_comma ']' { $$ = Node\AttributeGroup[$2]; } +; + +attributes: + attribute { init($1); } + | attributes attribute { push($1, $2); } +; + +optional_attributes: + /* empty */ { $$ = []; } + | attributes { $$ = $1; } +; top_statement: statement { $$ = $1; } @@ -69,11 +119,11 @@ top_statement: | class_declaration_statement { $$ = $1; } | T_HALT_COMPILER { $$ = Stmt\HaltCompiler[$this->lexer->handleHaltCompiler()]; } - | T_NAMESPACE namespace_name semi + | T_NAMESPACE namespace_declaration_name semi { $$ = Stmt\Namespace_[$2, null]; $$->setAttribute('kind', Stmt\Namespace_::KIND_SEMICOLON); $this->checkNamespace($$); } - | T_NAMESPACE namespace_name '{' top_statement_list '}' + | T_NAMESPACE namespace_declaration_name '{' top_statement_list '}' { $$ = Stmt\Namespace_[$2, $4]; $$->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); $this->checkNamespace($$); } @@ -92,16 +142,11 @@ use_type: | T_CONST { $$ = Stmt\Use_::TYPE_CONSTANT; } ; -/* Using namespace_name_parts here to avoid s/r conflict on T_NS_SEPARATOR */ group_use_declaration: - T_USE use_type namespace_name_parts T_NS_SEPARATOR '{' unprefixed_use_declarations '}' - { $$ = Stmt\GroupUse[new Name($3, stackAttributes(#3)), $6, $2]; } - | T_USE use_type T_NS_SEPARATOR namespace_name_parts T_NS_SEPARATOR '{' unprefixed_use_declarations '}' - { $$ = Stmt\GroupUse[new Name($4, stackAttributes(#4)), $7, $2]; } - | T_USE namespace_name_parts T_NS_SEPARATOR '{' inline_use_declarations '}' - { $$ = Stmt\GroupUse[new Name($2, stackAttributes(#2)), $5, Stmt\Use_::TYPE_UNKNOWN]; } - | T_USE T_NS_SEPARATOR namespace_name_parts T_NS_SEPARATOR '{' inline_use_declarations '}' - { $$ = Stmt\GroupUse[new Name($3, stackAttributes(#3)), $6, Stmt\Use_::TYPE_UNKNOWN]; } + T_USE use_type legacy_namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations '}' + { $$ = Stmt\GroupUse[$3, $6, $2]; } + | T_USE legacy_namespace_name T_NS_SEPARATOR '{' inline_use_declarations '}' + { $$ = Stmt\GroupUse[$2, $5, Stmt\Use_::TYPE_UNKNOWN]; } ; unprefixed_use_declarations: @@ -136,13 +181,15 @@ non_empty_inline_use_declarations: unprefixed_use_declaration: namespace_name { $$ = Stmt\UseUse[$1, null, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #1); } - | namespace_name T_AS T_STRING + | namespace_name T_AS identifier { $$ = Stmt\UseUse[$1, $3, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #3); } ; use_declaration: - unprefixed_use_declaration { $$ = $1; } - | T_NS_SEPARATOR unprefixed_use_declaration { $$ = $2; } + legacy_namespace_name + { $$ = Stmt\UseUse[$1, null, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #1); } + | legacy_namespace_name T_AS identifier + { $$ = Stmt\UseUse[$1, $3, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #3); } ; inline_use_declaration: @@ -161,7 +208,7 @@ non_empty_constant_declaration_list: ; constant_declaration: - T_STRING '=' expr { $$ = Node\Const_[$1, $3]; } + identifier '=' expr { $$ = Node\Const_[$1, $3]; } ; class_const_list: @@ -174,7 +221,7 @@ non_empty_class_const_list: ; class_const: - identifier '=' expr { $$ = Node\Const_[$1, $3]; } + identifier_ex '=' expr { $$ = Node\Const_[$1, $3]; } ; inner_statement_list_ex: @@ -184,7 +231,7 @@ inner_statement_list_ex: inner_statement_list: inner_statement_list_ex - { makeNop($nop, $this->lookaheadStartAttributes); + { makeZeroLengthNop($nop, $this->lookaheadStartAttributes); if ($nop !== null) { $1[] = $nop; } $$ = $1; } ; @@ -202,7 +249,7 @@ non_empty_statement: if ($2) { $$ = $2; prependLeadingComments($$); } else { - makeNop($$, $this->startAttributeStack[#1]); + makeNop($$, $this->startAttributeStack[#1], $this->endAttributes); if (null === $$) { $$ = array(); } } } @@ -220,27 +267,37 @@ non_empty_statement: | T_RETURN optional_expr semi { $$ = Stmt\Return_[$2]; } | T_GLOBAL global_var_list semi { $$ = Stmt\Global_[$2]; } | T_STATIC static_var_list semi { $$ = Stmt\Static_[$2]; } - | T_ECHO expr_list semi { $$ = Stmt\Echo_[$2]; } + | T_ECHO expr_list_forbid_comma semi { $$ = Stmt\Echo_[$2]; } | T_INLINE_HTML { $$ = Stmt\InlineHTML[$1]; } - | expr semi { $$ = $1; } + | expr semi { + $e = $1; + if ($e instanceof Expr\Throw_) { + // For backwards-compatibility reasons, convert throw in statement position into + // Stmt\Throw_ rather than Stmt\Expression(Expr\Throw_). + $$ = Stmt\Throw_[$e->expr]; + } else { + $$ = Stmt\Expression[$e]; + } + } | T_UNSET '(' variables_list ')' semi { $$ = Stmt\Unset_[$3]; } | T_FOREACH '(' expr T_AS foreach_variable ')' foreach_statement { $$ = Stmt\Foreach_[$3, $5[0], ['keyVar' => null, 'byRef' => $5[1], 'stmts' => $7]]; } | T_FOREACH '(' expr T_AS variable T_DOUBLE_ARROW foreach_variable ')' foreach_statement { $$ = Stmt\Foreach_[$3, $7[0], ['keyVar' => $5, 'byRef' => $7[1], 'stmts' => $9]]; } + | T_FOREACH '(' expr error ')' foreach_statement + { $$ = Stmt\Foreach_[$3, new Expr\Error(stackAttributes(#4)), ['stmts' => $6]]; } | T_DECLARE '(' declare_list ')' declare_statement { $$ = Stmt\Declare_[$3, $5]; } | T_TRY '{' inner_statement_list '}' catches optional_finally { $$ = Stmt\TryCatch[$3, $5, $6]; $this->checkTryCatch($$); } - | T_THROW expr semi { $$ = Stmt\Throw_[$2]; } - | T_GOTO T_STRING semi { $$ = Stmt\Goto_[$2]; } - | T_STRING ':' { $$ = Stmt\Label[$1]; } + | T_GOTO identifier semi { $$ = Stmt\Goto_[$2]; } + | identifier ':' { $$ = Stmt\Label[$1]; } | error { $$ = array(); /* means: no statement */ } ; statement: non_empty_statement { $$ = $1; } | ';' - { makeNop($$, $this->startAttributeStack[#1]); + { makeNop($$, $this->startAttributeStack[#1], $this->endAttributes); if ($$ === null) $$ = array(); /* means: no statement */ } ; @@ -255,8 +312,8 @@ name_union: ; catch: - T_CATCH '(' name_union T_VARIABLE ')' '{' inner_statement_list '}' - { $$ = Stmt\Catch_[$3, parseVar($4), $7]; } + T_CATCH '(' name_union optional_plain_variable ')' '{' inner_statement_list '}' + { $$ = Stmt\Catch_[$3, $4, $7]; } ; optional_finally: @@ -265,7 +322,7 @@ optional_finally: ; variables_list: - non_empty_variables_list no_comma { $$ = $1; } + non_empty_variables_list optional_comma { $$ = $1; } ; non_empty_variables_list: @@ -275,7 +332,12 @@ non_empty_variables_list: optional_ref: /* empty */ { $$ = false; } - | '&' { $$ = true; } + | ampersand { $$ = true; } +; + +optional_arg_ref: + /* empty */ { $$ = false; } + | T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG { $$ = true; } ; optional_ellipsis: @@ -283,20 +345,39 @@ optional_ellipsis: | T_ELLIPSIS { $$ = true; } ; +block_or_error: + '{' inner_statement_list '}' { $$ = $2; } + | error { $$ = []; } +; + function_declaration_statement: - T_FUNCTION optional_ref T_STRING '(' parameter_list ')' optional_return_type '{' inner_statement_list '}' - { $$ = Stmt\Function_[$3, ['byRef' => $2, 'params' => $5, 'returnType' => $7, 'stmts' => $9]]; } + T_FUNCTION optional_ref identifier '(' parameter_list ')' optional_return_type block_or_error + { $$ = Stmt\Function_[$3, ['byRef' => $2, 'params' => $5, 'returnType' => $7, 'stmts' => $8, 'attrGroups' => []]]; } + | attributes T_FUNCTION optional_ref identifier '(' parameter_list ')' optional_return_type block_or_error + { $$ = Stmt\Function_[$4, ['byRef' => $3, 'params' => $6, 'returnType' => $8, 'stmts' => $9, 'attrGroups' => $1]]; } ; class_declaration_statement: - class_entry_type T_STRING extends_from implements_list '{' class_statement_list '}' - { $$ = Stmt\Class_[$2, ['type' => $1, 'extends' => $3, 'implements' => $4, 'stmts' => $6]]; - $this->checkClass($$, #2); } - | T_INTERFACE T_STRING interface_extends_list '{' class_statement_list '}' - { $$ = Stmt\Interface_[$2, ['extends' => $3, 'stmts' => $5]]; - $this->checkInterface($$, #2); } - | T_TRAIT T_STRING '{' class_statement_list '}' - { $$ = Stmt\Trait_[$2, ['stmts' => $4]]; } + optional_attributes class_entry_type identifier extends_from implements_list '{' class_statement_list '}' + { $$ = Stmt\Class_[$3, ['type' => $2, 'extends' => $4, 'implements' => $5, 'stmts' => $7, 'attrGroups' => $1]]; + $this->checkClass($$, #3); } + | optional_attributes T_INTERFACE identifier interface_extends_list '{' class_statement_list '}' + { $$ = Stmt\Interface_[$3, ['extends' => $4, 'stmts' => $6, 'attrGroups' => $1]]; + $this->checkInterface($$, #3); } + | optional_attributes T_TRAIT identifier '{' class_statement_list '}' + { $$ = Stmt\Trait_[$3, ['stmts' => $5, 'attrGroups' => $1]]; } + | optional_attributes T_ENUM identifier enum_scalar_type implements_list '{' class_statement_list '}' + { $$ = Stmt\Enum_[$3, ['scalarType' => $4, 'implements' => $5, 'stmts' => $7, 'attrGroups' => $1]]; + $this->checkEnum($$, #3); } +; + +enum_scalar_type: + /* empty */ { $$ = null; } + | ':' type { $$ = $2; } + +enum_case_expr: + /* empty */ { $$ = null; } + | '=' expr { $$ = $2; } ; class_entry_type: @@ -355,7 +436,7 @@ non_empty_declare_list: ; declare_list_element: - T_STRING '=' expr { $$ = Stmt\DeclareDeclare[$1, $3]; } + identifier '=' expr { $$ = Stmt\DeclareDeclare[$1, $3]; } ; switch_case_list: @@ -380,6 +461,25 @@ case_separator: | ';' ; +match: + T_MATCH '(' expr ')' '{' match_arm_list '}' { $$ = Expr\Match_[$3, $6]; } +; + +match_arm_list: + /* empty */ { $$ = []; } + | non_empty_match_arm_list optional_comma { $$ = $1; } +; + +non_empty_match_arm_list: + match_arm { init($1); } + | non_empty_match_arm_list ',' match_arm { push($1, $3); } +; + +match_arm: + expr_list_allow_comma T_DOUBLE_ARROW expr { $$ = Node\MatchArm[$1, $3]; } + | T_DEFAULT optional_comma T_DOUBLE_ARROW expr { $$ = Node\MatchArm[null, $4]; } +; + while_statement: statement { $$ = toArray($1); } | ':' inner_statement_list T_ENDWHILE ';' { $$ = $2; } @@ -415,13 +515,13 @@ new_else_single: foreach_variable: variable { $$ = array($1, false); } - | '&' variable { $$ = array($2, true); } + | ampersand variable { $$ = array($2, true); } | list_expr { $$ = array($1, false); } | array_short_syntax { $$ = array($1, false); } ; parameter_list: - non_empty_parameter_list no_comma { $$ = $1; } + non_empty_parameter_list optional_comma { $$ = $1; } | /* empty */ { $$ = array(); } ; @@ -430,37 +530,75 @@ non_empty_parameter_list: | non_empty_parameter_list ',' parameter { push($1, $3); } ; +optional_visibility_modifier: + /* empty */ { $$ = 0; } + | T_PUBLIC { $$ = Stmt\Class_::MODIFIER_PUBLIC; } + | T_PROTECTED { $$ = Stmt\Class_::MODIFIER_PROTECTED; } + | T_PRIVATE { $$ = Stmt\Class_::MODIFIER_PRIVATE; } + | T_READONLY { $$ = Stmt\Class_::MODIFIER_READONLY; } +; + parameter: - optional_param_type optional_ref optional_ellipsis T_VARIABLE - { $$ = Node\Param[parseVar($4), null, $1, $2, $3]; $this->checkParam($$); } - | optional_param_type optional_ref optional_ellipsis T_VARIABLE '=' expr - { $$ = Node\Param[parseVar($4), $6, $1, $2, $3]; $this->checkParam($$); } + optional_attributes optional_visibility_modifier optional_type_without_static + optional_arg_ref optional_ellipsis plain_variable + { $$ = new Node\Param($6, null, $3, $4, $5, attributes(), $2, $1); + $this->checkParam($$); } + | optional_attributes optional_visibility_modifier optional_type_without_static + optional_arg_ref optional_ellipsis plain_variable '=' expr + { $$ = new Node\Param($6, $8, $3, $4, $5, attributes(), $2, $1); + $this->checkParam($$); } + | optional_attributes optional_visibility_modifier optional_type_without_static + optional_arg_ref optional_ellipsis error + { $$ = new Node\Param(Expr\Error[], null, $3, $4, $5, attributes(), $2, $1); } ; type_expr: type { $$ = $1; } | '?' type { $$ = Node\NullableType[$2]; } + | union_type { $$ = Node\UnionType[$1]; } ; type: - name { $$ = $this->handleBuiltinTypes($1); } - | T_ARRAY { $$ = 'array'; } - | T_CALLABLE { $$ = 'callable'; } + type_without_static { $$ = $1; } + | T_STATIC { $$ = Node\Name['static']; } ; -optional_param_type: +type_without_static: + name { $$ = $this->handleBuiltinTypes($1); } + | T_ARRAY { $$ = Node\Identifier['array']; } + | T_CALLABLE { $$ = Node\Identifier['callable']; } +; + +union_type: + type '|' type { init($1, $3); } + | union_type '|' type { push($1, $3); } +; + +union_type_without_static: + type_without_static '|' type_without_static { init($1, $3); } + | union_type_without_static '|' type_without_static { push($1, $3); } +; + +type_expr_without_static: + type_without_static { $$ = $1; } + | '?' type_without_static { $$ = Node\NullableType[$2]; } + | union_type_without_static { $$ = Node\UnionType[$1]; } +; + +optional_type_without_static: /* empty */ { $$ = null; } - | type_expr { $$ = $1; } + | type_expr_without_static { $$ = $1; } ; optional_return_type: /* empty */ { $$ = null; } | ':' type_expr { $$ = $2; } + | ':' error { $$ = null; } ; argument_list: '(' ')' { $$ = array(); } - | '(' non_empty_argument_list no_comma ')' { $$ = $2; } + | '(' non_empty_argument_list optional_comma ')' { $$ = $2; } ; non_empty_argument_list: @@ -470,8 +608,10 @@ non_empty_argument_list: argument: expr { $$ = Node\Arg[$1, false, false]; } - | '&' variable { $$ = Node\Arg[$2, true, false]; } + | ampersand variable { $$ = Node\Arg[$2, true, false]; } | T_ELLIPSIS expr { $$ = Node\Arg[$2, false, true]; } + | identifier_ex ':' expr + { $$ = new Node\Arg($3, false, false, attributes(), $1); } ; global_var_list: @@ -484,7 +624,7 @@ non_empty_global_var_list: ; global_var: - simple_variable { $$ = Expr\Variable[$1]; } + simple_variable { $$ = $1; } ; static_var_list: @@ -497,24 +637,35 @@ non_empty_static_var_list: ; static_var: - T_VARIABLE { $$ = Stmt\StaticVar[parseVar($1), null]; } - | T_VARIABLE '=' expr { $$ = Stmt\StaticVar[parseVar($1), $3]; } + plain_variable { $$ = Stmt\StaticVar[$1, null]; } + | plain_variable '=' expr { $$ = Stmt\StaticVar[$1, $3]; } ; -class_statement_list: - class_statement_list class_statement { push($1, $2); } +class_statement_list_ex: + class_statement_list_ex class_statement { if ($2 !== null) { push($1, $2); } } | /* empty */ { init(); } ; +class_statement_list: + class_statement_list_ex + { makeZeroLengthNop($nop, $this->lookaheadStartAttributes); + if ($nop !== null) { $1[] = $nop; } $$ = $1; } +; + class_statement: - variable_modifiers property_declaration_list ';' - { $$ = Stmt\Property[$1, $2]; $this->checkProperty($$, #1); } - | method_modifiers T_CONST class_const_list ';' - { $$ = Stmt\ClassConst[$3, $1]; $this->checkClassConst($$, #1); } - | method_modifiers T_FUNCTION optional_ref identifier '(' parameter_list ')' optional_return_type method_body - { $$ = Stmt\ClassMethod[$4, ['type' => $1, 'byRef' => $3, 'params' => $6, 'returnType' => $8, 'stmts' => $9]]; - $this->checkClassMethod($$, #1); } + optional_attributes variable_modifiers optional_type_without_static property_declaration_list semi + { $$ = new Stmt\Property($2, $4, attributes(), $3, $1); + $this->checkProperty($$, #2); } + | optional_attributes method_modifiers T_CONST class_const_list semi + { $$ = new Stmt\ClassConst($4, $2, attributes(), $1); + $this->checkClassConst($$, #2); } + | optional_attributes method_modifiers T_FUNCTION optional_ref identifier_ex '(' parameter_list ')' optional_return_type method_body + { $$ = Stmt\ClassMethod[$5, ['type' => $2, 'byRef' => $4, 'params' => $7, 'returnType' => $9, 'stmts' => $10, 'attrGroups' => $1]]; + $this->checkClassMethod($$, #2); } | T_USE class_name_list trait_adaptations { $$ = Stmt\TraitUse[$2, $3]; } + | optional_attributes T_CASE identifier enum_case_expr semi + { $$ = Stmt\EnumCase[$3, $4, $1]; } + | error { $$ = null; /* will be skipped */ } ; trait_adaptations: @@ -530,27 +681,27 @@ trait_adaptation_list: trait_adaptation: trait_method_reference_fully_qualified T_INSTEADOF class_name_list ';' { $$ = Stmt\TraitUseAdaptation\Precedence[$1[0], $1[1], $3]; } - | trait_method_reference T_AS member_modifier identifier ';' + | trait_method_reference T_AS member_modifier identifier_ex ';' { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], $3, $4]; } | trait_method_reference T_AS member_modifier ';' { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], $3, null]; } - | trait_method_reference T_AS T_STRING ';' + | trait_method_reference T_AS identifier ';' { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; } - | trait_method_reference T_AS reserved_non_modifiers ';' + | trait_method_reference T_AS reserved_non_modifiers_identifier ';' { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; } ; trait_method_reference_fully_qualified: - name T_PAAMAYIM_NEKUDOTAYIM identifier { $$ = array($1, $3); } + name T_PAAMAYIM_NEKUDOTAYIM identifier_ex { $$ = array($1, $3); } ; trait_method_reference: trait_method_reference_fully_qualified { $$ = $1; } - | identifier { $$ = array(null, $1); } + | identifier_ex { $$ = array(null, $1); } ; method_body: ';' /* abstract method */ { $$ = null; } - | '{' inner_statement_list '}' { $$ = $2; } + | block_or_error { $$ = $1; } ; variable_modifiers: @@ -575,6 +726,7 @@ member_modifier: | T_STATIC { $$ = Stmt\Class_::MODIFIER_STATIC; } | T_ABSTRACT { $$ = Stmt\Class_::MODIFIER_ABSTRACT; } | T_FINAL { $$ = Stmt\Class_::MODIFIER_FINAL; } + | T_READONLY { $$ = Stmt\Class_::MODIFIER_READONLY; } ; property_declaration_list: @@ -587,15 +739,23 @@ non_empty_property_declaration_list: { push($1, $3); } ; -property_declaration: - T_VARIABLE { $$ = Stmt\PropertyProperty[parseVar($1), null]; } - | T_VARIABLE '=' expr { $$ = Stmt\PropertyProperty[parseVar($1), $3]; } +property_decl_name: + T_VARIABLE { $$ = Node\VarLikeIdentifier[parseVar($1)]; } ; -expr_list: +property_declaration: + property_decl_name { $$ = Stmt\PropertyProperty[$1, null]; } + | property_decl_name '=' expr { $$ = Stmt\PropertyProperty[$1, $3]; } +; + +expr_list_forbid_comma: non_empty_expr_list no_comma { $$ = $1; } ; +expr_list_allow_comma: + non_empty_expr_list optional_comma { $$ = $1; } +; + non_empty_expr_list: non_empty_expr_list ',' expr { push($1, $3); } | expr { init($1); } @@ -603,7 +763,7 @@ non_empty_expr_list: for_expr: /* empty */ { $$ = array(); } - | expr_list { $$ = $1; } + | expr_list_forbid_comma { $$ = $1; } ; expr: @@ -611,8 +771,9 @@ expr: | list_expr '=' expr { $$ = Expr\Assign[$1, $3]; } | array_short_syntax '=' expr { $$ = Expr\Assign[$1, $3]; } | variable '=' expr { $$ = Expr\Assign[$1, $3]; } - | variable '=' '&' variable { $$ = Expr\AssignRef[$1, $4]; } + | variable '=' ampersand variable { $$ = Expr\AssignRef[$1, $4]; } | new_expr { $$ = $1; } + | match { $$ = $1; } | T_CLONE expr { $$ = Expr\Clone_[$2]; } | variable T_PLUS_EQUAL expr { $$ = Expr\AssignOp\Plus [$1, $3]; } | variable T_MINUS_EQUAL expr { $$ = Expr\AssignOp\Minus [$1, $3]; } @@ -626,6 +787,7 @@ expr: | variable T_SL_EQUAL expr { $$ = Expr\AssignOp\ShiftLeft [$1, $3]; } | variable T_SR_EQUAL expr { $$ = Expr\AssignOp\ShiftRight[$1, $3]; } | variable T_POW_EQUAL expr { $$ = Expr\AssignOp\Pow [$1, $3]; } + | variable T_COALESCE_EQUAL expr { $$ = Expr\AssignOp\Coalesce [$1, $3]; } | variable T_INC { $$ = Expr\PostInc[$1]; } | T_INC variable { $$ = Expr\PreInc [$2]; } | variable T_DEC { $$ = Expr\PostDec[$1]; } @@ -636,7 +798,8 @@ expr: | expr T_LOGICAL_AND expr { $$ = Expr\BinaryOp\LogicalAnd[$1, $3]; } | expr T_LOGICAL_XOR expr { $$ = Expr\BinaryOp\LogicalXor[$1, $3]; } | expr '|' expr { $$ = Expr\BinaryOp\BitwiseOr [$1, $3]; } - | expr '&' expr { $$ = Expr\BinaryOp\BitwiseAnd[$1, $3]; } + | expr T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG expr { $$ = Expr\BinaryOp\BitwiseAnd[$1, $3]; } + | expr T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG expr { $$ = Expr\BinaryOp\BitwiseAnd[$1, $3]; } | expr '^' expr { $$ = Expr\BinaryOp\BitwiseXor[$1, $3]; } | expr '.' expr { $$ = Expr\BinaryOp\Concat [$1, $3]; } | expr '+' expr { $$ = Expr\BinaryOp\Plus [$1, $3]; } @@ -665,7 +828,7 @@ expr: | expr '?' expr ':' expr { $$ = Expr\Ternary[$1, $3, $5]; } | expr '?' ':' expr { $$ = Expr\Ternary[$1, null, $4]; } | expr T_COALESCE expr { $$ = Expr\BinaryOp\Coalesce[$1, $3]; } - | T_ISSET '(' variables_list ')' { $$ = Expr\Isset_[$3]; } + | T_ISSET '(' expr_list_allow_comma ')' { $$ = Expr\Isset_[$3]; } | T_EMPTY '(' expr ')' { $$ = Expr\Empty_[$3]; } | T_INCLUDE expr { $$ = Expr\Include_[$2, Expr\Include_::TYPE_INCLUDE]; } | T_INCLUDE_ONCE expr { $$ = Expr\Include_[$2, Expr\Include_::TYPE_INCLUDE_ONCE]; } @@ -673,7 +836,10 @@ expr: | T_REQUIRE expr { $$ = Expr\Include_[$2, Expr\Include_::TYPE_REQUIRE]; } | T_REQUIRE_ONCE expr { $$ = Expr\Include_[$2, Expr\Include_::TYPE_REQUIRE_ONCE]; } | T_INT_CAST expr { $$ = Expr\Cast\Int_ [$2]; } - | T_DOUBLE_CAST expr { $$ = Expr\Cast\Double [$2]; } + | T_DOUBLE_CAST expr + { $attrs = attributes(); + $attrs['kind'] = $this->getFloatCastKind($1); + $$ = new Expr\Cast\Double($2, $attrs); } | T_STRING_CAST expr { $$ = Expr\Cast\String_ [$2]; } | T_ARRAY_CAST expr { $$ = Expr\Cast\Array_ [$2]; } | T_OBJECT_CAST expr { $$ = Expr\Cast\Object_ [$2]; } @@ -691,18 +857,32 @@ expr: | T_YIELD expr { $$ = Expr\Yield_[$2, null]; } | T_YIELD expr T_DOUBLE_ARROW expr { $$ = Expr\Yield_[$4, $2]; } | T_YIELD_FROM expr { $$ = Expr\YieldFrom[$2]; } - | T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars optional_return_type - '{' inner_statement_list '}' - { $$ = Expr\Closure[['static' => false, 'byRef' => $2, 'params' => $4, 'uses' => $6, 'returnType' => $7, 'stmts' => $9]]; } - | T_STATIC T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars optional_return_type - '{' inner_statement_list '}' - { $$ = Expr\Closure[['static' => true, 'byRef' => $3, 'params' => $5, 'uses' => $7, 'returnType' => $8, 'stmts' => $10]]; } + | T_THROW expr { $$ = Expr\Throw_[$2]; } + + | T_FN optional_ref '(' parameter_list ')' optional_return_type T_DOUBLE_ARROW expr %prec T_THROW + { $$ = Expr\ArrowFunction[['static' => false, 'byRef' => $2, 'params' => $4, 'returnType' => $6, 'expr' => $8, 'attrGroups' => []]]; } + | T_STATIC T_FN optional_ref '(' parameter_list ')' optional_return_type T_DOUBLE_ARROW expr %prec T_THROW + { $$ = Expr\ArrowFunction[['static' => true, 'byRef' => $3, 'params' => $5, 'returnType' => $7, 'expr' => $9, 'attrGroups' => []]]; } + | T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars optional_return_type block_or_error + { $$ = Expr\Closure[['static' => false, 'byRef' => $2, 'params' => $4, 'uses' => $6, 'returnType' => $7, 'stmts' => $8, 'attrGroups' => []]]; } + | T_STATIC T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars optional_return_type block_or_error + { $$ = Expr\Closure[['static' => true, 'byRef' => $3, 'params' => $5, 'uses' => $7, 'returnType' => $8, 'stmts' => $9, 'attrGroups' => []]]; } + + | attributes T_FN optional_ref '(' parameter_list ')' optional_return_type T_DOUBLE_ARROW expr %prec T_THROW + { $$ = Expr\ArrowFunction[['static' => false, 'byRef' => $3, 'params' => $5, 'returnType' => $7, 'expr' => $9, 'attrGroups' => $1]]; } + | attributes T_STATIC T_FN optional_ref '(' parameter_list ')' optional_return_type T_DOUBLE_ARROW expr %prec T_THROW + { $$ = Expr\ArrowFunction[['static' => true, 'byRef' => $4, 'params' => $6, 'returnType' => $8, 'expr' => $10, 'attrGroups' => $1]]; } + | attributes T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars optional_return_type block_or_error + { $$ = Expr\Closure[['static' => false, 'byRef' => $3, 'params' => $5, 'uses' => $7, 'returnType' => $8, 'stmts' => $9, 'attrGroups' => $1]]; } + | attributes T_STATIC T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars optional_return_type block_or_error + { $$ = Expr\Closure[['static' => true, 'byRef' => $4, 'params' => $6, 'uses' => $8, 'returnType' => $9, 'stmts' => $10, 'attrGroups' => $1]]; } ; anonymous_class: - T_CLASS ctor_arguments extends_from implements_list '{' class_statement_list '}' - { $$ = array(Stmt\Class_[null, ['type' => 0, 'extends' => $3, 'implements' => $4, 'stmts' => $6]], $2); + optional_attributes T_CLASS ctor_arguments extends_from implements_list '{' class_statement_list '}' + { $$ = array(Stmt\Class_[null, ['type' => 0, 'extends' => $4, 'implements' => $5, 'stmts' => $7, 'attrGroups' => $1]], $3); $this->checkClass($$[0], -1); } +; new_expr: T_NEW class_name_reference ctor_arguments { $$ = Expr\New_[$2, $3]; } @@ -716,7 +896,7 @@ lexical_vars: ; lexical_var_list: - non_empty_lexical_var_list no_comma { $$ = $1; } + non_empty_lexical_var_list optional_comma { $$ = $1; } ; non_empty_lexical_var_list: @@ -725,7 +905,7 @@ non_empty_lexical_var_list: ; lexical_var: - optional_ref T_VARIABLE { $$ = Expr\ClosureUse[parseVar($2), $1]; } + optional_ref plain_variable { $$ = Expr\ClosureUse[$2, $1]; } ; function_call: @@ -741,20 +921,22 @@ class_name: ; name: - namespace_name_parts { $$ = Name[$1]; } - | T_NS_SEPARATOR namespace_name_parts { $$ = Name\FullyQualified[$2]; } - | T_NAMESPACE T_NS_SEPARATOR namespace_name_parts { $$ = Name\Relative[$3]; } + T_STRING { $$ = Name[$1]; } + | T_NAME_QUALIFIED { $$ = Name[$1]; } + | T_NAME_FULLY_QUALIFIED { $$ = Name\FullyQualified[substr($1, 1)]; } + | T_NAME_RELATIVE { $$ = Name\Relative[substr($1, 10)]; } ; class_name_reference: class_name { $$ = $1; } | new_variable { $$ = $1; } + | '(' expr ')' { $$ = $2; } | error { $$ = Expr\Error[]; $this->errorState = 2; } ; class_name_or_var: class_name { $$ = $1; } - | dereferencable { $$ = $1; } + | fully_dereferencable { $$ = $1; } ; exit_expr: @@ -776,9 +958,20 @@ ctor_arguments: constant: name { $$ = Expr\ConstFetch[$1]; } - | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier + | T_LINE { $$ = Scalar\MagicConst\Line[]; } + | T_FILE { $$ = Scalar\MagicConst\File[]; } + | T_DIR { $$ = Scalar\MagicConst\Dir[]; } + | T_CLASS_C { $$ = Scalar\MagicConst\Class_[]; } + | T_TRAIT_C { $$ = Scalar\MagicConst\Trait_[]; } + | T_METHOD_C { $$ = Scalar\MagicConst\Method[]; } + | T_FUNC_C { $$ = Scalar\MagicConst\Function_[]; } + | T_NS_C { $$ = Scalar\MagicConst\Namespace_[]; } +; + +class_constant: + class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier_ex { $$ = Expr\ClassConstFetch[$1, $3]; } - /* We interpret and isolated FOO:: as an unfinished class constant fetch. It could also be + /* We interpret an isolated FOO:: as an unfinished class constant fetch. It could also be an unfinished static property fetch or unfinished scoped call. */ | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM error { $$ = Expr\ClassConstFetch[$1, new Expr\Error(stackAttributes(#3))]; $this->errorState = 2; } @@ -798,33 +991,23 @@ dereferencable_scalar: | T_CONSTANT_ENCAPSED_STRING { $attrs = attributes(); $attrs['kind'] = strKind($1); $$ = new Scalar\String_(Scalar\String_::parse($1), $attrs); } + | '"' encaps_list '"' + { $attrs = attributes(); $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; + parseEncapsed($2, '"', true); $$ = new Scalar\Encapsed($2, $attrs); } ; scalar: T_LNUMBER { $$ = $this->parseLNumber($1, attributes()); } | T_DNUMBER { $$ = Scalar\DNumber[Scalar\DNumber::parse($1)]; } - | T_LINE { $$ = Scalar\MagicConst\Line[]; } - | T_FILE { $$ = Scalar\MagicConst\File[]; } - | T_DIR { $$ = Scalar\MagicConst\Dir[]; } - | T_CLASS_C { $$ = Scalar\MagicConst\Class_[]; } - | T_TRAIT_C { $$ = Scalar\MagicConst\Trait_[]; } - | T_METHOD_C { $$ = Scalar\MagicConst\Method[]; } - | T_FUNC_C { $$ = Scalar\MagicConst\Function_[]; } - | T_NS_C { $$ = Scalar\MagicConst\Namespace_[]; } | dereferencable_scalar { $$ = $1; } | constant { $$ = $1; } + | class_constant { $$ = $1; } | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC - { $attrs = attributes(); setDocStringAttrs($attrs, $1); - $$ = new Scalar\String_(Scalar\String_::parseDocString($1, $2), $attrs); } + { $$ = $this->parseDocString($1, $2, $3, attributes(), stackAttributes(#3), true); } | T_START_HEREDOC T_END_HEREDOC - { $attrs = attributes(); setDocStringAttrs($attrs, $1); - $$ = new Scalar\String_('', $attrs); } - | '"' encaps_list '"' - { $attrs = attributes(); $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; - parseEncapsed($2, '"', true); $$ = new Scalar\Encapsed($2, $attrs); } + { $$ = $this->parseDocString($1, '', $2, attributes(), stackAttributes(#2), true); } | T_START_HEREDOC encaps_list T_END_HEREDOC - { $attrs = attributes(); setDocStringAttrs($attrs, $1); - parseEncapsedDoc($2, true); $$ = new Scalar\Encapsed($2, $attrs); } + { $$ = $this->parseDocString($1, $2, $3, attributes(), stackAttributes(#3), true); } ; optional_expr: @@ -832,10 +1015,16 @@ optional_expr: | expr { $$ = $1; } ; -dereferencable: +fully_dereferencable: variable { $$ = $1; } | '(' expr ')' { $$ = $2; } | dereferencable_scalar { $$ = $1; } + | class_constant { $$ = $1; } +; + +array_object_dereferencable: + fully_dereferencable { $$ = $1; } + | constant { $$ = $1; } ; callable_expr: @@ -845,87 +1034,100 @@ callable_expr: ; callable_variable: - simple_variable { $$ = Expr\Variable[$1]; } - | dereferencable '[' optional_expr ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } - | constant '[' optional_expr ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } - | dereferencable '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; } + simple_variable { $$ = $1; } + | array_object_dereferencable '[' optional_expr ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } + | array_object_dereferencable '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; } | function_call { $$ = $1; } - | dereferencable T_OBJECT_OPERATOR property_name argument_list + | array_object_dereferencable T_OBJECT_OPERATOR property_name argument_list { $$ = Expr\MethodCall[$1, $3, $4]; } + | array_object_dereferencable T_NULLSAFE_OBJECT_OPERATOR property_name argument_list + { $$ = Expr\NullsafeMethodCall[$1, $3, $4]; } +; + +optional_plain_variable: + /* empty */ { $$ = null; } + | plain_variable { $$ = $1; } ; variable: callable_variable { $$ = $1; } | static_member { $$ = $1; } - | dereferencable T_OBJECT_OPERATOR property_name { $$ = Expr\PropertyFetch[$1, $3]; } + | array_object_dereferencable T_OBJECT_OPERATOR property_name + { $$ = Expr\PropertyFetch[$1, $3]; } + | array_object_dereferencable T_NULLSAFE_OBJECT_OPERATOR property_name + { $$ = Expr\NullsafePropertyFetch[$1, $3]; } ; simple_variable: - T_VARIABLE { $$ = parseVar($1); } - | '$' '{' expr '}' { $$ = $3; } + plain_variable { $$ = $1; } + | '$' '{' expr '}' { $$ = Expr\Variable[$3]; } | '$' simple_variable { $$ = Expr\Variable[$2]; } - | '$' error { $$ = Expr\Error[]; $this->errorState = 2; } + | '$' error { $$ = Expr\Variable[Expr\Error[]]; $this->errorState = 2; } +; + +static_member_prop_name: + simple_variable + { $var = $1->name; $$ = \is_string($var) ? Node\VarLikeIdentifier[$var] : $var; } ; static_member: - class_name_or_var T_PAAMAYIM_NEKUDOTAYIM simple_variable + class_name_or_var T_PAAMAYIM_NEKUDOTAYIM static_member_prop_name { $$ = Expr\StaticPropertyFetch[$1, $3]; } ; new_variable: - simple_variable { $$ = Expr\Variable[$1]; } + simple_variable { $$ = $1; } | new_variable '[' optional_expr ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } | new_variable '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; } | new_variable T_OBJECT_OPERATOR property_name { $$ = Expr\PropertyFetch[$1, $3]; } - | class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable { $$ = Expr\StaticPropertyFetch[$1, $3]; } - | new_variable T_PAAMAYIM_NEKUDOTAYIM simple_variable { $$ = Expr\StaticPropertyFetch[$1, $3]; } + | new_variable T_NULLSAFE_OBJECT_OPERATOR property_name { $$ = Expr\NullsafePropertyFetch[$1, $3]; } + | class_name T_PAAMAYIM_NEKUDOTAYIM static_member_prop_name + { $$ = Expr\StaticPropertyFetch[$1, $3]; } + | new_variable T_PAAMAYIM_NEKUDOTAYIM static_member_prop_name + { $$ = Expr\StaticPropertyFetch[$1, $3]; } ; member_name: - identifier { $$ = $1; } - | '{' expr '}' { $$ = $2; } - | simple_variable { $$ = Expr\Variable[$1]; } + identifier_ex { $$ = $1; } + | '{' expr '}' { $$ = $2; } + | simple_variable { $$ = $1; } ; property_name: - T_STRING { $$ = $1; } - | '{' expr '}' { $$ = $2; } - | simple_variable { $$ = Expr\Variable[$1]; } + identifier { $$ = $1; } + | '{' expr '}' { $$ = $2; } + | simple_variable { $$ = $1; } | error { $$ = Expr\Error[]; $this->errorState = 2; } ; list_expr: - T_LIST '(' list_expr_elements ')' { $$ = Expr\List_[$3]; } -; - -list_expr_elements: - list_expr_elements ',' list_expr_element { push($1, $3); } - | list_expr_element { init($1); } -; - -list_expr_element: - variable { $$ = Expr\ArrayItem[$1, null, false]; } - | list_expr { $$ = Expr\ArrayItem[$1, null, false]; } - | expr T_DOUBLE_ARROW variable { $$ = Expr\ArrayItem[$3, $1, false]; } - | expr T_DOUBLE_ARROW list_expr { $$ = Expr\ArrayItem[$3, $1, false]; } - | /* empty */ { $$ = null; } + T_LIST '(' inner_array_pair_list ')' { $$ = Expr\List_[$3]; } ; array_pair_list: inner_array_pair_list - { $$ = $1; $end = count($$)-1; if ($$[$end] === null) unset($$[$end]); } + { $$ = $1; $end = count($$)-1; if ($$[$end] === null) array_pop($$); } +; + +comma_or_error: + ',' + | error + { /* do nothing -- prevent default action of $$=$1. See #551. */ } ; inner_array_pair_list: - inner_array_pair_list ',' array_pair { push($1, $3); } + inner_array_pair_list comma_or_error array_pair { push($1, $3); } | array_pair { init($1); } ; array_pair: - expr T_DOUBLE_ARROW expr { $$ = Expr\ArrayItem[$3, $1, false]; } - | expr { $$ = Expr\ArrayItem[$1, null, false]; } - | expr T_DOUBLE_ARROW '&' variable { $$ = Expr\ArrayItem[$4, $1, true]; } - | '&' variable { $$ = Expr\ArrayItem[$2, null, true]; } + expr { $$ = Expr\ArrayItem[$1, null, false]; } + | ampersand variable { $$ = Expr\ArrayItem[$2, null, true]; } + | list_expr { $$ = Expr\ArrayItem[$1, null, false]; } + | expr T_DOUBLE_ARROW expr { $$ = Expr\ArrayItem[$3, $1, false]; } + | expr T_DOUBLE_ARROW ampersand variable { $$ = Expr\ArrayItem[$4, $1, true]; } + | expr T_DOUBLE_ARROW list_expr { $$ = Expr\ArrayItem[$3, $1, false]; } + | T_ELLIPSIS expr { $$ = Expr\ArrayItem[$2, null, false, attributes(), true]; } | /* empty */ { $$ = null; } ; @@ -940,18 +1142,19 @@ encaps_string_part: T_ENCAPSED_AND_WHITESPACE { $$ = Scalar\EncapsedStringPart[$1]; } ; -encaps_base_var: - T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } +encaps_str_varname: + T_STRING_VARNAME { $$ = Expr\Variable[$1]; } ; encaps_var: - encaps_base_var { $$ = $1; } - | encaps_base_var '[' encaps_var_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } - | encaps_base_var T_OBJECT_OPERATOR T_STRING { $$ = Expr\PropertyFetch[$1, $3]; } + plain_variable { $$ = $1; } + | plain_variable '[' encaps_var_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } + | plain_variable T_OBJECT_OPERATOR identifier { $$ = Expr\PropertyFetch[$1, $3]; } + | plain_variable T_NULLSAFE_OBJECT_OPERATOR identifier { $$ = Expr\NullsafePropertyFetch[$1, $3]; } | T_DOLLAR_OPEN_CURLY_BRACES expr '}' { $$ = Expr\Variable[$2]; } | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' { $$ = Expr\Variable[$2]; } - | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' - { $$ = Expr\ArrayDimFetch[Expr\Variable[$2], $4]; } + | T_DOLLAR_OPEN_CURLY_BRACES encaps_str_varname '[' expr ']' '}' + { $$ = Expr\ArrayDimFetch[$2, $4]; } | T_CURLY_OPEN variable '}' { $$ = $2; } ; @@ -959,7 +1162,7 @@ encaps_var_offset: T_STRING { $$ = Scalar\String_[$1]; } | T_NUM_STRING { $$ = $this->parseNumString($1, attributes()); } | '-' T_NUM_STRING { $$ = $this->parseNumString('-' . $2, attributes()); } - | T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } + | plain_variable { $$ = $1; } ; %% diff --git a/lib/nikic/php-parser/grammar/phpyLang.php b/lib/nikic/php-parser/grammar/phpyLang.php new file mode 100644 index 000000000..1a9808dcf --- /dev/null +++ b/lib/nikic/php-parser/grammar/phpyLang.php @@ -0,0 +1,192 @@ +\'[^\\\\\']*+(?:\\\\.[^\\\\\']*+)*+\') + (?"[^\\\\"]*+(?:\\\\.[^\\\\"]*+)*+") + (?(?&singleQuotedString)|(?&doubleQuotedString)) + (?/\*[^*]*+(?:\*(?!/)[^*]*+)*+\*/) + (?\{[^\'"/{}]*+(?:(?:(?&string)|(?&comment)|(?&code)|/)[^\'"/{}]*+)*+}) +)'; + +const PARAMS = '\[(?[^[\]]*+(?:\[(?¶ms)\][^[\]]*+)*+)\]'; +const ARGS = '\((?[^()]*+(?:\((?&args)\)[^()]*+)*+)\)'; + +/////////////////////////////// +/// Preprocessing functions /// +/////////////////////////////// + +function preprocessGrammar($code) { + $code = resolveNodes($code); + $code = resolveMacros($code); + $code = resolveStackAccess($code); + + return $code; +} + +function resolveNodes($code) { + return preg_replace_callback( + '~\b(?[A-Z][a-zA-Z_\\\\]++)\s*' . PARAMS . '~', + function($matches) { + // recurse + $matches['params'] = resolveNodes($matches['params']); + + $params = magicSplit( + '(?:' . PARAMS . '|' . ARGS . ')(*SKIP)(*FAIL)|,', + $matches['params'] + ); + + $paramCode = ''; + foreach ($params as $param) { + $paramCode .= $param . ', '; + } + + return 'new ' . $matches['name'] . '(' . $paramCode . 'attributes())'; + }, + $code + ); +} + +function resolveMacros($code) { + return preg_replace_callback( + '~\b(?)(?!array\()(?[a-z][A-Za-z]++)' . ARGS . '~', + function($matches) { + // recurse + $matches['args'] = resolveMacros($matches['args']); + + $name = $matches['name']; + $args = magicSplit( + '(?:' . PARAMS . '|' . ARGS . ')(*SKIP)(*FAIL)|,', + $matches['args'] + ); + + if ('attributes' === $name) { + assertArgs(0, $args, $name); + return '$this->startAttributeStack[#1] + $this->endAttributes'; + } + + if ('stackAttributes' === $name) { + assertArgs(1, $args, $name); + return '$this->startAttributeStack[' . $args[0] . ']' + . ' + $this->endAttributeStack[' . $args[0] . ']'; + } + + if ('init' === $name) { + return '$$ = array(' . implode(', ', $args) . ')'; + } + + if ('push' === $name) { + assertArgs(2, $args, $name); + + return $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0]; + } + + if ('pushNormalizing' === $name) { + assertArgs(2, $args, $name); + + return 'if (is_array(' . $args[1] . ')) { $$ = array_merge(' . $args[0] . ', ' . $args[1] . '); }' + . ' else { ' . $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0] . '; }'; + } + + if ('toArray' == $name) { + assertArgs(1, $args, $name); + + return 'is_array(' . $args[0] . ') ? ' . $args[0] . ' : array(' . $args[0] . ')'; + } + + if ('parseVar' === $name) { + assertArgs(1, $args, $name); + + return 'substr(' . $args[0] . ', 1)'; + } + + if ('parseEncapsed' === $name) { + assertArgs(3, $args, $name); + + return 'foreach (' . $args[0] . ' as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) {' + . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, ' . $args[1] . ', ' . $args[2] . '); } }'; + } + + if ('makeNop' === $name) { + assertArgs(3, $args, $name); + + return '$startAttributes = ' . $args[1] . ';' + . ' if (isset($startAttributes[\'comments\']))' + . ' { ' . $args[0] . ' = new Stmt\Nop($startAttributes + ' . $args[2] . '); }' + . ' else { ' . $args[0] . ' = null; }'; + } + + if ('makeZeroLengthNop' == $name) { + assertArgs(2, $args, $name); + + return '$startAttributes = ' . $args[1] . ';' + . ' if (isset($startAttributes[\'comments\']))' + . ' { ' . $args[0] . ' = new Stmt\Nop($this->createCommentNopAttributes($startAttributes[\'comments\'])); }' + . ' else { ' . $args[0] . ' = null; }'; + } + + if ('strKind' === $name) { + assertArgs(1, $args, $name); + + return '(' . $args[0] . '[0] === "\'" || (' . $args[0] . '[1] === "\'" && ' + . '(' . $args[0] . '[0] === \'b\' || ' . $args[0] . '[0] === \'B\')) ' + . '? Scalar\String_::KIND_SINGLE_QUOTED : Scalar\String_::KIND_DOUBLE_QUOTED)'; + } + + if ('prependLeadingComments' === $name) { + assertArgs(1, $args, $name); + + return '$attrs = $this->startAttributeStack[#1]; $stmts = ' . $args[0] . '; ' + . 'if (!empty($attrs[\'comments\'])) {' + . '$stmts[0]->setAttribute(\'comments\', ' + . 'array_merge($attrs[\'comments\'], $stmts[0]->getAttribute(\'comments\', []))); }'; + } + + return $matches[0]; + }, + $code + ); +} + +function assertArgs($num, $args, $name) { + if ($num != count($args)) { + die('Wrong argument count for ' . $name . '().'); + } +} + +function resolveStackAccess($code) { + $code = preg_replace('/\$\d+/', '$this->semStack[$0]', $code); + $code = preg_replace('/#(\d+)/', '$$1', $code); + return $code; +} + +function removeTrailingWhitespace($code) { + $lines = explode("\n", $code); + $lines = array_map('rtrim', $lines); + return implode("\n", $lines); +} + +////////////////////////////// +/// Regex helper functions /// +////////////////////////////// + +function regex($regex) { + return '~' . LIB . '(?:' . str_replace('~', '\~', $regex) . ')~'; +} + +function magicSplit($regex, $string) { + $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string); + + foreach ($pieces as &$piece) { + $piece = trim($piece); + } + + if ($pieces === ['']) { + return []; + } + + return $pieces; +} diff --git a/lib/nikic/php-parser/grammar/rebuildParsers.php b/lib/nikic/php-parser/grammar/rebuildParsers.php index 340b0eacd..2d0c6b14d 100644 --- a/lib/nikic/php-parser/grammar/rebuildParsers.php +++ b/lib/nikic/php-parser/grammar/rebuildParsers.php @@ -1,5 +1,7 @@ 'Php5', __DIR__ . '/php7.y' => 'Php7', @@ -13,31 +15,16 @@ $tmpResultFile = __DIR__ . '/tmp_parser.php'; $resultDir = __DIR__ . '/../lib/PhpParser/Parser'; $tokensResultsFile = $resultDir . '/Tokens.php'; -// check for kmyacc.exe binary in this directory, otherwise fall back to global name -$kmyacc = __DIR__ . '/kmyacc.exe'; -if (!file_exists($kmyacc)) { - $kmyacc = 'kmyacc'; +$kmyacc = getenv('KMYACC'); +if (!$kmyacc) { + // Use phpyacc from dev dependencies by default. + $kmyacc = __DIR__ . '/../vendor/bin/phpyacc'; } $options = array_flip($argv); $optionDebug = isset($options['--debug']); $optionKeepTmpGrammar = isset($options['--keep-tmp-grammar']); -/////////////////////////////// -/// Utility regex constants /// -/////////////////////////////// - -const LIB = '(?(DEFINE) - (?\'[^\\\\\']*+(?:\\\\.[^\\\\\']*+)*+\') - (?"[^\\\\"]*+(?:\\\\.[^\\\\"]*+)*+") - (?(?&singleQuotedString)|(?&doubleQuotedString)) - (?/\*[^*]*+(?:\*(?!/)[^*]*+)*+\*/) - (?\{[^\'"/{}]*+(?:(?:(?&string)|(?&comment)|(?&code)|/)[^\'"/{}]*+)*+}) -)'; - -const PARAMS = '\[(?[^[\]]*+(?:\[(?¶ms)\][^[\]]*+)*+)\]'; -const ARGS = '\((?[^()]*+(?:\((?&args)\)[^()]*+)*+)\)'; - /////////////////// /// Main script /// /////////////////// @@ -49,18 +36,14 @@ foreach ($grammarFileToName as $grammarFile => $name) { $grammarCode = file_get_contents($grammarFile); $grammarCode = str_replace('%tokens', $tokens, $grammarCode); - - $grammarCode = resolveNodes($grammarCode); - $grammarCode = resolveMacros($grammarCode); - $grammarCode = resolveStackAccess($grammarCode); + $grammarCode = preprocessGrammar($grammarCode); file_put_contents($tmpGrammarFile, $grammarCode); $additionalArgs = $optionDebug ? '-t -v' : ''; echo "Building $name parser.\n"; - $output = trim(shell_exec("$kmyacc $additionalArgs -l -m $skeletonFile -p $name $tmpGrammarFile 2>&1")); - echo "Output: \"$output\"\n"; + $output = execCmd("$kmyacc $additionalArgs -m $skeletonFile -p $name $tmpGrammarFile"); $resultCode = file_get_contents($tmpResultFile); $resultCode = removeTrailingWhitespace($resultCode); @@ -70,8 +53,7 @@ foreach ($grammarFileToName as $grammarFile => $name) { unlink($tmpResultFile); echo "Building token definition.\n"; - $output = trim(shell_exec("$kmyacc -l -m $tokensTemplate $tmpGrammarFile 2>&1")); - assert($output === ''); + $output = execCmd("$kmyacc -m $tokensTemplate $tmpGrammarFile"); rename($tmpResultFile, $tokensResultsFile); if (!$optionKeepTmpGrammar) { @@ -79,160 +61,9 @@ foreach ($grammarFileToName as $grammarFile => $name) { } } -/////////////////////////////// -/// Preprocessing functions /// -/////////////////////////////// - -function resolveNodes($code) { - return preg_replace_callback( - '~\b(?[A-Z][a-zA-Z_\\\\]++)\s*' . PARAMS . '~', - function($matches) { - // recurse - $matches['params'] = resolveNodes($matches['params']); - - $params = magicSplit( - '(?:' . PARAMS . '|' . ARGS . ')(*SKIP)(*FAIL)|,', - $matches['params'] - ); - - $paramCode = ''; - foreach ($params as $param) { - $paramCode .= $param . ', '; - } - - return 'new ' . $matches['name'] . '(' . $paramCode . 'attributes())'; - }, - $code - ); -} - -function resolveMacros($code) { - return preg_replace_callback( - '~\b(?)(?!array\()(?[a-z][A-Za-z]++)' . ARGS . '~', - function($matches) { - // recurse - $matches['args'] = resolveMacros($matches['args']); - - $name = $matches['name']; - $args = magicSplit( - '(?:' . PARAMS . '|' . ARGS . ')(*SKIP)(*FAIL)|,', - $matches['args'] - ); - - if ('attributes' == $name) { - assertArgs(0, $args, $name); - return '$this->startAttributeStack[#1] + $this->endAttributes'; - } - - if ('stackAttributes' == $name) { - assertArgs(1, $args, $name); - return '$this->startAttributeStack[' . $args[0] . ']' - . ' + $this->endAttributeStack[' . $args[0] . ']'; - } - - if ('init' == $name) { - return '$$ = array(' . implode(', ', $args) . ')'; - } - - if ('push' == $name) { - assertArgs(2, $args, $name); - - return $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0]; - } - - if ('pushNormalizing' == $name) { - assertArgs(2, $args, $name); - - return 'if (is_array(' . $args[1] . ')) { $$ = array_merge(' . $args[0] . ', ' . $args[1] . '); }' - . ' else { ' . $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0] . '; }'; - } - - if ('toArray' == $name) { - assertArgs(1, $args, $name); - - return 'is_array(' . $args[0] . ') ? ' . $args[0] . ' : array(' . $args[0] . ')'; - } - - if ('parseVar' == $name) { - assertArgs(1, $args, $name); - - return 'substr(' . $args[0] . ', 1)'; - } - - if ('parseEncapsed' == $name) { - assertArgs(3, $args, $name); - - return 'foreach (' . $args[0] . ' as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) {' - . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, ' . $args[1] . ', ' . $args[2] . '); } }'; - } - - if ('parseEncapsedDoc' == $name) { - assertArgs(2, $args, $name); - - return 'foreach (' . $args[0] . ' as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) {' - . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, null, ' . $args[1] . '); } }' - . ' $s->value = preg_replace(\'~(\r\n|\n|\r)\z~\', \'\', $s->value);' - . ' if (\'\' === $s->value) array_pop(' . $args[0] . ');'; - } - - if ('makeNop' == $name) { - assertArgs(2, $args, $name); - - return '$startAttributes = ' . $args[1] . ';' - . ' if (isset($startAttributes[\'comments\']))' - . ' { ' . $args[0] . ' = new Stmt\Nop([\'comments\' => $startAttributes[\'comments\']]); }' - . ' else { ' . $args[0] . ' = null; }'; - } - - if ('strKind' == $name) { - assertArgs(1, $args, $name); - - return '(' . $args[0] . '[0] === "\'" || (' . $args[0] . '[1] === "\'" && ' - . '(' . $args[0] . '[0] === \'b\' || ' . $args[0] . '[0] === \'B\')) ' - . '? Scalar\String_::KIND_SINGLE_QUOTED : Scalar\String_::KIND_DOUBLE_QUOTED)'; - } - - if ('setDocStringAttrs' == $name) { - assertArgs(2, $args, $name); - - return $args[0] . '[\'kind\'] = strpos(' . $args[1] . ', "\'") === false ' - . '? Scalar\String_::KIND_HEREDOC : Scalar\String_::KIND_NOWDOC; ' - . 'preg_match(\'/\A[bB]?<<<[ \t]*[\\\'"]?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[\\\'"]?(?:\r\n|\n|\r)\z/\', ' . $args[1] . ', $matches); ' - . $args[0] . '[\'docLabel\'] = $matches[1];'; - } - - if ('prependLeadingComments' == $name) { - assertArgs(1, $args, $name); - - return '$attrs = $this->startAttributeStack[#1]; $stmts = ' . $args[0] . '; ' - . 'if (!empty($attrs[\'comments\'])) {' - . '$stmts[0]->setAttribute(\'comments\', ' - . 'array_merge($attrs[\'comments\'], $stmts[0]->getAttribute(\'comments\', []))); }'; - } - - return $matches[0]; - }, - $code - ); -} - -function assertArgs($num, $args, $name) { - if ($num != count($args)) { - die('Wrong argument count for ' . $name . '().'); - } -} - -function resolveStackAccess($code) { - $code = preg_replace('/\$\d+/', '$this->semStack[$0]', $code); - $code = preg_replace('/#(\d+)/', '$$1', $code); - return $code; -} - -function removeTrailingWhitespace($code) { - $lines = explode("\n", $code); - $lines = array_map('rtrim', $lines); - return implode("\n", $lines); -} +//////////////////////////////// +/// Utility helper functions /// +//////////////////////////////// function ensureDirExists($dir) { if (!is_dir($dir)) { @@ -240,24 +71,11 @@ function ensureDirExists($dir) { } } -////////////////////////////// -/// Regex helper functions /// -////////////////////////////// - -function regex($regex) { - return '~' . LIB . '(?:' . str_replace('~', '\~', $regex) . ')~'; -} - -function magicSplit($regex, $string) { - $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string); - - foreach ($pieces as &$piece) { - $piece = trim($piece); +function execCmd($cmd) { + $output = trim(shell_exec("$cmd 2>&1")); + if ($output !== "") { + echo "> " . $cmd . "\n"; + echo $output; } - - if ($pieces === ['']) { - return []; - } - - return $pieces; + return $output; } diff --git a/lib/nikic/php-parser/grammar/tokens.y b/lib/nikic/php-parser/grammar/tokens.y index 2b54f80b4..8f0b21725 100644 --- a/lib/nikic/php-parser/grammar/tokens.y +++ b/lib/nikic/php-parser/grammar/tokens.y @@ -1,6 +1,7 @@ /* We currently rely on the token ID mapping to be the same between PHP 5 and PHP 7 - so the same lexer can be used for * both. This is enforced by sharing this token file. */ +%right T_THROW %left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE %left ',' %left T_LOGICAL_OR @@ -10,14 +11,14 @@ %right T_YIELD %right T_DOUBLE_ARROW %right T_YIELD_FROM -%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL T_POW_EQUAL +%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL T_POW_EQUAL T_COALESCE_EQUAL %left '?' ':' %right T_COALESCE %left T_BOOLEAN_OR %left T_BOOLEAN_AND %left '|' %left '^' -%left '&' +%left T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG %nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL T_SPACESHIP %nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL %left T_SL T_SR @@ -41,8 +42,6 @@ %token T_VARIABLE %token T_NUM_STRING %token T_INLINE_HTML -%token T_CHARACTER -%token T_BAD_CHARACTER %token T_ENCAPSED_AND_WHITESPACE %token T_CONSTANT_ENCAPSED_STRING %token T_ECHO @@ -57,6 +56,7 @@ %token T_ENDDECLARE %token T_AS %token T_SWITCH +%token T_MATCH %token T_ENDSWITCH %token T_CASE %token T_DEFAULT @@ -64,6 +64,7 @@ %token T_CONTINUE %token T_GOTO %token T_FUNCTION +%token T_FN %token T_CONST %token T_RETURN %token T_TRY @@ -73,7 +74,7 @@ %token T_USE %token T_INSTEADOF %token T_GLOBAL -%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC +%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC T_READONLY %token T_VAR %token T_UNSET %token T_ISSET @@ -82,9 +83,11 @@ %token T_CLASS %token T_TRAIT %token T_INTERFACE +%token T_ENUM %token T_EXTENDS %token T_IMPLEMENTS %token T_OBJECT_OPERATOR +%token T_NULLSAFE_OBJECT_OPERATOR %token T_DOUBLE_ARROW %token T_LIST %token T_ARRAY @@ -95,12 +98,6 @@ %token T_FUNC_C %token T_LINE %token T_FILE -%token T_COMMENT -%token T_DOC_COMMENT -%token T_OPEN_TAG -%token T_OPEN_TAG_WITH_ECHO -%token T_CLOSE_TAG -%token T_WHITESPACE %token T_START_HEREDOC %token T_END_HEREDOC %token T_DOLLAR_OPEN_CURLY_BRACES @@ -111,3 +108,8 @@ %token T_DIR %token T_NS_SEPARATOR %token T_ELLIPSIS +%token T_NAME_FULLY_QUALIFIED +%token T_NAME_QUALIFIED +%token T_NAME_RELATIVE +%token T_ATTRIBUTE +%token T_ENUM diff --git a/lib/nikic/php-parser/lib/PhpParser/Autoloader.php b/lib/nikic/php-parser/lib/PhpParser/Autoloader.php deleted file mode 100644 index 809a06ed8..000000000 --- a/lib/nikic/php-parser/lib/PhpParser/Autoloader.php +++ /dev/null @@ -1,40 +0,0 @@ -constants = [new Const_($name, BuilderHelpers::normalizeValue($value))]; + } + + /** + * Add another constant to const group + * + * @param string|Identifier $name Name + * @param Node\Expr|bool|null|int|float|string|array $value Value + * + * @return $this The builder instance (for fluid interface) + */ + public function addConst($name, $value) { + $this->constants[] = new Const_($name, BuilderHelpers::normalizeValue($value)); + + return $this; + } + + /** + * Makes the constant public. + * + * @return $this The builder instance (for fluid interface) + */ + public function makePublic() { + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PUBLIC); + + return $this; + } + + /** + * Makes the constant protected. + * + * @return $this The builder instance (for fluid interface) + */ + public function makeProtected() { + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PROTECTED); + + return $this; + } + + /** + * Makes the constant private. + * + * @return $this The builder instance (for fluid interface) + */ + public function makePrivate() { + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PRIVATE); + + return $this; + } + + /** + * Makes the constant final. + * + * @return $this The builder instance (for fluid interface) + */ + public function makeFinal() { + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_FINAL); + + return $this; + } + + /** + * Sets doc comment for the constant. + * + * @param PhpParser\Comment\Doc|string $docComment Doc comment to set + * + * @return $this The builder instance (for fluid interface) + */ + public function setDocComment($docComment) { + $this->attributes = [ + 'comments' => [BuilderHelpers::normalizeDocComment($docComment)] + ]; + + return $this; + } + + /** + * Adds an attribute group. + * + * @param Node\Attribute|Node\AttributeGroup $attribute + * + * @return $this The builder instance (for fluid interface) + */ + public function addAttribute($attribute) { + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); + + return $this; + } + + /** + * Returns the built class node. + * + * @return Stmt\ClassConst The built constant node + */ + public function getNode(): PhpParser\Node { + return new Stmt\ClassConst( + $this->constants, + $this->flags, + $this->attributes, + $this->attributeGroups + ); + } +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Builder/Class_.php b/lib/nikic/php-parser/lib/PhpParser/Builder/Class_.php index f91f6a847..87e2901a9 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Builder/Class_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Builder/Class_.php @@ -1,8 +1,10 @@ -name = $name; } @@ -36,7 +41,7 @@ class Class_ extends Declaration * @return $this The builder instance (for fluid interface) */ public function extend($class) { - $this->extends = $this->normalizeName($class); + $this->extends = BuilderHelpers::normalizeName($class); return $this; } @@ -48,9 +53,9 @@ class Class_ extends Declaration * * @return $this The builder instance (for fluid interface) */ - public function implement() { - foreach (func_get_args() as $interface) { - $this->implements[] = $this->normalizeName($interface); + public function implement(...$interfaces) { + foreach ($interfaces as $interface) { + $this->implements[] = BuilderHelpers::normalizeName($interface); } return $this; @@ -62,7 +67,7 @@ class Class_ extends Declaration * @return $this The builder instance (for fluid interface) */ public function makeAbstract() { - $this->setModifier(Stmt\Class_::MODIFIER_ABSTRACT); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_ABSTRACT); return $this; } @@ -73,7 +78,7 @@ class Class_ extends Declaration * @return $this The builder instance (for fluid interface) */ public function makeFinal() { - $this->setModifier(Stmt\Class_::MODIFIER_FINAL); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_FINAL); return $this; } @@ -86,21 +91,34 @@ class Class_ extends Declaration * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { - $stmt = $this->normalizeNode($stmt); + $stmt = BuilderHelpers::normalizeNode($stmt); - $targets = array( - 'Stmt_TraitUse' => &$this->uses, - 'Stmt_ClassConst' => &$this->constants, - 'Stmt_Property' => &$this->properties, - 'Stmt_ClassMethod' => &$this->methods, - ); + $targets = [ + Stmt\TraitUse::class => &$this->uses, + Stmt\ClassConst::class => &$this->constants, + Stmt\Property::class => &$this->properties, + Stmt\ClassMethod::class => &$this->methods, + ]; - $type = $stmt->getType(); - if (!isset($targets[$type])) { - throw new \LogicException(sprintf('Unexpected node of type "%s"', $type)); + $class = \get_class($stmt); + if (!isset($targets[$class])) { + throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); } - $targets[$type][] = $stmt; + $targets[$class][] = $stmt; + + return $this; + } + + /** + * Adds an attribute group. + * + * @param Node\Attribute|Node\AttributeGroup $attribute + * + * @return $this The builder instance (for fluid interface) + */ + public function addAttribute($attribute) { + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } @@ -110,12 +128,13 @@ class Class_ extends Declaration * * @return Stmt\Class_ The built class node */ - public function getNode() { - return new Stmt\Class_($this->name, array( + public function getNode() : PhpParser\Node { + return new Stmt\Class_($this->name, [ 'flags' => $this->flags, 'extends' => $this->extends, 'implements' => $this->implements, 'stmts' => array_merge($this->uses, $this->constants, $this->properties, $this->methods), - ), $this->attributes); + 'attrGroups' => $this->attributeGroups, + ], $this->attributes); } -} \ No newline at end of file +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Builder/Declaration.php b/lib/nikic/php-parser/lib/PhpParser/Builder/Declaration.php index 30a1937f9..830949928 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Builder/Declaration.php +++ b/lib/nikic/php-parser/lib/PhpParser/Builder/Declaration.php @@ -1,12 +1,13 @@ -attributes['comments'] = array( - $this->normalizeDocComment($docComment) - ); + $this->attributes['comments'] = [ + BuilderHelpers::normalizeDocComment($docComment) + ]; return $this; } -} \ No newline at end of file +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php b/lib/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php index 28a2ea618..8e7db399d 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php +++ b/lib/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php @@ -1,14 +1,14 @@ -normalizeNode($param); + $param = BuilderHelpers::normalizeNode($param); if (!$param instanceof Node\Param) { throw new \LogicException(sprintf('Expected parameter node, got "%s"', $param->getType())); @@ -61,14 +61,13 @@ abstract class FunctionLike extends Declaration /** * Sets the return type for PHP 7. * - * @param string|Node\Name|Node\NullableType $type One of array, callable, string, int, float, bool, iterable, - * or a class/interface name. + * @param string|Node\Name|Node\NullableType $type One of array, callable, string, int, float, + * bool, iterable, or a class/interface name. * * @return $this The builder instance (for fluid interface) */ - public function setReturnType($type) - { - $this->returnType = $this->normalizeType($type); + public function setReturnType($type) { + $this->returnType = BuilderHelpers::normalizeType($type); return $this; } diff --git a/lib/nikic/php-parser/lib/PhpParser/Builder/Function_.php b/lib/nikic/php-parser/lib/PhpParser/Builder/Function_.php index 228bdfaa2..1cd73c0d3 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Builder/Function_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Builder/Function_.php @@ -1,22 +1,26 @@ -name = $name; } @@ -28,7 +32,20 @@ class Function_ extends FunctionLike * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { - $this->stmts[] = $this->normalizeNode($stmt); + $this->stmts[] = BuilderHelpers::normalizeStmt($stmt); + + return $this; + } + + /** + * Adds an attribute group. + * + * @param Node\Attribute|Node\AttributeGroup $attribute + * + * @return $this The builder instance (for fluid interface) + */ + public function addAttribute($attribute) { + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } @@ -38,12 +55,13 @@ class Function_ extends FunctionLike * * @return Stmt\Function_ The built function node */ - public function getNode() { - return new Stmt\Function_($this->name, array( + public function getNode() : Node { + return new Stmt\Function_($this->name, [ 'byRef' => $this->returnByRef, 'params' => $this->params, 'returnType' => $this->returnType, 'stmts' => $this->stmts, - ), $this->attributes); + 'attrGroups' => $this->attributeGroups, + ], $this->attributes); } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Builder/Interface_.php b/lib/nikic/php-parser/lib/PhpParser/Builder/Interface_.php index 8ebb292a5..7806e85fc 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Builder/Interface_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Builder/Interface_.php @@ -1,24 +1,29 @@ -name = $name; } @@ -29,9 +34,9 @@ class Interface_ extends Declaration * * @return $this The builder instance (for fluid interface) */ - public function extend() { - foreach (func_get_args() as $interface) { - $this->extends[] = $this->normalizeName($interface); + public function extend(...$interfaces) { + foreach ($interfaces as $interface) { + $this->extends[] = BuilderHelpers::normalizeName($interface); } return $this; @@ -45,36 +50,44 @@ class Interface_ extends Declaration * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { - $stmt = $this->normalizeNode($stmt); + $stmt = BuilderHelpers::normalizeNode($stmt); - $type = $stmt->getType(); - switch ($type) { - case 'Stmt_ClassConst': - $this->constants[] = $stmt; - break; - - case 'Stmt_ClassMethod': - // we erase all statements in the body of an interface method - $stmt->stmts = null; - $this->methods[] = $stmt; - break; - - default: - throw new \LogicException(sprintf('Unexpected node of type "%s"', $type)); + if ($stmt instanceof Stmt\ClassConst) { + $this->constants[] = $stmt; + } elseif ($stmt instanceof Stmt\ClassMethod) { + // we erase all statements in the body of an interface method + $stmt->stmts = null; + $this->methods[] = $stmt; + } else { + throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); } return $this; } + /** + * Adds an attribute group. + * + * @param Node\Attribute|Node\AttributeGroup $attribute + * + * @return $this The builder instance (for fluid interface) + */ + public function addAttribute($attribute) { + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); + + return $this; + } + /** * Returns the built interface node. * * @return Stmt\Interface_ The built interface node */ - public function getNode() { - return new Stmt\Interface_($this->name, array( + public function getNode() : PhpParser\Node { + return new Stmt\Interface_($this->name, [ 'extends' => $this->extends, 'stmts' => array_merge($this->constants, $this->methods), - ), $this->attributes); + 'attrGroups' => $this->attributeGroups, + ], $this->attributes); } -} \ No newline at end of file +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Builder/Method.php b/lib/nikic/php-parser/lib/PhpParser/Builder/Method.php index 1ed75eeda..232d7cb87 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Builder/Method.php +++ b/lib/nikic/php-parser/lib/PhpParser/Builder/Method.php @@ -1,8 +1,9 @@ -name = $name; } @@ -29,7 +33,7 @@ class Method extends FunctionLike * @return $this The builder instance (for fluid interface) */ public function makePublic() { - $this->setModifier(Stmt\Class_::MODIFIER_PUBLIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PUBLIC); return $this; } @@ -40,7 +44,7 @@ class Method extends FunctionLike * @return $this The builder instance (for fluid interface) */ public function makeProtected() { - $this->setModifier(Stmt\Class_::MODIFIER_PROTECTED); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PROTECTED); return $this; } @@ -51,7 +55,7 @@ class Method extends FunctionLike * @return $this The builder instance (for fluid interface) */ public function makePrivate() { - $this->setModifier(Stmt\Class_::MODIFIER_PRIVATE); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PRIVATE); return $this; } @@ -62,7 +66,7 @@ class Method extends FunctionLike * @return $this The builder instance (for fluid interface) */ public function makeStatic() { - $this->setModifier(Stmt\Class_::MODIFIER_STATIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_STATIC); return $this; } @@ -77,7 +81,7 @@ class Method extends FunctionLike throw new \LogicException('Cannot make method with statements abstract'); } - $this->setModifier(Stmt\Class_::MODIFIER_ABSTRACT); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_ABSTRACT); $this->stmts = null; // abstract methods don't have statements return $this; @@ -89,7 +93,7 @@ class Method extends FunctionLike * @return $this The builder instance (for fluid interface) */ public function makeFinal() { - $this->setModifier(Stmt\Class_::MODIFIER_FINAL); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_FINAL); return $this; } @@ -106,7 +110,20 @@ class Method extends FunctionLike throw new \LogicException('Cannot add statements to an abstract method'); } - $this->stmts[] = $this->normalizeNode($stmt); + $this->stmts[] = BuilderHelpers::normalizeStmt($stmt); + + return $this; + } + + /** + * Adds an attribute group. + * + * @param Node\Attribute|Node\AttributeGroup $attribute + * + * @return $this The builder instance (for fluid interface) + */ + public function addAttribute($attribute) { + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } @@ -116,13 +133,14 @@ class Method extends FunctionLike * * @return Stmt\ClassMethod The built method node */ - public function getNode() { - return new Stmt\ClassMethod($this->name, array( + public function getNode() : Node { + return new Stmt\ClassMethod($this->name, [ 'flags' => $this->flags, 'byRef' => $this->returnByRef, 'params' => $this->params, 'returnType' => $this->returnType, 'stmts' => $this->stmts, - ), $this->attributes); + 'attrGroups' => $this->attributeGroups, + ], $this->attributes); } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php b/lib/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php index fe636c4ff..1c751e163 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php @@ -1,15 +1,16 @@ -name = null !== $name ? $this->normalizeName($name) : null; + $this->name = null !== $name ? BuilderHelpers::normalizeName($name) : null; } /** @@ -28,7 +29,7 @@ class Namespace_ extends Declaration * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { - $this->stmts[] = $this->normalizeNode($stmt); + $this->stmts[] = BuilderHelpers::normalizeStmt($stmt); return $this; } @@ -36,9 +37,9 @@ class Namespace_ extends Declaration /** * Returns the built node. * - * @return Node The built node + * @return Stmt\Namespace_ The built node */ - public function getNode() { + public function getNode() : Node { return new Stmt\Namespace_($this->name, $this->stmts, $this->attributes); } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Builder/Param.php b/lib/nikic/php-parser/lib/PhpParser/Builder/Param.php index c029e748b..0ea91683c 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Builder/Param.php +++ b/lib/nikic/php-parser/lib/PhpParser/Builder/Param.php @@ -1,29 +1,33 @@ -name = $name; } @@ -35,27 +39,40 @@ class Param extends PhpParser\BuilderAbstract * @return $this The builder instance (for fluid interface) */ public function setDefault($value) { - $this->default = $this->normalizeValue($value); + $this->default = BuilderHelpers::normalizeValue($value); return $this; } /** - * Sets type hint for the parameter. + * Sets type for the parameter. * - * @param string|Node\Name|Node\NullableType $type Type hint to use + * @param string|Node\Name|Node\NullableType|Node\UnionType $type Parameter type * * @return $this The builder instance (for fluid interface) */ - public function setTypeHint($type) { - $this->type = $this->normalizeType($type); - if ($this->type === 'void') { + public function setType($type) { + $this->type = BuilderHelpers::normalizeType($type); + if ($this->type == 'void') { throw new \LogicException('Parameter type cannot be void'); } return $this; } + /** + * Sets type for the parameter. + * + * @param string|Node\Name|Node\NullableType|Node\UnionType $type Parameter type + * + * @return $this The builder instance (for fluid interface) + * + * @deprecated Use setType() instead + */ + public function setTypeHint($type) { + return $this->setType($type); + } + /** * Make the parameter accept the value by reference. * @@ -78,14 +95,28 @@ class Param extends PhpParser\BuilderAbstract return $this; } + /** + * Adds an attribute group. + * + * @param Node\Attribute|Node\AttributeGroup $attribute + * + * @return $this The builder instance (for fluid interface) + */ + public function addAttribute($attribute) { + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); + + return $this; + } + /** * Returns the built parameter node. * * @return Node\Param The built parameter node */ - public function getNode() { + public function getNode() : Node { return new Node\Param( - $this->name, $this->default, $this->type, $this->byRef, $this->variadic + new Node\Expr\Variable($this->name), + $this->default, $this->type, $this->byRef, $this->variadic, [], 0, $this->attributeGroups ); } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Builder/Property.php b/lib/nikic/php-parser/lib/PhpParser/Builder/Property.php index 053c851b9..90ee4b0ba 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Builder/Property.php +++ b/lib/nikic/php-parser/lib/PhpParser/Builder/Property.php @@ -1,24 +1,35 @@ -name = $name; } @@ -28,7 +39,7 @@ class Property extends PhpParser\BuilderAbstract * @return $this The builder instance (for fluid interface) */ public function makePublic() { - $this->setModifier(Stmt\Class_::MODIFIER_PUBLIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PUBLIC); return $this; } @@ -39,7 +50,7 @@ class Property extends PhpParser\BuilderAbstract * @return $this The builder instance (for fluid interface) */ public function makeProtected() { - $this->setModifier(Stmt\Class_::MODIFIER_PROTECTED); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PROTECTED); return $this; } @@ -50,7 +61,7 @@ class Property extends PhpParser\BuilderAbstract * @return $this The builder instance (for fluid interface) */ public function makePrivate() { - $this->setModifier(Stmt\Class_::MODIFIER_PRIVATE); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PRIVATE); return $this; } @@ -61,7 +72,18 @@ class Property extends PhpParser\BuilderAbstract * @return $this The builder instance (for fluid interface) */ public function makeStatic() { - $this->setModifier(Stmt\Class_::MODIFIER_STATIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_STATIC); + + return $this; + } + + /** + * Makes the property readonly. + * + * @return $this The builder instance (for fluid interface) + */ + public function makeReadonly() { + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_READONLY); return $this; } @@ -74,7 +96,7 @@ class Property extends PhpParser\BuilderAbstract * @return $this The builder instance (for fluid interface) */ public function setDefault($value) { - $this->default = $this->normalizeValue($value); + $this->default = BuilderHelpers::normalizeValue($value); return $this; } @@ -87,9 +109,35 @@ class Property extends PhpParser\BuilderAbstract * @return $this The builder instance (for fluid interface) */ public function setDocComment($docComment) { - $this->attributes = array( - 'comments' => array($this->normalizeDocComment($docComment)) - ); + $this->attributes = [ + 'comments' => [BuilderHelpers::normalizeDocComment($docComment)] + ]; + + return $this; + } + + /** + * Sets the property type for PHP 7.4+. + * + * @param string|Name|NullableType|Identifier $type + * + * @return $this + */ + public function setType($type) { + $this->type = BuilderHelpers::normalizeType($type); + + return $this; + } + + /** + * Adds an attribute group. + * + * @param Node\Attribute|Node\AttributeGroup $attribute + * + * @return $this The builder instance (for fluid interface) + */ + public function addAttribute($attribute) { + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } @@ -99,13 +147,15 @@ class Property extends PhpParser\BuilderAbstract * * @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( + [ new Stmt\PropertyProperty($this->name, $this->default) - ), - $this->attributes + ], + $this->attributes, + $this->type, + $this->attributeGroups ); } -} \ No newline at end of file +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Builder/Trait_.php b/lib/nikic/php-parser/lib/PhpParser/Builder/Trait_.php index 7b004fa96..97f32f98d 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Builder/Trait_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Builder/Trait_.php @@ -1,23 +1,28 @@ -name = $name; } @@ -29,13 +34,13 @@ class Trait_ extends Declaration * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { - $stmt = $this->normalizeNode($stmt); + $stmt = BuilderHelpers::normalizeNode($stmt); if ($stmt instanceof Stmt\Property) { $this->properties[] = $stmt; - } else if ($stmt instanceof Stmt\ClassMethod) { + } elseif ($stmt instanceof Stmt\ClassMethod) { $this->methods[] = $stmt; - } else if ($stmt instanceof Stmt\TraitUse) { + } elseif ($stmt instanceof Stmt\TraitUse) { $this->uses[] = $stmt; } else { throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); @@ -44,16 +49,30 @@ class Trait_ extends Declaration return $this; } + /** + * Adds an attribute group. + * + * @param Node\Attribute|Node\AttributeGroup $attribute + * + * @return $this The builder instance (for fluid interface) + */ + public function addAttribute($attribute) { + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); + + return $this; + } + /** * Returns the built trait node. * * @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->uses, $this->properties, $this->methods) - ), $this->attributes + $this->name, [ + 'stmts' => array_merge($this->uses, $this->properties, $this->methods), + 'attrGroups' => $this->attributeGroups, + ], $this->attributes ); } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Builder/Use_.php b/lib/nikic/php-parser/lib/PhpParser/Builder/Use_.php index f6d3a856f..4bd3d12df 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Builder/Use_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Builder/Use_.php @@ -1,15 +1,14 @@ -name = $this->normalizeName($name); + public function __construct($name, int $type) { + $this->name = BuilderHelpers::normalizeName($name); $this->type = $type; } @@ -32,27 +31,19 @@ class Use_ extends BuilderAbstract { * * @return $this The builder instance (for fluid interface) */ - protected function as_($alias) { + public function as(string $alias) { $this->alias = $alias; return $this; } - public function __call($name, $args) { - if (method_exists($this, $name . '_')) { - return call_user_func_array(array($this, $name . '_'), $args); - } - - throw new \LogicException(sprintf('Method "%s" does not exist', $name)); - } /** * Returns the built node. * - * @return Node The built node + * @return Stmt\Use_ The built node */ - public function getNode() { - $alias = null !== $this->alias ? $this->alias : $this->name->getLast(); - return new Stmt\Use_(array( - new Stmt\UseUse($this->name, $alias) - ), $this->type); + public function getNode() : Node { + return new Stmt\Use_([ + new Stmt\UseUse($this->name, $this->alias) + ], $this->type); } } diff --git a/lib/nikic/php-parser/lib/PhpParser/BuilderAbstract.php b/lib/nikic/php-parser/lib/PhpParser/BuilderAbstract.php deleted file mode 100644 index e353963e6..000000000 --- a/lib/nikic/php-parser/lib/PhpParser/BuilderAbstract.php +++ /dev/null @@ -1,175 +0,0 @@ -getNode(); - } elseif ($node instanceof Node) { - return $node; - } - - throw new \LogicException('Expected node or builder object'); - } - - /** - * Normalizes a name: Converts plain string names to PhpParser\Node\Name. - * - * @param Name|string $name The name to normalize - * - * @return Name The normalized name - */ - protected function normalizeName($name) { - if ($name instanceof Name) { - return $name; - } elseif (is_string($name)) { - if (!$name) { - throw new \LogicException('Name cannot be empty'); - } - - if ($name[0] == '\\') { - return new Name\FullyQualified(substr($name, 1)); - } elseif (0 === strpos($name, 'namespace\\')) { - return new Name\Relative(substr($name, strlen('namespace\\'))); - } else { - return new Name($name); - } - } - - throw new \LogicException('Name must be a string or an instance of PhpParser\Node\Name'); - } - - /** - * Normalizes a type: Converts plain-text type names into proper AST representation. - * - * In particular, builtin types are left as strings, custom types become Names and nullables - * are wrapped in NullableType nodes. - * - * @param Name|string|NullableType $type The type to normalize - * - * @return Name|string|NullableType The normalized type - */ - protected function normalizeType($type) { - if (!is_string($type)) { - if (!$type instanceof Name && !$type instanceof NullableType) { - throw new \LogicException( - 'Type must be a string, or an instance of Name or NullableType'); - } - return $type; - } - - $nullable = false; - if (strlen($type) > 0 && $type[0] === '?') { - $nullable = true; - $type = substr($type, 1); - } - - $builtinTypes = array( - 'array', 'callable', 'string', 'int', 'float', 'bool', 'iterable', 'void', 'object' - ); - - $lowerType = strtolower($type); - if (in_array($lowerType, $builtinTypes)) { - $type = $lowerType; - } else { - $type = $this->normalizeName($type); - } - - if ($nullable && $type === 'void') { - throw new \LogicException('void type cannot be nullable'); - } - - return $nullable ? new Node\NullableType($type) : $type; - } - - /** - * Normalizes a value: Converts nulls, booleans, integers, - * floats, strings and arrays into their respective nodes - * - * @param mixed $value The value to normalize - * - * @return Expr The normalized value - */ - protected function normalizeValue($value) { - if ($value instanceof Node) { - return $value; - } elseif (is_null($value)) { - return new Expr\ConstFetch( - new Name('null') - ); - } elseif (is_bool($value)) { - return new Expr\ConstFetch( - new Name($value ? 'true' : 'false') - ); - } elseif (is_int($value)) { - return new Scalar\LNumber($value); - } elseif (is_float($value)) { - return new Scalar\DNumber($value); - } elseif (is_string($value)) { - return new Scalar\String_($value); - } elseif (is_array($value)) { - $items = array(); - $lastKey = -1; - foreach ($value as $itemKey => $itemValue) { - // for consecutive, numeric keys don't generate keys - if (null !== $lastKey && ++$lastKey === $itemKey) { - $items[] = new Expr\ArrayItem( - $this->normalizeValue($itemValue) - ); - } else { - $lastKey = null; - $items[] = new Expr\ArrayItem( - $this->normalizeValue($itemValue), - $this->normalizeValue($itemKey) - ); - } - } - - return new Expr\Array_($items); - } else { - throw new \LogicException('Invalid value'); - } - } - - /** - * Normalizes a doc comment: Converts plain strings to PhpParser\Comment\Doc. - * - * @param Comment\Doc|string $docComment The doc comment to normalize - * - * @return Comment\Doc The normalized doc comment - */ - protected function normalizeDocComment($docComment) { - if ($docComment instanceof Comment\Doc) { - return $docComment; - } else if (is_string($docComment)) { - return new Comment\Doc($docComment); - } else { - throw new \LogicException('Doc comment must be a string or an instance of PhpParser\Comment\Doc'); - } - } - - /** - * Sets a modifier in the $this->type property. - * - * @param int $modifier Modifier to set - */ - protected function setModifier($modifier) { - Stmt\Class_::verifyModifier($this->flags, $modifier); - $this->flags |= $modifier; - } -} diff --git a/lib/nikic/php-parser/lib/PhpParser/BuilderFactory.php b/lib/nikic/php-parser/lib/PhpParser/BuilderFactory.php index 42c7f612c..6a6b7b07b 100644 --- a/lib/nikic/php-parser/lib/PhpParser/BuilderFactory.php +++ b/lib/nikic/php-parser/lib/PhpParser/BuilderFactory.php @@ -1,23 +1,32 @@ -args($args) + ); + } + /** * Creates a namespace builder. * @@ -25,7 +34,7 @@ class BuilderFactory * * @return Builder\Namespace_ The created namespace builder */ - protected function _namespace($name) { + public function namespace($name) : Builder\Namespace_ { return new Builder\Namespace_($name); } @@ -36,7 +45,7 @@ class BuilderFactory * * @return Builder\Class_ The created class builder */ - protected function _class($name) { + public function class(string $name) : Builder\Class_ { return new Builder\Class_($name); } @@ -47,7 +56,7 @@ class BuilderFactory * * @return Builder\Interface_ The created interface builder */ - protected function _interface($name) { + public function interface(string $name) : Builder\Interface_ { return new Builder\Interface_($name); } @@ -58,10 +67,38 @@ class BuilderFactory * * @return Builder\Trait_ The created trait builder */ - protected function _trait($name) { + public function trait(string $name) : Builder\Trait_ { return new Builder\Trait_($name); } + /** + * Creates a trait use builder. + * + * @param Node\Name|string ...$traits Trait names + * + * @return Builder\TraitUse The create trait use builder + */ + public function useTrait(...$traits) : Builder\TraitUse { + return new Builder\TraitUse(...$traits); + } + + /** + * Creates a trait use adaptation builder. + * + * @param Node\Name|string|null $trait Trait name + * @param Node\Identifier|string $method Method name + * + * @return Builder\TraitUseAdaptation The create trait use adaptation builder + */ + public function traitUseAdaptation($trait, $method = null) : Builder\TraitUseAdaptation { + if ($method === null) { + $method = $trait; + $trait = null; + } + + return new Builder\TraitUseAdaptation($trait, $method); + } + /** * Creates a method builder. * @@ -69,7 +106,7 @@ class BuilderFactory * * @return Builder\Method The created method builder */ - public function method($name) { + public function method(string $name) : Builder\Method { return new Builder\Method($name); } @@ -80,7 +117,7 @@ class BuilderFactory * * @return Builder\Param The created parameter builder */ - public function param($name) { + public function param(string $name) : Builder\Param { return new Builder\Param($name); } @@ -91,7 +128,7 @@ class BuilderFactory * * @return Builder\Property The created property builder */ - public function property($name) { + public function property(string $name) : Builder\Property { return new Builder\Property($name); } @@ -102,26 +139,239 @@ class BuilderFactory * * @return Builder\Function_ The created function builder */ - protected function _function($name) { + public function function(string $name) : Builder\Function_ { return new Builder\Function_($name); } /** * Creates a namespace/class use builder. * - * @param string|Node\Name Name to alias + * @param Node\Name|string $name Name of the entity (namespace or class) to alias * - * @return Builder\Use_ The create use builder + * @return Builder\Use_ The created use builder */ - protected function _use($name) { + public function use($name) : Builder\Use_ { return new Builder\Use_($name, Use_::TYPE_NORMAL); } - public function __call($name, array $args) { - if (method_exists($this, '_' . $name)) { - return call_user_func_array(array($this, '_' . $name), $args); + /** + * Creates a function use builder. + * + * @param Node\Name|string $name Name of the function to alias + * + * @return Builder\Use_ The created use function builder + */ + public function useFunction($name) : Builder\Use_ { + return new Builder\Use_($name, Use_::TYPE_FUNCTION); + } + + /** + * Creates a constant use builder. + * + * @param Node\Name|string $name Name of the const to alias + * + * @return Builder\Use_ The created use const builder + */ + public function useConst($name) : Builder\Use_ { + return new Builder\Use_($name, Use_::TYPE_CONSTANT); + } + + /** + * Creates a class constant builder. + * + * @param string|Identifier $name Name + * @param Node\Expr|bool|null|int|float|string|array $value Value + * + * @return Builder\ClassConst The created use const builder + */ + public function classConst($name, $value) : Builder\ClassConst { + return new Builder\ClassConst($name, $value); + } + + /** + * Creates node a for a literal value. + * + * @param Expr|bool|null|int|float|string|array $value $value + * + * @return Expr + */ + public function val($value) : Expr { + return BuilderHelpers::normalizeValue($value); + } + + /** + * Creates variable node. + * + * @param string|Expr $name Name + * + * @return Expr\Variable + */ + public function var($name) : Expr\Variable { + if (!\is_string($name) && !$name instanceof Expr) { + throw new \LogicException('Variable name must be string or Expr'); } - throw new \LogicException(sprintf('Method "%s" does not exist', $name)); + return new Expr\Variable($name); + } + + /** + * Normalizes an argument list. + * + * Creates Arg nodes for all arguments and converts literal values to expressions. + * + * @param array $args List of arguments to normalize + * + * @return Arg[] + */ + public function args(array $args) : array { + $normalizedArgs = []; + foreach ($args as $key => $arg) { + if (!($arg instanceof Arg)) { + $arg = new Arg(BuilderHelpers::normalizeValue($arg)); + } + if (\is_string($key)) { + $arg->name = BuilderHelpers::normalizeIdentifier($key); + } + $normalizedArgs[] = $arg; + } + return $normalizedArgs; + } + + /** + * Creates a function call node. + * + * @param string|Name|Expr $name Function name + * @param array $args Function arguments + * + * @return Expr\FuncCall + */ + public function funcCall($name, array $args = []) : Expr\FuncCall { + return new Expr\FuncCall( + BuilderHelpers::normalizeNameOrExpr($name), + $this->args($args) + ); + } + + /** + * Creates a method call node. + * + * @param Expr $var Variable the method is called on + * @param string|Identifier|Expr $name Method name + * @param array $args Method arguments + * + * @return Expr\MethodCall + */ + public function methodCall(Expr $var, $name, array $args = []) : Expr\MethodCall { + return new Expr\MethodCall( + $var, + BuilderHelpers::normalizeIdentifierOrExpr($name), + $this->args($args) + ); + } + + /** + * Creates a static method call node. + * + * @param string|Name|Expr $class Class name + * @param string|Identifier|Expr $name Method name + * @param array $args Method arguments + * + * @return Expr\StaticCall + */ + public function staticCall($class, $name, array $args = []) : Expr\StaticCall { + return new Expr\StaticCall( + BuilderHelpers::normalizeNameOrExpr($class), + BuilderHelpers::normalizeIdentifierOrExpr($name), + $this->args($args) + ); + } + + /** + * Creates an object creation node. + * + * @param string|Name|Expr $class Class name + * @param array $args Constructor arguments + * + * @return Expr\New_ + */ + public function new($class, array $args = []) : Expr\New_ { + return new Expr\New_( + BuilderHelpers::normalizeNameOrExpr($class), + $this->args($args) + ); + } + + /** + * Creates a constant fetch node. + * + * @param string|Name $name Constant name + * + * @return Expr\ConstFetch + */ + public function constFetch($name) : Expr\ConstFetch { + return new Expr\ConstFetch(BuilderHelpers::normalizeName($name)); + } + + /** + * Creates a property fetch node. + * + * @param Expr $var Variable holding object + * @param string|Identifier|Expr $name Property name + * + * @return Expr\PropertyFetch + */ + public function propertyFetch(Expr $var, $name) : Expr\PropertyFetch { + return new Expr\PropertyFetch($var, BuilderHelpers::normalizeIdentifierOrExpr($name)); + } + + /** + * Creates a class constant fetch node. + * + * @param string|Name|Expr $class Class name + * @param string|Identifier $name Constant name + * + * @return Expr\ClassConstFetch + */ + public function classConstFetch($class, $name): Expr\ClassConstFetch { + return new Expr\ClassConstFetch( + BuilderHelpers::normalizeNameOrExpr($class), + BuilderHelpers::normalizeIdentifier($name) + ); + } + + /** + * Creates nested Concat nodes from a list of expressions. + * + * @param Expr|string ...$exprs Expressions or literal strings + * + * @return Concat + */ + public function concat(...$exprs) : Concat { + $numExprs = count($exprs); + if ($numExprs < 2) { + throw new \LogicException('Expected at least two expressions'); + } + + $lastConcat = $this->normalizeStringExpr($exprs[0]); + for ($i = 1; $i < $numExprs; $i++) { + $lastConcat = new Concat($lastConcat, $this->normalizeStringExpr($exprs[$i])); + } + return $lastConcat; + } + + /** + * @param string|Expr $expr + * @return Expr + */ + private function normalizeStringExpr($expr) : Expr { + if ($expr instanceof Expr) { + return $expr; + } + + if (\is_string($expr)) { + return new String_($expr); + } + + throw new \LogicException('Expected string or Expr'); } } diff --git a/lib/nikic/php-parser/lib/PhpParser/BuilderHelpers.php b/lib/nikic/php-parser/lib/PhpParser/BuilderHelpers.php index 180bf35d0..c6d8f1613 100644 --- a/lib/nikic/php-parser/lib/PhpParser/BuilderHelpers.php +++ b/lib/nikic/php-parser/lib/PhpParser/BuilderHelpers.php @@ -27,7 +27,9 @@ final class BuilderHelpers public static function normalizeNode($node) : Node { if ($node instanceof Builder) { return $node->getNode(); - } elseif ($node instanceof Node) { + } + + if ($node instanceof Node) { return $node; } @@ -127,18 +129,22 @@ final class BuilderHelpers private static function normalizeNameCommon($name, bool $allowExpr) { if ($name instanceof Name) { return $name; - } elseif (is_string($name)) { + } + + if (is_string($name)) { if (!$name) { throw new \LogicException('Name cannot be empty'); } if ($name[0] === '\\') { return new Name\FullyQualified(substr($name, 1)); - } elseif (0 === strpos($name, 'namespace\\')) { - return new Name\Relative(substr($name, strlen('namespace\\'))); - } else { - return new Name($name); } + + if (0 === strpos($name, 'namespace\\')) { + return new Name\Relative(substr($name, strlen('namespace\\'))); + } + + return new Name($name); } if ($allowExpr) { @@ -148,9 +154,9 @@ final class BuilderHelpers throw new \LogicException( 'Name must be a string or an instance of Node\Name or Node\Expr' ); - } else { - throw new \LogicException('Name must be a string or an instance of Node\Name'); } + + throw new \LogicException('Name must be a string or an instance of Node\Name'); } /** @@ -183,7 +189,7 @@ final class BuilderHelpers } $builtinTypes = [ - 'array', 'callable', 'string', 'int', 'float', 'bool', 'iterable', 'void', 'object', 'mixed' + 'array', 'callable', 'string', 'int', 'float', 'bool', 'iterable', 'void', 'object', 'mixed', 'never', ]; $lowerType = strtolower($type); @@ -193,12 +199,11 @@ final class BuilderHelpers $type = self::normalizeName($type); } - if ($nullable && (string) $type === 'void') { - throw new \LogicException('void type cannot be nullable'); - } - - if ($nullable && (string) $type === 'mixed') { - throw new \LogicException('mixed type cannot be nullable'); + $notNullableTypes = [ + 'void', 'mixed', 'never', + ]; + if ($nullable && in_array((string) $type, $notNullableTypes)) { + throw new \LogicException(sprintf('%s type cannot be nullable', $type)); } return $nullable ? new NullableType($type) : $type; @@ -215,21 +220,33 @@ final class BuilderHelpers public static function normalizeValue($value) : Expr { if ($value instanceof Node\Expr) { return $value; - } elseif (is_null($value)) { + } + + if (is_null($value)) { return new Expr\ConstFetch( new Name('null') ); - } elseif (is_bool($value)) { + } + + if (is_bool($value)) { return new Expr\ConstFetch( new Name($value ? 'true' : 'false') ); - } elseif (is_int($value)) { + } + + if (is_int($value)) { return new Scalar\LNumber($value); - } elseif (is_float($value)) { + } + + if (is_float($value)) { return new Scalar\DNumber($value); - } elseif (is_string($value)) { + } + + if (is_string($value)) { return new Scalar\String_($value); - } elseif (is_array($value)) { + } + + if (is_array($value)) { $items = []; $lastKey = -1; foreach ($value as $itemKey => $itemValue) { @@ -248,9 +265,9 @@ final class BuilderHelpers } return new Expr\Array_($items); - } else { - throw new \LogicException('Invalid value'); } + + throw new \LogicException('Invalid value'); } /** @@ -263,11 +280,33 @@ final class BuilderHelpers public static function normalizeDocComment($docComment) : Comment\Doc { if ($docComment instanceof Comment\Doc) { return $docComment; - } elseif (is_string($docComment)) { - return new Comment\Doc($docComment); - } else { - throw new \LogicException('Doc comment must be a string or an instance of PhpParser\Comment\Doc'); } + + if (is_string($docComment)) { + return new Comment\Doc($docComment); + } + + throw new \LogicException('Doc comment must be a string or an instance of PhpParser\Comment\Doc'); + } + + /** + * Normalizes a attribute: Converts attribute to the Attribute Group if needed. + * + * @param Node\Attribute|Node\AttributeGroup $attribute + * + * @return Node\AttributeGroup The Attribute Group + */ + public static function normalizeAttribute($attribute) : Node\AttributeGroup + { + if ($attribute instanceof Node\AttributeGroup) { + return $attribute; + } + + if (!($attribute instanceof Node\Attribute)) { + throw new \LogicException('Attribute must be an instance of PhpParser\Node\Attribute or PhpParser\Node\AttributeGroup'); + } + + return new Node\AttributeGroup([$attribute]); } /** diff --git a/lib/nikic/php-parser/lib/PhpParser/Comment.php b/lib/nikic/php-parser/lib/PhpParser/Comment.php index 4034cfa6b..61e98d3dc 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Comment.php +++ b/lib/nikic/php-parser/lib/PhpParser/Comment.php @@ -1,24 +1,37 @@ -text = $text; - $this->line = $startLine; - $this->filePos = $startFilePos; + $this->startLine = $startLine; + $this->startFilePos = $startFilePos; + $this->startTokenPos = $startTokenPos; + $this->endLine = $endLine; + $this->endFilePos = $endFilePos; + $this->endTokenPos = $endTokenPos; } /** @@ -26,26 +39,95 @@ class Comment implements \JsonSerializable * * @return string The comment text (including comment delimiters like /*) */ - public function getText() { + public function getText() : string { return $this->text; } /** * Gets the line number the comment started on. * - * @return int Line number + * @return int Line number (or -1 if not available) */ - public function getLine() { - return $this->line; + public function getStartLine() : int { + return $this->startLine; } /** * Gets the file offset the comment started on. * + * @return int File offset (or -1 if not available) + */ + public function getStartFilePos() : int { + return $this->startFilePos; + } + + /** + * Gets the token offset the comment started on. + * + * @return int Token offset (or -1 if not available) + */ + public function getStartTokenPos() : int { + return $this->startTokenPos; + } + + /** + * Gets the line number the comment ends on. + * + * @return int Line number (or -1 if not available) + */ + public function getEndLine() : int { + return $this->endLine; + } + + /** + * Gets the file offset the comment ends on. + * + * @return int File offset (or -1 if not available) + */ + public function getEndFilePos() : int { + return $this->endFilePos; + } + + /** + * Gets the token offset the comment ends on. + * + * @return int Token offset (or -1 if not available) + */ + public function getEndTokenPos() : int { + return $this->endTokenPos; + } + + /** + * Gets the line number the comment started on. + * + * @deprecated Use getStartLine() instead + * + * @return int Line number + */ + public function getLine() : int { + return $this->startLine; + } + + /** + * Gets the file offset the comment started on. + * + * @deprecated Use getStartFilePos() instead + * * @return int File offset */ - public function getFilePos() { - return $this->filePos; + public function getFilePos() : int { + return $this->startFilePos; + } + + /** + * Gets the token offset the comment started on. + * + * @deprecated Use getStartTokenPos() instead + * + * @return int Token offset + */ + public function getTokenPos() : int { + return $this->startTokenPos; } /** @@ -53,7 +135,7 @@ class Comment implements \JsonSerializable * * @return string The comment text (including comment delimiters like /*) */ - public function __toString() { + public function __toString() : string { return $this->text; } @@ -114,9 +196,17 @@ class Comment implements \JsonSerializable return $text; } - private function getShortestWhitespacePrefixLen($str) { + /** + * Get length of shortest whitespace prefix (at the start of a line). + * + * If there is a line with no prefix whitespace, 0 is a valid return value. + * + * @param string $str String to check + * @return int Length in characters. Tabs count as single characters. + */ + private function getShortestWhitespacePrefixLen(string $str) : int { $lines = explode("\n", $str); - $shortestPrefixLen = INF; + $shortestPrefixLen = \INF; foreach ($lines as $line) { preg_match('(^\s*)', $line, $matches); $prefixLen = strlen($matches[0]); @@ -127,14 +217,23 @@ class Comment implements \JsonSerializable return $shortestPrefixLen; } - public function jsonSerialize() { + /** + * @return array + * @psalm-return array{nodeType:string, text:mixed, line:mixed, filePos:mixed} + */ + 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 [ 'nodeType' => $type, 'text' => $this->text, - 'line' => $this->line, - 'filePos' => $this->filePos, + // TODO: Rename these to include "start". + 'line' => $this->startLine, + 'filePos' => $this->startFilePos, + 'tokenPos' => $this->startTokenPos, + 'endLine' => $this->endLine, + 'endFilePos' => $this->endFilePos, + 'endTokenPos' => $this->endTokenPos, ]; } -} \ No newline at end of file +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Comment/Doc.php b/lib/nikic/php-parser/lib/PhpParser/Comment/Doc.php index 24fc6c9ec..a9db6128f 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Comment/Doc.php +++ b/lib/nikic/php-parser/lib/PhpParser/Comment/Doc.php @@ -1,7 +1,7 @@ -rawMessage = (string) $message; + public function __construct(string $message, $attributes = []) { + $this->rawMessage = $message; if (is_array($attributes)) { $this->attributes = $attributes; } else { - $this->attributes = array('startLine' => $attributes); + $this->attributes = ['startLine' => $attributes]; } $this->updateMessage(); } @@ -29,7 +29,7 @@ class Error extends \RuntimeException * * @return string Error message */ - public function getRawMessage() { + public function getRawMessage() : string { return $this->rawMessage; } @@ -38,8 +38,8 @@ class Error extends \RuntimeException * * @return int Error start line */ - public function getStartLine() { - return isset($this->attributes['startLine']) ? $this->attributes['startLine'] : -1; + public function getStartLine() : int { + return $this->attributes['startLine'] ?? -1; } /** @@ -47,22 +47,21 @@ class Error extends \RuntimeException * * @return int Error end line */ - public function getEndLine() { - return isset($this->attributes['endLine']) ? $this->attributes['endLine'] : -1; + public function getEndLine() : int { + return $this->attributes['endLine'] ?? -1; } - /** * Gets the attributes of the node/token the error occurred at. * * @return array */ - public function getAttributes() { + public function getAttributes() : array { return $this->attributes; } /** - * Sets the attributes of the node/token the error occured at. + * Sets the attributes of the node/token the error occurred at. * * @param array $attributes */ @@ -76,8 +75,8 @@ class Error extends \RuntimeException * * @param string $message Error message */ - public function setRawMessage($message) { - $this->rawMessage = (string) $message; + public function setRawMessage(string $message) { + $this->rawMessage = $message; $this->updateMessage(); } @@ -86,8 +85,8 @@ class Error extends \RuntimeException * * @param int $line Error start line */ - public function setStartLine($line) { - $this->attributes['startLine'] = (int) $line; + public function setStartLine(int $line) { + $this->attributes['startLine'] = $line; $this->updateMessage(); } @@ -98,8 +97,8 @@ class Error extends \RuntimeException * * @return bool */ - public function hasColumnInfo() { - return isset($this->attributes['startFilePos']) && isset($this->attributes['endFilePos']); + public function hasColumnInfo() : bool { + return isset($this->attributes['startFilePos'], $this->attributes['endFilePos']); } /** @@ -108,7 +107,7 @@ class Error extends \RuntimeException * @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 +121,7 @@ class Error extends \RuntimeException * @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'); } @@ -130,7 +129,14 @@ class Error extends \RuntimeException return $this->toColumn($code, $this->attributes['endFilePos']); } - public function getMessageWithColumnInfo($code) { + /** + * Formats message including line and column information. + * + * @param string $code Source code associated with the error, for calculation of the columns + * + * @return string Formatted message + */ + public function getMessageWithColumnInfo(string $code) : string { return sprintf( '%s from %d:%d to %d:%d', $this->getRawMessage(), $this->getStartLine(), $this->getStartColumn($code), @@ -138,7 +144,15 @@ class Error extends \RuntimeException ); } - private function toColumn($code, $pos) { + /** + * Converts a file offset into a column. + * + * @param string $code Source code that $pos indexes into + * @param int $pos 0-based position in $code + * + * @return int 1-based column (relative to start of line) + */ + private function toColumn(string $code, int $pos) : int { if ($pos > strlen($code)) { throw new \RuntimeException('Invalid position information'); } diff --git a/lib/nikic/php-parser/lib/PhpParser/ErrorHandler.php b/lib/nikic/php-parser/lib/PhpParser/ErrorHandler.php index fa2c2f8ce..d620e7453 100644 --- a/lib/nikic/php-parser/lib/PhpParser/ErrorHandler.php +++ b/lib/nikic/php-parser/lib/PhpParser/ErrorHandler.php @@ -1,4 +1,4 @@ -errors; } @@ -33,7 +33,7 @@ class Collecting implements ErrorHandler * * @return bool */ - public function hasErrors() { + public function hasErrors() : bool { return !empty($this->errors); } @@ -43,4 +43,4 @@ class Collecting implements ErrorHandler public function clearErrors() { $this->errors = []; } -} \ No newline at end of file +} diff --git a/lib/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php b/lib/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php index c5a76dd0c..aeee989b1 100644 --- a/lib/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php +++ b/lib/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php @@ -1,4 +1,4 @@ -defineCompatibilityTokens(); $this->tokenMap = $this->createTokenMap(); + $this->identifierTokens = $this->createIdentifierTokenMap(); // map of tokens to drop while lexing (the map is only used for isset lookup, // that's why the value is simply set to 1; the value is never actually used.) $this->dropTokens = array_fill_keys( - array(T_WHITESPACE, T_OPEN_TAG, T_COMMENT, T_DOC_COMMENT), 1 + [\T_WHITESPACE, \T_OPEN_TAG, \T_COMMENT, \T_DOC_COMMENT, \T_BAD_CHARACTER], 1 ); - // the usedAttributes member is a map of the used attribute names to a dummy - // value (here "true") - $options += array( - 'usedAttributes' => array('comments', 'startLine', 'endLine'), - ); - $this->usedAttributes = array_fill_keys($options['usedAttributes'], true); + $defaultAttributes = ['comments', 'startLine', 'endLine']; + $usedAttributes = array_fill_keys($options['usedAttributes'] ?? $defaultAttributes, true); + + // Create individual boolean properties to make these checks faster. + $this->attributeStartLineUsed = isset($usedAttributes['startLine']); + $this->attributeEndLineUsed = isset($usedAttributes['endLine']); + $this->attributeStartTokenPosUsed = isset($usedAttributes['startTokenPos']); + $this->attributeEndTokenPosUsed = isset($usedAttributes['endTokenPos']); + $this->attributeStartFilePosUsed = isset($usedAttributes['startFilePos']); + $this->attributeEndFilePosUsed = isset($usedAttributes['endFilePos']); + $this->attributeCommentsUsed = isset($usedAttributes['comments']); } /** @@ -55,7 +69,7 @@ class Lexer * @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(); } @@ -71,34 +85,18 @@ class Lexer $scream = ini_set('xdebug.scream', '0'); - $this->resetErrors(); $this->tokens = @token_get_all($code); - $this->handleErrors($errorHandler); + $this->postprocessTokens($errorHandler); if (false !== $scream) { ini_set('xdebug.scream', $scream); } } - protected function resetErrors() { - if (function_exists('error_clear_last')) { - error_clear_last(); - } else { - // set error_get_last() to defined state by forcing an undefined variable error - set_error_handler(function() { return false; }, 0); - @$undefinedVariable; - restore_error_handler(); - } - } - private function handleInvalidCharacterRange($start, $end, $line, ErrorHandler $errorHandler) { + $tokens = []; for ($i = $start; $i < $end; $i++) { $chr = $this->code[$i]; - if ($chr === 'b' || $chr === 'B') { - // HHVM does not treat b" tokens correctly, so ignore these - continue; - } - if ($chr === "\0") { // PHP cuts error message after null byte, so need special case $errorMsg = 'Unexpected null byte'; @@ -108,6 +106,7 @@ class Lexer ); } + $tokens[] = [\T_BAD_CHARACTER, $chr, $line]; $errorHandler->handleError(new Error($errorMsg, [ 'startLine' => $line, 'endLine' => $line, @@ -115,48 +114,130 @@ class Lexer 'endFilePos' => $i, ])); } + return $tokens; } - private function isUnterminatedComment($token) { - return ($token[0] === T_COMMENT || $token[0] === T_DOC_COMMENT) + /** + * Check whether comment token is unterminated. + * + * @return bool + */ + private function isUnterminatedComment($token) : bool { + return ($token[0] === \T_COMMENT || $token[0] === \T_DOC_COMMENT) && substr($token[1], 0, 2) === '/*' && substr($token[1], -2) !== '*/'; } - private function errorMayHaveOccurred() { - if (defined('HHVM_VERSION')) { - // In HHVM token_get_all() does not throw warnings, so we need to conservatively - // assume that an error occurred - return true; - } - - $error = error_get_last(); - return null !== $error - && false === strpos($error['message'], 'Undefined variable'); - } - - protected function handleErrors(ErrorHandler $errorHandler) { - if (!$this->errorMayHaveOccurred()) { - return; - } - + protected function postprocessTokens(ErrorHandler $errorHandler) { // PHP's error handling for token_get_all() is rather bad, so if we want detailed // error information we need to compute it ourselves. Invalid character errors are // detected by finding "gaps" in the token array. Unterminated comments are detected // by checking if a trailing comment has a "*/" at the end. + // + // Additionally, we perform a number of canonicalizations here: + // * Use the PHP 8.0 comment format, which does not include trailing whitespace anymore. + // * Use PHP 8.0 T_NAME_* tokens. + // * Use PHP 8.1 T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG and + // T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG tokens used to disambiguate intersection types. $filePos = 0; $line = 1; - foreach ($this->tokens as $i => $token) { + $numTokens = \count($this->tokens); + for ($i = 0; $i < $numTokens; $i++) { + $token = $this->tokens[$i]; + + // Since PHP 7.4 invalid characters are represented by a T_BAD_CHARACTER token. + // In this case we only need to emit an error. + if ($token[0] === \T_BAD_CHARACTER) { + $this->handleInvalidCharacterRange($filePos, $filePos + 1, $line, $errorHandler); + } + + if ($token[0] === \T_COMMENT && substr($token[1], 0, 2) !== '/*' + && preg_match('/(\r\n|\n|\r)$/D', $token[1], $matches)) { + $trailingNewline = $matches[0]; + $token[1] = substr($token[1], 0, -strlen($trailingNewline)); + $this->tokens[$i] = $token; + if (isset($this->tokens[$i + 1]) && $this->tokens[$i + 1][0] === \T_WHITESPACE) { + // Move trailing newline into following T_WHITESPACE token, if it already exists. + $this->tokens[$i + 1][1] = $trailingNewline . $this->tokens[$i + 1][1]; + $this->tokens[$i + 1][2]--; + } else { + // Otherwise, we need to create a new T_WHITESPACE token. + array_splice($this->tokens, $i + 1, 0, [ + [\T_WHITESPACE, $trailingNewline, $line], + ]); + $numTokens++; + } + } + + // Emulate PHP 8 T_NAME_* tokens, by combining sequences of T_NS_SEPARATOR and T_STRING + // into a single token. + if (\is_array($token) + && ($token[0] === \T_NS_SEPARATOR || isset($this->identifierTokens[$token[0]]))) { + $lastWasSeparator = $token[0] === \T_NS_SEPARATOR; + $text = $token[1]; + for ($j = $i + 1; isset($this->tokens[$j]); $j++) { + if ($lastWasSeparator) { + if (!isset($this->identifierTokens[$this->tokens[$j][0]])) { + break; + } + $lastWasSeparator = false; + } else { + if ($this->tokens[$j][0] !== \T_NS_SEPARATOR) { + break; + } + $lastWasSeparator = true; + } + $text .= $this->tokens[$j][1]; + } + if ($lastWasSeparator) { + // Trailing separator is not part of the name. + $j--; + $text = substr($text, 0, -1); + } + if ($j > $i + 1) { + if ($token[0] === \T_NS_SEPARATOR) { + $type = \T_NAME_FULLY_QUALIFIED; + } else if ($token[0] === \T_NAMESPACE) { + $type = \T_NAME_RELATIVE; + } else { + $type = \T_NAME_QUALIFIED; + } + $token = [$type, $text, $line]; + array_splice($this->tokens, $i, $j - $i, [$token]); + $numTokens -= $j - $i - 1; + } + } + + if ($token === '&') { + $next = $i + 1; + while (isset($this->tokens[$next]) && $this->tokens[$next][0] === \T_WHITESPACE) { + $next++; + } + $followedByVarOrVarArg = isset($this->tokens[$next]) && + ($this->tokens[$next][0] === \T_VARIABLE || $this->tokens[$next][0] === \T_ELLIPSIS); + $this->tokens[$i] = $token = [ + $followedByVarOrVarArg + ? \T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG + : \T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG, + '&', + $line, + ]; + } + $tokenValue = \is_string($token) ? $token : $token[1]; $tokenLen = \strlen($tokenValue); if (substr($this->code, $filePos, $tokenLen) !== $tokenValue) { // Something is missing, must be an invalid character $nextFilePos = strpos($this->code, $tokenValue, $filePos); - $this->handleInvalidCharacterRange( + $badCharTokens = $this->handleInvalidCharacterRange( $filePos, $nextFilePos, $line, $errorHandler); - $filePos = $nextFilePos; + $filePos = (int) $nextFilePos; + + array_splice($this->tokens, $i, 0, $badCharTokens); + $numTokens += \count($badCharTokens); + $i += \count($badCharTokens); } $filePos += $tokenLen; @@ -176,11 +257,12 @@ class Lexer // Emulate the PHP behavior $isDocComment = isset($comment[3]) && $comment[3] === '*'; - $this->tokens[] = [$isDocComment ? T_DOC_COMMENT : T_COMMENT, $comment, $line]; + $this->tokens[] = [$isDocComment ? \T_DOC_COMMENT : \T_COMMENT, $comment, $line]; } else { // Invalid characters at the end of the input - $this->handleInvalidCharacterRange( + $badCharTokens = $this->handleInvalidCharacterRange( $filePos, \strlen($this->code), $line, $errorHandler); + $this->tokens = array_merge($this->tokens, $badCharTokens); } return; } @@ -221,9 +303,9 @@ class Lexer * * @return int Token id */ - public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) { - $startAttributes = array(); - $endAttributes = array(); + public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) : int { + $startAttributes = []; + $endAttributes = []; while (1) { if (isset($this->tokens[++$this->pos])) { @@ -233,13 +315,13 @@ class Lexer $token = "\0"; } - if (isset($this->usedAttributes['startLine'])) { + if ($this->attributeStartLineUsed) { $startAttributes['startLine'] = $this->line; } - if (isset($this->usedAttributes['startTokenPos'])) { + if ($this->attributeStartTokenPosUsed) { $startAttributes['startTokenPos'] = $this->pos; } - if (isset($this->usedAttributes['startFilePos'])) { + if ($this->attributeStartFilePosUsed) { $startAttributes['startFilePos'] = $this->filePos; } @@ -256,36 +338,43 @@ class Lexer } elseif (!isset($this->dropTokens[$token[0]])) { $value = $token[1]; $id = $this->tokenMap[$token[0]]; - if (T_CLOSE_TAG === $token[0]) { - $this->prevCloseTagHasNewline = false !== strpos($token[1], "\n"); - } else if (T_INLINE_HTML === $token[0]) { + if (\T_CLOSE_TAG === $token[0]) { + $this->prevCloseTagHasNewline = false !== strpos($token[1], "\n") + || false !== strpos($token[1], "\r"); + } elseif (\T_INLINE_HTML === $token[0]) { $startAttributes['hasLeadingNewline'] = $this->prevCloseTagHasNewline; } $this->line += substr_count($value, "\n"); $this->filePos += \strlen($value); } else { - if (T_COMMENT === $token[0] || T_DOC_COMMENT === $token[0]) { - if (isset($this->usedAttributes['comments'])) { - $comment = T_DOC_COMMENT === $token[0] - ? new Comment\Doc($token[1], $this->line, $this->filePos) - : new Comment($token[1], $this->line, $this->filePos); + $origLine = $this->line; + $origFilePos = $this->filePos; + $this->line += substr_count($token[1], "\n"); + $this->filePos += \strlen($token[1]); + + if (\T_COMMENT === $token[0] || \T_DOC_COMMENT === $token[0]) { + if ($this->attributeCommentsUsed) { + $comment = \T_DOC_COMMENT === $token[0] + ? new Comment\Doc($token[1], + $origLine, $origFilePos, $this->pos, + $this->line, $this->filePos - 1, $this->pos) + : new Comment($token[1], + $origLine, $origFilePos, $this->pos, + $this->line, $this->filePos - 1, $this->pos); $startAttributes['comments'][] = $comment; } } - - $this->line += substr_count($token[1], "\n"); - $this->filePos += \strlen($token[1]); continue; } - if (isset($this->usedAttributes['endLine'])) { + if ($this->attributeEndLineUsed) { $endAttributes['endLine'] = $this->line; } - if (isset($this->usedAttributes['endTokenPos'])) { + if ($this->attributeEndTokenPosUsed) { $endAttributes['endTokenPos'] = $this->pos; } - if (isset($this->usedAttributes['endFilePos'])) { + if ($this->attributeEndFilePosUsed) { $endAttributes['endFilePos'] = $this->filePos - 1; } @@ -305,7 +394,7 @@ class Lexer * * @return array Array of tokens in token_get_all() format */ - public function getTokens() { + public function getTokens() : array { return $this->tokens; } @@ -314,7 +403,7 @@ class Lexer * * @return string Remaining text */ - public function handleHaltCompiler() { + public function handleHaltCompiler() : string { // text after T_HALT_COMPILER, still including (); $textAfter = substr($this->code, $this->filePos); @@ -329,7 +418,67 @@ class Lexer $this->pos = count($this->tokens); // return with (); removed - return (string) substr($textAfter, strlen($matches[0])); // (string) converts false to '' + return substr($textAfter, strlen($matches[0])); + } + + private function defineCompatibilityTokens() { + static $compatTokensDefined = false; + if ($compatTokensDefined) { + return; + } + + $compatTokens = [ + // PHP 7.4 + 'T_BAD_CHARACTER', + 'T_FN', + 'T_COALESCE_EQUAL', + // PHP 8.0 + 'T_NAME_QUALIFIED', + 'T_NAME_FULLY_QUALIFIED', + 'T_NAME_RELATIVE', + 'T_MATCH', + 'T_NULLSAFE_OBJECT_OPERATOR', + 'T_ATTRIBUTE', + // PHP 8.1 + 'T_ENUM', + 'T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG', + 'T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG', + 'T_READONLY', + ]; + + // PHP-Parser might be used together with another library that also emulates some or all + // of these tokens. Perform a sanity-check that all already defined tokens have been + // assigned a unique ID. + $usedTokenIds = []; + foreach ($compatTokens as $token) { + if (\defined($token)) { + $tokenId = \constant($token); + $clashingToken = $usedTokenIds[$tokenId] ?? null; + if ($clashingToken !== null) { + throw new \Error(sprintf( + 'Token %s has same ID as token %s, ' . + 'you may be using a library with broken token emulation', + $token, $clashingToken + )); + } + $usedTokenIds[$tokenId] = $token; + } + } + + // Now define any tokens that have not yet been emulated. Try to assign IDs from -1 + // downwards, but skip any IDs that may already be in use. + $newTokenId = -1; + foreach ($compatTokens as $token) { + if (!\defined($token)) { + while (isset($usedTokenIds[$newTokenId])) { + $newTokenId--; + } + \define($token, $newTokenId); + $newTokenId--; + } + } + + $compatTokensDefined = true; } /** @@ -341,26 +490,26 @@ class Lexer * * @return array The token map */ - protected function createTokenMap() { - $tokenMap = array(); + protected function createTokenMap() : array { + $tokenMap = []; // 256 is the minimum possible token number, as everything below // it is an ASCII value for ($i = 256; $i < 1000; ++$i) { - if (T_DOUBLE_COLON === $i) { + if (\T_DOUBLE_COLON === $i) { // T_DOUBLE_COLON is equivalent to T_PAAMAYIM_NEKUDOTAYIM $tokenMap[$i] = Tokens::T_PAAMAYIM_NEKUDOTAYIM; - } elseif(T_OPEN_TAG_WITH_ECHO === $i) { + } elseif(\T_OPEN_TAG_WITH_ECHO === $i) { // T_OPEN_TAG_WITH_ECHO with dropped T_OPEN_TAG results in T_ECHO $tokenMap[$i] = Tokens::T_ECHO; - } elseif(T_CLOSE_TAG === $i) { + } elseif(\T_CLOSE_TAG === $i) { // T_CLOSE_TAG is equivalent to ';' $tokenMap[$i] = ord(';'); } elseif ('UNKNOWN' !== $name = token_name($i)) { if ('T_HASHBANG' === $name) { // HHVM uses a special token for #! hashbang lines $tokenMap[$i] = Tokens::T_INLINE_HTML; - } else if (defined($name = Tokens::class . '::' . $name)) { + } elseif (defined($name = Tokens::class . '::' . $name)) { // Other tokens can be mapped directly $tokenMap[$i] = constant($name); } @@ -369,13 +518,43 @@ class Lexer // HHVM uses a special token for numbers that overflow to double if (defined('T_ONUMBER')) { - $tokenMap[T_ONUMBER] = Tokens::T_DNUMBER; + $tokenMap[\T_ONUMBER] = Tokens::T_DNUMBER; } // HHVM also has a separate token for the __COMPILER_HALT_OFFSET__ constant if (defined('T_COMPILER_HALT_OFFSET')) { - $tokenMap[T_COMPILER_HALT_OFFSET] = Tokens::T_STRING; + $tokenMap[\T_COMPILER_HALT_OFFSET] = Tokens::T_STRING; } + // Assign tokens for which we define compatibility constants, as token_name() does not know them. + $tokenMap[\T_FN] = Tokens::T_FN; + $tokenMap[\T_COALESCE_EQUAL] = Tokens::T_COALESCE_EQUAL; + $tokenMap[\T_NAME_QUALIFIED] = Tokens::T_NAME_QUALIFIED; + $tokenMap[\T_NAME_FULLY_QUALIFIED] = Tokens::T_NAME_FULLY_QUALIFIED; + $tokenMap[\T_NAME_RELATIVE] = Tokens::T_NAME_RELATIVE; + $tokenMap[\T_MATCH] = Tokens::T_MATCH; + $tokenMap[\T_NULLSAFE_OBJECT_OPERATOR] = Tokens::T_NULLSAFE_OBJECT_OPERATOR; + $tokenMap[\T_ATTRIBUTE] = Tokens::T_ATTRIBUTE; + $tokenMap[\T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG] = Tokens::T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG; + $tokenMap[\T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG] = Tokens::T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG; + $tokenMap[\T_ENUM] = Tokens::T_ENUM; + $tokenMap[\T_READONLY] = Tokens::T_READONLY; + return $tokenMap; } + + private function createIdentifierTokenMap(): array { + // Based on semi_reserved production. + return array_fill_keys([ + \T_STRING, + \T_STATIC, \T_ABSTRACT, \T_FINAL, \T_PRIVATE, \T_PROTECTED, \T_PUBLIC, \T_READONLY, + \T_INCLUDE, \T_INCLUDE_ONCE, \T_EVAL, \T_REQUIRE, \T_REQUIRE_ONCE, \T_LOGICAL_OR, \T_LOGICAL_XOR, \T_LOGICAL_AND, + \T_INSTANCEOF, \T_NEW, \T_CLONE, \T_EXIT, \T_IF, \T_ELSEIF, \T_ELSE, \T_ENDIF, \T_ECHO, \T_DO, \T_WHILE, + \T_ENDWHILE, \T_FOR, \T_ENDFOR, \T_FOREACH, \T_ENDFOREACH, \T_DECLARE, \T_ENDDECLARE, \T_AS, \T_TRY, \T_CATCH, + \T_FINALLY, \T_THROW, \T_USE, \T_INSTEADOF, \T_GLOBAL, \T_VAR, \T_UNSET, \T_ISSET, \T_EMPTY, \T_CONTINUE, \T_GOTO, + \T_FUNCTION, \T_CONST, \T_RETURN, \T_PRINT, \T_YIELD, \T_LIST, \T_SWITCH, \T_ENDSWITCH, \T_CASE, \T_DEFAULT, + \T_BREAK, \T_ARRAY, \T_CALLABLE, \T_EXTENDS, \T_IMPLEMENTS, \T_NAMESPACE, \T_TRAIT, \T_INTERFACE, \T_CLASS, + \T_CLASS_C, \T_TRAIT_C, \T_FUNC_C, \T_METHOD_C, \T_LINE, \T_FILE, \T_DIR, \T_NS_C, \T_HALT_COMPILER, \T_FN, + \T_MATCH, + ], true); + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php b/lib/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php index 739a328ab..a8f4e334a 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php +++ b/lib/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php @@ -1,174 +1,246 @@ -targetPhpVersion = $options['phpVersion'] ?? Emulative::PHP_8_1; + unset($options['phpVersion']); - public function __construct(array $options = array()) { parent::__construct($options); - $newKeywordsPerVersion = array( - // No new keywords since PHP 5.5 - ); + $emulators = [ + new FlexibleDocStringEmulator(), + new FnTokenEmulator(), + new MatchTokenEmulator(), + new CoaleseEqualTokenEmulator(), + new NumericLiteralSeparatorEmulator(), + new NullsafeTokenEmulator(), + new AttributeEmulator(), + new EnumTokenEmulator(), + new ReadonlyTokenEmulator(), + ]; - $this->newKeywords = array(); - foreach ($newKeywordsPerVersion as $version => $newKeywords) { - if (version_compare(PHP_VERSION, $version, '>=')) { - break; + // Collect emulators that are relevant for the PHP version we're running + // and the PHP version we're targeting for emulation. + foreach ($emulators as $emulator) { + $emulatorPhpVersion = $emulator->getPhpVersion(); + if ($this->isForwardEmulationNeeded($emulatorPhpVersion)) { + $this->emulators[] = $emulator; + } else if ($this->isReverseEmulationNeeded($emulatorPhpVersion)) { + $this->emulators[] = new ReverseEmulator($emulator); } - - $this->newKeywords += $newKeywords; } + } - if (version_compare(PHP_VERSION, self::PHP_7_0, '>=')) { + public function startLexing(string $code, ErrorHandler $errorHandler = null) { + $emulators = array_filter($this->emulators, function($emulator) use($code) { + return $emulator->isEmulationNeeded($code); + }); + + if (empty($emulators)) { + // Nothing to emulate, yay + parent::startLexing($code, $errorHandler); return; } - $this->tokenMap[self::T_COALESCE] = Tokens::T_COALESCE; - $this->tokenMap[self::T_SPACESHIP] = Tokens::T_SPACESHIP; - $this->tokenMap[self::T_YIELD_FROM] = Tokens::T_YIELD_FROM; - if (version_compare(PHP_VERSION, self::PHP_5_6, '>=')) { + $this->patches = []; + foreach ($emulators as $emulator) { + $code = $emulator->preprocessCode($code, $this->patches); + } + + $collector = new ErrorHandler\Collecting(); + parent::startLexing($code, $collector); + $this->sortPatches(); + $this->fixupTokens(); + + $errors = $collector->getErrors(); + if (!empty($errors)) { + $this->fixupErrors($errors); + foreach ($errors as $error) { + $errorHandler->handleError($error); + } + } + + foreach ($emulators as $emulator) { + $this->tokens = $emulator->emulate($code, $this->tokens); + } + } + + private function isForwardEmulationNeeded(string $emulatorPhpVersion): bool { + return version_compare(\PHP_VERSION, $emulatorPhpVersion, '<') + && version_compare($this->targetPhpVersion, $emulatorPhpVersion, '>='); + } + + private function isReverseEmulationNeeded(string $emulatorPhpVersion): bool { + return version_compare(\PHP_VERSION, $emulatorPhpVersion, '>=') + && version_compare($this->targetPhpVersion, $emulatorPhpVersion, '<'); + } + + private function sortPatches() + { + // Patches may be contributed by different emulators. + // Make sure they are sorted by increasing patch position. + usort($this->patches, function($p1, $p2) { + return $p1[0] <=> $p2[0]; + }); + } + + private function fixupTokens() + { + if (\count($this->patches) === 0) { return; } - $this->tokenMap[self::T_ELLIPSIS] = Tokens::T_ELLIPSIS; - $this->tokenMap[self::T_POW] = Tokens::T_POW; - $this->tokenMap[self::T_POW_EQUAL] = Tokens::T_POW_EQUAL; - } - public function startLexing($code, ErrorHandler $errorHandler = null) { - $this->inObjectAccess = false; + // Load first patch + $patchIdx = 0; - parent::startLexing($code, $errorHandler); - if ($this->requiresEmulation($code)) { - $this->emulateTokens(); + list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx]; + + // We use a manual loop over the tokens, because we modify the array on the fly + $pos = 0; + for ($i = 0, $c = \count($this->tokens); $i < $c; $i++) { + $token = $this->tokens[$i]; + if (\is_string($token)) { + if ($patchPos === $pos) { + // Only support replacement for string tokens. + assert($patchType === 'replace'); + $this->tokens[$i] = $patchText; + + // Fetch the next patch + $patchIdx++; + if ($patchIdx >= \count($this->patches)) { + // No more patches, we're done + return; + } + list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx]; + } + + $pos += \strlen($token); + continue; + } + + $len = \strlen($token[1]); + $posDelta = 0; + while ($patchPos >= $pos && $patchPos < $pos + $len) { + $patchTextLen = \strlen($patchText); + if ($patchType === 'remove') { + if ($patchPos === $pos && $patchTextLen === $len) { + // Remove token entirely + array_splice($this->tokens, $i, 1, []); + $i--; + $c--; + } else { + // Remove from token string + $this->tokens[$i][1] = substr_replace( + $token[1], '', $patchPos - $pos + $posDelta, $patchTextLen + ); + $posDelta -= $patchTextLen; + } + } elseif ($patchType === 'add') { + // Insert into the token string + $this->tokens[$i][1] = substr_replace( + $token[1], $patchText, $patchPos - $pos + $posDelta, 0 + ); + $posDelta += $patchTextLen; + } else if ($patchType === 'replace') { + // Replace inside the token string + $this->tokens[$i][1] = substr_replace( + $token[1], $patchText, $patchPos - $pos + $posDelta, $patchTextLen + ); + } else { + assert(false); + } + + // Fetch the next patch + $patchIdx++; + if ($patchIdx >= \count($this->patches)) { + // No more patches, we're done + return; + } + + list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx]; + + // Multiple patches may apply to the same token. Reload the current one to check + // If the new patch applies + $token = $this->tokens[$i]; + } + + $pos += $len; } + + // A patch did not apply + assert(false); } - /* - * Checks if the code is potentially using features that require emulation. + /** + * Fixup line and position information in errors. + * + * @param Error[] $errors */ - protected function requiresEmulation($code) { - if (version_compare(PHP_VERSION, self::PHP_7_0, '>=')) { - return false; - } + private function fixupErrors(array $errors) { + foreach ($errors as $error) { + $attrs = $error->getAttributes(); - if (preg_match('(\?\?|<=>|yield[ \n\r\t]+from)', $code)) { - return true; - } - - if (version_compare(PHP_VERSION, self::PHP_5_6, '>=')) { - return false; - } - - return preg_match('(\.\.\.|(?tokens); $i < $c; ++$i) { - $replace = null; - if (isset($this->tokens[$i + 1])) { - if ($this->tokens[$i] === '?' && $this->tokens[$i + 1] === '?') { - array_splice($this->tokens, $i, 2, array( - array(self::T_COALESCE, '??', $line) - )); - $c--; - continue; + $posDelta = 0; + $lineDelta = 0; + foreach ($this->patches as $patch) { + list($patchPos, $patchType, $patchText) = $patch; + if ($patchPos >= $attrs['startFilePos']) { + // No longer relevant + break; } - if ($this->tokens[$i][0] === T_IS_SMALLER_OR_EQUAL - && $this->tokens[$i + 1] === '>' - ) { - array_splice($this->tokens, $i, 2, array( - array(self::T_SPACESHIP, '<=>', $line) - )); - $c--; - continue; - } - if ($this->tokens[$i] === '*' && $this->tokens[$i + 1] === '*') { - array_splice($this->tokens, $i, 2, array( - array(self::T_POW, '**', $line) - )); - $c--; - continue; - } - if ($this->tokens[$i] === '*' && $this->tokens[$i + 1][0] === T_MUL_EQUAL) { - array_splice($this->tokens, $i, 2, array( - array(self::T_POW_EQUAL, '**=', $line) - )); - $c--; - continue; + + if ($patchType === 'add') { + $posDelta += strlen($patchText); + $lineDelta += substr_count($patchText, "\n"); + } else if ($patchType === 'remove') { + $posDelta -= strlen($patchText); + $lineDelta -= substr_count($patchText, "\n"); } } - if (isset($this->tokens[$i + 2])) { - if ($this->tokens[$i][0] === T_YIELD && $this->tokens[$i + 1][0] === T_WHITESPACE - && $this->tokens[$i + 2][0] === T_STRING - && !strcasecmp($this->tokens[$i + 2][1], 'from') - ) { - array_splice($this->tokens, $i, 3, array( - array( - self::T_YIELD_FROM, - $this->tokens[$i][1] . $this->tokens[$i + 1][1] . $this->tokens[$i + 2][1], - $line - ) - )); - $c -= 2; - $line += substr_count($this->tokens[$i][1], "\n"); - continue; - } - if ($this->tokens[$i] === '.' && $this->tokens[$i + 1] === '.' - && $this->tokens[$i + 2] === '.' - ) { - array_splice($this->tokens, $i, 3, array( - array(self::T_ELLIPSIS, '...', $line) - )); - $c -= 2; - continue; - } - } - - if (\is_array($this->tokens[$i])) { - $line += substr_count($this->tokens[$i][1], "\n"); - } + $attrs['startFilePos'] += $posDelta; + $attrs['endFilePos'] += $posDelta; + $attrs['startLine'] += $lineDelta; + $attrs['endLine'] += $lineDelta; + $error->setAttributes($attrs); } } - - public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) { - $token = parent::getNextToken($value, $startAttributes, $endAttributes); - - // replace new keywords by their respective tokens. This is not done - // if we currently are in an object access (e.g. in $obj->namespace - // "namespace" stays a T_STRING tokens and isn't converted to T_NAMESPACE) - if (Tokens::T_STRING === $token && !$this->inObjectAccess) { - if (isset($this->newKeywords[strtolower($value)])) { - return $this->newKeywords[strtolower($value)]; - } - } else { - // keep track of whether we currently are in an object access (after ->) - $this->inObjectAccess = Tokens::T_OBJECT_OPERATOR === $token; - } - - return $token; - } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php b/lib/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php new file mode 100644 index 000000000..4ddc0b17e --- /dev/null +++ b/lib/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php @@ -0,0 +1,31 @@ +getKeywordString()) !== false; } + protected function isKeywordContext(array $tokens, int $pos): bool + { + $previousNonSpaceToken = $this->getPreviousNonSpaceToken($tokens, $pos); + return $previousNonSpaceToken === null || $previousNonSpaceToken[0] !== \T_OBJECT_OPERATOR; + } + public function emulate(string $code, array $tokens): array { $keywordString = $this->getKeywordString(); foreach ($tokens as $i => $token) { - if ($token[0] === T_STRING && strtolower($token[1]) === $keywordString) { - $previousNonSpaceToken = $this->getPreviousNonSpaceToken($tokens, $i); - if ($previousNonSpaceToken !== null && $previousNonSpaceToken[0] === \T_OBJECT_OPERATOR) { - continue; - } - + if ($token[0] === T_STRING && strtolower($token[1]) === $keywordString + && $this->isKeywordContext($tokens, $i)) { $tokens[$i][0] = $this->getKeywordToken(); } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php b/lib/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php new file mode 100644 index 000000000..b97f8d112 --- /dev/null +++ b/lib/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php @@ -0,0 +1,23 @@ +attributes = $attributes; + $this->name = $name; $this->value = $value; $this->byRef = $byRef; $this->unpack = $unpack; } - public function getSubNodeNames() { - return array('value', 'byRef', 'unpack'); + public function getSubNodeNames() : array { + return ['name', 'value', 'byRef', 'unpack']; + } + + public function getType() : string { + return 'Arg'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Const_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Const_.php index 26322d49e..789a42655 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Const_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Const_.php @@ -1,12 +1,15 @@ -name = $name; + public function __construct($name, Expr $value, array $attributes = []) { + $this->attributes = $attributes; + $this->name = \is_string($name) ? new Identifier($name) : $name; $this->value = $value; } - public function getSubNodeNames() { - return array('name', 'value'); + public function getSubNodeNames() : array { + return ['name', 'value']; + } + + public function getType() : string { + return 'Const'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr.php index 2dae5bfcd..6cf4df223 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->var = $var; $this->dim = $dim; } - public function getSubNodeNames() { - return array('var', 'dim'); + public function getSubNodeNames() : array { + return ['var', 'dim']; + } + + public function getType() : string { + return 'Expr_ArrayDimFetch'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php index de73ef467..1b078f821 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->key = $key; $this->value = $value; $this->byRef = $byRef; + $this->unpack = $unpack; } - public function getSubNodeNames() { - return array('key', 'value', 'byRef'); + public function getSubNodeNames() : array { + return ['key', 'value', 'byRef', 'unpack']; + } + + public function getType() : string { + return 'Expr_ArrayItem'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php index 9151f27d8..e6eaa2834 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->items = $items; } - public function getSubNodeNames() { - return array('items'); + public function getSubNodeNames() : array { + return ['items']; + } + + public function getType() : string { + return 'Expr_Array'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php index 1f280ff0c..cf9e6e82b 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->var = $var; $this->expr = $expr; } - public function getSubNodeNames() { - return array('var', 'expr'); + public function getSubNodeNames() : array { + return ['var', 'expr']; + } + + public function getType() : string { + return 'Expr_Assign'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php index 83540a072..bce8604f1 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->var = $var; $this->expr = $expr; } - public function getSubNodeNames() { - return array('var', 'expr'); + public function getSubNodeNames() : array { + return ['var', 'expr']; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php index 9e3ed8226..420284cdc 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->var = $var; $this->expr = $expr; } - public function getSubNodeNames() { - return array('var', 'expr'); + public function getSubNodeNames() : array { + return ['var', 'expr']; + } + + public function getType() : string { + return 'Expr_AssignRef'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php index 6f87e2350..d9c582b0d 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->left = $left; $this->right = $right; } - public function getSubNodeNames() { - return array('left', 'right'); + public function getSubNodeNames() : array { + return ['left', 'right']; } + + /** + * Get the operator sigil for this binary operation. + * + * In the case there are multiple possible sigils for an operator, this method does not + * necessarily return the one used in the parsed code. + * + * @return string + */ + abstract public function getOperatorSigil() : string; } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php index bd6c5c1fb..d907393bf 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php @@ -1,4 +1,4 @@ -'; + } + + public function getType() : string { + return 'Expr_BinaryOp_Greater'; + } +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php index 9bd93a152..d677502cf 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php @@ -1,4 +1,4 @@ -='; + } + + public function getType() : string { + return 'Expr_BinaryOp_GreaterOrEqual'; + } +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php index 9562680e7..3d96285c6 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php @@ -1,4 +1,4 @@ ->'; + } + + public function getType() : string { + return 'Expr_BinaryOp_ShiftRight'; + } +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php index ba2c28b8b..3cb8e7e0d 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php @@ -1,4 +1,4 @@ -'; + } + + public function getType() : string { + return 'Expr_BinaryOp_Spaceship'; + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php index 1d9226410..ed44984be 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Expr_BitwiseNot'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php index 8f543b822..bf27e9f65 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Expr_BooleanNot'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php index bf850dc52..36769d4fc 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php index 08b3a384c..57cc473b6 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->class = $class; - $this->name = $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() { - return array('class', 'name'); + public function getSubNodeNames() : array { + return ['class', 'name']; + } + + public function getType() : string { + return 'Expr_ClassConstFetch'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php index 198ec4d89..db216b8f8 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Expr_Clone'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php index 5d3765508..56e621f25 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php @@ -1,4 +1,4 @@ - array(): use()s * 'returnType' => null : Return type * 'stmts' => array(): Statements + * 'attrGroups' => array(): PHP attributes groups * @param array $attributes Additional attributes */ - public function __construct(array $subNodes = array(), array $attributes = array()) { - parent::__construct($attributes); - $this->static = isset($subNodes['static']) ? $subNodes['static'] : false; - $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; - $this->params = isset($subNodes['params']) ? $subNodes['params'] : array(); - $this->uses = isset($subNodes['uses']) ? $subNodes['uses'] : array(); - $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null; - $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); + public function __construct(array $subNodes = [], array $attributes = []) { + $this->attributes = $attributes; + $this->static = $subNodes['static'] ?? false; + $this->byRef = $subNodes['byRef'] ?? false; + $this->params = $subNodes['params'] ?? []; + $this->uses = $subNodes['uses'] ?? []; + $returnType = $subNodes['returnType'] ?? null; + $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; + $this->stmts = $subNodes['stmts'] ?? []; + $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() { - return array('static', 'byRef', 'params', 'uses', 'returnType', 'stmts'); + public function getSubNodeNames() : array { + return ['attrGroups', '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; } @@ -59,7 +64,16 @@ class Closure extends Expr implements FunctionLike return $this->returnType; } - public function getStmts() { + /** @return Node\Stmt[] */ + public function getStmts() : array { return $this->stmts; } + + public function getAttrGroups() : array { + return $this->attrGroups; + } + + public function getType() : string { + return 'Expr_Closure'; + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php index f4d02023e..2b8a09666 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->var = $var; $this->byRef = $byRef; } - public function getSubNodeNames() { - return array('var', 'byRef'); + public function getSubNodeNames() : array { + return ['var', 'byRef']; + } + + public function getType() : string { + return 'Expr_ClosureUse'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php index 98e51d527..14ebd16bd 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->name = $name; } - public function getSubNodeNames() { - return array('name'); + public function getSubNodeNames() : array { + return ['name']; + } + + public function getType() : string { + return 'Expr_ConstFetch'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php index 0c0509efb..4042ec93c 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Expr_Empty'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php index 5ab8fd445..1637f3aea 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php @@ -1,4 +1,4 @@ -attributes = $attributes; } - public function getSubNodeNames() { - return array(); + public function getSubNodeNames() : array { + return []; + } + + public function getType() : string { + return 'Expr_Error'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php index 750c814c7..c44ff6f93 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Expr_ErrorSuppress'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php index eadffd008..856854743 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Expr_Eval'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php index b0b94cf7b..b88a8f7e6 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Expr_Exit'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php index 60d00507d..1e8afa559 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->name = $name; $this->args = $args; } - public function getSubNodeNames() { - return array('name', 'args'); + public function getSubNodeNames() : array { + return ['name', 'args']; + } + + public function getType() : string { + return 'Expr_FuncCall'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php index b27f3af18..07ce5968e 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; $this->type = $type; } - public function getSubNodeNames() { - return array('expr', 'type'); + public function getSubNodeNames() : array { + return ['expr', 'type']; + } + + public function getType() : string { + return 'Expr_Include'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php index 69573d865..9000d47bb 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; $this->class = $class; } - public function getSubNodeNames() { - return array('expr', 'class'); + public function getSubNodeNames() : array { + return ['expr', 'class']; + } + + public function getType() : string { + return 'Expr_Instanceof'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php index 4ec1d025a..76b738758 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->vars = $vars; } - public function getSubNodeNames() { - return array('vars'); + public function getSubNodeNames() : array { + return ['vars']; + } + + public function getType() : string { + return 'Expr_Isset'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php index 30f3dc165..c27a27b95 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->items = $items; } - public function getSubNodeNames() { - return array('items'); + public function getSubNodeNames() : array { + return ['items']; + } + + public function getType() : string { + return 'Expr_List'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php index a6cdd07c1..bd81bb43f 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php @@ -1,15 +1,16 @@ -attributes = $attributes; $this->var = $var; - $this->name = $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; $this->args = $args; } - public function getSubNodeNames() { - return array('var', 'name', 'args'); + public function getSubNodeNames() : array { + return ['var', 'name', 'args']; + } + + public function getType() : string { + return 'Expr_MethodCall'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php index a8c87794d..c86f0c601 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->class = $class; $this->args = $args; } - public function getSubNodeNames() { - return array('class', 'args'); + public function getSubNodeNames() : array { + return ['class', 'args']; + } + + public function getType() : string { + return 'Expr_New'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php index 06ce5470e..94d6c296d 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->var = $var; } - public function getSubNodeNames() { - return array('var'); + public function getSubNodeNames() : array { + return ['var']; + } + + public function getType() : string { + return 'Expr_PostDec'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php index 54865ba12..005c443a2 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->var = $var; } - public function getSubNodeNames() { - return array('var'); + public function getSubNodeNames() : array { + return ['var']; + } + + public function getType() : string { + return 'Expr_PostInc'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php index db30f5102..a5ca685a8 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->var = $var; } - public function getSubNodeNames() { - return array('var'); + public function getSubNodeNames() : array { + return ['var']; + } + + public function getType() : string { + return 'Expr_PreDec'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php index 06356028c..0986c4474 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->var = $var; } - public function getSubNodeNames() { - return array('var'); + public function getSubNodeNames() : array { + return ['var']; + } + + public function getType() : string { + return 'Expr_PreInc'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php index 0666ab84d..2d43c2ac8 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Expr_Print'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php index adcf21ce1..4281f31cc 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php @@ -1,30 +1,35 @@ -attributes = $attributes; $this->var = $var; - $this->name = $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() { - return array('var', 'name'); + public function getSubNodeNames() : array { + return ['var', 'name']; + } + + public function getType() : string { + return 'Expr_PropertyFetch'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php index 9516a32f4..537a7cc80 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->parts = $parts; } - public function getSubNodeNames() { - return array('parts'); + public function getSubNodeNames() : array { + return ['parts']; + } + + public function getType() : string { + return 'Expr_ShellExec'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php index 5118f34a7..9883f5af5 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php @@ -1,15 +1,16 @@ -attributes = $attributes; $this->class = $class; - $this->name = $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; $this->args = $args; } - public function getSubNodeNames() { - return array('class', 'name', 'args'); + public function getSubNodeNames() : array { + return ['class', 'name', 'args']; + } + + public function getType() : string { + return 'Expr_StaticCall'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php index 477a69ddb..1ee1a25e5 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php @@ -1,31 +1,36 @@ -attributes = $attributes; $this->class = $class; - $this->name = $name; + $this->name = \is_string($name) ? new VarLikeIdentifier($name) : $name; } - public function getSubNodeNames() { - return array('class', 'name'); + public function getSubNodeNames() : array { + return ['class', 'name']; + } + + public function getType() : string { + return 'Expr_StaticPropertyFetch'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php index 57301390f..9316f47d4 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->cond = $cond; $this->if = $if; $this->else = $else; } - public function getSubNodeNames() { - return array('cond', 'if', 'else'); + public function getSubNodeNames() : array { + return ['cond', 'if', 'else']; + } + + public function getType() : string { + return 'Expr_Ternary'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php index 94635d638..ce8808bc6 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Expr_UnaryMinus'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php index 651412003..d23047e54 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Expr_UnaryPlus'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php index 3ae3ecd9b..b47d38e93 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->name = $name; } - public function getSubNodeNames() { - return array('name'); + public function getSubNodeNames() : array { + return ['name']; + } + + public function getType() : string { + return 'Expr_Variable'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php index 993c82c20..a3efce618 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Expr_YieldFrom'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php index f3ca88e05..aef8fc333 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->key = $key; $this->value = $value; } - public function getSubNodeNames() { - return array('key', 'value'); + public function getSubNodeNames() : array { + return ['key', 'value']; + } + + public function getType() : string { + return 'Expr_Yield'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php b/lib/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php index 82569450c..bbcf53e55 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php @@ -1,4 +1,4 @@ - true, + 'parent' => true, + 'static' => true, + ]; + /** * Constructs a name node. * - * @param string|array|self $name Name as string, part array or Name instance (copy ctor) - * @param array $attributes Additional attributes + * @param string|string[]|self $name Name as string, part array or Name instance (copy ctor) + * @param array $attributes Additional attributes */ - public function __construct($name, array $attributes = array()) { - parent::__construct($attributes); + public function __construct($name, array $attributes = []) { + $this->attributes = $attributes; $this->parts = self::prepareName($name); } - public function getSubNodeNames() { - return array('parts'); + public function getSubNodeNames() : array { + return ['parts']; } /** @@ -31,7 +35,7 @@ class Name extends NodeAbstract * * @return string First part of the name */ - public function getFirst() { + public function getFirst() : string { return $this->parts[0]; } @@ -40,7 +44,7 @@ class Name extends NodeAbstract * * @return string Last part of the name */ - public function getLast() { + public function getLast() : string { return $this->parts[count($this->parts) - 1]; } @@ -49,8 +53,8 @@ class Name extends NodeAbstract * * @return bool Whether the name is unqualified */ - public function isUnqualified() { - return 1 == count($this->parts); + public function isUnqualified() : bool { + return 1 === count($this->parts); } /** @@ -58,7 +62,7 @@ class Name extends NodeAbstract * * @return bool Whether the name is qualified */ - public function isQualified() { + public function isQualified() : bool { return 1 < count($this->parts); } @@ -67,7 +71,7 @@ class Name extends NodeAbstract * * @return bool Whether the name is fully qualified */ - public function isFullyQualified() { + public function isFullyQualified() : bool { return false; } @@ -76,27 +80,57 @@ class Name extends NodeAbstract * * @return bool Whether the name is relative */ - public function isRelative() { + public function isRelative() : bool { return false; } /** - * Returns a string representation of the name by imploding the namespace parts with the - * namespace separator. + * Returns a string representation of the name itself, without taking the name type into + * account (e.g., not including a leading backslash for fully qualified names). * * @return string String representation */ - public function toString() { + public function toString() : string { return implode('\\', $this->parts); } + /** + * Returns a string representation of the name as it would occur in code (e.g., including + * leading backslash for fully qualified names. + * + * @return string String representation + */ + public function toCodeString() : string { + return $this->toString(); + } + + /** + * Returns lowercased string representation of the name, without taking the name type into + * account (e.g., no leading backslash for fully qualified names). + * + * @return string Lowercased string representation + */ + public function toLowerString() : string { + return strtolower(implode('\\', $this->parts)); + } + + /** + * Checks whether the identifier is a special class name (self, parent or static). + * + * @return bool Whether identifier is a special class name + */ + public function isSpecialClassName() : bool { + return count($this->parts) === 1 + && isset(self::$specialClassNames[strtolower($this->parts[0])]); + } + /** * Returns a string representation of the name by imploding the namespace parts with the * namespace separator. * * @return string String representation */ - public function __toString() { + public function __toString() : string { return implode('\\', $this->parts); } @@ -116,7 +150,7 @@ class Name extends NodeAbstract * * @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; @@ -152,9 +186,9 @@ class Name extends NodeAbstract * Name::concat($namespace, $shortName) * where $namespace is a Name node or null will work as expected. * - * @param string|array|self|null $name1 The first name - * @param string|array|self|null $name2 The second name - * @param array $attributes Attributes to assign to concatenated name + * @param string|string[]|self|null $name1 The first name + * @param string|string[]|self|null $name2 The second name + * @param array $attributes Attributes to assign to concatenated name * * @return static|null Concatenated name */ @@ -163,7 +197,7 @@ class Name extends NodeAbstract return null; } elseif (null === $name1) { return new static(self::prepareName($name2), $attributes); - } else if (null === $name2) { + } elseif (null === $name2) { return new static(self::prepareName($name1), $attributes); } else { return new static( @@ -176,14 +210,22 @@ class Name extends NodeAbstract * Prepares a (string, array or Name node) name for use in name changing methods by converting * it to an array. * - * @param string|array|self $name Name to prepare + * @param string|string[]|self $name Name to prepare * - * @return array Prepared name + * @return string[] Prepared name */ - private static function prepareName($name) { + private static function prepareName($name) : array { if (\is_string($name)) { + if ('' === $name) { + throw new \InvalidArgumentException('Name cannot be empty'); + } + return explode('\\', $name); } elseif (\is_array($name)) { + if (empty($name)) { + throw new \InvalidArgumentException('Name cannot be empty'); + } + return $name; } elseif ($name instanceof self) { return $name->parts; @@ -193,4 +235,8 @@ class Name extends NodeAbstract 'Expected string, array of parts or Name instance' ); } + + public function getType() : string { + return 'Name'; + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php b/lib/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php index 97cc1113d..1df93a56b 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php @@ -1,4 +1,4 @@ -toString(); + } + + public function getType() : string { + return 'Name_FullyQualified'; + } +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php b/lib/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php index 25676ce69..57bf7af2b 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php @@ -1,4 +1,4 @@ -toString(); + } + + public function getType() : string { + return 'Name_Relative'; + } +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/NullableType.php b/lib/nikic/php-parser/lib/PhpParser/Node/NullableType.php index d887b321a..36463657e 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/NullableType.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/NullableType.php @@ -1,4 +1,4 @@ -type = $type; + public function __construct($type, array $attributes = []) { + $this->attributes = $attributes; + $this->type = \is_string($type) ? new Identifier($type) : $type; } - public function getSubNodeNames() { - return array('type'); + public function getSubNodeNames() : array { + return ['type']; + } + + public function getType() : string { + return 'NullableType'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Param.php b/lib/nikic/php-parser/lib/PhpParser/Node/Param.php index b35ee4ef0..315b5f24f 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Param.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Param.php @@ -1,4 +1,4 @@ -type = $type; + public function __construct( + $var, Expr $default = null, $type = null, + bool $byRef = false, bool $variadic = false, + array $attributes = [], + int $flags = 0, + array $attrGroups = [] + ) { + $this->attributes = $attributes; + $this->type = \is_string($type) ? new Identifier($type) : $type; $this->byRef = $byRef; $this->variadic = $variadic; - $this->name = $name; + $this->var = $var; $this->default = $default; + $this->flags = $flags; + $this->attrGroups = $attrGroups; } - public function getSubNodeNames() { - return array('type', 'byRef', 'variadic', 'name', 'default'); + public function getSubNodeNames() : array { + return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; + } + + public function getType() : string { + return 'Param'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar.php b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar.php index 01177532c..8117909b6 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar.php @@ -1,7 +1,7 @@ -attributes = $attributes; $this->value = $value; } - public function getSubNodeNames() { - return array('value'); + public function getSubNodeNames() : array { + return ['value']; } /** @@ -33,7 +33,9 @@ class DNumber extends Scalar * * @return float The parsed number */ - public static function parse($str) { + public static function parse(string $str) : float { + $str = str_replace('_', '', $str); + // if string contains any of .eE just cast it to float if (false !== strpbrk($str, '.eE')) { return (float) $str; @@ -61,4 +63,8 @@ class DNumber extends Scalar // dec return (float) $str; } + + public function getType() : string { + return 'Scalar_DNumber'; + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php index 4f9b433c2..fa5d2e268 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->parts = $parts; } - public function getSubNodeNames() { - return array('parts'); + public function getSubNodeNames() : array { + return ['parts']; + } + + public function getType() : string { + return 'Scalar_Encapsed'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php index 50cb1afe6..bb3194c1d 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->value = $value; } - public function getSubNodeNames() { - return array('value'); + public function getSubNodeNames() : array { + return ['value']; + } + + public function getType() : string { + return 'Scalar_EncapsedStringPart'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php index 3559b982c..b33943547 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->value = $value; } - public function getSubNodeNames() { - return array('value'); + public function getSubNodeNames() : array { + return ['value']; } /** @@ -40,7 +40,9 @@ class LNumber extends Scalar * * @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 = [], bool $allowInvalidOctal = false) : LNumber { + $str = str_replace('_', '', $str); + if ('0' !== $str[0] || '0' === $str) { $attributes['kind'] = LNumber::KIND_DEC; return new LNumber((int) $str, $attributes); @@ -64,4 +66,8 @@ class LNumber extends Scalar $attributes['kind'] = LNumber::KIND_OCT; return new LNumber(intval($str, 8), $attributes); } + + public function getType() : string { + return 'Scalar_LNumber'; + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php index a50d68f3d..941f0c762 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php @@ -1,4 +1,4 @@ -attributes = $attributes; } - public function getSubNodeNames() { - return array(); + public function getSubNodeNames() : array { + return []; } /** @@ -24,5 +24,5 @@ abstract class MagicConst extends Scalar * * @return string Name of magic constant */ - abstract public function getName(); + abstract public function getName() : string; } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php index 3466b21a1..244328476 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php @@ -1,4 +1,4 @@ - '\\', '$' => '$', 'n' => "\n", @@ -25,7 +25,7 @@ class String_ extends Scalar 'f' => "\f", 'v' => "\v", 'e' => "\x1B", - ); + ]; /** * Constructs a string scalar node. @@ -33,13 +33,13 @@ class String_ extends Scalar * @param string $value Value of the string * @param array $attributes Additional attributes */ - public function __construct($value, array $attributes = array()) { - parent::__construct($attributes); + public function __construct(string $value, array $attributes = []) { + $this->attributes = $attributes; $this->value = $value; } - public function getSubNodeNames() { - return array('value'); + public function getSubNodeNames() : array { + return ['value']; } /** @@ -52,7 +52,7 @@ class String_ extends Scalar * * @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; @@ -60,8 +60,8 @@ class String_ extends Scalar if ('\'' === $str[$bLength]) { return str_replace( - array('\\\\', '\\\''), - array( '\\', '\''), + ['\\\\', '\\\''], + ['\\', '\''], substr($str, $bLength + 1, -1) ); } else { @@ -82,7 +82,7 @@ class String_ extends Scalar * * @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); } @@ -100,7 +100,7 @@ class String_ extends Scalar if (isset(self::$replacements[$str])) { return self::$replacements[$str]; } elseif ('x' === $str[0] || 'X' === $str[0]) { - return chr(hexdec($str)); + return chr(hexdec(substr($str, 1))); } elseif ('u' === $str[0]) { return self::codePointToUtf8(hexdec($matches[2])); } else { @@ -111,7 +111,14 @@ class String_ extends Scalar ); } - private static function codePointToUtf8($num) { + /** + * Converts a Unicode code point to its UTF-8 encoded representation. + * + * @param int $num Code point + * + * @return string UTF-8 representation of code point + */ + private static function codePointToUtf8(int $num) : string { if ($num <= 0x7F) { return chr($num); } @@ -128,26 +135,7 @@ class String_ extends Scalar throw new Error('Invalid UTF-8 codepoint escape sequence: Codepoint too large'); } - /** - * @internal - * - * Parses a constant doc string. - * - * @param string $startToken Doc string start token content (<<attributes = $attributes; $this->num = $num; } - public function getSubNodeNames() { - return array('num'); + public function getSubNodeNames() : array { + return ['num']; + } + + public function getType() : string { + return 'Stmt_Break'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php index 03f892c7c..2bf044c90 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->cond = $cond; $this->stmts = $stmts; } - public function getSubNodeNames() { - return array('cond', 'stmts'); + public function getSubNodeNames() : array { + return ['cond', 'stmts']; + } + + public function getType() : string { + return 'Stmt_Case'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php index 58337ad9b..9b9c09478 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php @@ -1,34 +1,41 @@ -attributes = $attributes; $this->types = $types; $this->var = $var; $this->stmts = $stmts; } - public function getSubNodeNames() { - return array('types', 'var', 'stmts'); + public function getSubNodeNames() : array { + return ['types', 'var', 'stmts']; + } + + public function getType() : string { + return 'Stmt_Catch'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php index 0d41094ff..1fc7f3362 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->flags = $flags; $this->consts = $consts; + $this->attrGroups = $attrGroups; } - public function getSubNodeNames() { - return array('flags', 'consts'); + public function getSubNodeNames() : array { + return ['attrGroups', 'flags', 'consts']; } - public function isPublic() { + /** + * Whether constant is explicitly or implicitly public. + * + * @return bool + */ + public function isPublic() : bool { return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; } - public function isProtected() { + /** + * Whether constant is protected. + * + * @return bool + */ + public function isProtected() : bool { return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); } - public function isPrivate() { + /** + * Whether constant is private. + * + * @return bool + */ + public function isPrivate() : bool { return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); } - public function isStatic() { - return (bool) ($this->flags & Class_::MODIFIER_STATIC); + /** + * Whether constant is final. + * + * @return bool + */ + public function isFinal() : bool { + return (bool) ($this->flags & Class_::MODIFIER_FINAL); + } + + public function getType() : string { + return 'Stmt_ClassConst'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php index f90533553..840c4f67e 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php @@ -1,22 +1,87 @@ -stmts as $stmt) { + if ($stmt instanceof TraitUse) { + $traitUses[] = $stmt; + } + } + return $traitUses; + } + + /** + * @return ClassConst[] + */ + public function getConstants() : array { + $constants = []; + foreach ($this->stmts as $stmt) { + if ($stmt instanceof ClassConst) { + $constants[] = $stmt; + } + } + return $constants; + } + + /** + * @return Property[] + */ + public function getProperties() : array { + $properties = []; + foreach ($this->stmts as $stmt) { + if ($stmt instanceof Property) { + $properties[] = $stmt; + } + } + return $properties; + } + + /** + * Gets property with the given name defined directly in this class/interface/trait. + * + * @param string $name Name of the property + * + * @return Property|null Property node or null if the property does not exist + */ + public function getProperty(string $name) { + foreach ($this->stmts as $stmt) { + if ($stmt instanceof Property) { + foreach ($stmt->props as $prop) { + if ($prop instanceof PropertyProperty && $name === $prop->name->toString()) { + return $stmt; + } + } + } + } + return null; + } /** * Gets all methods defined directly in this class/interface/trait * * @return ClassMethod[] */ - public function getMethods() { - $methods = array(); + public function getMethods() : array { + $methods = []; foreach ($this->stmts as $stmt) { if ($stmt instanceof ClassMethod) { $methods[] = $stmt; @@ -32,10 +97,10 @@ abstract class ClassLike extends Node\Stmt { * * @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)) { + if ($stmt instanceof ClassMethod && $lowerName === $stmt->name->toLowerString()) { return $stmt; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php index de05390ad..92157fab2 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php @@ -1,4 +1,4 @@ - true, + '__destruct' => true, + '__call' => true, + '__callstatic' => true, + '__get' => true, + '__set' => true, + '__isset' => true, + '__unset' => true, + '__sleep' => true, + '__wakeup' => true, + '__tostring' => true, + '__set_state' => true, + '__clone' => true, + '__invoke' => true, + '__debuginfo' => true, + ]; /** * Constructs a class method node. * - * @param string $name Name - * @param array $subNodes Array of the following optional subnodes: - * 'flags => MODIFIER_PUBLIC: Flags - * 'byRef' => false : Whether to return by reference - * 'params' => array() : Parameters - * 'returnType' => null : Return type - * 'stmts' => array() : Statements - * @param array $attributes Additional attributes + * @param string|Node\Identifier $name Name + * @param array $subNodes Array of the following optional subnodes: + * 'flags => MODIFIER_PUBLIC: Flags + * 'byRef' => false : Whether to return by reference + * 'params' => array() : Parameters + * 'returnType' => null : Return type + * 'stmts' => array() : Statements + * 'attrGroups' => array() : PHP attribute groups + * @param array $attributes Additional attributes */ - public function __construct($name, array $subNodes = array(), array $attributes = array()) { - parent::__construct($attributes); - $this->flags = isset($subNodes['flags']) ? $subNodes['flags'] - : (isset($subNodes['type']) ? $subNodes['type'] : 0); - $this->type = $this->flags; - $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; - $this->name = $name; - $this->params = isset($subNodes['params']) ? $subNodes['params'] : array(); - $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null; - $this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : array(); + public function __construct($name, array $subNodes = [], array $attributes = []) { + $this->attributes = $attributes; + $this->flags = $subNodes['flags'] ?? $subNodes['type'] ?? 0; + $this->byRef = $subNodes['byRef'] ?? false; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; + $this->params = $subNodes['params'] ?? []; + $returnType = $subNodes['returnType'] ?? null; + $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; + $this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : []; + $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() { - return array('flags', 'byRef', 'name', 'params', 'returnType', 'stmts'); + public function getSubNodeNames() : array { + return ['attrGroups', '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; } @@ -67,28 +85,75 @@ class ClassMethod extends Node\Stmt implements FunctionLike return $this->stmts; } - public function isPublic() { + public function getAttrGroups() : array { + return $this->attrGroups; + } + + /** + * Whether the method is explicitly or implicitly public. + * + * @return bool + */ + public function isPublic() : bool { return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; } - public function isProtected() { + /** + * Whether the method is protected. + * + * @return bool + */ + public function isProtected() : bool { return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); } - public function isPrivate() { + /** + * Whether the method is private. + * + * @return bool + */ + public function isPrivate() : bool { return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); } - public function isAbstract() { + /** + * Whether the method is abstract. + * + * @return bool + */ + public function isAbstract() : bool { return (bool) ($this->flags & Class_::MODIFIER_ABSTRACT); } - public function isFinal() { + /** + * Whether the method is final. + * + * @return bool + */ + public function isFinal() : bool { return (bool) ($this->flags & Class_::MODIFIER_FINAL); } - public function isStatic() { + /** + * Whether the method is static. + * + * @return bool + */ + public function isStatic() : bool { return (bool) ($this->flags & Class_::MODIFIER_STATIC); } + + /** + * Whether the method is magic. + * + * @return bool + */ + public function isMagic() : bool { + return isset(self::$magicNames[$this->name->toLowerString()]); + } + + public function getType() : string { + return 'Stmt_ClassMethod'; + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php index 0a65e3740..b290aaf6d 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php @@ -1,4 +1,4 @@ - true, - 'parent' => true, - 'static' => true, - ); - /** * Constructs a class node. * - * @param string|null $name Name + * @param string|Node\Identifier|null $name Name * @param array $subNodes Array of the following optional subnodes: - * 'flags' => 0 : Flags - * 'extends' => null : Name of extended class - * 'implements' => array(): Names of implemented interfaces - * 'stmts' => array(): Statements + * 'flags' => 0 : Flags + * 'extends' => null : Name of extended class + * 'implements' => array(): Names of implemented interfaces + * 'stmts' => array(): Statements + * 'attrGroups' => array(): PHP attribute groups * @param array $attributes Additional attributes */ - public function __construct($name, array $subNodes = array(), array $attributes = array()) { - parent::__construct($attributes); - $this->flags = isset($subNodes['flags']) ? $subNodes['flags'] - : (isset($subNodes['type']) ? $subNodes['type'] : 0); - $this->type = $this->flags; - $this->name = $name; - $this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : null; - $this->implements = isset($subNodes['implements']) ? $subNodes['implements'] : array(); - $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); + public function __construct($name, array $subNodes = [], array $attributes = []) { + $this->attributes = $attributes; + $this->flags = $subNodes['flags'] ?? $subNodes['type'] ?? 0; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; + $this->extends = $subNodes['extends'] ?? null; + $this->implements = $subNodes['implements'] ?? []; + $this->stmts = $subNodes['stmts'] ?? []; + $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() { - return array('flags', 'name', 'extends', 'implements', 'stmts'); + public function getSubNodeNames() : array { + return ['attrGroups', 'flags', 'name', 'extends', 'implements', 'stmts']; } - public function isAbstract() { + /** + * Whether the class is explicitly abstract. + * + * @return bool + */ + public function isAbstract() : bool { return (bool) ($this->flags & self::MODIFIER_ABSTRACT); } - public function isFinal() { + /** + * Whether the class is final. + * + * @return bool + */ + public function isFinal() : bool { return (bool) ($this->flags & self::MODIFIER_FINAL); } - public function isAnonymous() { + /** + * Whether the class is anonymous. + * + * @return bool + */ + public function isAnonymous() : bool { return null === $this->name; } @@ -92,8 +97,16 @@ class Class_ extends ClassLike throw new Error('Multiple final modifiers are not allowed'); } + if ($a & self::MODIFIER_READONLY && $b & self::MODIFIER_READONLY) { + throw new Error('Multiple readonly modifiers are not allowed'); + } + if ($a & 48 && $b & 48) { throw new Error('Cannot use the final modifier on an abstract class member'); } } + + public function getType() : string { + return 'Stmt_Class'; + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php index 8b2eecd51..e6316345e 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->consts = $consts; } - public function getSubNodeNames() { - return array('consts'); + public function getSubNodeNames() : array { + return ['consts']; + } + + public function getType() : string { + return 'Stmt_Const'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php index f78e19a2a..24882683b 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->num = $num; } - public function getSubNodeNames() { - return array('num'); + public function getSubNodeNames() : array { + return ['num']; + } + + public function getType() : string { + return 'Stmt_Continue'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php index 829dbaf25..ac07f30c7 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php @@ -1,4 +1,4 @@ -value pair node. * - * @param string $key Key - * @param Node\Expr $value Value - * @param array $attributes Additional attributes + * @param string|Node\Identifier $key Key + * @param Node\Expr $value Value + * @param array $attributes Additional attributes */ - public function __construct($key, Node\Expr $value, array $attributes = array()) { - parent::__construct($attributes); - $this->key = $key; + public function __construct($key, Node\Expr $value, array $attributes = []) { + $this->attributes = $attributes; + $this->key = \is_string($key) ? new Node\Identifier($key) : $key; $this->value = $value; } - public function getSubNodeNames() { - return array('key', 'value'); + public function getSubNodeNames() : array { + return ['key', 'value']; + } + + public function getType() : string { + return 'Stmt_DeclareDeclare'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php index 32739f35f..f46ff0baf 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->declares = $declares; $this->stmts = $stmts; } - public function getSubNodeNames() { - return array('declares', 'stmts'); + public function getSubNodeNames() : array { + return ['declares', 'stmts']; + } + + public function getType() : string { + return 'Stmt_Declare'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php index dd4c6c843..78e90da03 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->cond = $cond; $this->stmts = $stmts; } - public function getSubNodeNames() { - return array('cond', 'stmts'); + public function getSubNodeNames() : array { + return ['stmts', 'cond']; + } + + public function getType() : string { + return 'Stmt_Do'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php index 11e107072..7cc50d5d6 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->exprs = $exprs; } - public function getSubNodeNames() { - return array('exprs'); + public function getSubNodeNames() : array { + return ['exprs']; + } + + public function getType() : string { + return 'Stmt_Echo'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php index 608878f65..eef1ece32 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->cond = $cond; $this->stmts = $stmts; } - public function getSubNodeNames() { - return array('cond', 'stmts'); + public function getSubNodeNames() : array { + return ['cond', 'stmts']; + } + + public function getType() : string { + return 'Stmt_ElseIf'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php index c91a1484f..0e61778e2 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->stmts = $stmts; } - public function getSubNodeNames() { - return array('stmts'); + public function getSubNodeNames() : array { + return ['stmts']; + } + + public function getType() : string { + return 'Stmt_Else'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php new file mode 100644 index 000000000..5beff8b39 --- /dev/null +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php @@ -0,0 +1,37 @@ +name = \is_string($name) ? new Node\Identifier($name) : $name; + $this->expr = $expr; + $this->attrGroups = $attrGroups; + } + + public function getSubNodeNames() : array { + return ['attrGroups', 'name', 'expr']; + } + + public function getType() : string { + return 'Stmt_EnumCase'; + } +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php new file mode 100644 index 000000000..3a50c225d --- /dev/null +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php @@ -0,0 +1,40 @@ + null : Scalar type + * 'implements' => array() : Names of implemented interfaces + * 'stmts' => array() : Statements + * 'attrGroups' => array() : PHP attribute groups + * @param array $attributes Additional attributes + */ + public function __construct($name, array $subNodes = [], array $attributes = []) { + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; + $this->scalarType = $subNodes['scalarType'] ?? null; + $this->implements = $subNodes['implements'] ?? []; + $this->stmts = $subNodes['stmts'] ?? []; + $this->attrGroups = $subNodes['attrGroups'] ?? []; + + parent::__construct($attributes); + } + + public function getSubNodeNames() : array { + return ['attrGroups', 'name', 'scalarType', 'implements', 'stmts']; + } + + public function getType() : string { + return 'Stmt_Enum'; + } +} diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php index 0e3eabbe1..d55b8b687 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->stmts = $stmts; } - public function getSubNodeNames() { - return array('stmts'); + public function getSubNodeNames() : array { + return ['stmts']; + } + + public function getType() : string { + return 'Stmt_Finally'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php index 2ca88a332..1323d37cf 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php @@ -1,4 +1,4 @@ - array(): Statements * @param array $attributes Additional attributes */ - public function __construct(array $subNodes = array(), array $attributes = array()) { - parent::__construct($attributes); - $this->init = isset($subNodes['init']) ? $subNodes['init'] : array(); - $this->cond = isset($subNodes['cond']) ? $subNodes['cond'] : array(); - $this->loop = isset($subNodes['loop']) ? $subNodes['loop'] : array(); - $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); + public function __construct(array $subNodes = [], array $attributes = []) { + $this->attributes = $attributes; + $this->init = $subNodes['init'] ?? []; + $this->cond = $subNodes['cond'] ?? []; + $this->loop = $subNodes['loop'] ?? []; + $this->stmts = $subNodes['stmts'] ?? []; } - public function getSubNodeNames() { - return array('init', 'cond', 'loop', 'stmts'); + public function getSubNodeNames() : array { + return ['init', 'cond', 'loop', 'stmts']; + } + + public function getType() : string { + return 'Stmt_For'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php index d2c643205..0556a7ce5 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php @@ -1,4 +1,4 @@ - array(): Statements * @param array $attributes Additional attributes */ - public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = array(), array $attributes = array()) { - parent::__construct($attributes); + public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = [], array $attributes = []) { + $this->attributes = $attributes; $this->expr = $expr; - $this->keyVar = isset($subNodes['keyVar']) ? $subNodes['keyVar'] : null; - $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; + $this->keyVar = $subNodes['keyVar'] ?? null; + $this->byRef = $subNodes['byRef'] ?? false; $this->valueVar = $valueVar; - $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); + $this->stmts = $subNodes['stmts'] ?? []; } - public function getSubNodeNames() { - return array('expr', 'keyVar', 'byRef', 'valueVar', 'stmts'); + public function getSubNodeNames() : array { + return ['expr', 'keyVar', 'byRef', 'valueVar', 'stmts']; + } + + public function getType() : string { + return 'Stmt_Foreach'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php index 4c1f48d84..f08481fae 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php @@ -1,52 +1,60 @@ - false : Whether to return by reference * 'params' => array(): Parameters * 'returnType' => null : Return type * 'stmts' => array(): Statements + * 'attrGroups' => array(): PHP attribute groups * @param array $attributes Additional attributes */ - public function __construct($name, array $subNodes = array(), array $attributes = array()) { - parent::__construct($attributes); - $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; - $this->name = $name; - $this->params = isset($subNodes['params']) ? $subNodes['params'] : array(); - $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null; - $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); + public function __construct($name, array $subNodes = [], array $attributes = []) { + $this->attributes = $attributes; + $this->byRef = $subNodes['byRef'] ?? false; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; + $this->params = $subNodes['params'] ?? []; + $returnType = $subNodes['returnType'] ?? null; + $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; + $this->stmts = $subNodes['stmts'] ?? []; + $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() { - return array('byRef', 'name', 'params', 'returnType', 'stmts'); + public function getSubNodeNames() : array { + return ['attrGroups', '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; } @@ -54,7 +62,16 @@ class Function_ extends Node\Stmt implements FunctionLike return $this->returnType; } - public function getStmts() { + public function getAttrGroups() : array { + return $this->attrGroups; + } + + /** @return Node\Stmt[] */ + public function getStmts() : array { return $this->stmts; } + + public function getType() : string { + return 'Stmt_Function'; + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php index 29fbc488e..a0022ad93 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->vars = $vars; } - public function getSubNodeNames() { - return array('vars'); + public function getSubNodeNames() : array { + return ['vars']; + } + + public function getType() : string { + return 'Stmt_Global'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php index b087fe02b..24a57f780 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php @@ -1,26 +1,31 @@ -name = $name; + public function __construct($name, array $attributes = []) { + $this->attributes = $attributes; + $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() { - return array('name'); + public function getSubNodeNames() : array { + return ['name']; + } + + public function getType() : string { + return 'Stmt_Goto'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php index 30837dd6b..24520d223 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->type = $type; $this->prefix = $prefix; $this->uses = $uses; } - public function getSubNodeNames() { - return array('type', 'prefix', 'uses'); + public function getSubNodeNames() : array { + return ['type', 'prefix', 'uses']; + } + + public function getType() : string { + return 'Stmt_GroupUse'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php index c33ec9f1d..8e624e0f1 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->remaining = $remaining; } - public function getSubNodeNames() { - return array('remaining'); + public function getSubNodeNames() : array { + return ['remaining']; + } + + public function getType() : string { + return 'Stmt_HaltCompiler'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php index 98bda356f..a1bae4bf8 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php @@ -1,4 +1,4 @@ - null : Else clause * @param array $attributes Additional attributes */ - public function __construct(Node\Expr $cond, array $subNodes = array(), array $attributes = array()) { - parent::__construct($attributes); + public function __construct(Node\Expr $cond, array $subNodes = [], array $attributes = []) { + $this->attributes = $attributes; $this->cond = $cond; - $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); - $this->elseifs = isset($subNodes['elseifs']) ? $subNodes['elseifs'] : array(); - $this->else = isset($subNodes['else']) ? $subNodes['else'] : null; + $this->stmts = $subNodes['stmts'] ?? []; + $this->elseifs = $subNodes['elseifs'] ?? []; + $this->else = $subNodes['else'] ?? null; } - public function getSubNodeNames() { - return array('cond', 'stmts', 'elseifs', 'else'); + public function getSubNodeNames() : array { + return ['cond', 'stmts', 'elseifs', 'else']; + } + + public function getType() : string { + return 'Stmt_If'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php index accebe61e..0711d2842 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->value = $value; } - public function getSubNodeNames() { - return array('value'); + public function getSubNodeNames() : array { + return ['value']; + } + + public function getType() : string { + return 'Stmt_InlineHTML'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php index efb5891fc..4d587dd48 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php @@ -1,4 +1,4 @@ - array(): Name of extended interfaces - * 'stmts' => array(): Statements + * 'extends' => array(): Name of extended interfaces + * 'stmts' => array(): Statements + * 'attrGroups' => array(): PHP attribute groups * @param array $attributes Additional attributes */ - public function __construct($name, array $subNodes = array(), array $attributes = array()) { - parent::__construct($attributes); - $this->name = $name; - $this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : array(); - $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); + public function __construct($name, array $subNodes = [], array $attributes = []) { + $this->attributes = $attributes; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; + $this->extends = $subNodes['extends'] ?? []; + $this->stmts = $subNodes['stmts'] ?? []; + $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() { - return array('name', 'extends', 'stmts'); + public function getSubNodeNames() : array { + return ['attrGroups', 'name', 'extends', 'stmts']; + } + + public function getType() : string { + return 'Stmt_Interface'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php index edd0ee9a5..3edcb3be7 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php @@ -1,26 +1,31 @@ -name = $name; + public function __construct($name, array $attributes = []) { + $this->attributes = $attributes; + $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() { - return array('name'); + public function getSubNodeNames() : array { + return ['name']; + } + + public function getType() : string { + return 'Stmt_Label'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php index 444855c39..c63204577 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->name = $name; $this->stmts = $stmts; } - public function getSubNodeNames() { - return array('name', 'stmts'); + public function getSubNodeNames() : array { + return ['name', 'stmts']; + } + + public function getType() : string { + return 'Stmt_Namespace'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php index 270dd0995..f86f8df7d 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->flags = $flags; - $this->type = $flags; $this->props = $props; + $this->type = \is_string($type) ? new Identifier($type) : $type; + $this->attrGroups = $attrGroups; } - public function getSubNodeNames() { - return array('flags', 'props'); + public function getSubNodeNames() : array { + return ['attrGroups', 'flags', 'type', 'props']; } - public function isPublic() { + /** + * Whether the property is explicitly or implicitly public. + * + * @return bool + */ + public function isPublic() : bool { return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; } - public function isProtected() { + /** + * Whether the property is protected. + * + * @return bool + */ + public function isProtected() : bool { return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); } - public function isPrivate() { + /** + * Whether the property is private. + * + * @return bool + */ + public function isPrivate() : bool { return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); } - public function isStatic() { + /** + * Whether the property is static. + * + * @return bool + */ + public function isStatic() : bool { return (bool) ($this->flags & Class_::MODIFIER_STATIC); } + + /** + * Whether the property is readonly. + * + * @return bool + */ + public function isReadonly() : bool { + return (bool) ($this->flags & Class_::MODIFIER_READONLY); + } + + public function getType() : string { + return 'Stmt_Property'; + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php index b2d29dc77..205731e20 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php @@ -1,4 +1,4 @@ -name = $name; + public function __construct($name, Node\Expr $default = null, array $attributes = []) { + $this->attributes = $attributes; + $this->name = \is_string($name) ? new Node\VarLikeIdentifier($name) : $name; $this->default = $default; } - public function getSubNodeNames() { - return array('name', 'default'); + public function getSubNodeNames() : array { + return ['name', 'default']; + } + + public function getType() : string { + return 'Stmt_PropertyProperty'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php index b64284114..efc578c58 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Stmt_Return'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php index 4bc5dd25c..29584560d 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php @@ -1,30 +1,37 @@ -name = $name; + public function __construct( + Expr\Variable $var, Node\Expr $default = null, array $attributes = [] + ) { + $this->attributes = $attributes; + $this->var = $var; $this->default = $default; } - public function getSubNodeNames() { - return array('name', 'default'); + public function getSubNodeNames() : array { + return ['var', 'default']; + } + + public function getType() : string { + return 'Stmt_StaticVar'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php index 37cc0b36f..464898ffa 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->vars = $vars; } - public function getSubNodeNames() { - return array('vars'); + public function getSubNodeNames() : array { + return ['vars']; + } + + public function getType() : string { + return 'Stmt_Static'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php index 72d667b1e..2c8dae022 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->cond = $cond; $this->cases = $cases; } - public function getSubNodeNames() { - return array('cond', 'cases'); + public function getSubNodeNames() : array { + return ['cond', 'cases']; + } + + public function getType() : string { + return 'Stmt_Switch'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php index f8ff6aa38..a34e2b362 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() { - return array('expr'); + public function getSubNodeNames() : array { + return ['expr']; + } + + public function getType() : string { + return 'Stmt_Throw'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php index a29874bea..9e97053b4 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php @@ -1,10 +1,9 @@ -attributes = $attributes; $this->traits = $traits; $this->adaptations = $adaptations; } - public function getSubNodeNames() { - return array('traits', 'adaptations'); + public function getSubNodeNames() : array { + return ['traits', 'adaptations']; + } + + public function getType() : string { + return 'Stmt_TraitUse'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php index c6038c8ca..8bdd2c041 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->trait = $trait; - $this->method = $method; + $this->method = \is_string($method) ? new Node\Identifier($method) : $method; $this->newModifier = $newModifier; - $this->newName = $newName; + $this->newName = \is_string($newName) ? new Node\Identifier($newName) : $newName; } - public function getSubNodeNames() { - return array('trait', 'method', 'newModifier', 'newName'); + public function getSubNodeNames() : array { + return ['trait', 'method', 'newModifier', 'newName']; + } + + public function getType() : string { + return 'Stmt_TraitUseAdaptation_Alias'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php index 1f6bc1f98..80385f64e 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->trait = $trait; - $this->method = $method; + $this->method = \is_string($method) ? new Node\Identifier($method) : $method; $this->insteadof = $insteadof; } - public function getSubNodeNames() { - return array('trait', 'method', 'insteadof'); + public function getSubNodeNames() : array { + return ['trait', 'method', 'insteadof']; + } + + public function getType() : string { + return 'Stmt_TraitUseAdaptation_Precedence'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php index eed5844ae..0cec203ac 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php @@ -1,4 +1,4 @@ - array(): Statements + * 'stmts' => array(): Statements + * 'attrGroups' => array(): PHP attribute groups * @param array $attributes Additional attributes */ - public function __construct($name, array $subNodes = array(), array $attributes = array()) { - parent::__construct($attributes); - $this->name = $name; - $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); + public function __construct($name, array $subNodes = [], array $attributes = []) { + $this->attributes = $attributes; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; + $this->stmts = $subNodes['stmts'] ?? []; + $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() { - return array('name', 'stmts'); + public function getSubNodeNames() : array { + return ['attrGroups', 'name', 'stmts']; + } + + public function getType() : string { + return 'Stmt_Trait'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php index 0ff36cc77..7fc158c57 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->stmts = $stmts; $this->catches = $catches; $this->finally = $finally; } - public function getSubNodeNames() { - return array('stmts', 'catches', 'finally'); + public function getSubNodeNames() : array { + return ['stmts', 'catches', 'finally']; + } + + public function getType() : string { + return 'Stmt_TryCatch'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php index 0f00fe941..310e427aa 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->vars = $vars; } - public function getSubNodeNames() { - return array('vars'); + public function getSubNodeNames() : array { + return ['vars']; + } + + public function getType() : string { + return 'Stmt_Unset'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php index 2de8432d7..32bd7847d 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php @@ -1,8 +1,9 @@ -getLast(); - } - - parent::__construct($attributes); + public function __construct(Node\Name $name, $alias = null, int $type = Use_::TYPE_UNKNOWN, array $attributes = []) { + $this->attributes = $attributes; $this->type = $type; $this->name = $name; - $this->alias = $alias; + $this->alias = \is_string($alias) ? new Identifier($alias) : $alias; } - public function getSubNodeNames() { - return array('type', 'name', 'alias'); + public function getSubNodeNames() : array { + return ['type', 'name', 'alias']; + } + + /** + * Get alias. If not explicitly given this is the last component of the used name. + * + * @return Identifier + */ + public function getAlias() : Identifier { + if (null !== $this->alias) { + return $this->alias; + } + + return new Identifier($this->name->getLast()); + } + + public function getType() : string { + return 'Stmt_UseUse'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php index 6c89ebb1b..8753da313 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->type = $type; $this->uses = $uses; } - public function getSubNodeNames() { - return array('type', 'uses'); + public function getSubNodeNames() : array { + return ['type', 'uses']; + } + + public function getType() : string { + return 'Stmt_Use'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php index afad1b259..f41034f8c 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php +++ b/lib/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php @@ -1,4 +1,4 @@ -attributes = $attributes; $this->cond = $cond; $this->stmts = $stmts; } - public function getSubNodeNames() { - return array('cond', 'stmts'); + public function getSubNodeNames() : array { + return ['cond', 'stmts']; + } + + public function getType() : string { + return 'Stmt_While'; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/NodeAbstract.php b/lib/nikic/php-parser/lib/PhpParser/NodeAbstract.php index 1b757c7bc..04514da11 100644 --- a/lib/nikic/php-parser/lib/PhpParser/NodeAbstract.php +++ b/lib/nikic/php-parser/lib/PhpParser/NodeAbstract.php @@ -1,9 +1,7 @@ -attributes = $attributes; } /** - * Gets the type of the node. + * Gets line the node started in (alias of getStartLine). * - * @return string Type of the node + * @return int Start line (or -1 if not available) */ - public function getType() { - $className = rtrim(get_class($this), '_'); - return strtr( - substr($className, strlen(Node::class) + 1), - '\\', - '_' - ); + public function getLine() : int { + return $this->attributes['startLine'] ?? -1; } /** * Gets line the node started in. * - * @return int Line + * Requires the 'startLine' attribute to be enabled in the lexer (enabled by default). + * + * @return int Start line (or -1 if not available) */ - public function getLine() { - return $this->getAttribute('startLine', -1); + public function getStartLine() : int { + return $this->attributes['startLine'] ?? -1; } /** - * Sets line the node started in. + * Gets the line the node ended in. * - * @param int $line Line + * Requires the 'endLine' attribute to be enabled in the lexer (enabled by default). * - * @deprecated + * @return int End line (or -1 if not available) */ - public function setLine($line) { - $this->setAttribute('startLine', (int) $line); + public function getEndLine() : int { + return $this->attributes['endLine'] ?? -1; + } + + /** + * Gets the token offset of the first token that is part of this node. + * + * The offset is an index into the array returned by Lexer::getTokens(). + * + * Requires the 'startTokenPos' attribute to be enabled in the lexer (DISABLED by default). + * + * @return int Token start position (or -1 if not available) + */ + public function getStartTokenPos() : int { + return $this->attributes['startTokenPos'] ?? -1; + } + + /** + * Gets the token offset of the last token that is part of this node. + * + * The offset is an index into the array returned by Lexer::getTokens(). + * + * Requires the 'endTokenPos' attribute to be enabled in the lexer (DISABLED by default). + * + * @return int Token end position (or -1 if not available) + */ + public function getEndTokenPos() : int { + return $this->attributes['endTokenPos'] ?? -1; + } + + /** + * Gets the file offset of the first character that is part of this node. + * + * Requires the 'startFilePos' attribute to be enabled in the lexer (DISABLED by default). + * + * @return int File start position (or -1 if not available) + */ + public function getStartFilePos() : int { + return $this->attributes['startFilePos'] ?? -1; + } + + /** + * Gets the file offset of the last character that is part of this node. + * + * Requires the 'endFilePos' attribute to be enabled in the lexer (DISABLED by default). + * + * @return int File end position (or -1 if not available) + */ + public function getEndFilePos() : int { + return $this->attributes['endFilePos'] ?? -1; + } + + /** + * Gets all comments directly preceding this node. + * + * The comments are also available through the "comments" attribute. + * + * @return Comment[] + */ + public function getComments() : array { + return $this->attributes['comments'] ?? []; } /** * Gets the doc comment of the node. * - * The doc comment has to be the last comment associated with the node. - * * @return null|Comment\Doc Doc comment object or null */ public function getDocComment() { - $comments = $this->getAttribute('comments'); - if (!$comments) { - return null; + $comments = $this->getComments(); + for ($i = count($comments) - 1; $i >= 0; $i--) { + $comment = $comments[$i]; + if ($comment instanceof Comment\Doc) { + return $comment; + } } - $lastComment = $comments[count($comments) - 1]; - if (!$lastComment instanceof Comment\Doc) { - return null; - } - - return $lastComment; + return null; } /** @@ -80,41 +130,49 @@ abstract class NodeAbstract implements Node, \JsonSerializable * @param Comment\Doc $docComment Doc comment to set */ public function setDocComment(Comment\Doc $docComment) { - $comments = $this->getAttribute('comments', []); - - $numComments = count($comments); - if ($numComments > 0 && $comments[$numComments - 1] instanceof Comment\Doc) { - // Replace existing doc comment - $comments[$numComments - 1] = $docComment; - } else { - // Append new comment - $comments[] = $docComment; + $comments = $this->getComments(); + for ($i = count($comments) - 1; $i >= 0; $i--) { + if ($comments[$i] instanceof Comment\Doc) { + // Replace existing doc comment. + $comments[$i] = $docComment; + $this->setAttribute('comments', $comments); + return; + } } + // Append new doc comment. + $comments[] = $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) { - if (!array_key_exists($key, $this->attributes)) { - return $default; - } else { + public function getAttribute(string $key, $default = null) { + if (array_key_exists($key, $this->attributes)) { return $this->attributes[$key]; } + + return $default; } - public function getAttributes() { + public function getAttributes() : array { return $this->attributes; } - public function jsonSerialize() { + public function setAttributes(array $attributes) { + $this->attributes = $attributes; + } + + /** + * @return array + */ + public function jsonSerialize() : array { return ['nodeType' => $this->getType()] + get_object_vars($this); } } diff --git a/lib/nikic/php-parser/lib/PhpParser/NodeDumper.php b/lib/nikic/php-parser/lib/PhpParser/NodeDumper.php index 9946eb853..ba622efd1 100644 --- a/lib/nikic/php-parser/lib/PhpParser/NodeDumper.php +++ b/lib/nikic/php-parser/lib/PhpParser/NodeDumper.php @@ -1,4 +1,4 @@ -code = $code; return $this->dumpRecursive($node); } @@ -65,9 +65,9 @@ class NodeDumper } elseif (is_scalar($value)) { if ('flags' === $key || 'newModifier' === $key) { $r .= $this->dumpFlags($value); - } else if ('type' === $key && $node instanceof Include_) { + } elseif ('type' === $key && $node instanceof Include_) { $r .= $this->dumpIncludeType($value); - } else if ('type' === $key + } elseif ('type' === $key && ($node instanceof Use_ || $node instanceof UseUse || $node instanceof GroupUse)) { $r .= $this->dumpUseType($value); } else { @@ -78,7 +78,7 @@ class NodeDumper } } - if ($this->dumpComments && $comments = $node->getAttribute('comments')) { + if ($this->dumpComments && $comments = $node->getComments()) { $r .= "\n comments: " . str_replace("\n", "\n ", $this->dumpRecursive($comments)); } } elseif (is_array($node)) { @@ -128,6 +128,9 @@ class NodeDumper if ($flags & Class_::MODIFIER_FINAL) { $strs[] = 'MODIFIER_FINAL'; } + if ($flags & Class_::MODIFIER_READONLY) { + $strs[] = 'MODIFIER_READONLY'; + } if ($strs) { return implode(' | ', $strs) . ' (' . $flags . ')'; @@ -141,7 +144,7 @@ class NodeDumper Include_::TYPE_INCLUDE => 'TYPE_INCLUDE', Include_::TYPE_INCLUDE_ONCE => 'TYPE_INCLUDE_ONCE', Include_::TYPE_REQUIRE => 'TYPE_REQUIRE', - Include_::TYPE_REQUIRE_ONCE => 'TYPE_REQURE_ONCE', + Include_::TYPE_REQUIRE_ONCE => 'TYPE_REQUIRE_ONCE', ]; if (!isset($map[$type])) { @@ -164,18 +167,25 @@ class NodeDumper return $map[$type] . ' (' . $type . ')'; } + /** + * Dump node position, if possible. + * + * @param Node $node Node for which to dump position + * + * @return string|null Dump of position, or null if position information not available + */ protected function dumpPosition(Node $node) { if (!$node->hasAttribute('startLine') || !$node->hasAttribute('endLine')) { return null; } - $start = $node->getAttribute('startLine'); - $end = $node->getAttribute('endLine'); + $start = $node->getStartLine(); + $end = $node->getEndLine(); if ($node->hasAttribute('startFilePos') && $node->hasAttribute('endFilePos') && null !== $this->code ) { - $start .= ':' . $this->toColumn($this->code, $node->getAttribute('startFilePos')); - $end .= ':' . $this->toColumn($this->code, $node->getAttribute('endFilePos')); + $start .= ':' . $this->toColumn($this->code, $node->getStartFilePos()); + $end .= ':' . $this->toColumn($this->code, $node->getEndFilePos()); } return "[$start - $end]"; } diff --git a/lib/nikic/php-parser/lib/PhpParser/NodeTraverser.php b/lib/nikic/php-parser/lib/PhpParser/NodeTraverser.php index cce43d926..97d45bdaa 100644 --- a/lib/nikic/php-parser/lib/PhpParser/NodeTraverser.php +++ b/lib/nikic/php-parser/lib/PhpParser/NodeTraverser.php @@ -1,4 +1,4 @@ -visitors = array(); + // for BC } /** @@ -73,7 +79,7 @@ class NodeTraverser implements NodeTraverserInterface * * @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) { @@ -93,26 +99,46 @@ class NodeTraverser implements NodeTraverserInterface return $nodes; } - protected function traverseNode(Node $node) { + /** + * Recursively traverse a node. + * + * @param Node $node Node to traverse. + * + * @return Node Result of traversal (may be original node or new one) + */ + protected function traverseNode(Node $node) : Node { foreach ($node->getSubNodeNames() as $name) { $subNode =& $node->$name; - if (is_array($subNode)) { + if (\is_array($subNode)) { $subNode = $this->traverseArray($subNode); if ($this->stopTraversal) { break; } } elseif ($subNode instanceof Node) { $traverseChildren = true; - foreach ($this->visitors as $visitor) { + $breakVisitorIndex = null; + + foreach ($this->visitors as $visitorIndex => $visitor) { $return = $visitor->enterNode($subNode); - if (self::DONT_TRAVERSE_CHILDREN === $return) { - $traverseChildren = false; - } else if (self::STOP_TRAVERSAL === $return) { - $this->stopTraversal = true; - break 2; - } else if (null !== $return) { - $subNode = $return; + if (null !== $return) { + if ($return instanceof Node) { + $this->ensureReplacementReasonable($subNode, $return); + $subNode = $return; + } elseif (self::DONT_TRAVERSE_CHILDREN === $return) { + $traverseChildren = false; + } elseif (self::DONT_TRAVERSE_CURRENT_AND_CHILDREN === $return) { + $traverseChildren = false; + $breakVisitorIndex = $visitorIndex; + break; + } elseif (self::STOP_TRAVERSAL === $return) { + $this->stopTraversal = true; + break 2; + } else { + throw new \LogicException( + 'enterNode() returned invalid value of type ' . gettype($return) + ); + } } } @@ -123,19 +149,30 @@ class NodeTraverser implements NodeTraverserInterface } } - foreach ($this->visitors as $visitor) { + foreach ($this->visitors as $visitorIndex => $visitor) { $return = $visitor->leaveNode($subNode); - if (self::STOP_TRAVERSAL === $return) { - $this->stopTraversal = true; - break 2; - } else if (null !== $return) { - if (is_array($return)) { + + if (null !== $return) { + if ($return instanceof Node) { + $this->ensureReplacementReasonable($subNode, $return); + $subNode = $return; + } elseif (self::STOP_TRAVERSAL === $return) { + $this->stopTraversal = true; + break 2; + } elseif (\is_array($return)) { throw new \LogicException( 'leaveNode() may only return an array ' . 'if the parent structure is an array' ); + } else { + throw new \LogicException( + 'leaveNode() returned invalid value of type ' . gettype($return) + ); } - $subNode = $return; + } + + if ($breakVisitorIndex === $visitorIndex) { + break; } } } @@ -144,26 +181,41 @@ class NodeTraverser implements NodeTraverserInterface return $node; } - protected function traverseArray(array $nodes) { - $doNodes = array(); + /** + * Recursively traverse array (usually of nodes). + * + * @param array $nodes Array to traverse + * + * @return array Result of traversal (may be original array or changed one) + */ + protected function traverseArray(array $nodes) : array { + $doNodes = []; foreach ($nodes as $i => &$node) { - if (is_array($node)) { - $node = $this->traverseArray($node); - if ($this->stopTraversal) { - break; - } - } elseif ($node instanceof Node) { + if ($node instanceof Node) { $traverseChildren = true; - foreach ($this->visitors as $visitor) { + $breakVisitorIndex = null; + + foreach ($this->visitors as $visitorIndex => $visitor) { $return = $visitor->enterNode($node); - if (self::DONT_TRAVERSE_CHILDREN === $return) { - $traverseChildren = false; - } else if (self::STOP_TRAVERSAL === $return) { - $this->stopTraversal = true; - break 2; - } else if (null !== $return) { - $node = $return; + if (null !== $return) { + if ($return instanceof Node) { + $this->ensureReplacementReasonable($node, $return); + $node = $return; + } elseif (self::DONT_TRAVERSE_CHILDREN === $return) { + $traverseChildren = false; + } elseif (self::DONT_TRAVERSE_CURRENT_AND_CHILDREN === $return) { + $traverseChildren = false; + $breakVisitorIndex = $visitorIndex; + break; + } elseif (self::STOP_TRAVERSAL === $return) { + $this->stopTraversal = true; + break 2; + } else { + throw new \LogicException( + 'enterNode() returned invalid value of type ' . gettype($return) + ); + } } } @@ -174,22 +226,40 @@ class NodeTraverser implements NodeTraverserInterface } } - foreach ($this->visitors as $visitor) { + foreach ($this->visitors as $visitorIndex => $visitor) { $return = $visitor->leaveNode($node); - if (self::REMOVE_NODE === $return) { - $doNodes[] = array($i, array()); + if (null !== $return) { + if ($return instanceof Node) { + $this->ensureReplacementReasonable($node, $return); + $node = $return; + } elseif (\is_array($return)) { + $doNodes[] = [$i, $return]; + break; + } elseif (self::REMOVE_NODE === $return) { + $doNodes[] = [$i, []]; + break; + } elseif (self::STOP_TRAVERSAL === $return) { + $this->stopTraversal = true; + break 2; + } elseif (false === $return) { + throw new \LogicException( + 'bool(false) return from leaveNode() no longer supported. ' . + 'Return NodeTraverser::REMOVE_NODE instead' + ); + } else { + throw new \LogicException( + 'leaveNode() returned invalid value of type ' . gettype($return) + ); + } + } + + if ($breakVisitorIndex === $visitorIndex) { break; - } else if (self::STOP_TRAVERSAL === $return) { - $this->stopTraversal = true; - break 2; - } elseif (is_array($return)) { - $doNodes[] = array($i, $return); - break; - } elseif (null !== $return) { - $node = $return; } } + } elseif (\is_array($node)) { + throw new \LogicException('Invalid node structure: Contains nested arrays'); } } @@ -201,4 +271,21 @@ class NodeTraverser implements NodeTraverserInterface return $nodes; } + + private function ensureReplacementReasonable($old, $new) { + if ($old instanceof Node\Stmt && $new instanceof Node\Expr) { + throw new \LogicException( + "Trying to replace statement ({$old->getType()}) " . + "with expression ({$new->getType()}). Are you missing a " . + "Stmt_Expression wrapper?" + ); + } + + if ($old instanceof Node\Expr && $new instanceof Node\Stmt) { + throw new \LogicException( + "Trying to replace expression ({$old->getType()}) " . + "with statement ({$new->getType()})" + ); + } + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php b/lib/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php index 0f88e4671..77ff3d27f 100644 --- a/lib/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php +++ b/lib/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php @@ -1,4 +1,4 @@ - [aliasName => originalName]] */ - protected $aliases; - - /** @var ErrorHandler Error handler */ - protected $errorHandler; + /** @var NameContext Naming context */ + protected $nameContext; /** @var bool Whether to preserve original names */ protected $preserveOriginalNames; + /** @var bool Whether to replace resolved nodes in place, or to add resolvedNode attributes */ + protected $replaceNodes; + /** * Constructs a name resolution visitor. * - * Options: If "preserveOriginalNames" is enabled, an "originalName" attribute will be added to - * all name nodes that underwent resolution. + * Options: + * * preserveOriginalNames (default false): An "originalName" attribute will be added to + * all name nodes that underwent resolution. + * * replaceNodes (default true): Resolved names are replaced in-place. Otherwise, a + * resolvedName attribute is added. (Names that cannot be statically resolved receive a + * namespacedName attribute, as usual.) * * @param ErrorHandler|null $errorHandler Error handler * @param array $options Options */ public function __construct(ErrorHandler $errorHandler = null, array $options = []) { - $this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing; - $this->preserveOriginalNames = !empty($options['preserveOriginalNames']); + $this->nameContext = new NameContext($errorHandler ?? new ErrorHandler\Throwing); + $this->preserveOriginalNames = $options['preserveOriginalNames'] ?? false; + $this->replaceNodes = $options['replaceNodes'] ?? true; + } + + /** + * Get name resolution context. + * + * @return NameContext + */ + public function getNameContext() : NameContext { + return $this->nameContext; } public function beforeTraverse(array $nodes) { - $this->resetState(); + $this->nameContext->startNamespace(); + return null; } public function enterNode(Node $node) { if ($node instanceof Stmt\Namespace_) { - $this->resetState($node->name); + $this->nameContext->startNamespace($node->name); } elseif ($node instanceof Stmt\Use_) { foreach ($node->uses as $use) { $this->addAlias($use, $node->type, null); @@ -63,6 +75,7 @@ class NameResolver extends NodeVisitorAbstract $interface = $this->resolveClassName($interface); } + $this->resolveAttrGroups($node); if (null !== $node->name) { $this->addNamespacedName($node); } @@ -71,20 +84,43 @@ class NameResolver extends NodeVisitorAbstract $interface = $this->resolveClassName($interface); } + $this->resolveAttrGroups($node); $this->addNamespacedName($node); + } elseif ($node instanceof Stmt\Enum_) { + foreach ($node->implements as &$interface) { + $interface = $this->resolveClassName($interface); + } + + $this->resolveAttrGroups($node); + if (null !== $node->name) { + $this->addNamespacedName($node); + } } elseif ($node instanceof Stmt\Trait_) { + $this->resolveAttrGroups($node); $this->addNamespacedName($node); } elseif ($node instanceof Stmt\Function_) { - $this->addNamespacedName($node); $this->resolveSignature($node); + $this->resolveAttrGroups($node); + $this->addNamespacedName($node); } elseif ($node instanceof Stmt\ClassMethod || $node instanceof Expr\Closure + || $node instanceof Expr\ArrowFunction ) { $this->resolveSignature($node); + $this->resolveAttrGroups($node); + } elseif ($node instanceof Stmt\Property) { + if (null !== $node->type) { + $node->type = $this->resolveType($node->type); + } + $this->resolveAttrGroups($node); } elseif ($node instanceof Stmt\Const_) { foreach ($node->consts as $const) { $this->addNamespacedName($const); } + } else if ($node instanceof Stmt\ClassConst) { + $this->resolveAttrGroups($node); + } else if ($node instanceof Stmt\EnumCase) { + $this->resolveAttrGroups($node); } elseif ($node instanceof Expr\StaticCall || $node instanceof Expr\StaticPropertyFetch || $node instanceof Expr\ClassConstFetch @@ -100,10 +136,10 @@ class NameResolver extends NodeVisitorAbstract } } elseif ($node instanceof Expr\FuncCall) { if ($node->name instanceof Name) { - $node->name = $this->resolveOtherName($node->name, Stmt\Use_::TYPE_FUNCTION); + $node->name = $this->resolveName($node->name, Stmt\Use_::TYPE_FUNCTION); } } elseif ($node instanceof Expr\ConstFetch) { - $node->name = $this->resolveOtherName($node->name, Stmt\Use_::TYPE_CONSTANT); + $node->name = $this->resolveName($node->name, Stmt\Use_::TYPE_CONSTANT); } elseif ($node instanceof Stmt\TraitUse) { foreach ($node->traits as &$trait) { $trait = $this->resolveClassName($trait); @@ -121,70 +157,67 @@ class NameResolver extends NodeVisitorAbstract } } } + + return null; } - protected function resetState(Name $namespace = null) { - $this->namespace = $namespace; - $this->aliases = array( - Stmt\Use_::TYPE_NORMAL => array(), - Stmt\Use_::TYPE_FUNCTION => array(), - Stmt\Use_::TYPE_CONSTANT => array(), - ); - } - - protected function addAlias(Stmt\UseUse $use, $type, Name $prefix = null) { + private function addAlias(Stmt\UseUse $use, $type, Name $prefix = null) { // Add prefix for group uses $name = $prefix ? Name::concat($prefix, $use->name) : $use->name; // Type is determined either by individual element or whole use declaration $type |= $use->type; - // Constant names are case sensitive, everything else case insensitive - if ($type === Stmt\Use_::TYPE_CONSTANT) { - $aliasName = $use->alias; - } else { - $aliasName = strtolower($use->alias); - } - - if (isset($this->aliases[$type][$aliasName])) { - $typeStringMap = array( - Stmt\Use_::TYPE_NORMAL => '', - Stmt\Use_::TYPE_FUNCTION => 'function ', - Stmt\Use_::TYPE_CONSTANT => 'const ', - ); - - $this->errorHandler->handleError(new Error( - sprintf( - 'Cannot use %s%s as %s because the name is already in use', - $typeStringMap[$type], $name, $use->alias - ), - $use->getAttributes() - )); - return; - } - - $this->aliases[$type][$aliasName] = $name; + $this->nameContext->addAlias( + $name, (string) $use->getAlias(), $type, $use->getAttributes() + ); } /** @param Stmt\Function_|Stmt\ClassMethod|Expr\Closure $node */ private function resolveSignature($node) { foreach ($node->params as $param) { $param->type = $this->resolveType($param->type); + $this->resolveAttrGroups($param); } $node->returnType = $this->resolveType($node->returnType); } private function resolveType($node) { + if ($node instanceof Name) { + return $this->resolveClassName($node); + } if ($node instanceof Node\NullableType) { $node->type = $this->resolveType($node->type); return $node; } - if ($node instanceof Name) { - return $this->resolveClassName($node); + if ($node instanceof Node\UnionType) { + foreach ($node->types as &$type) { + $type = $this->resolveType($type); + } + return $node; } return $node; } - protected function resolveClassName(Name $name) { + /** + * Resolve name, according to name resolver options. + * + * @param Name $name Function or constant name to resolve + * @param int $type One of Stmt\Use_::TYPE_* + * + * @return Name Resolved name, or original name with attribute + */ + protected function resolveName(Name $name, int $type) : Name { + if (!$this->replaceNodes) { + $resolvedName = $this->nameContext->getResolvedName($name, $type); + if (null !== $resolvedName) { + $name->setAttribute('resolvedName', $resolvedName); + } else { + $name->setAttribute('namespacedName', FullyQualified::concat( + $this->nameContext->getNamespace(), $name, $name->getAttributes())); + } + return $name; + } + if ($this->preserveOriginalNames) { // Save the original name $originalName = $name; @@ -192,81 +225,33 @@ class NameResolver extends NodeVisitorAbstract $name->setAttribute('originalName', $originalName); } - // don't resolve special class names - if (in_array(strtolower($name->toString()), array('self', 'parent', 'static'))) { - if (!$name->isUnqualified()) { - $this->errorHandler->handleError(new Error( - sprintf("'\\%s' is an invalid class name", $name->toString()), - $name->getAttributes() - )); - } - return $name; + $resolvedName = $this->nameContext->getResolvedName($name, $type); + if (null !== $resolvedName) { + return $resolvedName; } - // fully qualified names are already resolved - if ($name->isFullyQualified()) { - return $name; - } - - $aliasName = strtolower($name->getFirst()); - if (!$name->isRelative() && isset($this->aliases[Stmt\Use_::TYPE_NORMAL][$aliasName])) { - // resolve aliases (for non-relative names) - $alias = $this->aliases[Stmt\Use_::TYPE_NORMAL][$aliasName]; - return FullyQualified::concat($alias, $name->slice(1), $name->getAttributes()); - } - - // if no alias exists prepend current namespace - return FullyQualified::concat($this->namespace, $name, $name->getAttributes()); + // unqualified names inside a namespace cannot be resolved at compile-time + // add the namespaced version of the name as an attribute + $name->setAttribute('namespacedName', FullyQualified::concat( + $this->nameContext->getNamespace(), $name, $name->getAttributes())); + return $name; } - protected function resolveOtherName(Name $name, $type) { - if ($this->preserveOriginalNames) { - // Save the original name - $originalName = $name; - $name = clone $originalName; - $name->setAttribute('originalName', $originalName); - } - - // fully qualified names are already resolved - if ($name->isFullyQualified()) { - return $name; - } - - // resolve aliases for qualified names - $aliasName = strtolower($name->getFirst()); - if ($name->isQualified() && isset($this->aliases[Stmt\Use_::TYPE_NORMAL][$aliasName])) { - $alias = $this->aliases[Stmt\Use_::TYPE_NORMAL][$aliasName]; - return FullyQualified::concat($alias, $name->slice(1), $name->getAttributes()); - } - - if ($name->isUnqualified()) { - if ($type === Stmt\Use_::TYPE_CONSTANT) { - // constant aliases are case-sensitive, function aliases case-insensitive - $aliasName = $name->getFirst(); - } - - if (isset($this->aliases[$type][$aliasName])) { - // resolve unqualified aliases - return new FullyQualified($this->aliases[$type][$aliasName], $name->getAttributes()); - } - - if (null === $this->namespace) { - // outside of a namespace unaliased unqualified is same as fully qualified - return new FullyQualified($name, $name->getAttributes()); - } - - // unqualified names inside a namespace cannot be resolved at compile-time - // add the namespaced version of the name as an attribute - $name->setAttribute('namespacedName', - FullyQualified::concat($this->namespace, $name, $name->getAttributes())); - return $name; - } - - // if no alias exists prepend current namespace - return FullyQualified::concat($this->namespace, $name, $name->getAttributes()); + protected function resolveClassName(Name $name) { + return $this->resolveName($name, Stmt\Use_::TYPE_NORMAL); } protected function addNamespacedName(Node $node) { - $node->namespacedName = Name::concat($this->namespace, $node->name); + $node->namespacedName = Name::concat( + $this->nameContext->getNamespace(), (string) $node->name); + } + + protected function resolveAttrGroups(Node $node) + { + foreach ($node->attrGroups as $attrGroup) { + foreach ($attrGroup->attrs as $attr) { + $attr->name = $this->resolveClassName($attr->name); + } + } } } diff --git a/lib/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php b/lib/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php index 3e1743a74..d378d6709 100644 --- a/lib/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php +++ b/lib/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php @@ -1,4 +1,4 @@ -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/nikic/php-parser/lib/PhpParser/Parser/Php5.php b/lib/nikic/php-parser/lib/PhpParser/Parser/Php5.php index 4fbddaa70..c62adfd2c 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Parser/Php5.php +++ b/lib/nikic/php-parser/lib/PhpParser/Parser/Php5.php @@ -17,21 +17,22 @@ use PhpParser\Node\Stmt; */ class Php5 extends \PhpParser\ParserAbstract { - protected $tokenToSymbolMapSize = 392; - protected $actionTableSize = 1077; - protected $gotoTableSize = 591; + protected $tokenToSymbolMapSize = 396; + protected $actionTableSize = 1093; + protected $gotoTableSize = 643; - protected $invalidSymbol = 157; + protected $invalidSymbol = 168; protected $errorSymbol = 1; protected $defaultAction = -32766; protected $unexpectedTokenRule = 32767; - protected $YY2TBLSTATE = 407; - protected $YYNLSTATES = 669; + protected $YY2TBLSTATE = 415; + protected $numNonLeafStates = 662; protected $symbolToName = array( "EOF", "error", + "T_THROW", "T_INCLUDE", "T_INCLUDE_ONCE", "T_EVAL", @@ -58,6 +59,7 @@ class Php5 extends \PhpParser\ParserAbstract "T_SL_EQUAL", "T_SR_EQUAL", "T_POW_EQUAL", + "T_COALESCE_EQUAL", "'?'", "':'", "T_COALESCE", @@ -65,7 +67,8 @@ class Php5 extends \PhpParser\ParserAbstract "T_BOOLEAN_AND", "'|'", "'^'", - "'&'", + "T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG", + "T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG", "T_IS_EQUAL", "T_IS_NOT_EQUAL", "T_IS_IDENTICAL", @@ -126,6 +129,7 @@ class Php5 extends \PhpParser\ParserAbstract "T_ENDDECLARE", "T_AS", "T_SWITCH", + "T_MATCH", "T_ENDSWITCH", "T_CASE", "T_DEFAULT", @@ -133,12 +137,12 @@ class Php5 extends \PhpParser\ParserAbstract "T_CONTINUE", "T_GOTO", "T_FUNCTION", + "T_FN", "T_CONST", "T_RETURN", "T_TRY", "T_CATCH", "T_FINALLY", - "T_THROW", "T_USE", "T_INSTEADOF", "T_GLOBAL", @@ -178,6 +182,9 @@ class Php5 extends \PhpParser\ParserAbstract "T_DIR", "T_NS_SEPARATOR", "T_ELLIPSIS", + "T_NAME_FULLY_QUALIFIED", + "T_NAME_QUALIFIED", + "T_NAME_RELATIVE", "';'", "'{'", "'}'", @@ -186,671 +193,693 @@ class Php5 extends \PhpParser\ParserAbstract "'$'", "'`'", "']'", - "'\"'" + "'\"'", + "T_READONLY", + "T_ENUM", + "T_NULLSAFE_OBJECT_OPERATOR", + "T_ATTRIBUTE" ); protected $tokenToSymbol = array( - 0, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 53, 156, 157, 153, 52, 35, 157, - 151, 152, 50, 47, 7, 48, 49, 51, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 29, 148, - 41, 15, 43, 28, 65, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 67, 157, 155, 34, 157, 154, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 149, 33, 150, 55, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 1, 2, 3, 4, - 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, + 0, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 56, 163, 168, 160, 55, 168, 168, + 158, 159, 53, 50, 8, 51, 52, 54, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 31, 155, + 44, 16, 46, 30, 68, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 70, 168, 162, 36, 168, 161, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 156, 35, 157, 58, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 1, 2, 3, 4, + 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 30, 31, 32, 36, 37, 38, 39, 40, 42, - 44, 45, 46, 54, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 66, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 77, 78, 79, 80, 81, 157, 157, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + 27, 28, 29, 32, 33, 34, 37, 38, 39, 40, + 41, 42, 43, 45, 47, 48, 49, 57, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 69, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, + 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 164, + 122, 123, 124, 125, 126, 127, 128, 129, 165, 130, + 131, 132, 166, 133, 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, + 150, 151, 152, 153, 154, 167 + ); + + protected $action = array( + 699, 669, 670, 671, 672, 673, 286, 674, 675, 676, + 712, 713, 223, 224, 225, 226, 227, 228, 229, 230, + 231, 232, 0, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244,-32766,-32766,-32766,-32766,-32766, + -32766,-32766,-32766,-32766,-32767,-32767,-32767,-32767, 245, 246, + 242, 243, 244,-32766,-32766, 677,-32766, 750,-32766,-32766, + -32766,-32766,-32766,-32766,-32766, 1224, 245, 246, 1225, 678, + 679, 680, 681, 682, 683, 684,-32766, 48, 746,-32766, + -32766,-32766,-32766,-32766,-32766, 685, 686, 687, 688, 689, + 690, 691, 692, 693, 694, 695, 715, 738, 716, 717, + 718, 719, 707, 708, 709, 737, 710, 711, 696, 697, + 698, 700, 701, 702, 740, 741, 742, 743, 744, 745, + 703, 704, 705, 706, 736, 727, 725, 726, 722, 723, + 751, 714, 720, 721, 728, 729, 731, 730, 732, 733, + 55, 56, 425, 57, 58, 724, 735, 734, 1073, 59, + 60, -224, 61,-32766,-32766,-32766,-32766,-32766,-32766,-32766, + -32766,-32766,-32766, 121,-32767,-32767,-32767,-32767, 29, 107, + 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, + 118, 119, 1043, 766, 1071, 767, 580, 62, 63,-32766, + -32766,-32766,-32766, 64, 516, 65, 294, 295, 66, 67, + 68, 69, 70, 71, 72, 73, 822, 25, 302, 74, + 418, 981, 983, 1043, 1181, 1095, 1096, 1073, 748, 754, + 1075, 1074, 1076, 469,-32766,-32766,-32766, 337, 823, 54, + -32767,-32767,-32767,-32767, 98, 99, 100, 101, 102, 220, + 221, 222, 78, 361, 1107,-32766, 341,-32766,-32766,-32766, + -32766,-32766, 1107, 492, 949, 950, 951, 948, 947, 946, + 207, 477, 478, 949, 950, 951, 948, 947, 946, 1043, + 479, 480, 52, 1101, 1102, 1103, 1104, 1098, 1099, 319, + 872, 668, 667, 27, -511, 1105, 1100,-32766, 130, 1075, + 1074, 1076, 345, 668, 667, 41, 126, 341, 334, 369, + 336, 426, -128, -128, -128, 896, 897, 468, 220, 221, + 222, 811, 1195, 619, 40, 21, 427, -128, 470, -128, + 471, -128, 472, -128, 802, 428, -4, 823, 54, 207, + 33, 34, 429, 360, 317, 28, 35, 473,-32766,-32766, + -32766, 211, 356, 357, 474, 475,-32766,-32766,-32766, 754, + 476, 49, 313, 794, 843, 430, 431, 289, 125,-32766, + 813,-32766,-32766,-32766,-32766,-32766,-32766,-32766,-32767,-32767, + -32767,-32767,-32767,-32766,-32766,-32766, 769, 103, 104, 105, + 327, 307, 825, 633, -128, 1075, 1074, 1076, 221, 222, + 927, 748, 1146, 106,-32766, 129,-32766,-32766,-32766,-32766, + 426, 823, 54, 902, 873, 302, 468, 75, 207, 359, + 811, 668, 667, 40, 21, 427, 754, 470, 754, 471, + 423, 472, 1043, 127, 428, 435, 1043, 341, 1043, 33, + 34, 429, 360, 1181, 415, 35, 473, 122, 10, 315, + 128, 356, 357, 474, 475,-32766,-32766,-32766, 768, 476, + 668, 667, 758, 843, 430, 431, 754, 1043, 1147,-32766, + -32766,-32766, 754, 419, 342, 1215,-32766, 131,-32766,-32766, + -32766, 341, 363, 346, 426, 823, 54, 100, 101, 102, + 468, 825, 633, -4, 811, 442, 903, 40, 21, 427, + 754, 470, 435, 471, 341, 472, 341, 766, 428, 767, + -209, -209, -209, 33, 34, 429, 360, 479, 1196, 35, + 473, 345,-32766,-32766,-32766, 356, 357, 474, 475, 220, + 221, 222, 421, 476, 32, 297, 794, 843, 430, 431, + 754, 754, 435,-32766, 341,-32766,-32766, 9, 300, 51, + 207, 249, 324, 753, 120, 220, 221, 222, 426, 30, + 247, 941, 422, 424, 468, 825, 633, -209, 811, 1043, + 1061, 40, 21, 427, 129, 470, 207, 471, 341, 472, + 804, 20, 428, 124, -208, -208, -208, 33, 34, 429, + 360, 479, 212, 35, 473, 923, -259, 823, 54, 356, + 357, 474, 475,-32766,-32766,-32766, 1043, 476, 213, 806, + 794, 843, 430, 431,-32766,-32766, 435, 435, 341, 341, + 443, 79, 80, 81,-32766, 668, 667, 636, 344, 808, + 668, 667, 239, 240, 241, 123, 214, 538, 250, 825, + 633, -208, 36, 251, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, + 98, 99, 100, 101, 102, 103, 104, 105, 252, 307, + 426, 220, 221, 222, 823, 54, 468,-32766, 222, 765, + 811, 106, 134, 40, 21, 427, 571, 470, 207, 471, + 445, 472, 207,-32766, 428, 896, 897, 207, 307, 33, + 34, 429, 245, 246, 637, 35, 473, 452, 22, 809, + 922, 356, 357, 457, 588, 135, 374, 595, 596, 476, + -228, 759, 639, 938, 653, 926, 661, -86, 823, 54, + 314, 644, 647, 821, 133, 836, 43, 106, 603, 44, + 45, 46, 47, 748, 50, 53, 132, 426, 302,-32766, + 520, 825, 633, 468, -84, 607, 577, 811, 641, 362, + 40, 21, 427, -278, 470, 754, 471, 954, 472, 441, + 627, 428, 823, 54, 574, 844, 33, 34, 429, 11, + 615, 845, 35, 473, 444, 461, 285, -511, 356, 357, + 592, -419, 593, 1106, 1153, -410, 476, 368, 838, 38, + 658, 426, 645, 795, 1052, 0, 325, 468, 0,-32766, + 0, 811, 0, 0, 40, 21, 427, 0, 470, 0, + 471, 0, 472, 0, 322, 428, 823, 54, 825, 633, + 33, 34, 429, 0, 326, 0, 35, 473, 323, 0, + 316, 318, 356, 357, -512, 426, 0, 753, 531, 0, + 476, 468, 6, 0, 0, 811, 650, 7, 40, 21, + 427, 12, 470, 14, 471, 373, 472, -420, 562, 428, + 823, 54, 78, -225, 33, 34, 429, 39, 656, 657, + 35, 473, 859, 633, 764, 812, 356, 357, 820, 799, + 814, 875, 866, 867, 476, 797, 860, 857, 855, 426, + 933, 934, 931, 819, 803, 468, 805, 807, 810, 811, + 930, 762, 40, 21, 427, 763, 470, 932, 471, 335, + 472, 358, 634, 428, 638, 640, 825, 633, 33, 34, + 429, 642, 643, 646, 35, 473, 648, 649, 651, 652, + 356, 357, 635, 426, 1221, 1223, 761, 842, 476, 468, + 248, 760, 841, 811, 1222, 840, 40, 21, 427, 1057, + 470, 830, 471, 1045, 472, 839, 1046, 428, 828, 215, + 216, 939, 33, 34, 429, 217, 864, 218, 35, 473, + 825, 633, 24, 865, 356, 357, 456, 1220, 1189, 209, + 1187, 1172, 476, 1185, 215, 216, 1086, 1095, 1096, 914, + 217, 1193, 218, 1183, -224, 1097, 26, 31, 37, 42, + 76, 77, 210, 288, 209, 292, 293, 308, 309, 310, + 311, 339, 1095, 1096, 825, 633, 355, 291, 416, 1152, + 1097, 16, 17, 18, 393, 453, 460, 462, 466, 552, + 624, 1048, 1051, 904, 1111, 1047, 1023, 563, 1022, 1088, + 0, 0, -429, 558, 1041, 1101, 1102, 1103, 1104, 1098, + 1099, 398, 1054, 1053, 1056, 1055, 1070, 1105, 1100, 1186, + 1171, 1167, 1184, 1085, 1218, 1112, 1166, 219, 558, 599, + 1101, 1102, 1103, 1104, 1098, 1099, 398, 0, 0, 0, + 0, 0, 1105, 1100, 0, 0, 0, 0, 0, 0, + 0, 0, 219 + ); + + protected $actionCheck = array( + 2, 3, 4, 5, 6, 7, 14, 9, 10, 11, + 12, 13, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 0, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 9, 10, 11, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 69, 70, + 53, 54, 55, 9, 10, 57, 30, 80, 32, 33, + 34, 35, 36, 37, 38, 80, 69, 70, 83, 71, + 72, 73, 74, 75, 76, 77, 9, 70, 80, 33, + 34, 35, 36, 37, 38, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, - 132, 133, 134, 135, 136, 137, 157, 157, 157, 157, - 157, 157, 138, 139, 140, 141, 142, 143, 144, 145, - 146, 147 - ); - - protected $action = array( - 674, 675, 676, 677, 678,-32766, 679, 680, 681, 717, - 718, 218, 219, 220, 221, 222, 223, 224, 225, 226, - 0, 227, 228, 229, 230, 231, 232, 233, 234, 235, - 236, 237, 238,-32766,-32766,-32766,-32766,-32766,-32766,-32766, - -32766,-32767,-32767,-32767,-32767, 442, 239, 240,-32766,-32766, - -32766,-32766, 682,-32766, 308,-32766,-32766,-32766,-32766,-32766, - -32766,-32767,-32767,-32767,-32767,-32767, 683, 684, 685, 686, - 687, 688, 689, 1174, 462, 749,-32766,-32766,-32766,-32766, - -32766, 25, 690, 691, 692, 693, 694, 695, 696, 697, - 698, 699, 700, 720, 721, 722, 723, 724, 712, 713, - 714, 715, 716, 701, 702, 703, 704, 705, 706, 707, - 743, 744, 745, 746, 747, 748, 708, 709, 710, 711, - 741, 732, 730, 731, 727, 728, 520, 719, 725, 726, - 733, 734, 736, 735, 737, 738, 54, 55, 422, 56, - 57, 729, 740, 739, 421, 58, 59, 341, 60,-32766, - -32766,-32766,-32766,-32766,-32766,-32766,-32766,-32766, 9,-32767, - -32767,-32767,-32767, 52, 327,-32766, 331, 947, 948, 949, - 946, 945, 944, 939, 1215, 29, 1217, 1216, 765, 766, - 823, 61, 62, 1101, -269, 1180, 764, 63, 1174, 64, - 293, 294, 65, 66, 67, 68, 69, 70, 71, 72, - 129, 26, 301, 73, 415,-32766,-32766,-32766,-32766, 1089, - 1090, 751, 635, 1180,-32766, 920, 206, 466,-32766,-32766, - -32766, 824, 409,-32766, 313,-32766, 902,-32766,-32766,-32766, - -32766,-32766,-32766, 215, 216, 217, 430,-32766,-32766,-32766, - -32766,-32766,-32766,-32766,-32766, 122, 493, 947, 948, 949, - 946, 945, 944, 202, 475, 476, 284, 625, 127, 336, - 895, 896, 341, 479, 480, 1187, 1095, 1096, 1097, 1098, - 1092, 1093, 309, 494, 10, 443, 427, 494, 1099, 1094, - 427, 587, -220, 1212, 123, 41, 449, 336, 323, 1056, - 324, 423, -122, -122, -122, -4, 824, 465, 101, 102, - 103, 813, 303, 282, 40, 21, 424, -122, 467, -122, - 468, -122, 469, -122, 104, 425, 215, 216, 217, 30, - 31, 470, 426, 626, 32, 471, 427, 814, 74, 871, - 925, 351, 352, 472, 473, 358, 202, 243, 1101, 474, - 414, 1184, 795, 842, 477, 478, 300, 236, 237, 238, - 35, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 239, 240, 1038, 423, 350, 826, 640, - -122, 824, 465, 215, 216, 217, 813, 1140, 241, 40, - 21, 424, 48, 467, 440, 468, 334, 469, 297, 1038, - 425, 977, 979, 202, 30, 31, 470, 426, 416, 32, - 471, 1188, 1038, 74, 322, 1038, 351, 352, 472, 473, - -32766,-32766,-32766, 128, 474, 921, 811, 757, 842, 477, - 478,-32767,-32767,-32767,-32767, 96, 97, 98, 99, 100, - -32766, 20,-32766,-32766,-32766,-32766, 895, 896, 335, 1038, - 479, 423, -216, 826, 640, -4, 824, 465, 872, 494, - 1207, 813, 427, 1206, 40, 21, 424, 299, 467, 121, - 468, 1038, 469, -497, 118, 425, -201, -201, -201, 30, - 31, 470, 426, 297, 32, 471, 810, 911, 74, 216, - 217, 351, 352, 472, 473,-32766,-32766,-32766, 36, 474, - 51, 340, 795, 842, 477, 478, 207, 751, 202, 1180, - 126,-32766,-32766,-32766, 441,-32766, 417,-32766,-32766,-32766, - 49, 33, 296,-32766,-32766,-32766, 423, 208, 826, 640, - -201,-32766, 465,-32766,-32766, 807, 813, 379, 117, 40, - 21, 424, 1066, 467,-32766, 468, 217, 469, 805, 245, - 425, -200, -200, -200, 30, 31, 470, 426, 1038, 32, - 471, 286, 548, 74, 202, 824, 351, 352, 472, 473, - -32766,-32766,-32766, 494, 474, 125, 427, 795, 842, 477, - 478, 431, 120, 336, 1038, 803, 78, 79, 80, 494, - -32766, 436, 427, 646, 642, 126,-32766,-32766,-32766, 244, - 901, 246, 119, 826, 640, -200, 34, 298, 81, 82, - 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, - 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, - 103, 209, 303, 202, 824, 423, 822, 1038, 215, 216, - 217, 465, 131, 130, 104, 813, 578, 1038, 40, 21, - 424, 650, 467, 835, 468, 647, 469, 315, 202, 425, - 285, 104, 643, 30, 31, 470, 824,-32766, 32, 471, - 295, 303, 74,-32766,-32766, 351, 352, 215, 216, 217, - -32766,-32766, 50, 474, 98, 99, 100, 233, 234, 235, - 239, 240, 456, 593, 644, 451, 22, 202, 132, 359, - 765, 766, 601, 602, 423, 758, 645, 924, 668, 301, - 465, 47, 858, 640, 813, 936, 656, 40, 21, 424, - 43, 467, 46, 468, 45, 469, 44, 53, 425, 751, - 607, 514, 30, 31, 470, 824, 423, 32, 471, 778, - 752, 74, 465, 437, 351, 352, 813, 535, 519, 40, - 21, 424, 474, 467, 536, 468, 1210, 469, 515, 435, - 425, 439, 518, 648, 30, 31, 470, 824, 624, 32, - 471, 614, 604, 74, 1059, 581, 351, 352,-32766, 526, - 634, 826, 640, 611, 474, 1139, 460, 434, 281, 621, - 328, 844, 314, 539, 14, 653, -80, 597, 837, 584, - 330, 843, 325, -398, 395, 423, 1146, 0, 0, 0, - 0, 465, 1100, 826, 640, 813, 598, 0, 40, 21, - 424, 0, 467, 0, 468, 0, 469, 0, 372, 425, - 0, 326, 0, 30, 31, 470, 824, 423, 32, 471, - 312, -498, 74, 465, -497, 351, 352, 813, 479, 0, - 40, 21, 424, 474, 467, 374, 468, 5, 469, 6, - 11, 425, -407, 13, -406, 30, 31, 470, 1036, 386, - 32, 471, 411, 410, 74, 387, 528, 351, 352, 436, - 856, 1213, 826, 640, 866, 474, 865, 874, 815, 800, - 821, 809, 763, 661, 660, 39, 38, 854, 931, 932, - 929, 859, 930, 820, 808, 761, 423, 928, 806, 804, - 798, 812, 465, 762, 826, 640, 813, 649, 77, 40, - 21, 424, 651, 467, 652, 468, 242, 469, 654, 655, - 425, 658, 663, 664, 30, 31, 470, 665, 124, 32, - 471, 332, 333, 74, 210, 211, 351, 352, 407, 641, - 212, 408, 213, 768, 474, 767, 864, 455, 1211, 1181, - 1179, 1165, 1177, 1080, 204, 913, 1185, 1175, 838, 210, - 211, 1040, 1089, 1090, 1041, 212,-32766, 213, 829, 863, - 1091, 1052, 759, 826, 640, 306, 839, 840, 760, 204, - 1214, 796, 662, 841, 770, 769, 937, 1089, 1090, 831, - 1042,-32766, 305, 304, 24, 1091, 27, 292, 291, 283, - 307, 338, 413, 419, 28, 205, 37, 42, 76, 75, - -32766, 0, 1018, 1017, 1082, 571, -216, 567, 1105, 1095, - 1096, 1097, 1098, 1092, 1093, 385, 903, 1046, 1043, 631, - 561, 1099, 1094, 463, 459, 457, 452, 380, 214, 0, - -32766, 18, 567, -217, 1095, 1096, 1097, 1098, 1092, 1093, - 385, 17, 16, 605, 0, -416, 1099, 1094, 1160, 1159, - 1106, 1209, 1079, 214, 1176,-32766, 1047, 0, 1164, 1178, - 1065, 1050, 1051, 1048, 1049, 0, 1145 - ); - - protected $actionCheck = array( - 2, 3, 4, 5, 6, 8, 8, 9, 10, 11, - 12, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 0, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 8, 9, 10, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 7, 66, 67, 31, 32, - 33, 34, 54, 28, 7, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 68, 69, 70, 71, - 72, 73, 74, 79, 7, 77, 31, 32, 33, 34, - 35, 7, 84, 85, 86, 87, 88, 89, 90, 91, - 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 123, 124, 125, 126, 127, 82, 129, 130, 131, - 132, 133, 134, 135, 136, 137, 2, 3, 4, 5, - 6, 143, 144, 145, 7, 11, 12, 153, 14, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 103, 41, - 42, 43, 44, 67, 109, 79, 7, 112, 113, 114, - 115, 116, 117, 118, 77, 7, 79, 80, 102, 103, - 1, 47, 48, 139, 79, 79, 148, 53, 79, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 67, 67, 68, 69, 70, 8, 9, 10, 103, 75, - 76, 77, 77, 79, 109, 148, 7, 83, 8, 9, - 10, 1, 146, 118, 128, 28, 152, 30, 31, 32, - 33, 34, 35, 8, 9, 10, 102, 151, 28, 153, - 30, 31, 32, 33, 34, 149, 112, 112, 113, 114, - 115, 116, 117, 28, 120, 121, 7, 77, 149, 153, - 130, 131, 153, 129, 130, 1, 132, 133, 134, 135, - 136, 137, 138, 143, 7, 7, 146, 143, 144, 145, - 146, 82, 152, 150, 7, 151, 7, 153, 154, 152, - 156, 71, 72, 73, 74, 0, 1, 77, 50, 51, - 52, 81, 54, 13, 84, 85, 86, 87, 88, 89, - 90, 91, 92, 93, 66, 95, 8, 9, 10, 99, - 100, 101, 102, 143, 104, 105, 146, 148, 108, 29, - 150, 111, 112, 113, 114, 7, 28, 29, 139, 119, - 7, 77, 122, 123, 124, 125, 35, 50, 51, 52, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 66, 67, 12, 71, 7, 148, 149, - 150, 1, 77, 8, 9, 10, 81, 152, 13, 84, - 85, 86, 67, 88, 29, 90, 7, 92, 35, 12, - 95, 56, 57, 28, 99, 100, 101, 102, 103, 104, - 105, 152, 12, 108, 109, 12, 111, 112, 113, 114, - 8, 9, 10, 149, 119, 148, 148, 122, 123, 124, - 125, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 28, 152, 30, 31, 32, 33, 130, 131, 143, 12, - 129, 71, 152, 148, 149, 150, 1, 77, 148, 143, - 79, 81, 146, 82, 84, 85, 86, 7, 88, 13, - 90, 12, 92, 128, 149, 95, 96, 97, 98, 99, - 100, 101, 102, 35, 104, 105, 148, 79, 108, 9, - 10, 111, 112, 113, 114, 8, 9, 10, 13, 119, - 67, 67, 122, 123, 124, 125, 15, 77, 28, 79, - 147, 8, 9, 10, 149, 28, 123, 30, 31, 32, - 67, 140, 141, 8, 9, 10, 71, 15, 148, 149, - 150, 28, 77, 30, 31, 148, 81, 78, 15, 84, - 85, 86, 112, 88, 151, 90, 10, 92, 148, 15, - 95, 96, 97, 98, 99, 100, 101, 102, 12, 104, - 105, 153, 128, 108, 28, 1, 111, 112, 113, 114, - 8, 9, 10, 143, 119, 29, 146, 122, 123, 124, - 125, 151, 149, 153, 12, 148, 8, 9, 10, 143, - 28, 146, 146, 29, 149, 147, 31, 32, 33, 15, - 152, 15, 149, 148, 149, 150, 28, 35, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 15, 54, 28, 1, 71, 29, 12, 8, 9, - 10, 77, 149, 29, 66, 81, 153, 12, 84, 85, - 86, 29, 88, 35, 90, 29, 92, 29, 28, 95, - 35, 66, 29, 99, 100, 101, 1, 31, 104, 105, - 35, 54, 108, 31, 32, 111, 112, 8, 9, 10, - 8, 9, 67, 119, 47, 48, 49, 47, 48, 49, - 66, 67, 72, 73, 29, 72, 73, 28, 97, 98, - 102, 103, 106, 107, 71, 148, 149, 148, 149, 68, - 77, 67, 148, 149, 81, 148, 149, 84, 85, 86, - 67, 88, 67, 90, 67, 92, 67, 67, 95, 77, - 74, 77, 99, 100, 101, 1, 71, 104, 105, 77, - 77, 108, 77, 77, 111, 112, 81, 77, 77, 84, - 85, 86, 119, 88, 77, 90, 77, 92, 77, 77, - 95, 86, 79, 29, 99, 100, 101, 1, 79, 104, - 105, 79, 79, 108, 79, 87, 111, 112, 82, 82, - 89, 148, 149, 93, 119, 155, 102, 102, 94, 91, - 110, 123, 128, 94, 94, 29, 94, 96, 147, 96, - 126, 123, 126, 142, 146, 71, 139, -1, -1, -1, - -1, 77, 139, 148, 149, 81, 109, -1, 84, 85, - 86, -1, 88, -1, 90, -1, 92, -1, 142, 95, - -1, 127, -1, 99, 100, 101, 1, 71, 104, 105, - 128, 128, 108, 77, 128, 111, 112, 81, 129, -1, - 84, 85, 86, 119, 88, 146, 90, 142, 92, 142, - 142, 95, 142, 142, 142, 99, 100, 101, 154, 146, - 104, 105, 146, 146, 108, 146, 146, 111, 112, 146, - 148, 150, 148, 149, 148, 119, 148, 148, 148, 148, - 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - 148, 148, 148, 148, 148, 148, 71, 148, 148, 148, - 148, 148, 77, 148, 148, 149, 81, 149, 149, 84, - 85, 86, 149, 88, 149, 90, 29, 92, 149, 149, - 95, 149, 149, 149, 99, 100, 101, 149, 149, 104, - 105, 149, 149, 108, 47, 48, 111, 112, 149, 149, - 53, 149, 55, 150, 119, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 67, 150, 150, 150, 150, 47, - 48, 150, 75, 76, 150, 53, 79, 55, 150, 150, - 83, 150, 150, 148, 149, 151, 150, 150, 150, 67, - 150, 150, 150, 150, 150, 150, 150, 75, 76, 150, - 152, 79, 151, 151, 151, 83, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, -1, 152, 152, 152, 152, 152, 130, 152, 132, - 133, 134, 135, 136, 137, 138, 152, 152, 152, 152, - 152, 144, 145, 152, 152, 152, 152, 152, 151, -1, - 153, 152, 130, 152, 132, 133, 134, 135, 136, 137, - 138, 152, 152, 155, -1, 154, 144, 145, 155, 155, - 155, 155, 155, 151, 155, 153, 155, -1, 155, 155, - 155, 155, 155, 155, 155, -1, 156 + 153, 133, 134, 135, 136, 137, 138, 139, 140, 141, + 3, 4, 5, 6, 7, 147, 148, 149, 80, 12, + 13, 159, 15, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 156, 44, 45, 46, 47, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 13, 106, 116, 108, 85, 50, 51, 33, + 34, 35, 36, 56, 85, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 1, 70, 71, 72, + 73, 59, 60, 13, 82, 78, 79, 80, 80, 82, + 152, 153, 154, 86, 9, 10, 11, 8, 1, 2, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 9, + 10, 11, 156, 106, 143, 30, 160, 32, 33, 34, + 35, 36, 143, 116, 116, 117, 118, 119, 120, 121, + 30, 124, 125, 116, 117, 118, 119, 120, 121, 13, + 133, 134, 70, 136, 137, 138, 139, 140, 141, 142, + 31, 37, 38, 8, 132, 148, 149, 116, 156, 152, + 153, 154, 160, 37, 38, 158, 8, 160, 161, 8, + 163, 74, 75, 76, 77, 134, 135, 80, 9, 10, + 11, 84, 1, 80, 87, 88, 89, 90, 91, 92, + 93, 94, 95, 96, 155, 98, 0, 1, 2, 30, + 103, 104, 105, 106, 132, 8, 109, 110, 9, 10, + 11, 8, 115, 116, 117, 118, 9, 10, 11, 82, + 123, 70, 8, 126, 127, 128, 129, 8, 156, 30, + 155, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 9, 10, 11, 157, 53, 54, 55, + 8, 57, 155, 156, 157, 152, 153, 154, 10, 11, + 157, 80, 162, 69, 30, 151, 32, 33, 34, 35, + 74, 1, 2, 159, 155, 71, 80, 151, 30, 8, + 84, 37, 38, 87, 88, 89, 82, 91, 82, 93, + 8, 95, 13, 156, 98, 158, 13, 160, 13, 103, + 104, 105, 106, 82, 108, 109, 110, 156, 8, 113, + 31, 115, 116, 117, 118, 9, 10, 11, 157, 123, + 37, 38, 126, 127, 128, 129, 82, 13, 159, 33, + 34, 35, 82, 127, 8, 85, 30, 156, 32, 33, + 34, 160, 8, 147, 74, 1, 2, 50, 51, 52, + 80, 155, 156, 157, 84, 31, 159, 87, 88, 89, + 82, 91, 158, 93, 160, 95, 160, 106, 98, 108, + 100, 101, 102, 103, 104, 105, 106, 133, 159, 109, + 110, 160, 9, 10, 11, 115, 116, 117, 118, 9, + 10, 11, 8, 123, 144, 145, 126, 127, 128, 129, + 82, 82, 158, 30, 160, 32, 33, 108, 8, 70, + 30, 31, 113, 152, 16, 9, 10, 11, 74, 14, + 14, 122, 8, 8, 80, 155, 156, 157, 84, 13, + 159, 87, 88, 89, 151, 91, 30, 93, 160, 95, + 155, 159, 98, 14, 100, 101, 102, 103, 104, 105, + 106, 133, 16, 109, 110, 155, 157, 1, 2, 115, + 116, 117, 118, 9, 10, 11, 13, 123, 16, 155, + 126, 127, 128, 129, 33, 34, 158, 158, 160, 160, + 156, 9, 10, 11, 30, 37, 38, 31, 70, 155, + 37, 38, 50, 51, 52, 156, 16, 81, 16, 155, + 156, 157, 30, 16, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 16, 57, + 74, 9, 10, 11, 1, 2, 80, 116, 11, 155, + 84, 69, 156, 87, 88, 89, 160, 91, 30, 93, + 132, 95, 30, 33, 98, 134, 135, 30, 57, 103, + 104, 105, 69, 70, 31, 109, 110, 75, 76, 155, + 155, 115, 116, 75, 76, 101, 102, 111, 112, 123, + 159, 155, 156, 155, 156, 155, 156, 31, 1, 2, + 31, 31, 31, 31, 31, 38, 70, 69, 77, 70, + 70, 70, 70, 80, 70, 70, 70, 74, 71, 85, + 85, 155, 156, 80, 97, 96, 100, 84, 31, 106, + 87, 88, 89, 82, 91, 82, 93, 82, 95, 89, + 92, 98, 1, 2, 90, 127, 103, 104, 105, 97, + 94, 127, 109, 110, 97, 97, 97, 132, 115, 116, + 100, 146, 113, 143, 143, 146, 123, 106, 151, 155, + 157, 74, 31, 157, 162, -1, 114, 80, -1, 116, + -1, 84, -1, -1, 87, 88, 89, -1, 91, -1, + 93, -1, 95, -1, 130, 98, 1, 2, 155, 156, + 103, 104, 105, -1, 130, -1, 109, 110, 131, -1, + 132, 132, 115, 116, 132, 74, -1, 152, 150, -1, + 123, 80, 146, -1, -1, 84, 31, 146, 87, 88, + 89, 146, 91, 146, 93, 146, 95, 146, 150, 98, + 1, 2, 156, 159, 103, 104, 105, 155, 155, 155, + 109, 110, 155, 156, 155, 155, 115, 116, 155, 155, + 155, 155, 155, 155, 123, 155, 155, 155, 155, 74, + 155, 155, 155, 155, 155, 80, 155, 155, 155, 84, + 155, 155, 87, 88, 89, 155, 91, 155, 93, 156, + 95, 156, 156, 98, 156, 156, 155, 156, 103, 104, + 105, 156, 156, 156, 109, 110, 156, 156, 156, 156, + 115, 116, 156, 74, 157, 157, 157, 157, 123, 80, + 31, 157, 157, 84, 157, 157, 87, 88, 89, 157, + 91, 157, 93, 157, 95, 157, 157, 98, 157, 50, + 51, 157, 103, 104, 105, 56, 157, 58, 109, 110, + 155, 156, 158, 157, 115, 116, 157, 157, 157, 70, + 157, 157, 123, 157, 50, 51, 157, 78, 79, 157, + 56, 157, 58, 157, 159, 86, 158, 158, 158, 158, + 158, 158, 158, 158, 70, 158, 158, 158, 158, 158, + 158, 158, 78, 79, 155, 156, 158, 160, 158, 163, + 86, 159, 159, 159, 159, 159, 159, 159, 159, 159, + 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, + -1, -1, 161, 134, 161, 136, 137, 138, 139, 140, + 141, 142, 162, 162, 162, 162, 162, 148, 149, 162, + 162, 162, 162, 162, 162, 162, 162, 158, 134, 162, + 136, 137, 138, 139, 140, 141, 142, -1, -1, -1, + -1, -1, 148, 149, -1, -1, -1, -1, -1, -1, + -1, -1, 158 ); protected $actionBase = array( - 0, 220, 295, 370, 445, 109, 109, 180, 744, -2, - -2, -2, -2, -2, 135, 655, 724, 756, 724, 623, - 554, 825, 825, 825, 438, 353, 625, 625, 862, 625, - 427, 390, 377, 449, 536, 615, 562, 393, 393, 393, - 393, 134, 134, 393, 393, 393, 393, 393, 393, 393, - 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, - 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, - 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, - 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, - 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, - 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, - 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, - 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, - 393, 393, 393, 300, 179, 446, 475, 751, 750, 746, - 745, 838, 684, 860, 798, 799, 604, 800, 801, 802, - 803, 805, 797, 806, 898, 807, 568, 568, 568, 568, - 568, 568, 568, 568, 568, 568, 568, -3, 365, 225, - 308, 620, 662, 659, 659, 659, 659, 659, 659, 659, - 505, 505, 505, 505, 505, 505, 505, 505, 505, 505, - 505, 505, 505, 505, 505, 505, 505, 470, 552, 552, - 552, 526, 887, 595, 912, 912, 912, 912, 912, 912, - 912, 912, 912, 912, 912, 912, 912, 912, 912, 912, - 912, 912, 912, 912, 912, 912, 912, 912, 912, 912, - 912, 912, 912, 912, 912, 912, 912, 912, 912, 912, - 912, 912, 912, 912, 912, 912, 912, 493, -20, -20, - 477, 626, 402, 632, 210, 555, 197, 25, 25, 25, - 25, 25, 17, 45, 5, 5, 5, 5, 335, 380, - 380, 380, 380, 118, 118, 118, 118, 833, 827, 826, - 821, 311, 311, 709, 709, 631, 779, 627, 627, 630, - 630, 420, 420, 420, 420, 420, 420, 420, 420, 420, - 420, 383, 105, 859, 130, 130, 130, 130, 306, 44, - 657, 920, 264, 264, 264, 306, 248, 248, 248, 297, - 297, 297, 76, 687, 371, 86, 86, 86, 86, 371, - 86, 86, 588, 588, 588, 435, 759, 686, 436, 443, - 97, 483, 693, 819, 691, 796, 549, 710, 96, 717, - 716, 398, 675, 613, 610, 586, 651, 355, 398, 300, - 557, 423, 607, 753, 667, 38, 747, 328, 268, 424, - 547, 315, -6, 279, 782, 755, 863, 861, 249, 133, - 703, 607, 607, 607, 74, 199, 783, 789, 315, 290, - 614, 614, 614, 614, 835, 792, 614, 614, 614, 614, - 834, 795, 267, 67, 793, 137, 749, 642, 642, 642, - 642, 642, 642, 608, 642, 853, 671, 843, 843, 660, - 683, 608, 856, 856, 856, 856, 608, 642, 843, 843, - 608, 631, 843, 168, 608, 666, 642, 664, 664, 856, - 736, 735, 671, 673, 694, 843, 843, 843, 694, 660, - 608, 856, 697, 641, 209, 843, 856, 618, 618, 697, - 608, 618, 683, 618, 20, 597, 643, 855, 858, 852, - 644, 790, 668, 658, 847, 846, 857, 661, 672, 848, - 845, 720, 734, 733, 656, 513, 649, 647, 645, 634, - 705, 605, 702, 675, 723, 585, 585, 585, 706, 707, - 706, 585, 585, 585, 585, 585, 585, 585, 585, 911, - 712, 676, 654, 665, 732, 481, 699, 689, 502, 772, - 663, 720, 720, 831, 876, 885, 901, 704, 653, 842, - 878, 706, 919, 738, 277, 606, 841, 832, 713, 652, - 719, 706, 824, 706, 773, 706, 875, 830, 669, 720, - 828, 585, 874, 918, 917, 916, 915, 914, 913, 903, - 909, 650, 907, 731, 678, 884, 47, 854, 651, 708, - 648, 730, 159, 906, 822, 706, 706, 774, 759, 706, - 778, 729, 737, 900, 728, 883, 905, 663, 882, 706, - 674, 904, 159, 616, 646, 891, 680, 726, 851, 682, - 866, 850, 758, 574, 524, 721, 612, 752, 899, 889, - 864, 743, 763, 765, 576, 688, 685, 679, 839, 769, - 849, 722, 808, 811, 877, 692, 723, 711, 670, 690, - 681, 770, 814, 881, 739, 740, 741, 818, 742, 836, + 0, 227, 326, 400, 474, 233, 132, 132, 752, -2, + -2, 138, -2, -2, -2, 663, 761, 815, 761, 586, + 717, 859, 859, 859, 244, 256, 256, 256, 413, 583, + 583, 880, 546, 169, 415, 444, 409, 200, 200, 200, + 200, 137, 137, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 249, 205, 738, 559, + 535, 739, 741, 742, 876, 679, 877, 820, 821, 693, + 823, 824, 826, 829, 832, 819, 834, 907, 836, 602, + 602, 602, 602, 602, 602, 602, 602, 602, 602, 602, + 602, 67, 536, 299, 510, 230, 44, 652, 652, 652, + 652, 652, 652, 652, 337, 337, 337, 337, 337, 337, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 337, 378, 584, 584, 584, 657, 909, 648, 934, + 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, + 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, + 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, + 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, + 934, 934, 934, 503, -21, -21, 436, 650, 364, 571, + 215, 426, 156, 26, 26, 329, 329, 329, 329, 329, + 46, 46, 5, 5, 5, 5, 152, 186, 186, 186, + 186, 120, 120, 120, 120, 374, 374, 429, 448, 448, + 334, 267, 449, 449, 449, 449, 449, 449, 449, 449, + 449, 449, 336, 427, 427, 572, 572, 408, 551, 551, + 551, 551, 671, 171, 171, 391, 311, 311, 311, 109, + 641, 856, 68, 68, 68, 68, 68, 68, 324, 324, + 324, -3, -3, -3, 655, 77, 380, 77, 380, 683, + 685, 86, 685, 654, -15, 516, 776, 281, 646, 809, + 680, 816, 560, 711, 202, 578, 857, 643, -23, 578, + 578, 578, 578, 857, 622, 628, 596, -23, 578, -23, + 639, 454, 849, 351, 249, 558, 469, 631, 743, 514, + 688, 746, 464, 544, 548, 556, 7, 412, 708, 750, + 878, 879, 349, 702, 631, 631, 631, 327, 101, 7, + -8, 623, 623, 623, 623, 219, 623, 623, 623, 623, + 291, 430, 545, 401, 745, 653, 653, 675, 839, 814, + 814, 653, 673, 653, 675, 841, 841, 841, 841, 653, + 653, 653, 653, 814, 814, 667, 814, 275, 684, 694, + 694, 841, 713, 714, 653, 653, 697, 814, 814, 814, + 697, 687, 841, 669, 637, 333, 814, 841, 689, 673, + 689, 653, 669, 689, 673, 673, 689, 22, 686, 656, + 840, 842, 860, 756, 638, 644, 847, 848, 843, 845, + 838, 692, 719, 720, 528, 659, 660, 661, 662, 696, + 664, 698, 643, 658, 658, 658, 645, 701, 645, 658, + 658, 658, 658, 658, 658, 658, 658, 632, 635, 709, + 699, 670, 723, 566, 582, 758, 640, 636, 872, 865, + 881, 883, 849, 870, 645, 890, 634, 288, 610, 850, + 633, 753, 645, 851, 645, 759, 645, 873, 777, 666, + 778, 779, 658, 874, 891, 892, 893, 894, 897, 898, + 899, 900, 665, 901, 724, 674, 866, 344, 844, 639, + 705, 677, 755, 725, 780, 372, 902, 784, 645, 645, + 765, 706, 645, 766, 726, 712, 862, 727, 867, 903, + 640, 678, 868, 645, 681, 785, 904, 372, 690, 651, + 704, 649, 728, 858, 875, 853, 767, 612, 617, 787, + 788, 792, 691, 730, 863, 864, 835, 731, 770, 642, + 771, 676, 794, 772, 852, 732, 796, 798, 871, 647, + 707, 682, 672, 668, 773, 799, 869, 733, 735, 736, + 801, 737, 804, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 137, 137, 137, 137, -2, -2, -2, + -2, 0, 0, -2, 0, 0, 0, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 0, 0, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 602, 602, + 602, 602, 602, 602, 602, 602, 602, 602, 602, 602, + 602, 602, 602, 602, 602, 602, 602, 602, 602, 602, + 602, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 602, -21, -21, -21, -21, 602, -21, + -21, -21, -21, -21, -21, -21, 602, 602, 602, 602, + 602, 602, 602, 602, 602, 602, 602, 602, 602, 602, + 602, 602, 602, 602, -21, 602, 602, 602, -21, 68, + -21, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 602, 0, 0, 602, -21, + 602, -21, 602, -21, -21, 602, 602, 602, 602, 602, + 602, 602, -21, -21, -21, -21, -21, -21, 0, 324, + 324, 324, 324, -21, -21, -21, -21, 68, 68, 147, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 324, 324, -3, -3, 68, + 68, 68, 68, 68, 147, 68, 68, -23, 673, 673, + 673, 380, 380, 380, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 380, -23, 0, -23, + 0, 68, -23, 673, -23, 380, 673, 673, -23, 814, + 604, 604, 604, 604, 372, 7, 0, 0, 673, 673, + 0, 0, 0, 0, 0, 673, 0, 0, 0, 0, + 0, 0, 814, 0, 653, 0, 0, 0, 0, 658, + 288, 0, 677, 456, 0, 0, 0, 0, 0, 0, + 677, 456, 530, 530, 0, 665, 658, 658, 658, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 134, 134, 134, 134, -2, -2, -2, -2, 0, 0, - 0, 0, 0, -2, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 0, 0, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 568, 568, 568, 568, 568, 568, 568, 568, - 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, - 568, 568, 568, 568, 568, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 568, -20, -20, -20, - -20, 568, -20, -20, -20, -20, -20, -20, -20, 568, - 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, - 568, 568, 568, 568, 568, 568, -20, 568, 568, 568, - -20, 420, -20, 420, 420, 420, 420, 420, 420, 420, - 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, - 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, - 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, - 420, 420, 420, 420, 420, 420, 568, 0, 0, 568, - -20, 568, -20, 568, -20, 568, 568, 568, 568, 568, - 568, -20, -20, -20, -20, -20, -20, 0, 248, 248, - 248, 248, -20, -20, -20, -20, 55, 55, 55, 55, - 420, 420, 420, 420, 420, 420, 248, 248, 297, 297, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 420, 55, 420, 642, 642, 642, 642, 642, 371, 371, - 371, 106, 106, 106, 642, 0, 0, 0, 0, 0, - 0, 642, 371, 0, 420, 420, 420, 420, 0, 420, - 420, 642, 642, 642, 642, 106, 371, 642, 843, 0, - 106, 591, 591, 591, 591, 159, 315, 0, 642, 642, - 0, 673, 0, 0, 0, 843, 0, 0, 0, 0, - 0, 585, 277, 842, 0, 360, 0, 0, 0, 0, - 0, 0, 0, 653, 360, 450, 450, 0, 0, 650, - 585, 585, 585, 0, 0, 653, 653, 0, 0, 0, - 0, 0, 0, 379, 653, 0, 0, 0, 0, 379, - 333, 0, 0, 333, 0, 159 + 0, 0, 0, 0, 0, 0, 372 ); protected $actionDefault = array( 3,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767, 525, 525,32767, 481, - 32767,32767,32767,32767,32767,32767,32767, 287, 287, 287, - 32767,32767,32767, 513, 513, 513, 513, 513, 513, 513, - 513, 513, 513, 513,32767,32767,32767,32767,32767, 369, + 32767,32767,32767,32767,32767, 540, 540, 495,32767,32767, + 32767,32767,32767,32767,32767,32767,32767, 297, 297, 297, + 32767,32767,32767, 528, 528, 528, 528, 528, 528, 528, + 528, 528, 528, 528,32767,32767,32767,32767,32767,32767, + 381,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767, 375, 530,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767, 350, 351, 353, 354, - 286, 514, 237, 376, 529, 285, 239, 314, 485,32767, - 32767,32767, 316, 116, 248, 193, 484, 119, 284, 224, - 368, 370, 315, 291, 296, 297, 298, 299, 300, 301, - 302, 303, 304, 305, 306, 307, 290, 441, 347, 346, - 345, 443,32767, 442, 478, 478, 481,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767, 387, + 545,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767, 362, + 363, 365, 366, 296, 548, 529, 245, 388, 544, 295, + 247, 325, 499,32767,32767,32767, 327, 122, 256, 201, + 498, 125, 294, 232, 380, 382, 326, 301, 306, 307, + 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, + 318, 300, 454, 359, 358, 357, 456,32767, 455, 492, + 492, 495,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767, 312, 469, 468, - 313, 439, 317, 440, 319, 444, 318, 335, 336, 333, - 334, 337, 446, 445, 462, 463, 460, 461, 289, 338, - 339, 340, 341, 464, 465, 466, 467, 271, 271, 271, - 271,32767,32767, 524, 524,32767,32767, 326, 327, 453, - 454,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767, 272,32767, 228, 228, 228, 228, 228,32767, - 32767,32767,32767,32767,32767,32767, 321, 322, 320, 448, - 449, 447,32767, 415,32767,32767,32767,32767,32767, 417, - 32767,32767,32767,32767,32767,32767,32767,32767,32767, 486, - 32767,32767,32767,32767,32767,32767,32767, 499, 404,32767, - 32767,32767, 397, 212, 214, 161, 472,32767,32767,32767, - 32767, 504, 331,32767,32767,32767,32767,32767,32767, 539, - 32767, 499,32767,32767,32767,32767,32767,32767,32767,32767, - 344, 323, 324, 325,32767,32767,32767,32767, 503, 497, - 456, 457, 458, 459,32767,32767, 450, 451, 452, 455, + 32767,32767,32767, 323, 483, 482, 324, 452, 328, 453, + 331, 457, 460, 329, 330, 347, 348, 345, 346, 349, + 458, 459, 476, 477, 474, 475, 299, 350, 351, 352, + 353, 478, 479, 480, 481,32767,32767, 280, 539, 539, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767, 165,32767, 412,32767, 418, 418,32767, - 32767, 165,32767,32767,32767,32767, 165,32767, 502, 501, - 165,32767, 398, 480, 165, 178,32767, 176, 176,32767, - 198, 198,32767,32767, 180, 473, 492,32767, 180,32767, - 165,32767, 386, 167, 480,32767,32767, 230, 230, 386, - 165, 230,32767, 230,32767, 82, 422,32767,32767,32767, + 32767,32767,32767, 338, 339, 467, 468,32767, 236, 236, + 236, 236, 281, 236,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767, 333, 334, + 332, 462, 463, 461, 428,32767,32767,32767, 430,32767, + 32767,32767,32767,32767,32767,32767,32767, 500,32767,32767, + 32767,32767,32767, 513, 417, 171,32767, 409,32767, 171, + 171, 171, 171,32767, 220, 222, 167,32767, 171,32767, + 486,32767,32767,32767,32767,32767, 518, 343,32767,32767, + 116,32767,32767,32767, 555,32767, 513,32767, 116,32767, + 32767,32767,32767, 356, 335, 336, 337,32767,32767, 517, + 511, 470, 471, 472, 473,32767, 464, 465, 466, 469, + 32767,32767,32767,32767,32767,32767,32767,32767, 425, 431, + 431,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767, 516, 515,32767, 410, 494, 186, 184, + 184,32767, 206, 206,32767,32767, 188, 487, 506,32767, + 188, 173,32767, 398, 175, 494,32767,32767, 238,32767, + 238,32767, 398, 238,32767,32767, 238,32767, 411, 435, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767, 399,32767,32767,32767,32767, 365, 366, 475, 488, - 32767, 489,32767, 397,32767, 329, 330, 332, 309,32767, - 311, 355, 356, 357, 358, 359, 360, 361, 363,32767, - 402,32767, 405,32767,32767,32767, 84, 108, 247,32767, - 537, 84, 400,32767,32767, 294, 537,32767,32767,32767, - 32767, 532,32767,32767, 288,32767,32767,32767, 84,32767, - 84, 243,32767, 163,32767, 522,32767, 497,32767, 401, - 32767, 328,32767,32767,32767,32767,32767,32767,32767,32767, - 32767, 498,32767,32767,32767,32767, 219,32767, 435,32767, - 84,32767, 179,32767,32767, 292, 238,32767,32767, 531, - 32767,32767,32767,32767,32767,32767,32767,32767,32767, 164, - 32767,32767, 181,32767,32767, 497,32767,32767,32767,32767, - 32767,32767,32767,32767, 283,32767,32767,32767,32767,32767, - 497,32767,32767,32767, 223,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767, 82, 60,32767, 265,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 121, 121, 3, 121, 121, 3, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 206, 250, 209, - 198, 198, 158, 250, 250, 250, 121, 121, 257 + 32767,32767,32767,32767,32767, 377, 378, 489, 502,32767, + 503,32767, 409, 341, 342, 344, 320,32767, 322, 367, + 368, 369, 370, 371, 372, 373, 375,32767, 415,32767, + 418,32767,32767,32767, 255,32767, 553,32767,32767, 304, + 553,32767,32767,32767, 547,32767,32767, 298,32767,32767, + 32767,32767, 251,32767, 169,32767, 537,32767, 554,32767, + 511,32767, 340,32767,32767,32767,32767,32767,32767,32767, + 32767,32767, 512,32767,32767,32767,32767, 227,32767, 448, + 32767, 116,32767,32767,32767, 187,32767,32767, 302, 246, + 32767,32767, 546,32767,32767,32767,32767,32767,32767,32767, + 32767, 114,32767, 170,32767,32767,32767, 189,32767,32767, + 511,32767,32767,32767,32767,32767,32767,32767, 293,32767, + 32767,32767,32767,32767,32767,32767, 511,32767,32767, 231, + 32767,32767,32767,32767,32767,32767,32767,32767,32767, 411, + 32767, 274,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767, 127, 127, 3, 127, 127, 258, 3, + 258, 127, 258, 258, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 214, 217, 206, 206, 164, 127, + 127, 266 ); protected $goto = array( - 162, 162, 136, 136, 141, 136, 137, 138, 139, 144, - 146, 183, 164, 160, 160, 160, 160, 141, 141, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 156, 157, 158, 159, 180, 135, 181, 495, 496, 362, - 497, 501, 502, 503, 504, 505, 506, 507, 508, 964, - 140, 142, 143, 145, 167, 172, 182, 198, 247, 250, - 252, 254, 256, 257, 258, 259, 260, 261, 269, 270, - 271, 272, 287, 288, 316, 317, 318, 381, 382, 383, - 551, 184, 185, 186, 187, 188, 189, 190, 191, 192, - 193, 194, 195, 196, 147, 148, 149, 163, 150, 165, - 151, 199, 166, 152, 153, 154, 200, 155, 133, 627, - 569, 786, 569, 569, 569, 569, 569, 569, 569, 569, - 569, 569, 569, 569, 569, 569, 569, 569, 569, 569, - 569, 569, 569, 569, 569, 569, 569, 569, 569, 569, - 569, 569, 569, 569, 569, 569, 569, 569, 569, 569, - 569, 569, 569, 569, 569, 1102, 636, 1102, 1102, 1102, - 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, - 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, - 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, - 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, - 525, 817, 499, 499, 499, 499, 499, 499, 1171, 510, - 1171, 510, 499, 499, 499, 499, 499, 499, 499, 499, - 499, 499, 511, 552, 511, 582, 608, 524, 887, 887, - 1192, 1192, 755, 851, 851, 851, 851, 170, 846, 852, - 524, 524, 173, 174, 175, 390, 391, 392, 393, 169, - 197, 201, 203, 251, 253, 255, 262, 263, 264, 265, - 266, 267, 273, 274, 275, 276, 289, 290, 319, 320, - 321, 396, 397, 398, 399, 171, 176, 248, 249, 177, - 178, 179, 389, 610, 545, 545, 575, 541, 8, 343, - 1078, 1077, 543, 543, 498, 500, 531, 547, 576, 579, - 589, 595, 550, 756, 568, 574, 568, 568, 568, 568, - 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, - 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, - 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, - 568, 568, 568, 568, 568, 568, 568, 568, 568, 516, - 445, 447, 935, 638, 329, 311, 1103, 620, 933, 521, - 521, 521, 521, 779, 553, 554, 555, 556, 557, 558, - 559, 560, 562, 591, 857, 613, 540, 521, 619, 512, - 360, 512, 905, 432, 432, 432, 432, 432, 432, 546, - 779, 779, 1196, 432, 432, 432, 432, 432, 432, 432, - 432, 432, 432, 1067, 1163, 1067, 894, 894, 894, 894, - 894, 1170, 363, 1170, 585, 588, 633, 894, 371, 371, - 371, 1060, 1186, 1186, 1186, 3, 4, 1067, 1067, 1067, - 1067, 600, 1067, 1067, 521, 521, 538, 570, 521, 521, - 617, 521, 371, 1151, 962, 609, 1169, 388, 772, 772, - 780, 780, 780, 782, 522, 771, 1189, 1202, 1202, 537, - 377, 659, 564, 549, 596, 884, 615, 618, 880, 622, - 623, 630, 632, 637, 639, 900, 1202, 1203, 1203, 364, - 592, 346, 406, 529, 1205, 754, 891, 542, 278, 279, - 280, 1011, 349, 1063, 1064, 400, 1203, 1060, 873, 855, - 853, 855, 657, 453, 513, 882, 877, 1083, 344, 345, - 1061, 1162, 1061, 12, 1021, 19, 15, 357, 775, 773, - 1062, 370, 375, 909, 404, 666, 1053, 448, 1058, 783, - 580, 563, 861, 914, 1148, 461, 951, 0, 0, 0, - 0, 0, 0, 23, 0, 0, 0, 0, 606, 0, + 166, 140, 140, 140, 166, 187, 168, 144, 147, 141, + 142, 143, 149, 163, 163, 163, 163, 144, 144, 165, + 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, + 138, 159, 160, 161, 162, 184, 139, 185, 493, 494, + 377, 495, 499, 500, 501, 502, 503, 504, 505, 506, + 967, 164, 145, 146, 148, 171, 176, 186, 203, 253, + 256, 258, 260, 263, 264, 265, 266, 267, 268, 269, + 277, 278, 279, 280, 303, 304, 328, 329, 330, 394, + 395, 396, 542, 188, 189, 190, 191, 192, 193, 194, + 195, 196, 197, 198, 199, 200, 201, 150, 151, 152, + 167, 153, 169, 154, 204, 170, 155, 156, 157, 205, + 158, 136, 620, 560, 756, 560, 560, 560, 560, 560, + 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, + 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, + 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, + 560, 560, 560, 560, 560, 560, 560, 560, 560, 1108, + 628, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, + 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, + 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, + 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, + 1108, 1108, 1108, 1108, 1108, 757, 888, 888, 508, 1200, + 1200, 400, 606, 508, 536, 536, 568, 532, 534, 534, + 496, 498, 524, 540, 569, 572, 583, 590, 852, 852, + 852, 852, 847, 853, 174, 585, 519, 600, 601, 177, + 178, 179, 401, 402, 403, 404, 173, 202, 206, 208, + 257, 259, 261, 262, 270, 271, 272, 273, 274, 275, + 281, 282, 283, 284, 305, 306, 331, 332, 333, 406, + 407, 408, 409, 175, 180, 254, 255, 181, 182, 183, + 497, 497, 785, 497, 497, 497, 497, 497, 497, 497, + 497, 497, 497, 497, 497, 497, 497, 509, 578, 582, + 626, 749, 509, 544, 545, 546, 547, 548, 549, 550, + 551, 553, 586, 338, 559, 321, 559, 559, 559, 559, + 559, 559, 559, 559, 559, 559, 559, 559, 559, 559, + 559, 559, 559, 559, 559, 559, 559, 559, 559, 559, + 559, 559, 559, 559, 559, 559, 559, 559, 559, 559, + 559, 559, 559, 559, 559, 559, 559, 559, 559, 559, + 530, 349, 655, 555, 587, 352, 414, 591, 575, 604, + 885, 611, 612, 881, 616, 617, 623, 625, 630, 632, + 298, 296, 296, 296, 298, 290, 299, 944, 610, 816, + 1170, 613, 436, 436, 375, 436, 436, 436, 436, 436, + 436, 436, 436, 436, 436, 436, 436, 436, 436, 1072, + 1084, 1083, 945, 1065, 1072, 895, 895, 895, 895, 1178, + 895, 895, 1212, 1212, 1178, 388, 858, 561, 755, 1072, + 1072, 1072, 1072, 1072, 1072, 3, 4, 384, 384, 384, + 1212, 874, 856, 854, 856, 654, 465, 511, 883, 878, + 1089, 541, 384, 537, 384, 567, 384, 1026, 19, 15, + 371, 384, 1226, 510, 1204, 1192, 1192, 1192, 510, 906, + 372, 522, 533, 554, 912, 514, 1068, 1069, 13, 1065, + 378, 912, 1158, 594, 23, 965, 386, 386, 386, 602, + 1066, 1169, 1066, 937, 447, 449, 631, 752, 1177, 1067, + 1109, 614, 935, 1177, 605, 1197, 391, 1211, 1211, 543, + 892, 386, 1194, 1194, 1194, 399, 518, 1016, 901, 389, + 771, 529, 752, 340, 752, 1211, 518, 518, 385, 781, + 1214, 770, 772, 1063, 910, 774, 1058, 1176, 659, 953, + 514, 782, 862, 915, 450, 573, 1155, 0, 463, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 513, 528, 0, 0, 0, 0, + 513, 0, 528, 0, 350, 351, 0, 609, 512, 515, + 438, 439, 1064, 618, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 779, 1219, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 943, 0, 0, 0, + 777, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 530 + 523, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 301, 301 ); protected $gotoCheck = array( - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 53, - 63, 25, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 119, 5, 119, 119, 119, - 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, - 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, - 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, - 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, - 94, 46, 110, 110, 110, 110, 110, 110, 111, 63, - 111, 63, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 40, 110, 36, 36, 40, 71, 71, - 71, 71, 11, 63, 63, 63, 63, 23, 63, 63, - 40, 40, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 47, 47, 47, 47, 47, 47, 91, 66, - 117, 117, 47, 47, 47, 47, 47, 47, 47, 47, - 47, 47, 2, 12, 53, 2, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 8, - 7, 7, 7, 7, 118, 118, 7, 7, 7, 8, - 8, 8, 8, 19, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 29, 57, 8, 8, 57, 115, - 57, 115, 78, 53, 53, 53, 53, 53, 53, 102, - 19, 19, 132, 53, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 76, 53, 53, 53, 53, 53, - 53, 112, 43, 112, 56, 56, 56, 53, 116, 116, - 116, 76, 112, 112, 112, 26, 26, 53, 53, 53, - 53, 120, 53, 53, 8, 8, 8, 8, 8, 8, - 53, 8, 116, 124, 94, 45, 112, 116, 19, 19, - 19, 19, 19, 19, 8, 19, 130, 133, 133, 28, - 44, 28, 28, 8, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 75, 133, 134, 134, 54, - 64, 64, 64, 54, 133, 10, 73, 54, 61, 61, - 61, 95, 14, 76, 76, 18, 134, 76, 10, 10, - 10, 10, 10, 54, 10, 10, 10, 30, 66, 66, - 76, 76, 76, 54, 30, 30, 30, 30, 21, 20, - 76, 9, 13, 79, 17, 68, 106, 59, 108, 22, - 60, 30, 65, 80, 123, 101, 93, -1, -1, -1, - -1, -1, -1, 30, -1, -1, -1, -1, 30, -1, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 57, 68, 15, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 126, + 9, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 16, 76, 76, 68, 76, + 76, 51, 51, 68, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 68, 68, + 68, 68, 68, 68, 27, 66, 101, 66, 66, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 117, 117, 29, 117, 117, 117, 117, 117, 117, 117, + 117, 117, 117, 117, 117, 117, 117, 117, 61, 61, + 61, 6, 117, 110, 110, 110, 110, 110, 110, 110, + 110, 110, 110, 125, 57, 125, 57, 57, 57, 57, + 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, + 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, + 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, + 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, + 32, 71, 32, 32, 69, 69, 69, 32, 40, 40, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 5, 5, 5, 5, 5, 5, 5, 97, 62, 50, + 81, 62, 57, 57, 62, 57, 57, 57, 57, 57, + 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, + 124, 124, 97, 81, 57, 57, 57, 57, 57, 118, + 57, 57, 142, 142, 118, 12, 33, 12, 14, 57, + 57, 57, 57, 57, 57, 30, 30, 13, 13, 13, + 142, 14, 14, 14, 14, 14, 57, 14, 14, 14, + 34, 2, 13, 109, 13, 2, 13, 34, 34, 34, + 34, 13, 13, 122, 140, 9, 9, 9, 122, 83, + 58, 58, 58, 34, 13, 13, 81, 81, 58, 81, + 46, 13, 131, 127, 34, 101, 123, 123, 123, 34, + 81, 81, 81, 8, 8, 8, 8, 11, 119, 81, + 8, 8, 8, 119, 49, 138, 48, 141, 141, 47, + 78, 123, 119, 119, 119, 123, 47, 102, 80, 17, + 23, 9, 11, 18, 11, 141, 47, 47, 11, 23, + 141, 23, 24, 115, 84, 25, 113, 119, 73, 99, + 13, 26, 70, 85, 64, 65, 130, -1, 108, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 9, 9, -1, -1, -1, -1, + 9, -1, 9, -1, 71, 71, -1, 13, 9, 9, + 9, 9, 13, 13, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 9, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 91, -1, -1, -1, + 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 94 + 101, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 5, 5 ); protected $gotoBase = array( - 0, 0, -340, 0, 0, 142, 0, 345, 27, 186, - 483, 230, 301, 173, 170, 0, 0, 116, 162, 41, - 169, 184, 87, 35, 0, 101, -241, 0, -182, 354, - 92, 0, 0, 0, 0, 0, 187, 0, 0, -24, - 199, 0, 0, 372, 168, 163, 183, 1, 0, 0, - 0, 0, 0, 102, 53, 0, 109, -83, 0, 89, - 82, -175, 0, -92, 154, 83, -152, 0, 166, 0, - 0, -53, 0, 178, 0, 160, 65, 0, 357, 165, - 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 274, 0, 74, 159, 188, 0, 0, 0, 0, - 0, 76, 362, 320, 0, 0, 108, 0, 107, 0, - -79, -93, 110, 0, 0, 78, 106, -23, 31, -47, - 226, 0, 0, 80, 237, 0, 0, 0, 0, 0, - 172, 0, 363, 147, 167, 0, 0 + 0, 0, -184, 0, 0, 356, 290, 0, 488, 149, + 0, 182, 85, 118, 426, 112, 203, 179, 208, 0, + 0, 0, 0, 162, 190, 198, 120, 27, 0, 272, + -224, 0, -274, 406, 32, 0, 0, 0, 0, 0, + 330, 0, 0, -24, 0, 0, 440, 485, 213, 218, + 371, -74, 0, 0, 0, 0, 0, 107, 110, 0, + 0, -11, -72, 0, 104, 95, -405, 0, -94, 41, + 119, -82, 0, 164, 0, 0, -79, 0, 197, 0, + 204, 43, 0, 441, 171, 121, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 100, 0, 115, + 0, 195, 210, 0, 0, 0, 0, 0, 86, 427, + 259, 0, 0, 116, 0, 174, 0, -5, 117, 196, + 0, 0, 161, 170, 93, -21, -48, 273, 0, 0, + 91, 271, 0, 0, 0, 0, 0, 0, 216, 0, + 437, 187, 102, 0, 0 ); protected $gotoDefault = array( - -32768, 464, 670, 2, 671, 742, 750, 603, 481, 517, - 792, 793, 794, 366, 412, 482, 365, 401, 394, 781, - 774, 776, 784, 168, 402, 787, 1, 789, 523, 825, - 1012, 353, 797, 354, 594, 799, 533, 801, 802, 134, - 483, 367, 368, 534, 376, 583, 816, 268, 373, 818, - 355, 819, 828, 356, 616, 599, 565, 612, 484, 444, - 577, 277, 544, 1075, 572, 860, 342, 868, 667, 876, - 879, 485, 566, 890, 450, 898, 1088, 384, 904, 910, - 915, 918, 420, 403, 590, 922, 923, 7, 927, 628, - 629, 942, 302, 950, 963, 418, 1031, 1033, 486, 487, - 527, 458, 509, 532, 488, 1054, 438, 405, 1057, 489, - 490, 428, 429, 1072, 348, 1156, 347, 446, 310, 1143, - 586, 1107, 454, 1195, 1152, 339, 491, 492, 361, 378, - 1190, 433, 1197, 1204, 337, 369, 573 + -32768, 467, 663, 2, 664, 834, 739, 747, 597, 481, + 629, 581, 380, 1188, 791, 792, 793, 381, 367, 482, + 379, 410, 405, 780, 773, 775, 783, 172, 411, 786, + 1, 788, 517, 824, 1017, 364, 796, 365, 589, 798, + 526, 800, 801, 137, 382, 383, 527, 483, 390, 576, + 815, 276, 387, 817, 366, 818, 827, 370, 464, 454, + 459, 556, 608, 432, 446, 570, 564, 535, 1081, 565, + 861, 348, 869, 660, 877, 880, 484, 557, 891, 451, + 899, 1094, 397, 905, 911, 916, 287, 919, 417, 412, + 584, 924, 925, 5, 929, 621, 622, 8, 312, 952, + 598, 966, 420, 1036, 1038, 485, 486, 521, 458, 507, + 525, 487, 1059, 440, 413, 1062, 488, 489, 433, 434, + 1078, 354, 1163, 353, 448, 320, 1150, 579, 1113, 455, + 1203, 1159, 347, 490, 491, 376, 1182, 392, 1198, 437, + 1205, 1213, 343, 539, 566 ); protected $ruleToNonTerminal = array( - 0, 1, 3, 3, 2, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 8, 8, 9, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 14, 14, 15, 15, - 15, 15, 17, 17, 13, 13, 18, 18, 19, 19, - 20, 20, 21, 21, 16, 16, 22, 24, 24, 25, - 26, 26, 28, 27, 27, 27, 27, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 10, 10, 50, 50, - 52, 51, 51, 44, 44, 54, 54, 55, 55, 11, - 12, 12, 12, 58, 58, 58, 59, 59, 62, 62, - 60, 60, 64, 64, 37, 37, 46, 46, 49, 49, - 49, 48, 48, 65, 38, 38, 38, 38, 66, 66, - 67, 67, 68, 68, 35, 35, 31, 31, 69, 33, - 33, 70, 32, 32, 34, 34, 45, 45, 45, 56, - 56, 72, 72, 73, 73, 75, 75, 75, 74, 74, - 57, 57, 76, 76, 76, 77, 77, 78, 78, 78, - 41, 41, 79, 79, 79, 42, 42, 80, 80, 61, - 61, 81, 81, 81, 81, 86, 86, 87, 87, 88, - 88, 88, 88, 88, 89, 90, 90, 85, 85, 82, - 82, 84, 84, 92, 92, 91, 91, 91, 91, 91, - 91, 83, 83, 93, 93, 43, 43, 36, 36, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 30, 30, 40, 40, 98, 98, 99, - 99, 99, 99, 105, 94, 94, 101, 101, 107, 107, - 108, 109, 109, 109, 109, 109, 109, 63, 63, 53, - 53, 53, 95, 95, 113, 113, 110, 110, 114, 114, - 114, 114, 96, 96, 96, 100, 100, 100, 106, 106, - 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, - 119, 119, 119, 23, 23, 23, 23, 23, 23, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 104, 104, 97, 97, 97, 97, 120, 120, - 123, 123, 122, 122, 124, 124, 47, 47, 47, 47, - 126, 126, 125, 125, 125, 125, 125, 127, 127, 112, - 112, 115, 115, 111, 111, 128, 128, 128, 128, 116, - 116, 116, 116, 103, 103, 117, 117, 117, 117, 71, - 129, 129, 130, 130, 130, 102, 102, 131, 131, 132, - 132, 132, 132, 118, 118, 118, 118, 134, 135, 133, - 133, 133, 133, 133, 133, 133, 136, 136, 136 + 0, 1, 3, 3, 2, 5, 5, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, + 7, 7, 7, 7, 8, 8, 9, 10, 11, 11, + 12, 12, 13, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 18, 18, 19, 19, 21, 21, + 17, 17, 22, 22, 23, 23, 24, 24, 25, 25, + 20, 20, 26, 28, 28, 29, 30, 30, 32, 31, + 31, 31, 31, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 14, 14, 54, 54, 56, 55, 55, 48, + 48, 58, 58, 59, 59, 60, 60, 15, 16, 16, + 16, 63, 63, 63, 64, 64, 67, 67, 65, 65, + 69, 69, 41, 41, 50, 50, 53, 53, 53, 52, + 52, 70, 42, 42, 42, 42, 71, 71, 72, 72, + 73, 73, 39, 39, 35, 35, 74, 37, 37, 75, + 36, 36, 38, 38, 49, 49, 49, 61, 61, 77, + 77, 78, 78, 80, 80, 80, 79, 79, 62, 62, + 81, 81, 81, 82, 82, 83, 83, 83, 44, 44, + 84, 84, 84, 45, 45, 85, 85, 86, 86, 66, + 87, 87, 87, 87, 92, 92, 93, 93, 94, 94, + 94, 94, 94, 95, 96, 96, 91, 91, 88, 88, + 90, 90, 98, 98, 97, 97, 97, 97, 97, 97, + 89, 89, 100, 99, 99, 46, 46, 40, 40, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 34, 34, 47, 47, 105, + 105, 106, 106, 106, 106, 112, 101, 101, 108, 108, + 114, 114, 115, 116, 116, 116, 116, 116, 116, 68, + 68, 57, 57, 57, 57, 102, 102, 120, 120, 117, + 117, 121, 121, 121, 121, 103, 103, 103, 107, 107, + 107, 113, 113, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 27, 27, 27, 27, + 27, 27, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 111, 111, 104, 104, + 104, 104, 127, 127, 130, 130, 129, 129, 131, 131, + 51, 51, 51, 51, 133, 133, 132, 132, 132, 132, + 132, 134, 134, 119, 119, 122, 122, 118, 118, 136, + 135, 135, 135, 135, 123, 123, 123, 123, 110, 110, + 124, 124, 124, 124, 76, 137, 137, 138, 138, 138, + 109, 109, 139, 139, 140, 140, 140, 140, 140, 125, + 125, 125, 125, 142, 143, 141, 141, 141, 141, 141, + 141, 141, 144, 144, 144 ); protected $ruleToLength = array( @@ -862,2292 +891,1784 @@ class Php5 extends \PhpParser\ParserAbstract 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 1, 1, 1, 1, 1, 3, - 5, 4, 3, 4, 2, 3, 1, 1, 7, 8, - 6, 7, 3, 1, 3, 1, 3, 1, 1, 3, - 1, 2, 1, 2, 3, 1, 3, 3, 1, 3, - 2, 0, 1, 1, 1, 1, 1, 3, 5, 8, - 3, 5, 9, 3, 2, 3, 2, 3, 2, 3, - 2, 3, 3, 3, 1, 2, 5, 7, 9, 5, - 6, 3, 3, 2, 2, 1, 1, 1, 0, 2, - 8, 0, 4, 1, 3, 0, 1, 0, 1, 10, - 7, 6, 5, 1, 2, 2, 0, 2, 0, 2, - 0, 2, 1, 3, 1, 4, 1, 4, 1, 1, - 4, 1, 3, 3, 3, 4, 4, 5, 0, 2, - 4, 3, 1, 1, 1, 4, 0, 2, 3, 0, - 2, 4, 0, 2, 0, 3, 1, 2, 1, 1, - 0, 1, 3, 4, 6, 1, 1, 1, 0, 1, - 0, 2, 2, 3, 3, 1, 3, 1, 2, 2, - 3, 1, 1, 2, 4, 3, 1, 1, 3, 2, - 0, 3, 3, 9, 3, 1, 3, 0, 2, 4, - 5, 4, 4, 4, 3, 1, 1, 1, 3, 1, - 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, - 1, 1, 3, 1, 3, 3, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 3, 5, 4, + 3, 4, 2, 3, 1, 1, 7, 6, 3, 1, + 3, 1, 3, 1, 1, 3, 1, 3, 1, 2, + 3, 1, 3, 3, 1, 3, 2, 0, 1, 1, + 1, 1, 1, 3, 5, 8, 3, 5, 9, 3, + 2, 3, 2, 3, 2, 3, 3, 3, 3, 1, + 2, 2, 5, 7, 9, 5, 6, 3, 3, 2, + 2, 1, 1, 1, 0, 2, 8, 0, 4, 1, + 3, 0, 1, 0, 1, 0, 1, 10, 7, 6, + 5, 1, 2, 2, 0, 2, 0, 2, 0, 2, + 1, 3, 1, 4, 1, 4, 1, 1, 4, 1, + 3, 3, 3, 4, 4, 5, 0, 2, 4, 3, + 1, 1, 1, 4, 0, 2, 3, 0, 2, 4, + 0, 2, 0, 3, 1, 2, 1, 1, 0, 1, + 3, 4, 6, 1, 1, 1, 0, 1, 0, 2, + 2, 3, 3, 1, 3, 1, 2, 2, 3, 1, + 1, 2, 4, 3, 1, 1, 3, 2, 0, 1, + 3, 3, 9, 3, 1, 3, 0, 2, 4, 5, + 4, 4, 4, 3, 1, 1, 1, 3, 1, 1, + 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 1, 3, 3, 1, 0, 1, 1, 3, 3, 4, 4, 1, 2, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, - 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 1, 3, 5, 4, 3, 4, 4, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 1, 1, 1, 3, 2, 1, - 2, 10, 11, 3, 3, 2, 4, 4, 3, 4, - 4, 4, 4, 7, 3, 2, 0, 4, 1, 3, - 2, 2, 4, 6, 2, 2, 4, 1, 1, 1, - 2, 3, 1, 1, 1, 1, 1, 1, 3, 3, - 4, 4, 0, 2, 1, 0, 1, 1, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 3, 2, 1, 3, 1, 4, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, - 4, 3, 1, 3, 1, 1, 3, 3, 0, 2, - 0, 1, 3, 1, 3, 1, 1, 1, 1, 1, - 6, 4, 3, 4, 2, 4, 4, 1, 3, 1, - 2, 1, 1, 4, 1, 3, 6, 4, 4, 4, - 4, 1, 4, 0, 1, 1, 3, 1, 1, 4, - 3, 1, 1, 1, 0, 0, 2, 3, 1, 3, - 1, 4, 2, 2, 2, 1, 2, 1, 1, 1, - 4, 3, 3, 3, 6, 3, 1, 1, 1 + 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 1, 3, 5, 4, 3, + 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 1, 1, 3, + 2, 1, 2, 10, 11, 3, 3, 2, 4, 4, + 3, 4, 4, 4, 4, 7, 3, 2, 0, 4, + 1, 3, 2, 2, 4, 6, 2, 2, 4, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 3, 4, 4, 0, 2, 1, 0, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 3, 2, 1, 3, 1, 4, + 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, + 3, 3, 5, 4, 4, 3, 1, 3, 1, 1, + 3, 3, 0, 2, 0, 1, 3, 1, 3, 1, + 1, 1, 1, 1, 6, 4, 3, 4, 2, 4, + 4, 1, 3, 1, 2, 1, 1, 4, 1, 1, + 3, 6, 4, 4, 4, 4, 1, 4, 0, 1, + 1, 3, 1, 1, 4, 3, 1, 1, 1, 0, + 0, 2, 3, 1, 3, 1, 4, 2, 2, 2, + 2, 1, 2, 1, 1, 1, 4, 3, 3, 3, + 6, 3, 1, 1, 1 ); - protected function reduceRule0() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule1() { - $this->semValue = $this->handleNamespaces($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule2() { - if (is_array($this->semStack[$this->stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)]); } else { $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; }; - } - - protected function reduceRule3() { - $this->semValue = array(); - } - - protected function reduceRule4() { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; - if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule5() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule6() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule7() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule8() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule9() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule10() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule11() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule12() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule13() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule14() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule15() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule16() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule17() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule18() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule19() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule20() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule21() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule22() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule23() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule24() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule25() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule26() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule27() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule28() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule29() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule30() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule31() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule32() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule33() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule34() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule35() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule36() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule37() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule38() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule39() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule40() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule41() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule42() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule43() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule44() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule45() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule46() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule47() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule48() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule49() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule50() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule51() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule52() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule53() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule54() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule55() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule56() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule57() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule58() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule59() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule60() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule61() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule62() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule63() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule64() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule65() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule66() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule67() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule68() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule69() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule70() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule71() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule72() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule73() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule74() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule75() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule76() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule77() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule78() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule79() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule80() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule81() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule82() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule83() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule84() { - $this->semValue = new Name($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule85() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule86() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule87() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule88() { - $this->semValue = new Stmt\HaltCompiler($this->lexer->handleHaltCompiler(), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule89() { - $this->semValue = new Stmt\Namespace_($this->semStack[$this->stackPos-(3-2)], null, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); + protected function initReduceCallbacks() { + $this->reduceCallbacks = [ + 0 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 1 => function ($stackPos) { + $this->semValue = $this->handleNamespaces($this->semStack[$stackPos-(1-1)]); + }, + 2 => function ($stackPos) { + if (is_array($this->semStack[$stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); } else { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; }; + }, + 3 => function ($stackPos) { + $this->semValue = array(); + }, + 4 => function ($stackPos) { + $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; + if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 5 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 6 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 7 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 8 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 9 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 10 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 11 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 12 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 13 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 14 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 15 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 16 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 17 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 18 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 19 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 20 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 21 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 22 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 23 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 24 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 25 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 26 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 27 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 28 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 29 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 30 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 31 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 32 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 33 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 34 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 35 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 36 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 37 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 38 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 39 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 40 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 41 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 42 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 43 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 44 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 45 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 46 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 47 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 48 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 49 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 50 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 51 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 52 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 53 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 54 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 55 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 56 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 57 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 58 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 59 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 60 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 61 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 62 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 63 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 64 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 65 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 66 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 67 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 68 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 69 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 70 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 71 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 72 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 73 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 74 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 75 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 76 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 77 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 78 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 79 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 80 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 81 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 82 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 83 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 84 => function ($stackPos) { + $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 85 => function ($stackPos) { + $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 86 => function ($stackPos) { + $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 87 => function ($stackPos) { + $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 88 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 89 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 90 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 91 => function ($stackPos) { + $this->semValue = new Name(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 92 => function ($stackPos) { + $this->semValue = new Expr\Variable(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 93 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 94 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 95 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 96 => function ($stackPos) { + $this->semValue = new Stmt\HaltCompiler($this->lexer->handleHaltCompiler(), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 97 => function ($stackPos) { + $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos-(3-2)], null, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_SEMICOLON); $this->checkNamespace($this->semValue); - } - - protected function reduceRule90() { - $this->semValue = new Stmt\Namespace_($this->semStack[$this->stackPos-(5-2)], $this->semStack[$this->stackPos-(5-4)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); + }, + 98 => function ($stackPos) { + $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos-(5-2)], $this->semStack[$stackPos-(5-4)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); $this->checkNamespace($this->semValue); - } - - protected function reduceRule91() { - $this->semValue = new Stmt\Namespace_(null, $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); + }, + 99 => function ($stackPos) { + $this->semValue = new Stmt\Namespace_(null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); $this->checkNamespace($this->semValue); - } + }, + 100 => function ($stackPos) { + $this->semValue = new Stmt\Use_($this->semStack[$stackPos-(3-2)], Stmt\Use_::TYPE_NORMAL, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 101 => function ($stackPos) { + $this->semValue = new Stmt\Use_($this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-2)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 102 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 103 => function ($stackPos) { + $this->semValue = new Stmt\Const_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 104 => function ($stackPos) { + $this->semValue = Stmt\Use_::TYPE_FUNCTION; + }, + 105 => function ($stackPos) { + $this->semValue = Stmt\Use_::TYPE_CONSTANT; + }, + 106 => function ($stackPos) { + $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(7-3)], $this->semStack[$stackPos-(7-6)], $this->semStack[$stackPos-(7-2)], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + }, + 107 => function ($stackPos) { + $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-5)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + }, + 108 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 109 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 110 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 111 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 112 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 113 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 114 => function ($stackPos) { + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(1-1)); + }, + 115 => function ($stackPos) { + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(3-3)); + }, + 116 => function ($stackPos) { + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(1-1)); + }, + 117 => function ($stackPos) { + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(3-3)); + }, + 118 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; $this->semValue->type = Stmt\Use_::TYPE_NORMAL; + }, + 119 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; $this->semValue->type = $this->semStack[$stackPos-(2-1)]; + }, + 120 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 121 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 122 => function ($stackPos) { + $this->semValue = new Node\Const_($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 123 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 124 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 125 => function ($stackPos) { + $this->semValue = new Node\Const_($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 126 => function ($stackPos) { + if (is_array($this->semStack[$stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); } else { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; }; + }, + 127 => function ($stackPos) { + $this->semValue = array(); + }, + 128 => function ($stackPos) { + $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; + if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 129 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 130 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 131 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 132 => function ($stackPos) { + throw new Error('__HALT_COMPILER() can only be used from the outermost scope', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 133 => function ($stackPos) { - protected function reduceRule92() { - $this->semValue = new Stmt\Use_($this->semStack[$this->stackPos-(3-2)], Stmt\Use_::TYPE_NORMAL, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule93() { - $this->semValue = new Stmt\Use_($this->semStack[$this->stackPos-(4-3)], $this->semStack[$this->stackPos-(4-2)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule94() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule95() { - $this->semValue = new Stmt\Const_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule96() { - $this->semValue = Stmt\Use_::TYPE_FUNCTION; - } - - protected function reduceRule97() { - $this->semValue = Stmt\Use_::TYPE_CONSTANT; - } - - protected function reduceRule98() { - $this->semValue = new Stmt\GroupUse(new Name($this->semStack[$this->stackPos-(7-3)], $this->startAttributeStack[$this->stackPos-(7-3)] + $this->endAttributeStack[$this->stackPos-(7-3)]), $this->semStack[$this->stackPos-(7-6)], $this->semStack[$this->stackPos-(7-2)], $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes); - } - - protected function reduceRule99() { - $this->semValue = new Stmt\GroupUse(new Name($this->semStack[$this->stackPos-(8-4)], $this->startAttributeStack[$this->stackPos-(8-4)] + $this->endAttributeStack[$this->stackPos-(8-4)]), $this->semStack[$this->stackPos-(8-7)], $this->semStack[$this->stackPos-(8-2)], $this->startAttributeStack[$this->stackPos-(8-1)] + $this->endAttributes); - } - - protected function reduceRule100() { - $this->semValue = new Stmt\GroupUse(new Name($this->semStack[$this->stackPos-(6-2)], $this->startAttributeStack[$this->stackPos-(6-2)] + $this->endAttributeStack[$this->stackPos-(6-2)]), $this->semStack[$this->stackPos-(6-5)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); - } - - protected function reduceRule101() { - $this->semValue = new Stmt\GroupUse(new Name($this->semStack[$this->stackPos-(7-3)], $this->startAttributeStack[$this->stackPos-(7-3)] + $this->endAttributeStack[$this->stackPos-(7-3)]), $this->semStack[$this->stackPos-(7-6)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes); - } - - protected function reduceRule102() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule103() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule104() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule105() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule106() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule107() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule108() { - $this->semValue = new Stmt\UseUse($this->semStack[$this->stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $this->stackPos-(1-1)); - } - - protected function reduceRule109() { - $this->semValue = new Stmt\UseUse($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $this->stackPos-(3-3)); - } - - protected function reduceRule110() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule111() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule112() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; $this->semValue->type = Stmt\Use_::TYPE_NORMAL; - } - - protected function reduceRule113() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; $this->semValue->type = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule114() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule115() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule116() { - $this->semValue = new Node\Const_($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule117() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule118() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule119() { - $this->semValue = new Node\Const_($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule120() { - if (is_array($this->semStack[$this->stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)]); } else { $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; }; - } - - protected function reduceRule121() { - $this->semValue = array(); - } - - protected function reduceRule122() { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; - if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule123() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule124() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule125() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule126() { - throw new Error('__HALT_COMPILER() can only be used from the outermost scope', $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule127() { - - if ($this->semStack[$this->stackPos-(3-2)]) { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; $attrs = $this->startAttributeStack[$this->stackPos-(3-1)]; $stmts = $this->semValue; if (!empty($attrs['comments'])) {$stmts[0]->setAttribute('comments', array_merge($attrs['comments'], $stmts[0]->getAttribute('comments', []))); }; + if ($this->semStack[$stackPos-(3-2)]) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; $attrs = $this->startAttributeStack[$stackPos-(3-1)]; $stmts = $this->semValue; if (!empty($attrs['comments'])) {$stmts[0]->setAttribute('comments', array_merge($attrs['comments'], $stmts[0]->getAttribute('comments', []))); }; } else { - $startAttributes = $this->startAttributeStack[$this->stackPos-(3-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $this->semValue = null; }; + $startAttributes = $this->startAttributeStack[$stackPos-(3-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; }; if (null === $this->semValue) { $this->semValue = array(); } } - } - - protected function reduceRule128() { - $this->semValue = new Stmt\If_($this->semStack[$this->stackPos-(5-2)], ['stmts' => is_array($this->semStack[$this->stackPos-(5-3)]) ? $this->semStack[$this->stackPos-(5-3)] : array($this->semStack[$this->stackPos-(5-3)]), 'elseifs' => $this->semStack[$this->stackPos-(5-4)], 'else' => $this->semStack[$this->stackPos-(5-5)]], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule129() { - $this->semValue = new Stmt\If_($this->semStack[$this->stackPos-(8-2)], ['stmts' => $this->semStack[$this->stackPos-(8-4)], 'elseifs' => $this->semStack[$this->stackPos-(8-5)], 'else' => $this->semStack[$this->stackPos-(8-6)]], $this->startAttributeStack[$this->stackPos-(8-1)] + $this->endAttributes); - } - - protected function reduceRule130() { - $this->semValue = new Stmt\While_($this->semStack[$this->stackPos-(3-2)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule131() { - $this->semValue = new Stmt\Do_($this->semStack[$this->stackPos-(5-4)], is_array($this->semStack[$this->stackPos-(5-2)]) ? $this->semStack[$this->stackPos-(5-2)] : array($this->semStack[$this->stackPos-(5-2)]), $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule132() { - $this->semValue = new Stmt\For_(['init' => $this->semStack[$this->stackPos-(9-3)], 'cond' => $this->semStack[$this->stackPos-(9-5)], 'loop' => $this->semStack[$this->stackPos-(9-7)], 'stmts' => $this->semStack[$this->stackPos-(9-9)]], $this->startAttributeStack[$this->stackPos-(9-1)] + $this->endAttributes); - } - - protected function reduceRule133() { - $this->semValue = new Stmt\Switch_($this->semStack[$this->stackPos-(3-2)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule134() { - $this->semValue = new Stmt\Break_(null, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule135() { - $this->semValue = new Stmt\Break_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule136() { - $this->semValue = new Stmt\Continue_(null, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule137() { - $this->semValue = new Stmt\Continue_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule138() { - $this->semValue = new Stmt\Return_(null, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule139() { - $this->semValue = new Stmt\Return_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule140() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule141() { - $this->semValue = new Stmt\Global_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule142() { - $this->semValue = new Stmt\Static_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule143() { - $this->semValue = new Stmt\Echo_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule144() { - $this->semValue = new Stmt\InlineHTML($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule145() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule146() { - $this->semValue = new Stmt\Unset_($this->semStack[$this->stackPos-(5-3)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule147() { - $this->semValue = new Stmt\Foreach_($this->semStack[$this->stackPos-(7-3)], $this->semStack[$this->stackPos-(7-5)][0], ['keyVar' => null, 'byRef' => $this->semStack[$this->stackPos-(7-5)][1], 'stmts' => $this->semStack[$this->stackPos-(7-7)]], $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes); - } - - protected function reduceRule148() { - $this->semValue = new Stmt\Foreach_($this->semStack[$this->stackPos-(9-3)], $this->semStack[$this->stackPos-(9-7)][0], ['keyVar' => $this->semStack[$this->stackPos-(9-5)], 'byRef' => $this->semStack[$this->stackPos-(9-7)][1], 'stmts' => $this->semStack[$this->stackPos-(9-9)]], $this->startAttributeStack[$this->stackPos-(9-1)] + $this->endAttributes); - } - - protected function reduceRule149() { - $this->semValue = new Stmt\Declare_($this->semStack[$this->stackPos-(5-3)], $this->semStack[$this->stackPos-(5-5)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule150() { - $this->semValue = new Stmt\TryCatch($this->semStack[$this->stackPos-(6-3)], $this->semStack[$this->stackPos-(6-5)], $this->semStack[$this->stackPos-(6-6)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); $this->checkTryCatch($this->semValue); - } - - protected function reduceRule151() { - $this->semValue = new Stmt\Throw_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule152() { - $this->semValue = new Stmt\Goto_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule153() { - $this->semValue = new Stmt\Label($this->semStack[$this->stackPos-(2-1)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule154() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule155() { - $this->semValue = array(); /* means: no statement */ - } - - protected function reduceRule156() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule157() { - $startAttributes = $this->startAttributeStack[$this->stackPos-(1-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $this->semValue = null; }; + }, + 134 => function ($stackPos) { + $this->semValue = new Stmt\If_($this->semStack[$stackPos-(5-2)], ['stmts' => is_array($this->semStack[$stackPos-(5-3)]) ? $this->semStack[$stackPos-(5-3)] : array($this->semStack[$stackPos-(5-3)]), 'elseifs' => $this->semStack[$stackPos-(5-4)], 'else' => $this->semStack[$stackPos-(5-5)]], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 135 => function ($stackPos) { + $this->semValue = new Stmt\If_($this->semStack[$stackPos-(8-2)], ['stmts' => $this->semStack[$stackPos-(8-4)], 'elseifs' => $this->semStack[$stackPos-(8-5)], 'else' => $this->semStack[$stackPos-(8-6)]], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); + }, + 136 => function ($stackPos) { + $this->semValue = new Stmt\While_($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 137 => function ($stackPos) { + $this->semValue = new Stmt\Do_($this->semStack[$stackPos-(5-4)], is_array($this->semStack[$stackPos-(5-2)]) ? $this->semStack[$stackPos-(5-2)] : array($this->semStack[$stackPos-(5-2)]), $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 138 => function ($stackPos) { + $this->semValue = new Stmt\For_(['init' => $this->semStack[$stackPos-(9-3)], 'cond' => $this->semStack[$stackPos-(9-5)], 'loop' => $this->semStack[$stackPos-(9-7)], 'stmts' => $this->semStack[$stackPos-(9-9)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + }, + 139 => function ($stackPos) { + $this->semValue = new Stmt\Switch_($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 140 => function ($stackPos) { + $this->semValue = new Stmt\Break_(null, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 141 => function ($stackPos) { + $this->semValue = new Stmt\Break_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 142 => function ($stackPos) { + $this->semValue = new Stmt\Continue_(null, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 143 => function ($stackPos) { + $this->semValue = new Stmt\Continue_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 144 => function ($stackPos) { + $this->semValue = new Stmt\Return_(null, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 145 => function ($stackPos) { + $this->semValue = new Stmt\Return_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 146 => function ($stackPos) { + $this->semValue = new Stmt\Global_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 147 => function ($stackPos) { + $this->semValue = new Stmt\Static_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 148 => function ($stackPos) { + $this->semValue = new Stmt\Echo_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 149 => function ($stackPos) { + $this->semValue = new Stmt\InlineHTML($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 150 => function ($stackPos) { + $this->semValue = new Stmt\Expression($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 151 => function ($stackPos) { + $this->semValue = new Stmt\Expression($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 152 => function ($stackPos) { + $this->semValue = new Stmt\Unset_($this->semStack[$stackPos-(5-3)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 153 => function ($stackPos) { + $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos-(7-3)], $this->semStack[$stackPos-(7-5)][0], ['keyVar' => null, 'byRef' => $this->semStack[$stackPos-(7-5)][1], 'stmts' => $this->semStack[$stackPos-(7-7)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + }, + 154 => function ($stackPos) { + $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos-(9-3)], $this->semStack[$stackPos-(9-7)][0], ['keyVar' => $this->semStack[$stackPos-(9-5)], 'byRef' => $this->semStack[$stackPos-(9-7)][1], 'stmts' => $this->semStack[$stackPos-(9-9)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + }, + 155 => function ($stackPos) { + $this->semValue = new Stmt\Declare_($this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 156 => function ($stackPos) { + $this->semValue = new Stmt\TryCatch($this->semStack[$stackPos-(6-3)], $this->semStack[$stackPos-(6-5)], $this->semStack[$stackPos-(6-6)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); $this->checkTryCatch($this->semValue); + }, + 157 => function ($stackPos) { + $this->semValue = new Stmt\Throw_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 158 => function ($stackPos) { + $this->semValue = new Stmt\Goto_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 159 => function ($stackPos) { + $this->semValue = new Stmt\Label($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 160 => function ($stackPos) { + $this->semValue = new Stmt\Expression($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 161 => function ($stackPos) { + $this->semValue = array(); /* means: no statement */ + }, + 162 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 163 => function ($stackPos) { + $startAttributes = $this->startAttributeStack[$stackPos-(1-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; }; if ($this->semValue === null) $this->semValue = array(); /* means: no statement */ - } - - protected function reduceRule158() { - $this->semValue = array(); - } - - protected function reduceRule159() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule160() { - $this->semValue = new Stmt\Catch_(array($this->semStack[$this->stackPos-(8-3)]), substr($this->semStack[$this->stackPos-(8-4)], 1), $this->semStack[$this->stackPos-(8-7)], $this->startAttributeStack[$this->stackPos-(8-1)] + $this->endAttributes); - } - - protected function reduceRule161() { - $this->semValue = null; - } - - protected function reduceRule162() { - $this->semValue = new Stmt\Finally_($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule163() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule164() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule165() { - $this->semValue = false; - } - - protected function reduceRule166() { - $this->semValue = true; - } - - protected function reduceRule167() { - $this->semValue = false; - } - - protected function reduceRule168() { - $this->semValue = true; - } - - protected function reduceRule169() { - $this->semValue = new Stmt\Function_($this->semStack[$this->stackPos-(10-3)], ['byRef' => $this->semStack[$this->stackPos-(10-2)], 'params' => $this->semStack[$this->stackPos-(10-5)], 'returnType' => $this->semStack[$this->stackPos-(10-7)], 'stmts' => $this->semStack[$this->stackPos-(10-9)]], $this->startAttributeStack[$this->stackPos-(10-1)] + $this->endAttributes); - } - - protected function reduceRule170() { - $this->semValue = new Stmt\Class_($this->semStack[$this->stackPos-(7-2)], ['type' => $this->semStack[$this->stackPos-(7-1)], 'extends' => $this->semStack[$this->stackPos-(7-3)], 'implements' => $this->semStack[$this->stackPos-(7-4)], 'stmts' => $this->semStack[$this->stackPos-(7-6)]], $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes); - $this->checkClass($this->semValue, $this->stackPos-(7-2)); - } - - protected function reduceRule171() { - $this->semValue = new Stmt\Interface_($this->semStack[$this->stackPos-(6-2)], ['extends' => $this->semStack[$this->stackPos-(6-3)], 'stmts' => $this->semStack[$this->stackPos-(6-5)]], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); - $this->checkInterface($this->semValue, $this->stackPos-(6-2)); - } - - protected function reduceRule172() { - $this->semValue = new Stmt\Trait_($this->semStack[$this->stackPos-(5-2)], ['stmts' => $this->semStack[$this->stackPos-(5-4)]], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule173() { - $this->semValue = 0; - } - - protected function reduceRule174() { - $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; - } - - protected function reduceRule175() { - $this->semValue = Stmt\Class_::MODIFIER_FINAL; - } - - protected function reduceRule176() { - $this->semValue = null; - } - - protected function reduceRule177() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule178() { - $this->semValue = array(); - } - - protected function reduceRule179() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule180() { - $this->semValue = array(); - } - - protected function reduceRule181() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule182() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule183() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule184() { - $this->semValue = is_array($this->semStack[$this->stackPos-(1-1)]) ? $this->semStack[$this->stackPos-(1-1)] : array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule185() { - $this->semValue = $this->semStack[$this->stackPos-(4-2)]; - } - - protected function reduceRule186() { - $this->semValue = is_array($this->semStack[$this->stackPos-(1-1)]) ? $this->semStack[$this->stackPos-(1-1)] : array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule187() { - $this->semValue = $this->semStack[$this->stackPos-(4-2)]; - } - - protected function reduceRule188() { - $this->semValue = is_array($this->semStack[$this->stackPos-(1-1)]) ? $this->semStack[$this->stackPos-(1-1)] : array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule189() { - $this->semValue = null; - } - - protected function reduceRule190() { - $this->semValue = $this->semStack[$this->stackPos-(4-2)]; - } - - protected function reduceRule191() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule192() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule193() { - $this->semValue = new Stmt\DeclareDeclare($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule194() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule195() { - $this->semValue = $this->semStack[$this->stackPos-(4-3)]; - } - - protected function reduceRule196() { - $this->semValue = $this->semStack[$this->stackPos-(4-2)]; - } - - protected function reduceRule197() { - $this->semValue = $this->semStack[$this->stackPos-(5-3)]; - } - - protected function reduceRule198() { - $this->semValue = array(); - } - - protected function reduceRule199() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule200() { - $this->semValue = new Stmt\Case_($this->semStack[$this->stackPos-(4-2)], $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule201() { - $this->semValue = new Stmt\Case_(null, $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule202() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule203() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule204() { - $this->semValue = is_array($this->semStack[$this->stackPos-(1-1)]) ? $this->semStack[$this->stackPos-(1-1)] : array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule205() { - $this->semValue = $this->semStack[$this->stackPos-(4-2)]; - } - - protected function reduceRule206() { - $this->semValue = array(); - } - - protected function reduceRule207() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule208() { - $this->semValue = new Stmt\ElseIf_($this->semStack[$this->stackPos-(3-2)], is_array($this->semStack[$this->stackPos-(3-3)]) ? $this->semStack[$this->stackPos-(3-3)] : array($this->semStack[$this->stackPos-(3-3)]), $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule209() { - $this->semValue = array(); - } - - protected function reduceRule210() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule211() { - $this->semValue = new Stmt\ElseIf_($this->semStack[$this->stackPos-(4-2)], $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule212() { - $this->semValue = null; - } - - protected function reduceRule213() { - $this->semValue = new Stmt\Else_(is_array($this->semStack[$this->stackPos-(2-2)]) ? $this->semStack[$this->stackPos-(2-2)] : array($this->semStack[$this->stackPos-(2-2)]), $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule214() { - $this->semValue = null; - } - - protected function reduceRule215() { - $this->semValue = new Stmt\Else_($this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule216() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)], false); - } - - protected function reduceRule217() { - $this->semValue = array($this->semStack[$this->stackPos-(2-2)], true); - } - - protected function reduceRule218() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)], false); - } - - protected function reduceRule219() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule220() { - $this->semValue = array(); - } - - protected function reduceRule221() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule222() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule223() { - $this->semValue = new Node\Param(substr($this->semStack[$this->stackPos-(4-4)], 1), null, $this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-2)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); $this->checkParam($this->semValue); - } - - protected function reduceRule224() { - $this->semValue = new Node\Param(substr($this->semStack[$this->stackPos-(6-4)], 1), $this->semStack[$this->stackPos-(6-6)], $this->semStack[$this->stackPos-(6-1)], $this->semStack[$this->stackPos-(6-2)], $this->semStack[$this->stackPos-(6-3)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); $this->checkParam($this->semValue); - } - - protected function reduceRule225() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule226() { - $this->semValue = 'array'; - } - - protected function reduceRule227() { - $this->semValue = 'callable'; - } - - protected function reduceRule228() { - $this->semValue = null; - } - - protected function reduceRule229() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule230() { - $this->semValue = null; - } - - protected function reduceRule231() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule232() { - $this->semValue = array(); - } - - protected function reduceRule233() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule234() { - $this->semValue = array(new Node\Arg($this->semStack[$this->stackPos-(3-2)], false, false, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes)); - } - - protected function reduceRule235() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule236() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule237() { - $this->semValue = new Node\Arg($this->semStack[$this->stackPos-(1-1)], false, false, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule238() { - $this->semValue = new Node\Arg($this->semStack[$this->stackPos-(2-2)], true, false, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule239() { - $this->semValue = new Node\Arg($this->semStack[$this->stackPos-(2-2)], false, true, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule240() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule241() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule242() { - $this->semValue = new Expr\Variable(substr($this->semStack[$this->stackPos-(1-1)], 1), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule243() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule244() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule245() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule246() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule247() { - $this->semValue = new Stmt\StaticVar(substr($this->semStack[$this->stackPos-(1-1)], 1), null, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule248() { - $this->semValue = new Stmt\StaticVar(substr($this->semStack[$this->stackPos-(3-1)], 1), $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule249() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule250() { - $this->semValue = array(); - } - - protected function reduceRule251() { - $this->semValue = new Stmt\Property($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); $this->checkProperty($this->semValue, $this->stackPos-(3-1)); - } - - protected function reduceRule252() { - $this->semValue = new Stmt\ClassConst($this->semStack[$this->stackPos-(3-2)], 0, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule253() { - $this->semValue = new Stmt\ClassMethod($this->semStack[$this->stackPos-(9-4)], ['type' => $this->semStack[$this->stackPos-(9-1)], 'byRef' => $this->semStack[$this->stackPos-(9-3)], 'params' => $this->semStack[$this->stackPos-(9-6)], 'returnType' => $this->semStack[$this->stackPos-(9-8)], 'stmts' => $this->semStack[$this->stackPos-(9-9)]], $this->startAttributeStack[$this->stackPos-(9-1)] + $this->endAttributes); - $this->checkClassMethod($this->semValue, $this->stackPos-(9-1)); - } - - protected function reduceRule254() { - $this->semValue = new Stmt\TraitUse($this->semStack[$this->stackPos-(3-2)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule255() { - $this->semValue = array(); - } - - protected function reduceRule256() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule257() { - $this->semValue = array(); - } - - protected function reduceRule258() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule259() { - $this->semValue = new Stmt\TraitUseAdaptation\Precedence($this->semStack[$this->stackPos-(4-1)][0], $this->semStack[$this->stackPos-(4-1)][1], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule260() { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$this->stackPos-(5-1)][0], $this->semStack[$this->stackPos-(5-1)][1], $this->semStack[$this->stackPos-(5-3)], $this->semStack[$this->stackPos-(5-4)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule261() { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$this->stackPos-(4-1)][0], $this->semStack[$this->stackPos-(4-1)][1], $this->semStack[$this->stackPos-(4-3)], null, $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule262() { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$this->stackPos-(4-1)][0], $this->semStack[$this->stackPos-(4-1)][1], null, $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule263() { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$this->stackPos-(4-1)][0], $this->semStack[$this->stackPos-(4-1)][1], null, $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule264() { - $this->semValue = array($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)]); - } - - protected function reduceRule265() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule266() { - $this->semValue = array(null, $this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule267() { - $this->semValue = null; - } - - protected function reduceRule268() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule269() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule270() { - $this->semValue = 0; - } - - protected function reduceRule271() { - $this->semValue = 0; - } - - protected function reduceRule272() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule273() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule274() { - $this->checkModifier($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)], $this->stackPos-(2-2)); $this->semValue = $this->semStack[$this->stackPos-(2-1)] | $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule275() { - $this->semValue = Stmt\Class_::MODIFIER_PUBLIC; - } - - protected function reduceRule276() { - $this->semValue = Stmt\Class_::MODIFIER_PROTECTED; - } - - protected function reduceRule277() { - $this->semValue = Stmt\Class_::MODIFIER_PRIVATE; - } - - protected function reduceRule278() { - $this->semValue = Stmt\Class_::MODIFIER_STATIC; - } - - protected function reduceRule279() { - $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; - } - - protected function reduceRule280() { - $this->semValue = Stmt\Class_::MODIFIER_FINAL; - } - - protected function reduceRule281() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule282() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule283() { - $this->semValue = new Stmt\PropertyProperty(substr($this->semStack[$this->stackPos-(1-1)], 1), null, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule284() { - $this->semValue = new Stmt\PropertyProperty(substr($this->semStack[$this->stackPos-(3-1)], 1), $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule285() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule286() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule287() { - $this->semValue = array(); - } - - protected function reduceRule288() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule289() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule290() { - $this->semValue = new Expr\Assign($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule291() { - $this->semValue = new Expr\Assign($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule292() { - $this->semValue = new Expr\AssignRef($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule293() { - $this->semValue = new Expr\AssignRef($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule294() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule295() { - $this->semValue = new Expr\Clone_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule296() { - $this->semValue = new Expr\AssignOp\Plus($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule297() { - $this->semValue = new Expr\AssignOp\Minus($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule298() { - $this->semValue = new Expr\AssignOp\Mul($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule299() { - $this->semValue = new Expr\AssignOp\Div($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule300() { - $this->semValue = new Expr\AssignOp\Concat($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule301() { - $this->semValue = new Expr\AssignOp\Mod($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule302() { - $this->semValue = new Expr\AssignOp\BitwiseAnd($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule303() { - $this->semValue = new Expr\AssignOp\BitwiseOr($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule304() { - $this->semValue = new Expr\AssignOp\BitwiseXor($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule305() { - $this->semValue = new Expr\AssignOp\ShiftLeft($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule306() { - $this->semValue = new Expr\AssignOp\ShiftRight($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule307() { - $this->semValue = new Expr\AssignOp\Pow($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule308() { - $this->semValue = new Expr\PostInc($this->semStack[$this->stackPos-(2-1)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule309() { - $this->semValue = new Expr\PreInc($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule310() { - $this->semValue = new Expr\PostDec($this->semStack[$this->stackPos-(2-1)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule311() { - $this->semValue = new Expr\PreDec($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule312() { - $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule313() { - $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule314() { - $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule315() { - $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule316() { - $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule317() { - $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule318() { - $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule319() { - $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule320() { - $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule321() { - $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule322() { - $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule323() { - $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule324() { - $this->semValue = new Expr\BinaryOp\Div($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule325() { - $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule326() { - $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule327() { - $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule328() { - $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule329() { - $this->semValue = new Expr\UnaryPlus($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule330() { - $this->semValue = new Expr\UnaryMinus($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule331() { - $this->semValue = new Expr\BooleanNot($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule332() { - $this->semValue = new Expr\BitwiseNot($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule333() { - $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule334() { - $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule335() { - $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule336() { - $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule337() { - $this->semValue = new Expr\BinaryOp\Spaceship($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule338() { - $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule339() { - $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule340() { - $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule341() { - $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule342() { - $this->semValue = new Expr\Instanceof_($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule343() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule344() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule345() { - $this->semValue = new Expr\Ternary($this->semStack[$this->stackPos-(5-1)], $this->semStack[$this->stackPos-(5-3)], $this->semStack[$this->stackPos-(5-5)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule346() { - $this->semValue = new Expr\Ternary($this->semStack[$this->stackPos-(4-1)], null, $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule347() { - $this->semValue = new Expr\BinaryOp\Coalesce($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule348() { - $this->semValue = new Expr\Isset_($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule349() { - $this->semValue = new Expr\Empty_($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule350() { - $this->semValue = new Expr\Include_($this->semStack[$this->stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule351() { - $this->semValue = new Expr\Include_($this->semStack[$this->stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE_ONCE, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule352() { - $this->semValue = new Expr\Eval_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule353() { - $this->semValue = new Expr\Include_($this->semStack[$this->stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule354() { - $this->semValue = new Expr\Include_($this->semStack[$this->stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE_ONCE, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule355() { - $this->semValue = new Expr\Cast\Int_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule356() { - $this->semValue = new Expr\Cast\Double($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule357() { - $this->semValue = new Expr\Cast\String_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule358() { - $this->semValue = new Expr\Cast\Array_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule359() { - $this->semValue = new Expr\Cast\Object_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule360() { - $this->semValue = new Expr\Cast\Bool_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule361() { - $this->semValue = new Expr\Cast\Unset_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule362() { - $attrs = $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes; - $attrs['kind'] = strtolower($this->semStack[$this->stackPos-(2-1)]) === 'exit' ? Expr\Exit_::KIND_EXIT : Expr\Exit_::KIND_DIE; - $this->semValue = new Expr\Exit_($this->semStack[$this->stackPos-(2-2)], $attrs); - } - - protected function reduceRule363() { - $this->semValue = new Expr\ErrorSuppress($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule364() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule365() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule366() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule367() { - $this->semValue = new Expr\ShellExec($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule368() { - $this->semValue = new Expr\Print_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule369() { - $this->semValue = new Expr\Yield_(null, null, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule370() { - $this->semValue = new Expr\YieldFrom($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule371() { - $this->semValue = new Expr\Closure(['static' => false, 'byRef' => $this->semStack[$this->stackPos-(10-2)], 'params' => $this->semStack[$this->stackPos-(10-4)], 'uses' => $this->semStack[$this->stackPos-(10-6)], 'returnType' => $this->semStack[$this->stackPos-(10-7)], 'stmts' => $this->semStack[$this->stackPos-(10-9)]], $this->startAttributeStack[$this->stackPos-(10-1)] + $this->endAttributes); - } - - protected function reduceRule372() { - $this->semValue = new Expr\Closure(['static' => true, 'byRef' => $this->semStack[$this->stackPos-(11-3)], 'params' => $this->semStack[$this->stackPos-(11-5)], 'uses' => $this->semStack[$this->stackPos-(11-7)], 'returnType' => $this->semStack[$this->stackPos-(11-8)], 'stmts' => $this->semStack[$this->stackPos-(11-10)]], $this->startAttributeStack[$this->stackPos-(11-1)] + $this->endAttributes); - } - - protected function reduceRule373() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule374() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule375() { - $this->semValue = new Expr\Yield_($this->semStack[$this->stackPos-(2-2)], null, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule376() { - $this->semValue = new Expr\Yield_($this->semStack[$this->stackPos-(4-4)], $this->semStack[$this->stackPos-(4-2)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule377() { - $attrs = $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_LONG; - $this->semValue = new Expr\Array_($this->semStack[$this->stackPos-(4-3)], $attrs); - } - - protected function reduceRule378() { - $attrs = $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_SHORT; - $this->semValue = new Expr\Array_($this->semStack[$this->stackPos-(3-2)], $attrs); - } - - protected function reduceRule379() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule380() { - $attrs = $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes; $attrs['kind'] = ($this->semStack[$this->stackPos-(4-1)][0] === "'" || ($this->semStack[$this->stackPos-(4-1)][1] === "'" && ($this->semStack[$this->stackPos-(4-1)][0] === 'b' || $this->semStack[$this->stackPos-(4-1)][0] === 'B')) ? Scalar\String_::KIND_SINGLE_QUOTED : Scalar\String_::KIND_DOUBLE_QUOTED); - $this->semValue = new Expr\ArrayDimFetch(new Scalar\String_(Scalar\String_::parse($this->semStack[$this->stackPos-(4-1)]), $attrs), $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule381() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule382() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule383() { - $this->semValue = array(new Stmt\Class_(null, ['type' => 0, 'extends' => $this->semStack[$this->stackPos-(7-3)], 'implements' => $this->semStack[$this->stackPos-(7-4)], 'stmts' => $this->semStack[$this->stackPos-(7-6)]], $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes), $this->semStack[$this->stackPos-(7-2)]); + }, + 164 => function ($stackPos) { + $this->semValue = array(); + }, + 165 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 166 => function ($stackPos) { + $this->semValue = new Stmt\Catch_(array($this->semStack[$stackPos-(8-3)]), $this->semStack[$stackPos-(8-4)], $this->semStack[$stackPos-(8-7)], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); + }, + 167 => function ($stackPos) { + $this->semValue = null; + }, + 168 => function ($stackPos) { + $this->semValue = new Stmt\Finally_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 169 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 170 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 171 => function ($stackPos) { + $this->semValue = false; + }, + 172 => function ($stackPos) { + $this->semValue = true; + }, + 173 => function ($stackPos) { + $this->semValue = false; + }, + 174 => function ($stackPos) { + $this->semValue = true; + }, + 175 => function ($stackPos) { + $this->semValue = false; + }, + 176 => function ($stackPos) { + $this->semValue = true; + }, + 177 => function ($stackPos) { + $this->semValue = new Stmt\Function_($this->semStack[$stackPos-(10-3)], ['byRef' => $this->semStack[$stackPos-(10-2)], 'params' => $this->semStack[$stackPos-(10-5)], 'returnType' => $this->semStack[$stackPos-(10-7)], 'stmts' => $this->semStack[$stackPos-(10-9)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); + }, + 178 => function ($stackPos) { + $this->semValue = new Stmt\Class_($this->semStack[$stackPos-(7-2)], ['type' => $this->semStack[$stackPos-(7-1)], 'extends' => $this->semStack[$stackPos-(7-3)], 'implements' => $this->semStack[$stackPos-(7-4)], 'stmts' => $this->semStack[$stackPos-(7-6)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + $this->checkClass($this->semValue, $stackPos-(7-2)); + }, + 179 => function ($stackPos) { + $this->semValue = new Stmt\Interface_($this->semStack[$stackPos-(6-2)], ['extends' => $this->semStack[$stackPos-(6-3)], 'stmts' => $this->semStack[$stackPos-(6-5)]], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + $this->checkInterface($this->semValue, $stackPos-(6-2)); + }, + 180 => function ($stackPos) { + $this->semValue = new Stmt\Trait_($this->semStack[$stackPos-(5-2)], ['stmts' => $this->semStack[$stackPos-(5-4)]], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 181 => function ($stackPos) { + $this->semValue = 0; + }, + 182 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; + }, + 183 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_FINAL; + }, + 184 => function ($stackPos) { + $this->semValue = null; + }, + 185 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; + }, + 186 => function ($stackPos) { + $this->semValue = array(); + }, + 187 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; + }, + 188 => function ($stackPos) { + $this->semValue = array(); + }, + 189 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; + }, + 190 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 191 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 192 => function ($stackPos) { + $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + }, + 193 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-2)]; + }, + 194 => function ($stackPos) { + $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + }, + 195 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-2)]; + }, + 196 => function ($stackPos) { + $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + }, + 197 => function ($stackPos) { + $this->semValue = null; + }, + 198 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-2)]; + }, + 199 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 200 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 201 => function ($stackPos) { + $this->semValue = new Stmt\DeclareDeclare($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 202 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 203 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-3)]; + }, + 204 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-2)]; + }, + 205 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(5-3)]; + }, + 206 => function ($stackPos) { + $this->semValue = array(); + }, + 207 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 208 => function ($stackPos) { + $this->semValue = new Stmt\Case_($this->semStack[$stackPos-(4-2)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 209 => function ($stackPos) { + $this->semValue = new Stmt\Case_(null, $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 210 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 211 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 212 => function ($stackPos) { + $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + }, + 213 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-2)]; + }, + 214 => function ($stackPos) { + $this->semValue = array(); + }, + 215 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 216 => function ($stackPos) { + $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos-(3-2)], is_array($this->semStack[$stackPos-(3-3)]) ? $this->semStack[$stackPos-(3-3)] : array($this->semStack[$stackPos-(3-3)]), $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 217 => function ($stackPos) { + $this->semValue = array(); + }, + 218 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 219 => function ($stackPos) { + $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos-(4-2)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 220 => function ($stackPos) { + $this->semValue = null; + }, + 221 => function ($stackPos) { + $this->semValue = new Stmt\Else_(is_array($this->semStack[$stackPos-(2-2)]) ? $this->semStack[$stackPos-(2-2)] : array($this->semStack[$stackPos-(2-2)]), $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 222 => function ($stackPos) { + $this->semValue = null; + }, + 223 => function ($stackPos) { + $this->semValue = new Stmt\Else_($this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 224 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)], false); + }, + 225 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(2-2)], true); + }, + 226 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)], false); + }, + 227 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 228 => function ($stackPos) { + $this->semValue = array(); + }, + 229 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 230 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 231 => function ($stackPos) { + $this->semValue = new Node\Param($this->semStack[$stackPos-(4-4)], null, $this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-2)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); $this->checkParam($this->semValue); + }, + 232 => function ($stackPos) { + $this->semValue = new Node\Param($this->semStack[$stackPos-(6-4)], $this->semStack[$stackPos-(6-6)], $this->semStack[$stackPos-(6-1)], $this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-3)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); $this->checkParam($this->semValue); + }, + 233 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 234 => function ($stackPos) { + $this->semValue = new Node\Identifier('array', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 235 => function ($stackPos) { + $this->semValue = new Node\Identifier('callable', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 236 => function ($stackPos) { + $this->semValue = null; + }, + 237 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 238 => function ($stackPos) { + $this->semValue = null; + }, + 239 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; + }, + 240 => function ($stackPos) { + $this->semValue = array(); + }, + 241 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 242 => function ($stackPos) { + $this->semValue = array(new Node\Arg($this->semStack[$stackPos-(3-2)], false, false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes)); + }, + 243 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 244 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 245 => function ($stackPos) { + $this->semValue = new Node\Arg($this->semStack[$stackPos-(1-1)], false, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 246 => function ($stackPos) { + $this->semValue = new Node\Arg($this->semStack[$stackPos-(2-2)], true, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 247 => function ($stackPos) { + $this->semValue = new Node\Arg($this->semStack[$stackPos-(2-2)], false, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 248 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 249 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 250 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 251 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 252 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 253 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 254 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 255 => function ($stackPos) { + $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos-(1-1)], null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 256 => function ($stackPos) { + $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 257 => function ($stackPos) { + if ($this->semStack[$stackPos-(2-2)] !== null) { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; } + }, + 258 => function ($stackPos) { + $this->semValue = array(); + }, + 259 => function ($stackPos) { + $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; + if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 260 => function ($stackPos) { + $this->semValue = new Stmt\Property($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->checkProperty($this->semValue, $stackPos-(3-1)); + }, + 261 => function ($stackPos) { + $this->semValue = new Stmt\ClassConst($this->semStack[$stackPos-(3-2)], 0, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 262 => function ($stackPos) { + $this->semValue = new Stmt\ClassMethod($this->semStack[$stackPos-(9-4)], ['type' => $this->semStack[$stackPos-(9-1)], 'byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-6)], 'returnType' => $this->semStack[$stackPos-(9-8)], 'stmts' => $this->semStack[$stackPos-(9-9)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + $this->checkClassMethod($this->semValue, $stackPos-(9-1)); + }, + 263 => function ($stackPos) { + $this->semValue = new Stmt\TraitUse($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 264 => function ($stackPos) { + $this->semValue = array(); + }, + 265 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 266 => function ($stackPos) { + $this->semValue = array(); + }, + 267 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 268 => function ($stackPos) { + $this->semValue = new Stmt\TraitUseAdaptation\Precedence($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 269 => function ($stackPos) { + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(5-1)][0], $this->semStack[$stackPos-(5-1)][1], $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-4)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 270 => function ($stackPos) { + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], $this->semStack[$stackPos-(4-3)], null, $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 271 => function ($stackPos) { + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 272 => function ($stackPos) { + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 273 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)]); + }, + 274 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 275 => function ($stackPos) { + $this->semValue = array(null, $this->semStack[$stackPos-(1-1)]); + }, + 276 => function ($stackPos) { + $this->semValue = null; + }, + 277 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 278 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 279 => function ($stackPos) { + $this->semValue = 0; + }, + 280 => function ($stackPos) { + $this->semValue = 0; + }, + 281 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 282 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 283 => function ($stackPos) { + $this->checkModifier($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $this->semValue = $this->semStack[$stackPos-(2-1)] | $this->semStack[$stackPos-(2-2)]; + }, + 284 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_PUBLIC; + }, + 285 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_PROTECTED; + }, + 286 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_PRIVATE; + }, + 287 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_STATIC; + }, + 288 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; + }, + 289 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_FINAL; + }, + 290 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 291 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 292 => function ($stackPos) { + $this->semValue = new Node\VarLikeIdentifier(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 293 => function ($stackPos) { + $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos-(1-1)], null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 294 => function ($stackPos) { + $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 295 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 296 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 297 => function ($stackPos) { + $this->semValue = array(); + }, + 298 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 299 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 300 => function ($stackPos) { + $this->semValue = new Expr\Assign($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 301 => function ($stackPos) { + $this->semValue = new Expr\Assign($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 302 => function ($stackPos) { + $this->semValue = new Expr\AssignRef($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 303 => function ($stackPos) { + $this->semValue = new Expr\AssignRef($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 304 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 305 => function ($stackPos) { + $this->semValue = new Expr\Clone_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 306 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Plus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 307 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Minus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 308 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Mul($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 309 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Div($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 310 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Concat($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 311 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Mod($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 312 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 313 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\BitwiseOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 314 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\BitwiseXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 315 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\ShiftLeft($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 316 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\ShiftRight($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 317 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Pow($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 318 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Coalesce($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 319 => function ($stackPos) { + $this->semValue = new Expr\PostInc($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 320 => function ($stackPos) { + $this->semValue = new Expr\PreInc($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 321 => function ($stackPos) { + $this->semValue = new Expr\PostDec($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 322 => function ($stackPos) { + $this->semValue = new Expr\PreDec($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 323 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 324 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 325 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 326 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 327 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 328 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 329 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 330 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 331 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 332 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 333 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 334 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 335 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 336 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Div($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 337 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 338 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 339 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 340 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 341 => function ($stackPos) { + $this->semValue = new Expr\UnaryPlus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 342 => function ($stackPos) { + $this->semValue = new Expr\UnaryMinus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 343 => function ($stackPos) { + $this->semValue = new Expr\BooleanNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 344 => function ($stackPos) { + $this->semValue = new Expr\BitwiseNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 345 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 346 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 347 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 348 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 349 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Spaceship($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 350 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 351 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 352 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 353 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 354 => function ($stackPos) { + $this->semValue = new Expr\Instanceof_($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 355 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 356 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 357 => function ($stackPos) { + $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(5-1)], $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 358 => function ($stackPos) { + $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(4-1)], null, $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 359 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Coalesce($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 360 => function ($stackPos) { + $this->semValue = new Expr\Isset_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 361 => function ($stackPos) { + $this->semValue = new Expr\Empty_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 362 => function ($stackPos) { + $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 363 => function ($stackPos) { + $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE_ONCE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 364 => function ($stackPos) { + $this->semValue = new Expr\Eval_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 365 => function ($stackPos) { + $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 366 => function ($stackPos) { + $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE_ONCE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 367 => function ($stackPos) { + $this->semValue = new Expr\Cast\Int_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 368 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes; + $attrs['kind'] = $this->getFloatCastKind($this->semStack[$stackPos-(2-1)]); + $this->semValue = new Expr\Cast\Double($this->semStack[$stackPos-(2-2)], $attrs); + }, + 369 => function ($stackPos) { + $this->semValue = new Expr\Cast\String_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 370 => function ($stackPos) { + $this->semValue = new Expr\Cast\Array_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 371 => function ($stackPos) { + $this->semValue = new Expr\Cast\Object_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 372 => function ($stackPos) { + $this->semValue = new Expr\Cast\Bool_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 373 => function ($stackPos) { + $this->semValue = new Expr\Cast\Unset_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 374 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes; + $attrs['kind'] = strtolower($this->semStack[$stackPos-(2-1)]) === 'exit' ? Expr\Exit_::KIND_EXIT : Expr\Exit_::KIND_DIE; + $this->semValue = new Expr\Exit_($this->semStack[$stackPos-(2-2)], $attrs); + }, + 375 => function ($stackPos) { + $this->semValue = new Expr\ErrorSuppress($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 376 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 377 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 378 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 379 => function ($stackPos) { + $this->semValue = new Expr\ShellExec($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 380 => function ($stackPos) { + $this->semValue = new Expr\Print_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 381 => function ($stackPos) { + $this->semValue = new Expr\Yield_(null, null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 382 => function ($stackPos) { + $this->semValue = new Expr\YieldFrom($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 383 => function ($stackPos) { + $this->semValue = new Expr\Closure(['static' => false, 'byRef' => $this->semStack[$stackPos-(10-2)], 'params' => $this->semStack[$stackPos-(10-4)], 'uses' => $this->semStack[$stackPos-(10-6)], 'returnType' => $this->semStack[$stackPos-(10-7)], 'stmts' => $this->semStack[$stackPos-(10-9)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); + }, + 384 => function ($stackPos) { + $this->semValue = new Expr\Closure(['static' => true, 'byRef' => $this->semStack[$stackPos-(11-3)], 'params' => $this->semStack[$stackPos-(11-5)], 'uses' => $this->semStack[$stackPos-(11-7)], 'returnType' => $this->semStack[$stackPos-(11-8)], 'stmts' => $this->semStack[$stackPos-(11-10)]], $this->startAttributeStack[$stackPos-(11-1)] + $this->endAttributes); + }, + 385 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 386 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 387 => function ($stackPos) { + $this->semValue = new Expr\Yield_($this->semStack[$stackPos-(2-2)], null, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 388 => function ($stackPos) { + $this->semValue = new Expr\Yield_($this->semStack[$stackPos-(4-4)], $this->semStack[$stackPos-(4-2)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 389 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_LONG; + $this->semValue = new Expr\Array_($this->semStack[$stackPos-(4-3)], $attrs); + }, + 390 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_SHORT; + $this->semValue = new Expr\Array_($this->semStack[$stackPos-(3-2)], $attrs); + }, + 391 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 392 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes; $attrs['kind'] = ($this->semStack[$stackPos-(4-1)][0] === "'" || ($this->semStack[$stackPos-(4-1)][1] === "'" && ($this->semStack[$stackPos-(4-1)][0] === 'b' || $this->semStack[$stackPos-(4-1)][0] === 'B')) ? Scalar\String_::KIND_SINGLE_QUOTED : Scalar\String_::KIND_DOUBLE_QUOTED); + $this->semValue = new Expr\ArrayDimFetch(new Scalar\String_(Scalar\String_::parse($this->semStack[$stackPos-(4-1)]), $attrs), $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 393 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 394 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 395 => function ($stackPos) { + $this->semValue = array(new Stmt\Class_(null, ['type' => 0, 'extends' => $this->semStack[$stackPos-(7-3)], 'implements' => $this->semStack[$stackPos-(7-4)], 'stmts' => $this->semStack[$stackPos-(7-6)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes), $this->semStack[$stackPos-(7-2)]); $this->checkClass($this->semValue[0], -1); - } - - protected function reduceRule384() { - $this->semValue = new Expr\New_($this->semStack[$this->stackPos-(3-2)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule385() { - list($class, $ctorArgs) = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = new Expr\New_($class, $ctorArgs, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule386() { - $this->semValue = array(); - } - - protected function reduceRule387() { - $this->semValue = $this->semStack[$this->stackPos-(4-3)]; - } - - protected function reduceRule388() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule389() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule390() { - $this->semValue = new Expr\ClosureUse(substr($this->semStack[$this->stackPos-(2-2)], 1), $this->semStack[$this->stackPos-(2-1)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule391() { - $this->semValue = new Expr\FuncCall($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule392() { - $this->semValue = new Expr\StaticCall($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule393() { - $this->semValue = new Expr\StaticCall($this->semStack[$this->stackPos-(6-1)], $this->semStack[$this->stackPos-(6-4)], $this->semStack[$this->stackPos-(6-6)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); - } - - protected function reduceRule394() { - - if ($this->semStack[$this->stackPos-(2-1)] instanceof Node\Expr\StaticPropertyFetch) { - $this->semValue = new Expr\StaticCall($this->semStack[$this->stackPos-(2-1)]->class, new Expr\Variable($this->semStack[$this->stackPos-(2-1)]->name, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes), $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } elseif ($this->semStack[$this->stackPos-(2-1)] instanceof Node\Expr\ArrayDimFetch) { - $tmp = $this->semStack[$this->stackPos-(2-1)]; - while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { - $tmp = $tmp->var; - } - - $this->semValue = new Expr\StaticCall($tmp->var->class, $this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - $tmp->var = new Expr\Variable($tmp->var->name, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } else { - throw new \Exception; - } - - } - - protected function reduceRule395() { - $this->semValue = new Expr\FuncCall($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule396() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule397() { - $this->semValue = new Name($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule398() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule399() { - $this->semValue = new Name($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule400() { - $this->semValue = new Name\FullyQualified($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule401() { - $this->semValue = new Name\Relative($this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule402() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule403() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule404() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule405() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule406() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule407() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule408() { - $this->semValue = new Expr\PropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule409() { - $this->semValue = new Expr\PropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule410() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule411() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule412() { - $this->semValue = null; - } - - protected function reduceRule413() { - $this->semValue = null; - } - - protected function reduceRule414() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule415() { - $this->semValue = array(); - } - - protected function reduceRule416() { - $this->semValue = array(new Scalar\EncapsedStringPart(Scalar\String_::parseEscapeSequences($this->semStack[$this->stackPos-(1-1)], '`', false), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes)); - } - - protected function reduceRule417() { - foreach ($this->semStack[$this->stackPos-(1-1)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', false); } }; $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule418() { - $this->semValue = array(); - } - - protected function reduceRule419() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule420() { - $this->semValue = $this->parseLNumber($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes, true); - } - - protected function reduceRule421() { - $this->semValue = new Scalar\DNumber(Scalar\DNumber::parse($this->semStack[$this->stackPos-(1-1)]), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule422() { - $attrs = $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes; $attrs['kind'] = ($this->semStack[$this->stackPos-(1-1)][0] === "'" || ($this->semStack[$this->stackPos-(1-1)][1] === "'" && ($this->semStack[$this->stackPos-(1-1)][0] === 'b' || $this->semStack[$this->stackPos-(1-1)][0] === 'B')) ? Scalar\String_::KIND_SINGLE_QUOTED : Scalar\String_::KIND_DOUBLE_QUOTED); - $this->semValue = new Scalar\String_(Scalar\String_::parse($this->semStack[$this->stackPos-(1-1)], false), $attrs); - } - - protected function reduceRule423() { - $this->semValue = new Scalar\MagicConst\Line($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule424() { - $this->semValue = new Scalar\MagicConst\File($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule425() { - $this->semValue = new Scalar\MagicConst\Dir($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule426() { - $this->semValue = new Scalar\MagicConst\Class_($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule427() { - $this->semValue = new Scalar\MagicConst\Trait_($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule428() { - $this->semValue = new Scalar\MagicConst\Method($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule429() { - $this->semValue = new Scalar\MagicConst\Function_($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule430() { - $this->semValue = new Scalar\MagicConst\Namespace_($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule431() { - $attrs = $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = strpos($this->semStack[$this->stackPos-(3-1)], "'") === false ? Scalar\String_::KIND_HEREDOC : Scalar\String_::KIND_NOWDOC; preg_match('/\A[bB]?<<<[ \t]*[\'"]?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[\'"]?(?:\r\n|\n|\r)\z/', $this->semStack[$this->stackPos-(3-1)], $matches); $attrs['docLabel'] = $matches[1];; - $this->semValue = new Scalar\String_(Scalar\String_::parseDocString($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-2)], false), $attrs); - } - - protected function reduceRule432() { - $attrs = $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes; $attrs['kind'] = strpos($this->semStack[$this->stackPos-(2-1)], "'") === false ? Scalar\String_::KIND_HEREDOC : Scalar\String_::KIND_NOWDOC; preg_match('/\A[bB]?<<<[ \t]*[\'"]?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[\'"]?(?:\r\n|\n|\r)\z/', $this->semStack[$this->stackPos-(2-1)], $matches); $attrs['docLabel'] = $matches[1];; - $this->semValue = new Scalar\String_('', $attrs); - } - - protected function reduceRule433() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule434() { - $this->semValue = new Expr\ClassConstFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule435() { - $this->semValue = new Expr\ConstFetch($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule436() { - $this->semValue = new Expr\Array_($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule437() { - $this->semValue = new Expr\Array_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule438() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule439() { - $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule440() { - $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule441() { - $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule442() { - $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule443() { - $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule444() { - $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule445() { - $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule446() { - $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule447() { - $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule448() { - $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule449() { - $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule450() { - $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule451() { - $this->semValue = new Expr\BinaryOp\Div($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule452() { - $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule453() { - $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule454() { - $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule455() { - $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule456() { - $this->semValue = new Expr\UnaryPlus($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule457() { - $this->semValue = new Expr\UnaryMinus($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule458() { - $this->semValue = new Expr\BooleanNot($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule459() { - $this->semValue = new Expr\BitwiseNot($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule460() { - $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule461() { - $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule462() { - $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule463() { - $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule464() { - $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule465() { - $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule466() { - $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule467() { - $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule468() { - $this->semValue = new Expr\Ternary($this->semStack[$this->stackPos-(5-1)], $this->semStack[$this->stackPos-(5-3)], $this->semStack[$this->stackPos-(5-5)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule469() { - $this->semValue = new Expr\Ternary($this->semStack[$this->stackPos-(4-1)], null, $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule470() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule471() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule472() { - $this->semValue = new Expr\ConstFetch($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule473() { - $this->semValue = new Expr\ClassConstFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule474() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule475() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule476() { - $attrs = $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; - foreach ($this->semStack[$this->stackPos-(3-2)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '"', true); } }; $this->semValue = new Scalar\Encapsed($this->semStack[$this->stackPos-(3-2)], $attrs); - } - - protected function reduceRule477() { - $attrs = $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = strpos($this->semStack[$this->stackPos-(3-1)], "'") === false ? Scalar\String_::KIND_HEREDOC : Scalar\String_::KIND_NOWDOC; preg_match('/\A[bB]?<<<[ \t]*[\'"]?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[\'"]?(?:\r\n|\n|\r)\z/', $this->semStack[$this->stackPos-(3-1)], $matches); $attrs['docLabel'] = $matches[1];; - foreach ($this->semStack[$this->stackPos-(3-2)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, null, true); } } $s->value = preg_replace('~(\r\n|\n|\r)\z~', '', $s->value); if ('' === $s->value) array_pop($this->semStack[$this->stackPos-(3-2)]);; $this->semValue = new Scalar\Encapsed($this->semStack[$this->stackPos-(3-2)], $attrs); - } - - protected function reduceRule478() { - $this->semValue = array(); - } - - protected function reduceRule479() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule480() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule481() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule482() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule483() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule484() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(3-3)], $this->semStack[$this->stackPos-(3-1)], false, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule485() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(1-1)], null, false, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule486() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule487() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule488() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule489() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule490() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(6-2)], $this->semStack[$this->stackPos-(6-5)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); - } - - protected function reduceRule491() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule492() { - $this->semValue = new Expr\PropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule493() { - $this->semValue = new Expr\MethodCall($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule494() { - $this->semValue = new Expr\FuncCall($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule495() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule496() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule497() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule498() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule499() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule500() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule501() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule502() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule503() { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule504() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule505() { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$this->stackPos-(3-1)], substr($this->semStack[$this->stackPos-(3-3)], 1), $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule506() { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$this->stackPos-(6-1)], $this->semStack[$this->stackPos-(6-5)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); - } - - protected function reduceRule507() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule508() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule509() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule510() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule511() { - $this->semValue = new Expr\Variable(substr($this->semStack[$this->stackPos-(1-1)], 1), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule512() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule513() { - $this->semValue = null; - } - - protected function reduceRule514() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule515() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule516() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule517() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule518() { - $this->semValue = new Expr\Error($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); $this->errorState = 2; - } - - protected function reduceRule519() { - $this->semValue = new Expr\List_($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule520() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule521() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule522() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(1-1)], null, false, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule523() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(1-1)], null, false, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule524() { - $this->semValue = null; - } - - protected function reduceRule525() { - $this->semValue = array(); - } - - protected function reduceRule526() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule527() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule528() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule529() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(3-3)], $this->semStack[$this->stackPos-(3-1)], false, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule530() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(1-1)], null, false, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule531() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(4-4)], $this->semStack[$this->stackPos-(4-1)], true, $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule532() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(2-2)], null, true, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule533() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule534() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule535() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule536() { - $this->semValue = array($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)]); - } - - protected function reduceRule537() { - $this->semValue = new Scalar\EncapsedStringPart($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule538() { - $this->semValue = new Expr\Variable(substr($this->semStack[$this->stackPos-(1-1)], 1), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule539() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule540() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule541() { - $this->semValue = new Expr\PropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule542() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule543() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule544() { - $this->semValue = new Expr\ArrayDimFetch(new Expr\Variable($this->semStack[$this->stackPos-(6-2)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes), $this->semStack[$this->stackPos-(6-4)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); - } - - protected function reduceRule545() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule546() { - $this->semValue = new Scalar\String_($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule547() { - $this->semValue = $this->parseNumString($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule548() { - $this->semValue = new Expr\Variable(substr($this->semStack[$this->stackPos-(1-1)], 1), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); + }, + 396 => function ($stackPos) { + $this->semValue = new Expr\New_($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 397 => function ($stackPos) { + list($class, $ctorArgs) = $this->semStack[$stackPos-(2-2)]; $this->semValue = new Expr\New_($class, $ctorArgs, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 398 => function ($stackPos) { + $this->semValue = array(); + }, + 399 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-3)]; + }, + 400 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 401 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 402 => function ($stackPos) { + $this->semValue = new Expr\ClosureUse($this->semStack[$stackPos-(2-2)], $this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 403 => function ($stackPos) { + $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 404 => function ($stackPos) { + $this->semValue = new Expr\StaticCall($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 405 => function ($stackPos) { + $this->semValue = new Expr\StaticCall($this->semStack[$stackPos-(6-1)], $this->semStack[$stackPos-(6-4)], $this->semStack[$stackPos-(6-6)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + }, + 406 => function ($stackPos) { + $this->semValue = $this->fixupPhp5StaticPropCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 407 => function ($stackPos) { + $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 408 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 409 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 410 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 411 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 412 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 413 => function ($stackPos) { + $this->semValue = new Name\FullyQualified(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 414 => function ($stackPos) { + $this->semValue = new Name\Relative(substr($this->semStack[$stackPos-(1-1)], 10), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 415 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 416 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 417 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 418 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 419 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 420 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 421 => function ($stackPos) { + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 422 => function ($stackPos) { + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 423 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 424 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 425 => function ($stackPos) { + $this->semValue = null; + }, + 426 => function ($stackPos) { + $this->semValue = null; + }, + 427 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 428 => function ($stackPos) { + $this->semValue = array(); + }, + 429 => function ($stackPos) { + $this->semValue = array(new Scalar\EncapsedStringPart(Scalar\String_::parseEscapeSequences($this->semStack[$stackPos-(1-1)], '`', false), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes)); + }, + 430 => function ($stackPos) { + foreach ($this->semStack[$stackPos-(1-1)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', false); } }; $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 431 => function ($stackPos) { + $this->semValue = array(); + }, + 432 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 433 => function ($stackPos) { + $this->semValue = $this->parseLNumber($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes, true); + }, + 434 => function ($stackPos) { + $this->semValue = new Scalar\DNumber(Scalar\DNumber::parse($this->semStack[$stackPos-(1-1)]), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 435 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes; $attrs['kind'] = ($this->semStack[$stackPos-(1-1)][0] === "'" || ($this->semStack[$stackPos-(1-1)][1] === "'" && ($this->semStack[$stackPos-(1-1)][0] === 'b' || $this->semStack[$stackPos-(1-1)][0] === 'B')) ? Scalar\String_::KIND_SINGLE_QUOTED : Scalar\String_::KIND_DOUBLE_QUOTED); + $this->semValue = new Scalar\String_(Scalar\String_::parse($this->semStack[$stackPos-(1-1)], false), $attrs); + }, + 436 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Line($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 437 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\File($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 438 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Dir($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 439 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Class_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 440 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Trait_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 441 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Method($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 442 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Function_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 443 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Namespace_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 444 => function ($stackPos) { + $this->semValue = $this->parseDocString($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(3-3)] + $this->endAttributeStack[$stackPos-(3-3)], false); + }, + 445 => function ($stackPos) { + $this->semValue = $this->parseDocString($this->semStack[$stackPos-(2-1)], '', $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(2-2)] + $this->endAttributeStack[$stackPos-(2-2)], false); + }, + 446 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 447 => function ($stackPos) { + $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 448 => function ($stackPos) { + $this->semValue = new Expr\ConstFetch($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 449 => function ($stackPos) { + $this->semValue = new Expr\Array_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 450 => function ($stackPos) { + $this->semValue = new Expr\Array_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 451 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 452 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 453 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 454 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 455 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 456 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 457 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 458 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 459 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 460 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 461 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 462 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 463 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 464 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 465 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Div($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 466 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 467 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 468 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 469 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 470 => function ($stackPos) { + $this->semValue = new Expr\UnaryPlus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 471 => function ($stackPos) { + $this->semValue = new Expr\UnaryMinus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 472 => function ($stackPos) { + $this->semValue = new Expr\BooleanNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 473 => function ($stackPos) { + $this->semValue = new Expr\BitwiseNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 474 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 475 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 476 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 477 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 478 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 479 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 480 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 481 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 482 => function ($stackPos) { + $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(5-1)], $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 483 => function ($stackPos) { + $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(4-1)], null, $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 484 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 485 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 486 => function ($stackPos) { + $this->semValue = new Expr\ConstFetch($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 487 => function ($stackPos) { + $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 488 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 489 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 490 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; + foreach ($this->semStack[$stackPos-(3-2)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '"', true); } }; $this->semValue = new Scalar\Encapsed($this->semStack[$stackPos-(3-2)], $attrs); + }, + 491 => function ($stackPos) { + $this->semValue = $this->parseDocString($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(3-3)] + $this->endAttributeStack[$stackPos-(3-3)], true); + }, + 492 => function ($stackPos) { + $this->semValue = array(); + }, + 493 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 494 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 495 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 496 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 497 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 498 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(3-3)], $this->semStack[$stackPos-(3-1)], false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 499 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 500 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 501 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 502 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 503 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 504 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-5)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + }, + 505 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 506 => function ($stackPos) { + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 507 => function ($stackPos) { + $this->semValue = new Expr\MethodCall($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 508 => function ($stackPos) { + $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 509 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 510 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 511 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 512 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 513 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 514 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 515 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 516 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 517 => function ($stackPos) { + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 518 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 519 => function ($stackPos) { + $var = substr($this->semStack[$stackPos-(1-1)], 1); $this->semValue = \is_string($var) ? new Node\VarLikeIdentifier($var, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes) : $var; + }, + 520 => function ($stackPos) { + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 521 => function ($stackPos) { + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(6-1)], $this->semStack[$stackPos-(6-5)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + }, + 522 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 523 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 524 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 525 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 526 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 527 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 528 => function ($stackPos) { + $this->semValue = null; + }, + 529 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 530 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 531 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 532 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 533 => function ($stackPos) { + $this->semValue = new Expr\Error($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->errorState = 2; + }, + 534 => function ($stackPos) { + $this->semValue = new Expr\List_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 535 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 536 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 537 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 538 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 539 => function ($stackPos) { + $this->semValue = null; + }, + 540 => function ($stackPos) { + $this->semValue = array(); + }, + 541 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 542 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 543 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 544 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(3-3)], $this->semStack[$stackPos-(3-1)], false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 545 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 546 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(4-4)], $this->semStack[$stackPos-(4-1)], true, $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 547 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(2-2)], null, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 548 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(2-2)], null, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 549 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 550 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 551 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 552 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); + }, + 553 => function ($stackPos) { + $this->semValue = new Scalar\EncapsedStringPart($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 554 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 555 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 556 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 557 => function ($stackPos) { + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 558 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 559 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 560 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-4)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + }, + 561 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 562 => function ($stackPos) { + $this->semValue = new Scalar\String_($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 563 => function ($stackPos) { + $this->semValue = $this->parseNumString($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 564 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + ]; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Parser/Php7.php b/lib/nikic/php-parser/lib/PhpParser/Parser/Php7.php index 591bd61fc..75fc06db7 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Parser/Php7.php +++ b/lib/nikic/php-parser/lib/PhpParser/Parser/Php7.php @@ -17,21 +17,22 @@ use PhpParser\Node\Stmt; */ class Php7 extends \PhpParser\ParserAbstract { - protected $tokenToSymbolMapSize = 392; - protected $actionTableSize = 915; - protected $gotoTableSize = 429; + protected $tokenToSymbolMapSize = 396; + protected $actionTableSize = 1187; + protected $gotoTableSize = 579; - protected $invalidSymbol = 157; + protected $invalidSymbol = 168; protected $errorSymbol = 1; protected $defaultAction = -32766; protected $unexpectedTokenRule = 32767; - protected $YY2TBLSTATE = 330; - protected $YYNLSTATES = 578; + protected $YY2TBLSTATE = 415; + protected $numNonLeafStates = 702; protected $symbolToName = array( "EOF", "error", + "T_THROW", "T_INCLUDE", "T_INCLUDE_ONCE", "T_EVAL", @@ -58,6 +59,7 @@ class Php7 extends \PhpParser\ParserAbstract "T_SL_EQUAL", "T_SR_EQUAL", "T_POW_EQUAL", + "T_COALESCE_EQUAL", "'?'", "':'", "T_COALESCE", @@ -65,7 +67,8 @@ class Php7 extends \PhpParser\ParserAbstract "T_BOOLEAN_AND", "'|'", "'^'", - "'&'", + "T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG", + "T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG", "T_IS_EQUAL", "T_IS_NOT_EQUAL", "T_IS_IDENTICAL", @@ -126,6 +129,7 @@ class Php7 extends \PhpParser\ParserAbstract "T_ENDDECLARE", "T_AS", "T_SWITCH", + "T_MATCH", "T_ENDSWITCH", "T_CASE", "T_DEFAULT", @@ -133,12 +137,12 @@ class Php7 extends \PhpParser\ParserAbstract "T_CONTINUE", "T_GOTO", "T_FUNCTION", + "T_FN", "T_CONST", "T_RETURN", "T_TRY", "T_CATCH", "T_FINALLY", - "T_THROW", "T_USE", "T_INSTEADOF", "T_GLOBAL", @@ -148,6 +152,7 @@ class Php7 extends \PhpParser\ParserAbstract "T_PRIVATE", "T_PROTECTED", "T_PUBLIC", + "T_READONLY", "T_VAR", "T_UNSET", "T_ISSET", @@ -156,9 +161,11 @@ class Php7 extends \PhpParser\ParserAbstract "T_CLASS", "T_TRAIT", "T_INTERFACE", + "T_ENUM", "T_EXTENDS", "T_IMPLEMENTS", "T_OBJECT_OPERATOR", + "T_NULLSAFE_OBJECT_OPERATOR", "T_LIST", "T_ARRAY", "T_CALLABLE", @@ -178,585 +185,721 @@ class Php7 extends \PhpParser\ParserAbstract "T_DIR", "T_NS_SEPARATOR", "T_ELLIPSIS", + "T_NAME_FULLY_QUALIFIED", + "T_NAME_QUALIFIED", + "T_NAME_RELATIVE", + "T_ATTRIBUTE", "';'", + "']'", "'{'", "'}'", "'('", "')'", "'`'", - "']'", "'\"'", "'$'" ); protected $tokenToSymbol = array( - 0, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 53, 155, 157, 156, 52, 35, 157, - 151, 152, 50, 47, 7, 48, 49, 51, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 29, 148, - 41, 15, 43, 28, 65, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 67, 157, 154, 34, 157, 153, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 149, 33, 150, 55, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 1, 2, 3, 4, - 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, + 0, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 56, 166, 168, 167, 55, 168, 168, + 163, 164, 53, 50, 8, 51, 52, 54, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 31, 159, + 44, 16, 46, 30, 68, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 70, 168, 160, 36, 168, 165, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 161, 35, 162, 58, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 1, 2, 3, 4, + 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 30, 31, 32, 36, 37, 38, 39, 40, 42, - 44, 45, 46, 54, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 66, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 77, 78, 79, 80, 81, 157, 157, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + 27, 28, 29, 32, 33, 34, 37, 38, 39, 40, + 41, 42, 43, 45, 47, 48, 49, 57, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 69, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, + 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, + 153, 154, 155, 156, 157, 158 + ); + + protected $action = array( + 131, 132, 133, 563, 134, 135, 0, 714, 715, 716, + 136, 36, 977, 976, 975, 978,-32766,-32766,-32766,-32767, + -32767,-32767,-32767, 100, 101, 102, 103, 104, 1051, 1052, + 1053, 1050, 1049, 1048, 1054, 708, 707,-32766,-32766,-32766, + -32766,-32766,-32766,-32766,-32766,-32766,-32767,-32767,-32767,-32767, + -32767, 539, 540, 903, 2, 717,-32766,-32766,-32766, 988, + 989, -88, 914, 440, 441, 442, 365, 366, 462, 265, + 137, 391, 721, 722, 723, 724, 409,-32766, 415,-32766, + -32766,-32766,-32766,-32766, -305, 725, 726, 727, 728, 729, + 730, 731, 732, 733, 734, 735, 755, 564, 756, 757, + 758, 759, 747, 748, 331, 332, 750, 751, 736, 737, + 738, 740, 741, 742, 341, 782, 783, 784, 785, 786, + 787, 743, 744, 565, 566, 776, 767, 765, 766, 779, + 762, 763, 981, 415, 567, 568, 761, 569, 570, 571, + 572, 573, 574, -193, -566, 535, 485, 790, 764, 575, + 576, -566, 138,-32766,-32766,-32766, 131, 132, 133, 563, + 134, 135, 1002, 714, 715, 716, 136, 36, 1043,-32766, + -32766,-32766, 799, -86,-32766, 1276,-32766,-32766,-32766,-32766, + -32766,-32766,-32766, 1051, 1052, 1053, 1050, 1049, 1048, 1054, + -32766, 708, 707,-32766,-32766,-32766, 1241, 238, 463,-32766, + -32766,-32766,-32766,-32766,-32766, 883, 1213, 125, 1176, 1175, + 1177, 717, 801, 689,-32766, 1029,-32766,-32766,-32766,-32766, + -32766, -192,-32766,-32766,-32766, 265, 137, 391, 721, 722, + 723, 724, 883, 945, 415, 680, 12, 34, 247, -86, + -305, 725, 726, 727, 728, 729, 730, 731, 732, 733, + 734, 735, 755, 564, 756, 757, 758, 759, 747, 748, + 331, 332, 750, 751, 736, 737, 738, 740, 741, 742, + 341, 782, 783, 784, 785, 786, 787, 743, 744, 565, + 566, 776, 767, 765, 766, 779, 762, 763, 873, 585, + 567, 568, 761, 569, 570, 571, 572, 573, 574, -193, + 81, 82, 83, -566, 764, 575, 576, -566, 138, 739, + 709, 710, 711, 712, 713, 873, 714, 715, 716, 752, + 753, 35, 33, 84, 85, 86, 87, 88, 89, 90, + 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, + 101, 102, 103, 104, 105, 106, 107, -264, 267,-32766, + -32766,-32766,-32766, 105, 106, 107, 80, 267, 127, 1001, + 108, 946, 314, 885, 717, 675, 367, 366, 143, 108, + 800,-32766, 1027,-32766,-32766, 148, 409, -192, 718, 719, + 720, 721, 722, 723, 724, 237, 1181, 788, 276, -517, + 885, 315, 675, 149, 725, 726, 727, 728, 729, 730, + 731, 732, 733, 734, 735, 755, 778, 756, 757, 758, + 759, 747, 748, 749, 777, 750, 751, 736, 737, 738, + 740, 741, 742, 781, 782, 783, 784, 785, 786, 787, + 743, 744, 745, 746, 776, 767, 765, 766, 779, 762, + 763,-32766,-32766, 754, 760, 761, 768, 769, 771, 770, + 772, 773, 251, -517, -517, 448, 449, 764, 775, 774, + 48, 49, 50, 494, 51, 52, 795, 799, -517, 591, + 53, 54, -111, 55, 986, 708, 707, -111, 792, -111, + -517, 298, -523, 986, 294, 631, 24, -111, -111, -111, + -111, -111, -111, -111, -111, 988, 989, 300, 1286, 1261, + -343, 1287, -343, 1174, 988, 989, 1260, 312, 56, 57, + -32766,-32766,-32766, -111, 58, 1201, 59, 244, 245, 60, + 61, 62, 63, 64, 65, 66, 67, -516, 26, 266, + 68, 429, 495, -319, 647, 648, 1207, 1208, 496, 1172, + 799, 1181, 796, 287, 1205, 40, 23, 497, 73, 498, + 328, 499, 314, 500, 794, 329, 501, 502, 826, 677, + 827, 42, 43, 430, 362, 361, 883, 44, 503, 147, + 394, -16, -557, 353, 327, 355, -557, 1181, 1176, 1175, + 1177, -518, 504, 505, 506, 359, -515, 1257, 47, 363, + 364, -516, -516, 374, 507, 508, 799, 1195, 1196, 1197, + 1198, 1192, 1193, 286, -563, 425, -516, 798, 151, 1199, + 1194, -563, 426, 1176, 1175, 1177, 287, 883, -516, 427, + -522, 69, 799, 310, 311, 314, 30, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, + -153, -153, -153, 368, 369, -518, -518, 681, 428, 873, + -515, -515, 290, 291, 883, -153, 805, -153, 799, -153, + -518, -153, 708, 707, 152, -515, 790, 358, -111, 1088, + 1090, 360, -518, 153, 883, 139, 376, -515, 11, 126, + -515, 314, -111, -111, 682, 155, 279, -520, 102, 103, + 104, 31, 859, -111, -111, -111, -111, 46, 287,-32766, + 873, 623, 624, 73, 684, 1174, 826, 314, 827, 1028, + -79, 700,-32766,-32766,-32766, 122,-32766, 123,-32766, 128, + -32766, 708, 707,-32766, 885, 883, 675, -153,-32766,-32766, + -32766, 708, 707, 129,-32766,-32766, 142, 873, 156, 73, + -32766, 406, 157, 314, -515, -515, 158, 140, 159,-32766, + -75, -520, -520, 314, 26, 691, -73, 873, -72, -515, + -71, 288, 289, -563, -70, -69, 799, -563,-32766, -68, + 1205, -515,-32766, -67, 1174, 885, -66, 675, -520, 72, + -47,-32766,-32766,-32766, -18,-32766, 146,-32766, 124,-32766, + 268, 275,-32766, 988, 989, 690, -51,-32766,-32766,-32766, + 693, 882, 145,-32766,-32766, 899, 108, 277, 873,-32766, + 406, 278, 931, 280, 675, 281, 321, 144,-32766, 267, + 507, 508, 799, 1195, 1196, 1197, 1198, 1192, 1193, 655, + 130, 790, 885, 1288, 675, 1199, 1194, 543, 1058,-32766, + 650, 13,-32766, 537, 632, 1174, 424, 71, 621, 915, + 311, 314,-32766,-32766,-32766, 668,-32766, 637,-32766,-32766, + -32766, 293, 1212,-32766, 916, 445, 638, 549,-32766,-32766, + -32766, 473, -481,-32766,-32766,-32766, -4, 883, -551, 1174, + -32766, 406, 651, 885, 589, 675,-32766,-32766,-32766,-32766, + -32766, 295,-32766, 901,-32766, 0, 798,-32766, 0, 0, + 0, 0,-32766,-32766,-32766,-32766, 0, 292,-32766,-32766, + 0, 1174, 0, 0,-32766, 406, 299, 0,-32766,-32766, + -32766, 0,-32766,-32766,-32766, 1214,-32766, 0, 0,-32766, + 0, 287, -471, 468,-32766,-32766,-32766,-32766, 7, 15, + -32766,-32766, 357, 1174, 555, 38,-32766, 406, 1202, 883, + -32766,-32766,-32766, 39,-32766,-32766,-32766, 697,-32766, 698, + 873,-32766, 864, 955, 932, 939,-32766,-32766,-32766, 929, + 940, 862,-32766,-32766, 927, 1032, 1035, 1036,-32766, 406, + 1033, 1034, 360, 1040, 420, 883, 810,-32766, 1227, 285, + 1245, 694, 1279, -111, -111, 626, 860, 32, 309, 356, + 676, 679, 683, 818, -111, -111, -111, -111, 685, 686, + -32766, 687, 688, 692, 678, 1206, 1174, 1283, 1285, 821, + 820, 829, 908,-32766,-32766,-32766, 9,-32766, 947,-32766, + 828,-32766, 873, 1284,-32766, 885, 907, 675, -4,-32766, + -32766,-32766, 909, 906, 1160,-32766,-32766, 892, -242, -242, + -242,-32766, 406, 902, 360, 26, 890, 937, 938, 1282, + -32766, 1239, 1228, 1246, 1252, -111, -111, 799, 873, 1255, + -267, 1205, -549, -523, -522, 859, -111, -111, -111, -111, + -521, 1, 27, 28, -241, -241, -241, 37, 41, 45, + 360, 70, 74, 75, 76, 77, 78, 79, 141, 0, + 150, -111, -111, 154, 243, 316, 342, 885, 343, 675, + -242, 859, -111, -111, -111, -111, 344, 345, 346, 347, + 348, 349, 508, 350, 1195, 1196, 1197, 1198, 1192, 1193, + 351, 352, 354, 421, 0, -265, 1199, 1194, -264, 17, + 18, 19, 20, 885, 22, 675, -241, 393, 71, 314, + 464, 311, 314, 465, 472, 475, 476, 477, 478, 482, + 483, 484, 492, 662, 1185, 1128, 1203, 1003, 1164, -269, + -103, 16, 21, 25, 284, 392, 582, 586, 613, 667, + 1132, 1180, 1129, 1258, 0, -485, 1145 + ); + + protected $actionCheck = array( + 2, 3, 4, 5, 6, 7, 0, 9, 10, 11, + 12, 13, 119, 120, 121, 122, 9, 10, 11, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 116, 117, + 118, 119, 120, 121, 122, 37, 38, 30, 116, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 117, 118, 1, 8, 57, 9, 10, 11, 137, + 138, 31, 128, 129, 130, 131, 106, 107, 31, 71, + 72, 73, 74, 75, 76, 77, 116, 30, 80, 32, + 33, 34, 35, 36, 8, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, - 132, 133, 134, 135, 136, 137, 157, 157, 157, 157, - 157, 157, 138, 139, 140, 141, 142, 143, 144, 145, - 146, 147 - ); - - protected $action = array( - 583, 584, 585, 586, 587, 1037, 588, 589, 590, 626, - 627, 479, 29, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112,-32766,-32766,-32766, 97, 98, - 99, 0, 241, 387, -282,-32766,-32766,-32766,-32766, -487, - 1081, 544, 1084, 1082, 100,-32766, 664,-32766,-32766,-32766, - -32766,-32766, 591, 901, 903,-32766, 30,-32766,-32766,-32766, - -32766,-32766,-32766, 1034,-32766, 295, 592, 593, 594, 595, - 596, 597, 598,-32766, 274, 658, 869, 870, 871, 868, - 867, 866, 599, 600, 601, 602, 603, 604, 605, 606, - 607, 608, 609, 629, 630, 631, 632, 633, 621, 622, - 623, 624, 625, 610, 611, 612, 613, 614, 615, 616, - 652, 653, 654, 655, 656, 657, 617, 618, 619, 620, - 650, 641, 639, 640, 636, 637, -251, 628, 634, 635, - 642, 643, 645, 644, 646, 647, 74, 75, 76, 556, - 266, 638, 649, 648, 739, 44, 45, 392, 46, 47, - 375, 680, 681, 73, 48, 49, 28, 50, 77, 78, - 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, - 99, 218, 241, 996, -487, -443, -487,-32766,-32766,-32766, - 51, 52, 116, 663, 100, 339, 53, 242, 54, 221, - 222, 55, 56, 57, 58, 59, 60, 61, 62, -173, - 24, 234, 63, 347, 393,-32766,-32766,-32766, 1001, 1002, - 394, 228, 1034, 217, 729,-32766, 1000, 34, 19, 395, - 1051, 396, 127, 397, 118, 398, -442, 24, 399, 984, - 43, 267, 36, 37, 400, 351, -443, 38, 401, 1034, - 248, 64, 289, 1000, 288, 290, 248,-32766, 741, 226, - -443, 1034, 404, 405, 406, 442, 291, -443, 371, -446, - 376, -251, 409, 410, 26, 1006, 1007, 1008, 1009, 1003, - 1004, 245, 977,-32766,-32766,-32766, 419, 1010, 1005, 349, - -488, 226, 549, 278, 65,-32766, 257, -442, 262, 266, - 410, 660, 467,-32766, 1073,-32766, 1048, 1072,-32766,-32766, - -32766, -442,-32766,-32766,-32766, 1078,-32766, 1034, -442,-32766, - -445, 67, 1014,-32766,-32766,-32766, 266,-32766,-32766,-32766, - -479, 123,-32766, 660, -172,-32766, 418,-32766, 266, 531, - -32766,-32766,-32766,-32766,-32766,-32766,-32766, 223,-32766, 560, - 977,-32766, 818, 819, -173,-32766,-32766,-32766, 818, 819, - -32766,-32766, -227, 561,-32766, 27, 224,-32766, 418,-32766, - -32766, 122, -441,-32766, -232,-32766, 824, 40, 124, 227, - -88, 791, 265,-32766, 984, 1052,-32766,-32766,-32766, 660, - 94, 95, 96,-32766, 266, 364,-32766,-32766,-32766, 42, - -32766, 553,-32766, 122,-32766,-32766,-32766,-32766,-32766,-32766, - -32766,-32766,-32766,-32766,-32766,-32766,-32766,-32766, 363, 532, - -32766, 660, 554,-32766, 418,-32766, -477, 9,-32766,-32766, - -32766,-32766,-32766, -441,-32766, -488,-32766, -488, 249,-32766, - 248, 660, 121,-32766,-32766,-32766,-32766, -441,-32766,-32766, - 359, 555,-32766, 551, -441,-32766, 418, 517, 518, 115, - 250,-32766, 1034,-32766,-32767,-32767,-32767,-32767, 92, 93, - 94, 95, 96, 23, 308, -479, 504, 20, 344, -172, - 225, 117, 741, 126,-32766, 533, -441, 564, 349,-32766, - 660, 133, 847,-32766,-32766, 977, 120,-32766,-32766,-32766, - 792,-32766, 119,-32766, 114,-32766, 345, 419,-32766, 113, - 349, 130,-32766,-32766,-32766, 132,-32766,-32766,-32766, 738, - 741,-32766, 660, 241,-32766, 418,-32766, 244,-32766,-32766, - -32766,-32766,-32766,-32766, 128,-32766, 753,-32766, 527, 266, - -32766, 741, 818, 819,-32766,-32766,-32766, -441, 100,-32766, - -32766, 129, 313,-32766, 680, 681,-32766, 418, 41,-32766, - 660, -441,-32766, 453,-32766, 660, 321,-32766, -441,-32766, - 777, -477,-32766,-32766,-32766, 1083,-32766, 261,-32766, 441, - -32766, 385, 8,-32766, 437, 24, 360,-32766,-32766,-32766, - 497, 498,-32766,-32766,-32766, 501,-32766, 1034,-32766,-32766, - 418, 1000, 818, 819, 660, 846, 575,-32766,-32766, 358, - -4,-32766,-32766,-32766, 301,-32766, 1076,-32766, 661,-32766, - 455, 696,-32766, 858, 565, 513,-32766,-32766,-32766, 440, - 977,-32766,-32766, 973, 446,-32766, 505,-32766,-32766, 418, - -133, -133, -133,-32766,-32766,-32766,-32766, 409, 410, 451, - 542, 528, 509, 521, 510, -133, 12, -133, -80, -133, - 216, -133, 495,-32766, 458,-32766,-32766,-32766,-32766, 67, - 348, 356, 259, 258, 266, 1016,-32766,-32766,-32766,-32766, - 260, 402, 403, 869, 870, 871, 868, 867, 866, 861, - 715, 760, 407, 408, 977, 761, 762,-32766, 11,-32766, - -32766,-32766,-32766,-32766,-32766,-32767,-32767,-32767,-32767,-32767, - 264, 229, 348, 337, 1013, 852, 741, 17, -133, 256, - -212, -212, -212, 402, 403, -400, 348, 5, 307, 775, - 758, 21, 672, 760, 407, 408, 329, 402, 403, -211, - -211, -211, 448, 24, 326, 348, 715, 760, 407, 408, - 341, 340, 318, 276, 325, 1034, 402, 403, 741, 1000, - -4,-32766,-32766,-32766, 359, 715, 760, 407, 408, 755, - 552, 33, 741, 573, -212, 574, 720, 842, 794, 778, - 32,-32766, 851,-32766,-32766, 854, 853, 850, 977, 773, - 785, 741, 718, -211, 786, 843, 741, 252, 334, 550, - 557, 558, 559, 562, 272, 409, 410, 273, 571, 570, - 568, 566, 563, 335, 0, 757, 965, 783, 859, 0, - 746, 964, 963, 756, 748, 683, 0, 67, 1079, 682, - 685, 784, 266, 567, 716, 1080, 675, 674, 684, 759, - 1049, 1046, 1041, 1077, 1035, 1028, 0, -444, -467, -446, - -445, 22, 25, 31, 35, 39, 66, 338, 336, 275, - 240, 239, 238, 237, 220, 219, 134, 131, 125, 72, - 71, 70, 69, 68, -469, 0, 310, 475, 941, 491, - 541, 944, 13, 969, 825, 998, 940, 988, -230, -88, - 538, 390, 383, 380, 377, 311, 18, 16, 15, 14, - -227, -228, 0, 957, -412, 0, 503, 0, 1040, 1075, - 1026, 1027, 997, 0, 1015 - ); - - protected $actionCheck = array( - 2, 3, 4, 5, 6, 1, 8, 9, 10, 11, - 12, 48, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 8, 9, 10, 50, 51, - 52, 0, 54, 7, 79, 8, 9, 10, 8, 7, - 77, 77, 79, 80, 66, 28, 1, 30, 31, 32, - 33, 34, 54, 56, 57, 28, 13, 30, 31, 32, - 33, 34, 35, 79, 109, 7, 68, 69, 70, 71, - 72, 73, 74, 118, 7, 77, 112, 113, 114, 115, - 116, 117, 84, 85, 86, 87, 88, 89, 90, 91, - 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 123, 124, 125, 126, 127, 7, 129, 130, 131, - 132, 133, 134, 135, 136, 137, 8, 9, 10, 29, - 156, 143, 144, 145, 1, 2, 3, 4, 5, 6, - 29, 102, 103, 149, 11, 12, 28, 14, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 13, 54, 1, 152, 67, 154, 8, 9, 10, - 47, 48, 13, 148, 66, 146, 53, 7, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 7, - 67, 68, 69, 70, 71, 8, 9, 10, 75, 76, - 77, 7, 79, 13, 81, 1, 83, 84, 85, 86, - 1, 88, 67, 90, 7, 92, 67, 67, 95, 1, - 7, 67, 99, 100, 101, 102, 128, 104, 105, 79, - 28, 108, 7, 83, 111, 112, 28, 1, 148, 35, - 142, 79, 119, 120, 121, 82, 7, 149, 7, 151, - 149, 152, 129, 130, 7, 132, 133, 134, 135, 136, - 137, 138, 112, 8, 9, 10, 143, 144, 145, 146, - 7, 35, 149, 33, 151, 71, 153, 128, 155, 156, - 130, 77, 128, 28, 79, 81, 77, 82, 84, 85, - 86, 142, 88, 1, 90, 150, 92, 79, 149, 95, - 151, 151, 139, 99, 100, 101, 156, 71, 104, 105, - 7, 149, 108, 77, 7, 111, 112, 81, 156, 79, - 84, 85, 86, 119, 88, 1, 90, 35, 92, 29, - 112, 95, 130, 131, 152, 99, 100, 101, 130, 131, - 104, 105, 152, 29, 108, 140, 141, 111, 112, 8, - 9, 147, 67, 149, 152, 119, 152, 67, 149, 35, - 152, 29, 7, 71, 1, 152, 8, 9, 10, 77, - 47, 48, 49, 81, 156, 7, 84, 85, 86, 67, - 88, 29, 90, 147, 92, 149, 28, 95, 30, 31, - 32, 99, 100, 101, 1, 71, 104, 105, 7, 77, - 108, 77, 29, 111, 112, 81, 7, 7, 84, 85, - 86, 119, 88, 128, 90, 152, 92, 154, 128, 95, - 28, 77, 29, 99, 100, 101, 1, 142, 104, 105, - 146, 29, 108, 149, 149, 111, 112, 72, 73, 149, - 128, 149, 79, 119, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 7, 142, 152, 72, 73, 7, 152, - 35, 149, 148, 15, 71, 143, 67, 29, 146, 1, - 77, 15, 150, 149, 81, 112, 15, 84, 85, 86, - 148, 88, 15, 90, 15, 92, 123, 143, 95, 15, - 146, 15, 99, 100, 101, 15, 71, 104, 105, 29, - 148, 108, 77, 54, 111, 112, 81, 29, 1, 84, - 85, 86, 119, 88, 29, 90, 35, 92, 74, 156, - 95, 148, 130, 131, 99, 100, 101, 128, 66, 104, - 105, 97, 98, 108, 102, 103, 111, 112, 67, 71, - 77, 142, 149, 77, 119, 77, 78, 82, 149, 81, - 148, 152, 84, 85, 86, 80, 88, 110, 90, 77, - 92, 102, 103, 95, 77, 67, 77, 99, 100, 101, - 106, 107, 104, 105, 149, 79, 108, 79, 71, 111, - 112, 83, 130, 131, 77, 148, 149, 119, 81, 77, - 0, 84, 85, 86, 77, 88, 77, 90, 77, 92, - 77, 77, 95, 148, 149, 79, 99, 100, 101, 79, - 112, 104, 105, 79, 82, 108, 87, 149, 111, 112, - 72, 73, 74, 8, 9, 10, 119, 129, 130, 86, - 89, 91, 93, 96, 96, 87, 94, 89, 94, 91, - 94, 93, 109, 28, 94, 30, 31, 32, 33, 151, - 102, 102, 127, 126, 156, 139, 149, 8, 9, 10, - 109, 113, 114, 112, 113, 114, 115, 116, 117, 118, - 122, 123, 124, 125, 112, 123, 123, 28, 142, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 126, 35, 102, 103, 139, 148, 148, 152, 150, 109, - 96, 97, 98, 113, 114, 142, 102, 142, 142, 148, - 150, 152, 122, 123, 124, 125, 146, 113, 114, 96, - 97, 98, 146, 67, 146, 102, 122, 123, 124, 125, - 146, 146, 146, 143, 146, 79, 113, 114, 148, 83, - 150, 8, 9, 10, 146, 122, 123, 124, 125, 147, - 149, 148, 148, 148, 150, 148, 148, 148, 148, 148, - 148, 28, 148, 30, 31, 148, 148, 148, 112, 148, - 148, 148, 148, 150, 148, 148, 148, 152, 149, 149, - 149, 149, 149, 149, 149, 129, 130, 149, 149, 149, - 149, 149, 149, 149, -1, 150, 150, 150, 150, -1, - 150, 150, 150, 150, 150, 150, -1, 151, 150, 150, - 150, 150, 156, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, -1, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, -1, 152, 152, 152, 152, - 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, - 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, - 152, 152, -1, 153, 153, -1, 154, -1, 154, 154, - 154, 154, 154, -1, 155 + 132, 133, 1, 80, 136, 137, 138, 139, 140, 141, + 142, 143, 144, 8, 1, 85, 101, 80, 150, 151, + 152, 8, 154, 9, 10, 11, 2, 3, 4, 5, + 6, 7, 164, 9, 10, 11, 12, 13, 123, 9, + 10, 11, 82, 31, 30, 85, 32, 33, 34, 35, + 36, 37, 38, 116, 117, 118, 119, 120, 121, 122, + 30, 37, 38, 9, 10, 11, 1, 14, 161, 9, + 10, 11, 9, 10, 11, 1, 146, 14, 155, 156, + 157, 57, 1, 161, 30, 162, 32, 33, 34, 35, + 30, 8, 32, 33, 34, 71, 72, 73, 74, 75, + 76, 77, 1, 31, 80, 31, 8, 147, 148, 97, + 164, 87, 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, + 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, + 126, 127, 128, 129, 130, 131, 132, 133, 84, 1, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 164, + 9, 10, 11, 160, 150, 151, 152, 164, 154, 2, + 3, 4, 5, 6, 7, 84, 9, 10, 11, 12, + 13, 30, 8, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 164, 57, 9, + 9, 10, 11, 53, 54, 55, 161, 57, 8, 1, + 69, 159, 167, 159, 57, 161, 106, 107, 8, 69, + 159, 30, 1, 32, 33, 14, 116, 164, 71, 72, + 73, 74, 75, 76, 77, 97, 1, 80, 30, 70, + 159, 70, 161, 14, 87, 88, 89, 90, 91, 92, + 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, + 133, 9, 10, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 8, 134, 135, 134, 135, 150, 151, 152, + 2, 3, 4, 5, 6, 7, 80, 82, 149, 51, + 12, 13, 101, 15, 116, 37, 38, 106, 80, 108, + 161, 8, 163, 116, 113, 75, 76, 116, 117, 118, + 119, 120, 121, 122, 123, 137, 138, 8, 80, 1, + 106, 83, 108, 80, 137, 138, 8, 8, 50, 51, + 9, 10, 11, 128, 56, 1, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 70, 70, 71, + 72, 73, 74, 162, 75, 76, 78, 79, 80, 116, + 82, 1, 156, 158, 86, 87, 88, 89, 163, 91, + 8, 93, 167, 95, 156, 8, 98, 99, 106, 161, + 108, 103, 104, 105, 106, 107, 1, 109, 110, 101, + 102, 31, 160, 115, 116, 8, 164, 1, 155, 156, + 157, 70, 124, 125, 126, 8, 70, 1, 70, 106, + 107, 134, 135, 8, 136, 137, 82, 139, 140, 141, + 142, 143, 144, 145, 1, 8, 149, 155, 14, 151, + 152, 8, 8, 155, 156, 157, 158, 1, 161, 8, + 163, 163, 82, 165, 166, 167, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 75, 76, 77, 106, 107, 134, 135, 31, 8, 84, + 134, 135, 134, 135, 1, 90, 8, 92, 82, 94, + 149, 96, 37, 38, 14, 149, 80, 149, 128, 59, + 60, 106, 161, 14, 1, 161, 106, 161, 108, 161, + 70, 167, 117, 118, 31, 14, 30, 70, 50, 51, + 52, 14, 127, 128, 129, 130, 131, 70, 158, 74, + 84, 111, 112, 163, 31, 80, 106, 167, 108, 159, + 31, 161, 87, 88, 89, 16, 91, 16, 93, 16, + 95, 37, 38, 98, 159, 1, 161, 162, 103, 104, + 105, 37, 38, 16, 109, 110, 16, 84, 16, 163, + 115, 116, 16, 167, 134, 135, 16, 161, 16, 124, + 31, 134, 135, 167, 70, 31, 31, 84, 31, 149, + 31, 134, 135, 160, 31, 31, 82, 164, 74, 31, + 86, 161, 116, 31, 80, 159, 31, 161, 161, 154, + 31, 87, 88, 89, 31, 91, 31, 93, 161, 95, + 31, 31, 98, 137, 138, 31, 31, 103, 104, 105, + 31, 31, 31, 109, 110, 38, 69, 35, 84, 115, + 116, 35, 159, 35, 161, 35, 35, 70, 124, 57, + 136, 137, 82, 139, 140, 141, 142, 143, 144, 77, + 31, 80, 159, 83, 161, 151, 152, 89, 82, 74, + 94, 97, 85, 85, 90, 80, 128, 163, 113, 128, + 166, 167, 87, 88, 89, 92, 91, 96, 93, 116, + 95, 133, 146, 98, 128, 97, 100, 153, 103, 104, + 105, 97, 149, 74, 109, 110, 0, 1, 163, 80, + 115, 116, 100, 159, 153, 161, 87, 88, 89, 124, + 91, 114, 93, 154, 95, -1, 155, 98, -1, -1, + -1, -1, 103, 104, 105, 74, -1, 132, 109, 110, + -1, 80, -1, -1, 115, 116, 132, -1, 87, 88, + 89, -1, 91, 124, 93, 146, 95, -1, -1, 98, + -1, 158, 149, 102, 103, 104, 105, 74, 149, 149, + 109, 110, 149, 80, 81, 159, 115, 116, 160, 1, + 87, 88, 89, 159, 91, 124, 93, 159, 95, 159, + 84, 98, 159, 159, 159, 159, 103, 104, 105, 159, + 159, 159, 109, 110, 159, 159, 159, 159, 115, 116, + 159, 159, 106, 159, 108, 1, 160, 124, 160, 113, + 160, 162, 160, 117, 118, 160, 162, 161, 161, 161, + 161, 161, 161, 127, 128, 129, 130, 131, 161, 161, + 74, 161, 161, 161, 161, 166, 80, 162, 162, 162, + 162, 162, 162, 87, 88, 89, 150, 91, 162, 93, + 162, 95, 84, 162, 98, 159, 162, 161, 162, 103, + 104, 105, 162, 162, 162, 109, 110, 162, 100, 101, + 102, 115, 116, 162, 106, 70, 162, 162, 162, 162, + 124, 162, 162, 162, 162, 117, 118, 82, 84, 162, + 164, 86, 163, 163, 163, 127, 128, 129, 130, 131, + 163, 163, 163, 163, 100, 101, 102, 163, 163, 163, + 106, 163, 163, 163, 163, 163, 163, 163, 163, -1, + 163, 117, 118, 163, 163, 163, 163, 159, 163, 161, + 162, 127, 128, 129, 130, 131, 163, 163, 163, 163, + 163, 163, 137, 163, 139, 140, 141, 142, 143, 144, + 163, 163, 163, 163, -1, 164, 151, 152, 164, 164, + 164, 164, 164, 159, 164, 161, 162, 164, 163, 167, + 164, 166, 167, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164, 164, -1, 165, 165 ); protected $actionBase = array( - 0, 568, 610, 624, 643, 182, 342, 567, -2, -2, - -2, -2, -36, 393, 110, 334, 110, 372, 422, 648, - 648, 648, 224, 256, 312, 312, 312, 488, 413, 445, - 344, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 45, 45, 352, 43, 645, - 729, 725, 565, 730, 566, 724, 726, 168, 693, 694, - 505, 695, 692, 691, 690, 727, 752, 579, 728, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 30, 179, 361, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 275, 275, 275, - 753, 378, 419, 635, 17, 305, 27, 669, 669, 669, - 669, 669, 423, 423, 423, 423, 676, 676, 518, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 689, 580, 665, 666, 383, 343, 343, 222, 222, 222, - 222, 238, 228, -45, 412, 183, 536, 759, 472, 229, - 229, 118, 169, -22, -22, -22, 49, 552, 582, 582, - 582, 582, 225, 225, 582, 582, 4, -37, 305, 305, - 332, 305, 452, 452, 452, 364, 304, 485, 364, 621, - 558, 667, 557, 681, 310, 283, 32, 605, -16, 604, - 569, -16, 484, 404, 385, 737, 45, 583, 45, 45, - 45, 45, 45, 45, 45, 45, 45, -16, -16, 45, - 121, 45, 457, 352, 475, 469, 543, 174, 655, 327, - 233, 165, 469, 469, 469, 658, 649, 119, 210, 664, - 202, 479, 323, 260, 483, 483, 501, 507, 486, 483, - 483, 483, 483, 516, 483, 700, 700, 704, 501, 483, - 700, 501, 227, 411, 245, 259, 501, 388, 547, 483, - 584, 584, 261, 507, 550, 214, 466, 545, 700, 700, - 545, 486, 190, 501, 375, 625, 627, 553, 622, 67, - 498, 498, 471, 553, 26, 501, 498, 516, 420, 58, - 498, 31, 705, 722, 490, 721, 702, 720, 706, 719, - 537, 650, 572, 573, 714, 713, 718, 502, 532, 703, - 701, 596, 509, 494, 489, 585, 491, 696, 569, 618, - 482, 482, 482, 491, 698, 482, 482, 482, 482, 482, - 482, 482, 482, 758, 267, 586, 563, 487, 606, 570, - 481, 662, 575, 596, 596, 684, 751, 750, 541, 712, - 735, 717, 632, 468, 744, 711, 683, 608, 544, 598, - 710, 743, 734, 661, 494, 733, 685, 539, 596, 686, - 482, 697, 723, 756, 757, 699, 754, 742, 590, 495, - 755, 687, 732, 660, 659, 623, 747, 736, 741, 688, - 740, 628, 549, 749, 559, 707, 546, 708, 651, 680, - 679, 496, 629, 678, 716, 630, 746, 745, 748, 631, - 642, 652, 653, 500, 675, 476, 647, 715, 320, 464, - 560, 646, 554, 731, 674, 654, 709, 644, 581, 673, - 672, 738, 564, 618, 556, 467, 562, 561, 663, 671, - 739, 458, 641, 639, 638, 637, 670, 634, 668, 0, + 0, -2, 154, 565, 876, 948, 984, 514, 53, 398, + 822, 307, 307, 67, 307, 307, 616, 673, 673, 724, + 673, 204, 653, 231, 231, 231, 625, 625, 625, 625, + 694, 694, 831, 831, 863, 799, 765, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 936, 936, 936, 936, 936, 936, 936, 936, 936, 936, + 211, 202, 288, 677, 1010, 1016, 1012, 1017, 1008, 1007, + 1011, 1013, 1018, 897, 899, 771, 900, 901, 902, 907, + 1014, 835, 1009, 1015, 291, 291, 291, 291, 291, 291, + 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + 340, 193, 432, 501, 501, 501, 501, 501, 501, 501, + 501, 501, 501, 501, 501, 501, 501, 501, 501, 501, + 501, 501, 501, 160, 160, 160, 341, 684, 684, 190, + 184, 610, 47, 985, 985, 985, 985, 985, 985, 985, + 985, 985, 985, 144, 144, 7, 7, 7, 7, 7, + 371, -25, -25, -25, -25, 540, 385, 576, 358, 45, + 394, 638, 638, 656, 656, 367, 367, 367, 367, -78, + -78, -78, -66, 319, 457, 452, 60, 423, 586, 586, + 586, 586, 423, 423, 423, 423, 779, 849, 423, 423, + 423, 511, 516, 516, 518, 300, 300, 300, 516, 600, + 758, 90, 600, 90, 195, 418, 743, -40, 260, 412, + -107, 743, 617, 627, 603, 143, 741, 483, 741, 1006, + 757, 749, 719, 824, 853, 1019, 766, 895, 782, 896, + 321, 679, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, + 1005, 1005, 1005, 982, 438, 1006, 386, 982, 982, 982, + 438, 438, 438, 438, 438, 438, 438, 438, 438, 438, + 590, 386, 410, 459, 386, 781, 438, 211, 783, 211, + 211, 211, 211, 943, 211, 211, 211, 211, 211, 211, + 956, 753, 37, 211, 202, 52, 52, 550, 131, 52, + 52, 52, 52, 211, 211, 211, 483, 762, 714, 537, + 731, 213, 762, 762, 762, 142, 76, 183, 135, 570, + 751, 751, 756, 918, 918, 751, 740, 751, 756, 926, + 751, 918, 773, 350, 597, 542, 577, 604, 918, 473, + 751, 751, 751, 751, 611, 751, 444, 360, 751, 751, + 775, 760, 784, 46, 918, 918, 918, 784, 567, 728, + 728, 728, 798, 800, 735, 759, 499, 489, 648, 314, + 767, 759, 759, 751, 585, 735, 759, 735, 759, 739, + 759, 759, 759, 735, 759, 751, 740, 547, 759, 722, + 640, 228, 759, 6, 928, 929, 30, 930, 924, 931, + 970, 932, 933, 839, 941, 925, 934, 920, 919, 770, + 699, 701, 789, 723, 917, 737, 737, 737, 910, 737, + 737, 737, 737, 737, 737, 737, 737, 699, 788, 793, + 718, 748, 945, 703, 717, 716, 834, 1020, 1021, 721, + 736, 943, 1000, 935, 786, 720, 980, 953, 829, 837, + 954, 955, 983, 1001, 1002, 855, 747, 856, 857, 826, + 957, 840, 737, 928, 933, 925, 934, 920, 919, 745, + 742, 734, 738, 733, 729, 725, 727, 755, 909, 715, + 828, 956, 911, 699, 830, 975, 836, 986, 989, 838, + 768, 750, 832, 858, 958, 960, 967, 841, 1003, 794, + 976, 906, 990, 774, 859, 991, 992, 993, 994, 860, + 847, 848, 850, 803, 754, 971, 761, 866, 361, 778, + 780, 969, 379, 942, 851, 868, 871, 995, 996, 997, + 874, 937, 804, 977, 746, 978, 974, 805, 806, 594, + 772, 776, 650, 659, 880, 881, 882, 940, 764, 752, + 810, 811, 1004, 885, 671, 812, 726, 891, 999, 730, + 732, 763, 852, 790, 777, 744, 968, 769, 815, 894, + 816, 817, 818, 998, 821, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 143, - 143, 143, 143, -2, -2, -2, 0, 0, 0, 0, - -2, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, + 0, 0, 0, 458, 458, 458, 458, 458, 458, 307, + 307, 307, 307, 0, 0, 307, 0, 0, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 291, 291, 291, 291, 291, 291, 291, 291, + 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + 291, 291, 291, 291, 291, 291, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - -3, 128, 128, -3, 128, 128, 128, 128, 128, 128, - -22, -22, -22, -22, 364, 364, 364, 364, 364, 364, - 364, 364, 364, 364, 364, 364, 364, 364, 571, 571, - 571, 571, 364, -22, -22, 364, 364, 364, 364, 364, - 364, 571, 364, 225, 225, 225, 364, -16, -16, 0, - 0, 0, 0, 0, 483, 225, 364, 364, 364, 364, - 0, 0, 364, 364, -16, 0, 0, 0, 0, 0, - 483, 483, 483, 0, 483, 225, 0, 45, 454, 454, - 454, 454, 0, 0, 0, 483, 0, 483, 550, 0, - 0, 0, 0, 501, 0, 700, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 482, 712, 0, 541, 0, 0, 0, - 482, 482, 482, 541, 541, 0, 0, 541 + 0, 0, 291, 291, 291, 291, 291, 291, 291, 291, + 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + 291, 291, 291, 291, 291, 291, 291, 291, 291, 423, + 423, 291, 291, 0, 291, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 291, 291, 291, 291, 291, + 291, 291, 773, 300, 300, 300, 300, 423, 423, 423, + 423, -88, -88, 300, 300, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 0, 0, 0, 386, 90, 0, + 740, 740, 740, 740, 0, 0, 0, 0, 90, 90, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 386, 90, 0, 386, 0, 740, 740, 423, 773, + 773, 498, 0, 423, 0, 0, 0, 0, 386, 740, + 386, 438, 90, 438, 438, 52, 211, 498, 468, 468, + 468, 468, 0, 483, 773, 773, 773, 773, 773, 773, + 773, 773, 773, 773, 773, 740, 0, 773, 0, 740, + 740, 740, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 740, 0, 0, + 918, 0, 0, 0, 0, 751, 0, 0, 0, 0, + 0, 0, 751, 926, 0, 0, 0, 0, 0, 0, + 740, 0, 0, 0, 0, 0, 0, 0, 0, 737, + 768, 0, 768, 0, 737, 737, 737 ); protected $actionDefault = array( - 3,32767,32767,32767,32767,32767,32767,32767,32767, 88, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767, 88, 489, 489, 489,32767,32767,32767, - 32767, 302, 302, 302,32767, 481, 439, 439, 439, 439, - 439, 439, 439, 481,32767,32767,32767,32767,32767, 381, + 3,32767, 103,32767,32767,32767,32767,32767,32767,32767, + 32767,32767, 101,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767, 569, 569, 569, 569, + 32767,32767, 246, 103,32767,32767, 445, 363, 363, 363, + 32767,32767, 513, 513, 513, 513, 513, 513,32767,32767, + 32767,32767,32767,32767, 445,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767, 88,32767, + 32767,32767,32767,32767,32767,32767,32767, 101,32767,32767, + 32767, 37, 7, 8, 10, 11, 50, 17,32767,32767, + 32767,32767,32767, 103,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767, 486,32767, + 32767,32767,32767, 562,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767, 364, - 365, 367, 368, 301, 440, 250, 485, 300, 126, 261, - 252, 204, 298, 236, 130, 329, 382, 331, 380, 384, - 330, 307, 311, 312, 313, 314, 315, 316, 317, 318, - 319, 320, 321, 322, 305, 306, 383, 361, 360, 359, - 327, 328, 304, 332, 334, 304, 333, 350, 351, 348, - 349, 352, 353, 354, 355, 356,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767, 88,32767, - 284, 284, 284, 284,32767, 341, 342, 242, 242, 242, - 242,32767, 242, 285,32767,32767,32767,32767,32767,32767, - 32767, 433, 358, 336, 337, 335,32767, 411,32767,32767, - 32767,32767,32767, 413,32767, 88,32767,32767, 324, 326, - 405, 308,32767,32767, 90,32767,32767,32767,32767,32767, - 32767,32767,32767,32767, 408, 441, 441,32767,32767, 88, - 399, 88, 169, 223, 225, 174,32767, 416,32767,32767, + 32767,32767,32767,32767, 449, 428, 429, 431, 432, 362, + 514, 568, 304, 565, 361, 146, 316, 306, 234, 307, + 250, 450, 251, 451, 454, 455, 211, 278, 358, 150, + 392, 446, 394, 444, 448, 393, 368, 373, 374, 375, + 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, + 366, 367, 447, 425, 424, 423, 390,32767,32767, 391, + 395, 365, 398,32767,32767,32767,32767,32767,32767,32767, + 32767, 103,32767, 396, 397, 414, 415, 412, 413, 416, + 32767, 417, 418, 419, 420,32767,32767,32767,32767, 342, + 340, 405, 406, 295, 295,32767,32767,32767,32767,32767, + 32767,32767,32767, 507, 422,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767, 103,32767, + 101, 509, 387, 389, 477, 400, 401, 399, 369,32767, + 484,32767, 103, 486,32767,32767,32767, 112,32767,32767, + 272,32767, 508,32767, 515, 515,32767, 470, 101, 194, + 32767, 194, 194,32767,32767,32767,32767,32767,32767,32767, + 576, 470, 111, 111, 111, 111, 111, 111, 111, 111, + 111, 111, 111,32767, 194, 111,32767,32767,32767, 101, + 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, + 189,32767, 260, 262, 103, 530, 194,32767, 489,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767, 346,32767, 496,32767, 441, - 32767,32767, 338, 339, 340,32767,32767, 441, 441,32767, - 441,32767, 441,32767,32767,32767, 174,32767,32767,32767, - 32767,32767,32767,32767, 90, 414, 414, 409, 174,32767, - 32767, 174, 87, 87, 87, 87, 174, 87, 187,32767, - 185, 185, 87, 88, 88, 87, 87, 189,32767, 455, - 189, 88, 87, 174, 87, 209, 209, 390, 176, 89, - 244, 244, 89, 390, 87, 174, 244, 88, 87, 87, - 244,32767,32767,32767, 82,32767,32767,32767,32767,32767, + 32767, 482,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767, 470, 410, 139,32767, + 139, 515, 402, 403, 404, 472, 515, 515, 515,32767, + 32767,32767,32767, 487, 487, 101, 101, 101, 101, 482, + 32767,32767, 112, 100, 100, 100, 100, 100, 104, 102, + 32767,32767,32767,32767, 100,32767, 102, 102,32767,32767, + 217, 208, 215, 102,32767, 534, 535, 215, 102, 219, + 219, 219, 239, 239, 461, 297, 102, 100, 102, 102, + 196, 297, 297,32767, 102, 461, 297, 461, 297, 198, + 297, 297, 297, 461, 297,32767,32767, 102, 297, 210, + 100, 100, 297,32767,32767,32767, 472,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767, 401,32767,32767, 421,32767, 434, 453, 399,32767, - 344, 345, 347,32767, 443, 369, 370, 371, 372, 373, - 374, 375, 377,32767, 482, 404,32767,32767, 84, 117, - 260,32767, 494, 84, 402,32767, 494,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767, 84,32767, 84, - 32767,32767,32767,32767, 478,32767, 441,32767, 403,32767, - 343, 417, 460,32767,32767, 442,32767,32767, 84,32767, - 32767,32767,32767,32767,32767,32767,32767, 421,32767,32767, - 32767,32767,32767, 441,32767,32767,32767,32767,32767,32767, - 32767, 297,32767,32767,32767,32767,32767,32767, 441,32767, - 32767,32767,32767, 235,32767,32767,32767,32767,32767,32767, + 32767, 502,32767, 519, 532, 408, 409, 411, 517, 433, + 434, 435, 436, 437, 438, 439, 441, 564,32767, 476, + 32767,32767,32767,32767, 315, 574,32767, 574,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767, 82, 60,32767, 278,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767, 132, - 132, 3, 3, 132, 132, 132, 132, 132, 132, 132, - 132, 132, 132, 132, 132, 132, 263, 164, 263, 217, - 263, 263, 220, 209, 209, 270, 132, 132 + 32767,32767,32767,32767,32767, 575,32767, 515,32767,32767, + 32767,32767, 407, 9, 76, 43, 44, 52, 58, 493, + 494, 495, 496, 490, 491, 497, 492,32767, 498, 540, + 32767,32767, 516, 567,32767,32767,32767,32767,32767,32767, + 139,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767, 502,32767, 137,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767, 515,32767,32767,32767, 292, + 294,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767, 515,32767,32767,32767, + 280, 282,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767, 277,32767,32767, 357, + 32767,32767,32767,32767, 336,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767, 152, 152, 3, 3, 318, + 152, 152, 152, 318, 152, 318, 318, 318, 152, 152, + 152, 152, 152, 152, 184, 254, 257, 239, 239, 152, + 328, 152 ); protected $goto = array( - 165, 165, 138, 138, 138, 148, 150, 181, 166, 163, - 163, 163, 163, 147, 164, 164, 164, 164, 164, 164, - 164, 147, 159, 160, 161, 162, 178, 176, 179, 420, - 421, 315, 422, 425, 426, 427, 428, 429, 430, 431, - 432, 888, 136, 139, 140, 141, 142, 143, 144, 145, - 146, 149, 175, 177, 180, 197, 200, 201, 203, 204, - 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, - 235, 236, 253, 254, 255, 322, 323, 324, 470, 182, - 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, - 193, 194, 195, 151, 196, 152, 167, 168, 169, 198, - 170, 153, 154, 155, 171, 156, 199, 137, 172, 157, - 173, 174, 158, 534, 202, 438, 736, 281, 471, 857, - 547, 7, 202, 526, 855, 472, 669, 231, 464, 232, - 233, 443, 443, 443, 671, 443, 464, 793, 774, 772, - 774, 569, 670, 436, 802, 797, 459, 456, 443, 545, - 572, 492, 494, 520, 524, 529, 530, 804, 537, 539, - 546, 800, 548, 424, 424, 424, 424, 424, 424, 424, - 424, 424, 424, 424, 424, 424, 424, 423, 423, 423, - 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, - 423, 485, 506, 443, 443, 488, 490, 540, 457, 478, - 443, 443, 974, 443, 768, 312, 543, 706, 444, 300, - 303, 450, 473, 474, 476, 469, 481, 733, 468, 487, - 487, 999, 999, 999, 999, 999, 999, 999, 999, 999, - 999, 999, 999, 701, 689, 831, 435, 835, 776, 697, - 1068, 1068, 779, 435, 263, 749, 482, 3, 4, 247, - 316, 827, 809, 449, 769, 975, 465, 1068, 460, 673, - 770, 770, 770, 770, 872, 1061, 764, 771, 705, 970, - 697, 1071, 697, 976, 1030, 378, 678, 298, 728, 723, - 724, 737, 679, 725, 676, 726, 727, 10, 1053, 677, - 507, 731, 462, 935, 823, 328, 508, 332, 319, 319, - 268, 269, 285, 466, 271, 327, 286, 330, 493, 807, - 807, 1058, 1069, 1069, 282, 283, 812, 688, 688, 816, - 1042, 512, 698, 698, 698, 700, 525, 687, 499, 1069, - 314, 287, 693, 279, 309, 690, 832, 576, 966, 514, - 370, 978, 971, 484, 817, 817, 817, 817, 978, 817, - 836, 817, 865, 702, 1039, 817, 781, 686, 874, 386, - 0, 1039, 0, 0, 0, 978, 978, 978, 978, 1050, - 1050, 978, 978, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 744, 0, 0, 745, 1036, 0, 0, 0, + 192, 192, 663, 417, 636, 911, 983, 990, 991, 411, + 302, 303, 324, 557, 308, 416, 325, 418, 615, 1005, + 671, 317, 317, 317, 317, 163, 163, 163, 163, 216, + 193, 189, 189, 173, 175, 211, 189, 189, 189, 189, + 189, 190, 190, 190, 190, 190, 190, 184, 185, 186, + 187, 188, 213, 211, 214, 515, 516, 407, 517, 519, + 520, 521, 522, 523, 524, 525, 526, 1074, 164, 165, + 166, 191, 167, 168, 169, 162, 170, 171, 172, 174, + 210, 212, 215, 233, 236, 239, 240, 242, 253, 254, + 255, 256, 257, 258, 259, 261, 262, 263, 264, 271, + 272, 305, 306, 307, 412, 413, 414, 562, 217, 218, + 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, + 229, 230, 231, 176, 232, 177, 194, 195, 196, 234, + 184, 185, 186, 187, 188, 213, 1074, 197, 178, 179, + 180, 198, 194, 181, 235, 199, 161, 200, 201, 182, + 202, 203, 204, 183, 205, 206, 207, 208, 209, 819, + 579, 601, 601, 541, 532, 815, 816, 1204, 1204, 1204, + 1204, 1204, 1204, 1204, 1204, 1204, 1204, 954, 928, 928, + 926, 928, 695, 817, 531, 963, 958, 381, 385, 542, + 580, 584, 383, 532, 541, 550, 551, 390, 560, 581, + 595, 596, 824, 793, 872, 867, 868, 881, 14, 825, + 869, 822, 870, 871, 823, 480, 850, 481, 875, 527, + 527, 527, 527, 488, 583, 1222, 1222, 791, 1026, 1022, + 1023, 1222, 1222, 1222, 1222, 1222, 1222, 1222, 1222, 1222, + 1222, 1220, 1220, 812, 812, 599, 633, 1220, 1220, 1220, + 1220, 1220, 1220, 1220, 1220, 1220, 1220, 313, 297, 1173, + 1173, 1173, 987, 282, 282, 282, 282, 987, 987, 987, + 987, 987, 987, 987, 987, 987, 447, 447, 432, 249, + 249, 1173, 554, 432, 432, 447, 1173, 1173, 1173, 1173, + 1046, 1047, 1173, 1173, 1173, 1254, 1254, 1254, 1254, 337, + 797, 1272, 1272, 930, 246, 246, 246, 246, 248, 250, + 888, 335, 876, 340, 877, 889, 1249, 1250, 1272, 518, + 518, 832, 1262, 340, 340, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 1275, 844, 340, 340, 831, + 340, 797, 1289, 797, 630, 1169, 644, 645, 646, 529, + 529, 529, 611, 612, 534, 1273, 1273, 340, 812, 951, + 432, 432, 432, 432, 432, 432, 432, 432, 432, 432, + 432, 438, 1273, 432, 558, 593, 924, 924, 924, 924, + 379, 635, 438, 918, 925, 553, 1123, 1154, 904, 422, + 547, 1155, 1158, 905, 1159, 548, 326, 594, 1170, 696, + 614, 616, 1233, 634, 410, 807, 590, 653, 657, 965, + 661, 669, 961, 456, 1247, 1248, 809, 837, 1244, 1244, + 1244, 1171, 1230, 1231, 5, 656, 6, 533, 545, 389, + 968, 968, 533, 1166, 545, 834, 973, 382, 922, 397, + 670, 1256, 1256, 1256, 1256, 1011, 699, 561, 450, 451, + 452, 846, 842, 534, 457, 1280, 1281, 619, 619, 1015, + 1057, 395, 396, 995, 992, 993, 642, 1240, 643, 935, + 399, 400, 401, 461, 654, 0, 0, 0, 402, 0, + 840, 0, 333, 578, 1039, 0, 674, 660, 660, 0, + 666, 1037, 489, 588, 602, 605, 606, 607, 608, 627, + 628, 629, 673, 0, 0, 0, 1013, 893, 1062, 0, + 1242, 1242, 1013, 1168, 598, 252, 252, 0, 0, 970, + 269, 845, 833, 1010, 1014, 530, 530, 836, 0, 639, + 949, 933, 0, 338, 339, 830, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1165, 0, + 0, 0, 0, 0, 923, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 834, 0, - 0, 834, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1043, 1044 + 0, 0, 0, 0, 0, 0, 0, 1055, 849 ); protected $gotoCheck = array( - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 60, 53, 8, 10, 76, 7, 7, - 7, 106, 53, 7, 7, 93, 13, 69, 81, 69, - 69, 8, 8, 8, 15, 8, 81, 13, 13, 13, - 13, 13, 14, 13, 13, 13, 8, 36, 8, 5, - 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, - 36, 36, 36, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 129, 129, 129, - 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, - 129, 43, 43, 8, 8, 64, 64, 64, 8, 8, - 8, 8, 88, 8, 72, 72, 72, 33, 8, 46, - 46, 46, 46, 46, 46, 2, 2, 52, 8, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 11, 11, 11, 71, 11, 37, 23, - 139, 139, 11, 71, 128, 11, 11, 34, 34, 128, - 62, 90, 11, 62, 11, 88, 130, 139, 62, 10, - 71, 71, 71, 71, 11, 138, 71, 71, 11, 11, - 23, 139, 23, 88, 88, 62, 10, 49, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 62, 136, 10, - 51, 10, 50, 112, 86, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 81, - 81, 81, 140, 140, 76, 76, 84, 23, 23, 87, - 133, 65, 23, 23, 23, 23, 65, 23, 21, 140, - 65, 17, 27, 9, 16, 25, 92, 78, 118, 20, - 67, 60, 121, 68, 60, 60, 60, 60, 60, 60, - 95, 60, 106, 29, 93, 60, 75, 12, 109, 116, - -1, 93, -1, -1, -1, 60, 60, 60, 60, 93, - 93, 60, 60, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 60, -1, -1, 60, 93, -1, -1, -1, + 42, 42, 72, 65, 65, 87, 87, 87, 87, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 115, + 9, 23, 23, 23, 23, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 15, + 118, 104, 104, 75, 75, 25, 26, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 25, 25, 25, + 25, 25, 25, 27, 25, 25, 25, 58, 58, 58, + 58, 58, 75, 75, 75, 75, 75, 75, 75, 75, + 75, 75, 15, 7, 15, 15, 15, 15, 75, 15, + 15, 15, 15, 15, 15, 143, 45, 143, 15, 103, + 103, 103, 103, 143, 103, 156, 156, 6, 15, 15, + 15, 156, 156, 156, 156, 156, 156, 156, 156, 156, + 156, 157, 157, 22, 22, 55, 55, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 155, 155, 72, + 72, 72, 72, 24, 24, 24, 24, 72, 72, 72, + 72, 72, 72, 72, 72, 72, 137, 137, 23, 5, + 5, 72, 158, 23, 23, 137, 72, 72, 72, 72, + 132, 132, 72, 72, 72, 9, 9, 9, 9, 93, + 12, 168, 168, 49, 5, 5, 5, 5, 5, 5, + 72, 165, 64, 14, 64, 72, 164, 164, 168, 159, + 159, 35, 167, 14, 14, 159, 159, 159, 159, 159, + 159, 159, 159, 159, 159, 168, 35, 14, 14, 35, + 14, 12, 14, 12, 84, 20, 84, 84, 84, 19, + 19, 19, 83, 83, 14, 169, 169, 14, 22, 99, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 19, 169, 23, 2, 2, 19, 19, 19, 19, + 61, 63, 19, 19, 19, 100, 139, 78, 78, 108, + 9, 78, 78, 78, 78, 48, 29, 9, 20, 48, + 48, 48, 14, 48, 13, 20, 13, 48, 48, 48, + 48, 48, 48, 162, 162, 162, 18, 39, 118, 118, + 118, 20, 20, 20, 46, 14, 46, 9, 9, 28, + 103, 103, 9, 148, 9, 37, 106, 9, 89, 89, + 89, 118, 118, 118, 118, 117, 95, 9, 9, 9, + 9, 41, 9, 14, 145, 9, 9, 111, 111, 120, + 135, 80, 80, 111, 111, 111, 80, 118, 80, 92, + 80, 80, 80, 82, 80, -1, -1, -1, 80, -1, + 9, -1, 80, 8, 8, -1, 8, 8, 8, -1, + 8, 8, 9, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, -1, -1, -1, 118, 17, 17, -1, + 118, 118, 118, 14, 17, 5, 5, -1, -1, 17, + 24, 16, 16, 16, 16, 24, 24, 17, -1, 17, + 17, 16, -1, 93, 93, 17, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 17, -1, + -1, -1, -1, -1, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, - -1, 93, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 93, 93 + -1, -1, -1, -1, -1, -1, -1, 16, 16 ); protected $gotoBase = array( - 0, 0, -336, 0, 0, 137, 0, 113, -141, 57, - -20, -120, -25, 124, 140, 132, 47, 75, 0, 0, - 4, 55, 0, -17, 0, 46, 0, 58, 0, -10, - -22, 0, 0, 198, -329, 0, -403, 220, 0, 0, - 0, 0, 0, 159, 0, 0, 172, 0, 0, 243, - 72, 73, 201, 79, 0, 0, 0, 0, 0, 0, - 107, 0, -98, 0, -43, -60, 0, -21, -27, -441, - 0, 2, -55, 0, 0, -15, -259, 0, 24, 0, - 0, 93, 3, 0, 74, 0, 50, 71, -95, 0, - 228, 0, 45, 120, 0, -14, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 109, 0, 0, -29, - 0, 0, 52, 0, 0, 0, -24, 0, -8, 0, - 0, 6, 0, 0, 0, 0, 0, 0, -13, -39, - 231, -53, 0, 70, 0, 0, 245, 0, 239, -6, - 66, 0, 0 + 0, 0, -303, 0, 0, 278, 214, 194, 476, 7, + 0, 0, 15, 78, 27, -175, 87, 61, 118, 84, + -33, 0, -74, 18, 260, 161, 162, 179, 103, 111, + 0, 0, 0, 0, 0, -35, 0, 107, 0, 105, + 0, 26, -1, 0, 0, 204, -275, 0, -281, 281, + 0, 0, 0, 0, 0, 207, 0, 0, 144, 0, + 0, 340, 0, 143, 294, -234, 0, 0, 0, 0, + 0, 0, -6, 0, 0, -168, 0, 0, -8, 150, + -10, 0, 16, -108, -339, 0, 0, -270, 0, 145, + 0, 0, 42, -164, 0, 52, 0, 0, 0, 326, + 344, 0, 0, 193, -76, 0, 81, 0, 115, 0, + 0, 184, 0, 0, 0, 17, 0, 86, 153, 0, + 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 21, 0, 0, 32, 0, 244, 0, 119, + 0, 0, 0, -260, 0, 30, 0, 0, 79, 0, + 0, 0, 0, 0, 0, -53, -12, 4, 255, 82, + 0, 0, 124, 0, -41, 283, 0, 293, 5, 59, + 0, 0 ); protected $gotoDefault = array( - -32768, 391, 579, 2, 580, 651, 659, 515, 411, 439, - 730, 877, 692, 712, 713, 714, 304, 342, 296, 302, - 500, 489, 382, 699, 354, 691, 379, 694, 353, 703, - 135, 516, 388, 707, 1, 709, 445, 740, 293, 717, - 294, 519, 719, 452, 721, 722, 299, 305, 306, 881, - 461, 486, 732, 205, 454, 734, 292, 735, 743, 333, - 297, 365, 522, 496, 477, 511, 412, 367, 483, 230, - 463, 985, 766, 374, 362, 780, 280, 788, 577, 796, - 799, 413, 414, 372, 811, 373, 821, 815, 993, 366, - 826, 355, 833, 1025, 357, 837, 840, 343, 502, 331, - 844, 845, 6, 849, 535, 536, 864, 243, 384, 873, - 352, 887, 346, 954, 956, 447, 381, 967, 361, 523, - 389, 972, 1029, 350, 415, 368, 270, 284, 246, 416, - 433, 251, 417, 369, 1032, 320, 1054, 434, 1062, 1070, - 277, 317, 480 + -32768, 493, 703, 4, 704, 897, 780, 789, 577, 509, + 672, 334, 603, 408, 1238, 874, 1061, 559, 808, 1182, + 1190, 439, 811, 318, 320, 856, 857, 858, 386, 371, + 377, 384, 625, 604, 474, 843, 435, 835, 466, 838, + 434, 847, 160, 405, 491, 851, 3, 853, 536, 884, + 372, 861, 373, 649, 863, 544, 865, 866, 380, 387, + 388, 1066, 552, 600, 878, 241, 546, 879, 370, 880, + 887, 375, 378, 658, 446, 486, 479, 398, 1041, 587, + 622, 443, 460, 610, 609, 597, 459, 640, 403, 920, + 467, 444, 934, 336, 942, 701, 1073, 617, 469, 950, + 618, 957, 960, 510, 511, 458, 972, 273, 470, 1000, + 641, 985, 620, 998, 453, 1004, 436, 1012, 1226, 437, + 1016, 260, 1019, 274, 404, 419, 1024, 1025, 8, 1031, + 664, 665, 10, 270, 490, 1056, 659, 433, 1072, 423, + 1142, 1144, 538, 471, 1162, 1161, 652, 487, 1167, 1229, + 431, 512, 454, 304, 513, 296, 322, 301, 528, 283, + 323, 514, 455, 1235, 1243, 319, 29, 1263, 1274, 330, + 556, 592 ); protected $ruleToNonTerminal = array( - 0, 1, 3, 3, 2, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 8, 8, 9, 10, 10, 11, 11, 12, - 12, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 17, 17, 18, 18, 18, 18, 20, 22, - 22, 16, 24, 24, 21, 26, 26, 23, 23, 25, - 25, 27, 27, 19, 28, 28, 29, 31, 32, 32, - 33, 34, 34, 36, 35, 35, 35, 35, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 13, 13, 56, 56, 59, 59, 58, 57, - 57, 50, 61, 61, 62, 62, 63, 63, 14, 15, - 15, 15, 66, 66, 66, 67, 67, 70, 70, 68, - 68, 72, 73, 73, 44, 44, 52, 52, 55, 55, - 55, 54, 74, 74, 75, 45, 45, 45, 45, 76, - 76, 77, 77, 78, 78, 42, 42, 38, 38, 79, - 40, 40, 80, 39, 39, 41, 41, 51, 51, 51, - 51, 64, 64, 83, 83, 84, 84, 86, 86, 87, - 87, 87, 85, 85, 65, 65, 88, 88, 89, 89, - 90, 90, 90, 47, 91, 91, 92, 48, 94, 94, - 95, 95, 69, 69, 96, 96, 96, 96, 101, 101, - 102, 102, 103, 103, 103, 103, 103, 104, 105, 105, - 100, 100, 97, 97, 99, 99, 107, 107, 106, 106, - 106, 106, 106, 106, 98, 108, 108, 109, 109, 49, - 110, 110, 43, 43, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 117, 111, 111, - 116, 116, 119, 120, 120, 121, 122, 122, 122, 71, - 71, 60, 60, 60, 112, 112, 112, 124, 124, 113, - 113, 115, 115, 115, 118, 118, 129, 129, 129, 82, - 131, 131, 131, 114, 114, 114, 114, 114, 114, 114, - 114, 114, 114, 114, 114, 114, 114, 114, 114, 46, - 46, 127, 127, 127, 123, 123, 123, 132, 132, 132, - 132, 132, 132, 53, 53, 53, 93, 93, 93, 93, - 134, 126, 126, 126, 126, 126, 126, 125, 125, 125, - 133, 133, 133, 133, 81, 135, 135, 136, 136, 136, - 136, 136, 130, 137, 137, 138, 138, 138, 138, 138, - 128, 128, 128, 128, 140, 141, 139, 139, 139, 139, - 139, 139, 139, 142, 142, 142, 142 + 0, 1, 3, 3, 2, 5, 5, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, + 7, 7, 7, 7, 7, 7, 8, 8, 9, 10, + 11, 11, 11, 12, 12, 13, 13, 14, 15, 15, + 16, 16, 17, 17, 18, 18, 21, 21, 22, 23, + 23, 24, 24, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 29, 29, 30, 30, 32, 34, + 34, 28, 36, 36, 33, 38, 38, 35, 35, 37, + 37, 39, 39, 31, 40, 40, 41, 43, 44, 44, + 45, 46, 46, 48, 47, 47, 47, 47, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 25, 25, 68, 68, 71, 71, 70, 69, + 69, 62, 74, 74, 75, 75, 76, 76, 77, 77, + 78, 78, 26, 26, 27, 27, 27, 27, 86, 86, + 88, 88, 81, 81, 81, 82, 82, 85, 85, 83, + 83, 89, 90, 90, 56, 56, 64, 64, 67, 67, + 67, 66, 91, 91, 92, 57, 57, 57, 57, 93, + 93, 94, 94, 95, 95, 96, 97, 97, 98, 98, + 99, 99, 54, 54, 50, 50, 101, 52, 52, 102, + 51, 51, 53, 53, 63, 63, 63, 63, 79, 79, + 105, 105, 107, 107, 107, 107, 107, 106, 106, 106, + 109, 109, 109, 87, 87, 111, 111, 111, 110, 110, + 112, 112, 113, 113, 113, 108, 108, 80, 80, 80, + 20, 20, 114, 114, 115, 115, 115, 115, 59, 116, + 116, 117, 60, 119, 119, 120, 120, 121, 121, 84, + 122, 122, 122, 122, 122, 122, 127, 127, 128, 128, + 129, 129, 129, 129, 129, 130, 131, 131, 126, 126, + 123, 123, 125, 125, 133, 133, 132, 132, 132, 132, + 132, 132, 132, 124, 134, 134, 136, 135, 135, 61, + 100, 137, 137, 55, 55, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 144, 138, + 138, 143, 143, 146, 147, 147, 148, 149, 149, 149, + 19, 19, 72, 72, 72, 72, 139, 139, 139, 139, + 151, 151, 140, 140, 142, 142, 142, 145, 145, 156, + 156, 156, 156, 156, 156, 156, 156, 156, 157, 157, + 104, 159, 159, 159, 159, 141, 141, 141, 141, 141, + 141, 141, 141, 58, 58, 154, 154, 154, 154, 160, + 160, 150, 150, 150, 161, 161, 161, 161, 161, 161, + 73, 73, 65, 65, 65, 65, 118, 118, 118, 118, + 164, 163, 153, 153, 153, 153, 153, 153, 153, 152, + 152, 152, 162, 162, 162, 162, 103, 158, 166, 166, + 165, 165, 167, 167, 167, 167, 167, 167, 167, 167, + 155, 155, 155, 155, 169, 170, 168, 168, 168, 168, + 168, 168, 168, 168, 171, 171, 171, 171 ); protected $ruleToLength = array( @@ -768,2105 +911,1868 @@ class Php7 extends \PhpParser\ParserAbstract 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 1, 1, 1, 0, 1, 0, - 1, 1, 1, 1, 1, 3, 5, 4, 3, 4, - 2, 3, 1, 1, 7, 8, 6, 7, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 0, 1, 1, 2, 1, 3, 4, 1, + 2, 0, 1, 1, 1, 1, 1, 3, 5, 4, + 3, 4, 2, 3, 1, 1, 7, 6, 2, 3, 1, 2, 3, 1, 2, 3, 1, 1, 3, 1, - 2, 1, 2, 2, 3, 1, 3, 2, 3, 1, + 3, 1, 2, 2, 3, 1, 3, 2, 3, 1, 3, 2, 0, 1, 1, 1, 1, 1, 3, 7, 10, 5, 7, 9, 5, 3, 3, 3, 3, 3, - 3, 1, 2, 5, 7, 9, 5, 6, 3, 3, + 3, 1, 2, 5, 7, 9, 6, 5, 6, 3, 2, 1, 1, 1, 0, 2, 1, 3, 8, 0, - 4, 2, 1, 3, 0, 1, 0, 1, 10, 7, - 6, 5, 1, 2, 2, 0, 2, 0, 2, 0, + 4, 2, 1, 3, 0, 1, 0, 1, 0, 1, + 3, 1, 8, 9, 8, 7, 6, 8, 0, 2, + 0, 2, 1, 2, 2, 0, 2, 0, 2, 0, 2, 2, 1, 3, 1, 4, 1, 4, 1, 1, 4, 2, 1, 3, 3, 3, 4, 4, 5, 0, - 2, 4, 3, 1, 1, 1, 4, 0, 2, 5, - 0, 2, 6, 0, 2, 0, 3, 1, 2, 1, - 1, 2, 0, 1, 3, 4, 6, 1, 2, 1, - 1, 1, 0, 1, 0, 2, 2, 4, 1, 3, - 1, 2, 2, 2, 3, 1, 1, 2, 3, 1, - 1, 3, 2, 0, 3, 4, 9, 3, 1, 3, - 0, 2, 4, 5, 4, 4, 4, 3, 1, 1, - 1, 3, 1, 1, 0, 1, 1, 2, 1, 1, - 1, 1, 1, 1, 2, 1, 3, 1, 3, 2, - 3, 1, 0, 1, 1, 3, 3, 3, 4, 1, - 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, + 2, 4, 3, 1, 1, 7, 0, 2, 1, 3, + 3, 4, 1, 4, 0, 2, 5, 0, 2, 6, + 0, 2, 0, 3, 1, 2, 1, 1, 2, 0, + 1, 3, 0, 1, 1, 1, 1, 6, 8, 6, + 1, 2, 1, 1, 1, 1, 1, 1, 3, 3, + 3, 3, 1, 2, 1, 0, 1, 0, 2, 2, + 2, 4, 1, 3, 1, 2, 2, 3, 2, 3, + 1, 1, 2, 3, 1, 1, 3, 2, 0, 1, + 5, 5, 10, 3, 5, 1, 1, 3, 0, 2, + 4, 5, 4, 4, 4, 3, 1, 1, 1, 1, + 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, + 1, 1, 1, 2, 1, 3, 1, 1, 3, 2, + 2, 3, 1, 0, 1, 1, 3, 3, 3, 4, + 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, - 4, 3, 4, 4, 2, 2, 4, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, - 2, 1, 2, 4, 2, 10, 11, 7, 3, 2, - 0, 4, 2, 1, 3, 2, 2, 2, 4, 1, - 1, 1, 2, 3, 1, 1, 1, 1, 1, 0, - 3, 0, 1, 1, 0, 1, 1, 3, 3, 3, - 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 2, 3, 3, 0, - 1, 1, 3, 1, 1, 3, 1, 1, 4, 4, - 4, 1, 4, 1, 1, 3, 1, 4, 2, 2, - 3, 1, 4, 4, 3, 3, 3, 1, 3, 1, - 1, 3, 1, 1, 4, 3, 1, 1, 1, 3, - 3, 0, 1, 3, 1, 3, 1, 4, 2, 0, + 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 5, 4, 3, 4, 4, 2, 2, + 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 1, 3, 2, 1, 2, 4, 2, 2, + 8, 9, 8, 9, 9, 10, 9, 10, 8, 3, + 2, 0, 4, 2, 1, 3, 2, 2, 2, 4, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, + 1, 1, 0, 3, 0, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, + 3, 4, 1, 1, 3, 1, 1, 1, 1, 1, + 3, 2, 3, 0, 1, 1, 3, 1, 1, 1, + 1, 1, 3, 1, 1, 4, 4, 1, 4, 4, + 0, 1, 1, 1, 3, 3, 1, 4, 2, 2, + 1, 3, 1, 4, 4, 3, 3, 3, 3, 1, + 3, 1, 1, 3, 1, 1, 4, 1, 1, 1, + 3, 1, 1, 2, 1, 3, 4, 3, 2, 0, 2, 2, 1, 2, 1, 1, 1, 4, 3, 3, - 3, 6, 3, 1, 1, 2, 1 + 3, 3, 6, 3, 1, 1, 2, 1 ); - protected function reduceRule0() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule1() { - $this->semValue = $this->handleNamespaces($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule2() { - if (is_array($this->semStack[$this->stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)]); } else { $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; }; - } - - protected function reduceRule3() { - $this->semValue = array(); - } - - protected function reduceRule4() { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; - if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule5() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule6() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule7() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule8() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule9() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule10() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule11() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule12() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule13() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule14() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule15() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule16() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule17() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule18() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule19() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule20() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule21() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule22() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule23() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule24() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule25() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule26() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule27() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule28() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule29() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule30() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule31() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule32() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule33() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule34() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule35() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule36() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule37() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule38() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule39() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule40() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule41() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule42() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule43() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule44() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule45() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule46() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule47() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule48() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule49() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule50() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule51() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule52() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule53() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule54() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule55() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule56() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule57() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule58() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule59() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule60() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule61() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule62() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule63() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule64() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule65() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule66() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule67() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule68() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule69() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule70() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule71() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule72() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule73() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule74() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule75() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule76() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule77() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule78() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule79() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule80() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule81() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule82() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule83() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule84() { - $this->semValue = new Name($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule85() { - /* nothing */ - } - - protected function reduceRule86() { - /* nothing */ - } - - protected function reduceRule87() { - /* nothing */ - } - - protected function reduceRule88() { - $this->emitError(new Error('A trailing comma is not allowed here', $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes)); - } - - protected function reduceRule89() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule90() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule91() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule92() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule93() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule94() { - $this->semValue = new Stmt\HaltCompiler($this->lexer->handleHaltCompiler(), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule95() { - $this->semValue = new Stmt\Namespace_($this->semStack[$this->stackPos-(3-2)], null, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); + protected function initReduceCallbacks() { + $this->reduceCallbacks = [ + 0 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 1 => function ($stackPos) { + $this->semValue = $this->handleNamespaces($this->semStack[$stackPos-(1-1)]); + }, + 2 => function ($stackPos) { + if (is_array($this->semStack[$stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); } else { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; }; + }, + 3 => function ($stackPos) { + $this->semValue = array(); + }, + 4 => function ($stackPos) { + $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; + if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 5 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 6 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 7 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 8 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 9 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 10 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 11 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 12 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 13 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 14 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 15 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 16 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 17 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 18 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 19 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 20 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 21 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 22 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 23 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 24 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 25 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 26 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 27 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 28 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 29 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 30 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 31 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 32 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 33 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 34 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 35 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 36 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 37 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 38 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 39 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 40 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 41 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 42 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 43 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 44 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 45 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 46 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 47 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 48 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 49 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 50 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 51 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 52 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 53 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 54 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 55 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 56 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 57 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 58 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 59 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 60 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 61 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 62 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 63 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 64 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 65 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 66 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 67 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 68 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 69 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 70 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 71 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 72 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 73 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 74 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 75 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 76 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 77 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 78 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 79 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 80 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 81 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 82 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 83 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 84 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 85 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 86 => function ($stackPos) { + $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 87 => function ($stackPos) { + $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 88 => function ($stackPos) { + $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 89 => function ($stackPos) { + $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 90 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 91 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 92 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 93 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 94 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 95 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 96 => function ($stackPos) { + $this->semValue = new Name(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 97 => function ($stackPos) { + $this->semValue = new Expr\Variable(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 98 => function ($stackPos) { + /* nothing */ + }, + 99 => function ($stackPos) { + /* nothing */ + }, + 100 => function ($stackPos) { + /* nothing */ + }, + 101 => function ($stackPos) { + $this->emitError(new Error('A trailing comma is not allowed here', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes)); + }, + 102 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 103 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 104 => function ($stackPos) { + $this->semValue = new Node\Attribute($this->semStack[$stackPos-(1-1)], [], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 105 => function ($stackPos) { + $this->semValue = new Node\Attribute($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 106 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 107 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 108 => function ($stackPos) { + $this->semValue = new Node\AttributeGroup($this->semStack[$stackPos-(4-2)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 109 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 110 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 111 => function ($stackPos) { + $this->semValue = []; + }, + 112 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 113 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 114 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 115 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 116 => function ($stackPos) { + $this->semValue = new Stmt\HaltCompiler($this->lexer->handleHaltCompiler(), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 117 => function ($stackPos) { + $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos-(3-2)], null, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_SEMICOLON); $this->checkNamespace($this->semValue); - } - - protected function reduceRule96() { - $this->semValue = new Stmt\Namespace_($this->semStack[$this->stackPos-(5-2)], $this->semStack[$this->stackPos-(5-4)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); + }, + 118 => function ($stackPos) { + $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos-(5-2)], $this->semStack[$stackPos-(5-4)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); $this->checkNamespace($this->semValue); - } - - protected function reduceRule97() { - $this->semValue = new Stmt\Namespace_(null, $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); + }, + 119 => function ($stackPos) { + $this->semValue = new Stmt\Namespace_(null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); $this->checkNamespace($this->semValue); - } + }, + 120 => function ($stackPos) { + $this->semValue = new Stmt\Use_($this->semStack[$stackPos-(3-2)], Stmt\Use_::TYPE_NORMAL, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 121 => function ($stackPos) { + $this->semValue = new Stmt\Use_($this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-2)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 122 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 123 => function ($stackPos) { + $this->semValue = new Stmt\Const_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 124 => function ($stackPos) { + $this->semValue = Stmt\Use_::TYPE_FUNCTION; + }, + 125 => function ($stackPos) { + $this->semValue = Stmt\Use_::TYPE_CONSTANT; + }, + 126 => function ($stackPos) { + $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(7-3)], $this->semStack[$stackPos-(7-6)], $this->semStack[$stackPos-(7-2)], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + }, + 127 => function ($stackPos) { + $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-5)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + }, + 128 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 129 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 130 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 131 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 132 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 133 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 134 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 135 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 136 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 137 => function ($stackPos) { + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(1-1)); + }, + 138 => function ($stackPos) { + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(3-3)); + }, + 139 => function ($stackPos) { + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(1-1)); + }, + 140 => function ($stackPos) { + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(3-3)); + }, + 141 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; $this->semValue->type = Stmt\Use_::TYPE_NORMAL; + }, + 142 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; $this->semValue->type = $this->semStack[$stackPos-(2-1)]; + }, + 143 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 144 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 145 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 146 => function ($stackPos) { + $this->semValue = new Node\Const_($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 147 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 148 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 149 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 150 => function ($stackPos) { + $this->semValue = new Node\Const_($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 151 => function ($stackPos) { + if (is_array($this->semStack[$stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); } else { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; }; + }, + 152 => function ($stackPos) { + $this->semValue = array(); + }, + 153 => function ($stackPos) { + $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; + if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 154 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 155 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 156 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 157 => function ($stackPos) { + throw new Error('__HALT_COMPILER() can only be used from the outermost scope', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 158 => function ($stackPos) { - protected function reduceRule98() { - $this->semValue = new Stmt\Use_($this->semStack[$this->stackPos-(3-2)], Stmt\Use_::TYPE_NORMAL, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule99() { - $this->semValue = new Stmt\Use_($this->semStack[$this->stackPos-(4-3)], $this->semStack[$this->stackPos-(4-2)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule100() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule101() { - $this->semValue = new Stmt\Const_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule102() { - $this->semValue = Stmt\Use_::TYPE_FUNCTION; - } - - protected function reduceRule103() { - $this->semValue = Stmt\Use_::TYPE_CONSTANT; - } - - protected function reduceRule104() { - $this->semValue = new Stmt\GroupUse(new Name($this->semStack[$this->stackPos-(7-3)], $this->startAttributeStack[$this->stackPos-(7-3)] + $this->endAttributeStack[$this->stackPos-(7-3)]), $this->semStack[$this->stackPos-(7-6)], $this->semStack[$this->stackPos-(7-2)], $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes); - } - - protected function reduceRule105() { - $this->semValue = new Stmt\GroupUse(new Name($this->semStack[$this->stackPos-(8-4)], $this->startAttributeStack[$this->stackPos-(8-4)] + $this->endAttributeStack[$this->stackPos-(8-4)]), $this->semStack[$this->stackPos-(8-7)], $this->semStack[$this->stackPos-(8-2)], $this->startAttributeStack[$this->stackPos-(8-1)] + $this->endAttributes); - } - - protected function reduceRule106() { - $this->semValue = new Stmt\GroupUse(new Name($this->semStack[$this->stackPos-(6-2)], $this->startAttributeStack[$this->stackPos-(6-2)] + $this->endAttributeStack[$this->stackPos-(6-2)]), $this->semStack[$this->stackPos-(6-5)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); - } - - protected function reduceRule107() { - $this->semValue = new Stmt\GroupUse(new Name($this->semStack[$this->stackPos-(7-3)], $this->startAttributeStack[$this->stackPos-(7-3)] + $this->endAttributeStack[$this->stackPos-(7-3)]), $this->semStack[$this->stackPos-(7-6)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes); - } - - protected function reduceRule108() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule109() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule110() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule111() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule112() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule113() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule114() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule115() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule116() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule117() { - $this->semValue = new Stmt\UseUse($this->semStack[$this->stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $this->stackPos-(1-1)); - } - - protected function reduceRule118() { - $this->semValue = new Stmt\UseUse($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $this->stackPos-(3-3)); - } - - protected function reduceRule119() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule120() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule121() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; $this->semValue->type = Stmt\Use_::TYPE_NORMAL; - } - - protected function reduceRule122() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; $this->semValue->type = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule123() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule124() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule125() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule126() { - $this->semValue = new Node\Const_($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule127() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule128() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule129() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule130() { - $this->semValue = new Node\Const_($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule131() { - if (is_array($this->semStack[$this->stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)]); } else { $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; }; - } - - protected function reduceRule132() { - $this->semValue = array(); - } - - protected function reduceRule133() { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; - if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule134() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule135() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule136() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule137() { - throw new Error('__HALT_COMPILER() can only be used from the outermost scope', $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule138() { - - if ($this->semStack[$this->stackPos-(3-2)]) { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; $attrs = $this->startAttributeStack[$this->stackPos-(3-1)]; $stmts = $this->semValue; if (!empty($attrs['comments'])) {$stmts[0]->setAttribute('comments', array_merge($attrs['comments'], $stmts[0]->getAttribute('comments', []))); }; + if ($this->semStack[$stackPos-(3-2)]) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; $attrs = $this->startAttributeStack[$stackPos-(3-1)]; $stmts = $this->semValue; if (!empty($attrs['comments'])) {$stmts[0]->setAttribute('comments', array_merge($attrs['comments'], $stmts[0]->getAttribute('comments', []))); }; } else { - $startAttributes = $this->startAttributeStack[$this->stackPos-(3-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $this->semValue = null; }; + $startAttributes = $this->startAttributeStack[$stackPos-(3-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; }; if (null === $this->semValue) { $this->semValue = array(); } } - } + }, + 159 => function ($stackPos) { + $this->semValue = new Stmt\If_($this->semStack[$stackPos-(7-3)], ['stmts' => is_array($this->semStack[$stackPos-(7-5)]) ? $this->semStack[$stackPos-(7-5)] : array($this->semStack[$stackPos-(7-5)]), 'elseifs' => $this->semStack[$stackPos-(7-6)], 'else' => $this->semStack[$stackPos-(7-7)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + }, + 160 => function ($stackPos) { + $this->semValue = new Stmt\If_($this->semStack[$stackPos-(10-3)], ['stmts' => $this->semStack[$stackPos-(10-6)], 'elseifs' => $this->semStack[$stackPos-(10-7)], 'else' => $this->semStack[$stackPos-(10-8)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); + }, + 161 => function ($stackPos) { + $this->semValue = new Stmt\While_($this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 162 => function ($stackPos) { + $this->semValue = new Stmt\Do_($this->semStack[$stackPos-(7-5)], is_array($this->semStack[$stackPos-(7-2)]) ? $this->semStack[$stackPos-(7-2)] : array($this->semStack[$stackPos-(7-2)]), $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + }, + 163 => function ($stackPos) { + $this->semValue = new Stmt\For_(['init' => $this->semStack[$stackPos-(9-3)], 'cond' => $this->semStack[$stackPos-(9-5)], 'loop' => $this->semStack[$stackPos-(9-7)], 'stmts' => $this->semStack[$stackPos-(9-9)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + }, + 164 => function ($stackPos) { + $this->semValue = new Stmt\Switch_($this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 165 => function ($stackPos) { + $this->semValue = new Stmt\Break_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 166 => function ($stackPos) { + $this->semValue = new Stmt\Continue_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 167 => function ($stackPos) { + $this->semValue = new Stmt\Return_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 168 => function ($stackPos) { + $this->semValue = new Stmt\Global_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 169 => function ($stackPos) { + $this->semValue = new Stmt\Static_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 170 => function ($stackPos) { + $this->semValue = new Stmt\Echo_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 171 => function ($stackPos) { + $this->semValue = new Stmt\InlineHTML($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 172 => function ($stackPos) { - protected function reduceRule139() { - $this->semValue = new Stmt\If_($this->semStack[$this->stackPos-(7-3)], ['stmts' => is_array($this->semStack[$this->stackPos-(7-5)]) ? $this->semStack[$this->stackPos-(7-5)] : array($this->semStack[$this->stackPos-(7-5)]), 'elseifs' => $this->semStack[$this->stackPos-(7-6)], 'else' => $this->semStack[$this->stackPos-(7-7)]], $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes); - } + $e = $this->semStack[$stackPos-(2-1)]; + if ($e instanceof Expr\Throw_) { + // For backwards-compatibility reasons, convert throw in statement position into + // Stmt\Throw_ rather than Stmt\Expression(Expr\Throw_). + $this->semValue = new Stmt\Throw_($e->expr, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + } else { + $this->semValue = new Stmt\Expression($e, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + } - protected function reduceRule140() { - $this->semValue = new Stmt\If_($this->semStack[$this->stackPos-(10-3)], ['stmts' => $this->semStack[$this->stackPos-(10-6)], 'elseifs' => $this->semStack[$this->stackPos-(10-7)], 'else' => $this->semStack[$this->stackPos-(10-8)]], $this->startAttributeStack[$this->stackPos-(10-1)] + $this->endAttributes); - } - - protected function reduceRule141() { - $this->semValue = new Stmt\While_($this->semStack[$this->stackPos-(5-3)], $this->semStack[$this->stackPos-(5-5)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule142() { - $this->semValue = new Stmt\Do_($this->semStack[$this->stackPos-(7-5)], is_array($this->semStack[$this->stackPos-(7-2)]) ? $this->semStack[$this->stackPos-(7-2)] : array($this->semStack[$this->stackPos-(7-2)]), $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes); - } - - protected function reduceRule143() { - $this->semValue = new Stmt\For_(['init' => $this->semStack[$this->stackPos-(9-3)], 'cond' => $this->semStack[$this->stackPos-(9-5)], 'loop' => $this->semStack[$this->stackPos-(9-7)], 'stmts' => $this->semStack[$this->stackPos-(9-9)]], $this->startAttributeStack[$this->stackPos-(9-1)] + $this->endAttributes); - } - - protected function reduceRule144() { - $this->semValue = new Stmt\Switch_($this->semStack[$this->stackPos-(5-3)], $this->semStack[$this->stackPos-(5-5)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule145() { - $this->semValue = new Stmt\Break_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule146() { - $this->semValue = new Stmt\Continue_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule147() { - $this->semValue = new Stmt\Return_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule148() { - $this->semValue = new Stmt\Global_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule149() { - $this->semValue = new Stmt\Static_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule150() { - $this->semValue = new Stmt\Echo_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule151() { - $this->semValue = new Stmt\InlineHTML($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule152() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule153() { - $this->semValue = new Stmt\Unset_($this->semStack[$this->stackPos-(5-3)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule154() { - $this->semValue = new Stmt\Foreach_($this->semStack[$this->stackPos-(7-3)], $this->semStack[$this->stackPos-(7-5)][0], ['keyVar' => null, 'byRef' => $this->semStack[$this->stackPos-(7-5)][1], 'stmts' => $this->semStack[$this->stackPos-(7-7)]], $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes); - } - - protected function reduceRule155() { - $this->semValue = new Stmt\Foreach_($this->semStack[$this->stackPos-(9-3)], $this->semStack[$this->stackPos-(9-7)][0], ['keyVar' => $this->semStack[$this->stackPos-(9-5)], 'byRef' => $this->semStack[$this->stackPos-(9-7)][1], 'stmts' => $this->semStack[$this->stackPos-(9-9)]], $this->startAttributeStack[$this->stackPos-(9-1)] + $this->endAttributes); - } - - protected function reduceRule156() { - $this->semValue = new Stmt\Declare_($this->semStack[$this->stackPos-(5-3)], $this->semStack[$this->stackPos-(5-5)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule157() { - $this->semValue = new Stmt\TryCatch($this->semStack[$this->stackPos-(6-3)], $this->semStack[$this->stackPos-(6-5)], $this->semStack[$this->stackPos-(6-6)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); $this->checkTryCatch($this->semValue); - } - - protected function reduceRule158() { - $this->semValue = new Stmt\Throw_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule159() { - $this->semValue = new Stmt\Goto_($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule160() { - $this->semValue = new Stmt\Label($this->semStack[$this->stackPos-(2-1)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule161() { - $this->semValue = array(); /* means: no statement */ - } - - protected function reduceRule162() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule163() { - $startAttributes = $this->startAttributeStack[$this->stackPos-(1-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $this->semValue = null; }; + }, + 173 => function ($stackPos) { + $this->semValue = new Stmt\Unset_($this->semStack[$stackPos-(5-3)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 174 => function ($stackPos) { + $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos-(7-3)], $this->semStack[$stackPos-(7-5)][0], ['keyVar' => null, 'byRef' => $this->semStack[$stackPos-(7-5)][1], 'stmts' => $this->semStack[$stackPos-(7-7)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + }, + 175 => function ($stackPos) { + $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos-(9-3)], $this->semStack[$stackPos-(9-7)][0], ['keyVar' => $this->semStack[$stackPos-(9-5)], 'byRef' => $this->semStack[$stackPos-(9-7)][1], 'stmts' => $this->semStack[$stackPos-(9-9)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + }, + 176 => function ($stackPos) { + $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos-(6-3)], new Expr\Error($this->startAttributeStack[$stackPos-(6-4)] + $this->endAttributeStack[$stackPos-(6-4)]), ['stmts' => $this->semStack[$stackPos-(6-6)]], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + }, + 177 => function ($stackPos) { + $this->semValue = new Stmt\Declare_($this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 178 => function ($stackPos) { + $this->semValue = new Stmt\TryCatch($this->semStack[$stackPos-(6-3)], $this->semStack[$stackPos-(6-5)], $this->semStack[$stackPos-(6-6)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); $this->checkTryCatch($this->semValue); + }, + 179 => function ($stackPos) { + $this->semValue = new Stmt\Goto_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 180 => function ($stackPos) { + $this->semValue = new Stmt\Label($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 181 => function ($stackPos) { + $this->semValue = array(); /* means: no statement */ + }, + 182 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 183 => function ($stackPos) { + $startAttributes = $this->startAttributeStack[$stackPos-(1-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; }; if ($this->semValue === null) $this->semValue = array(); /* means: no statement */ - } - - protected function reduceRule164() { - $this->semValue = array(); - } - - protected function reduceRule165() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule166() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule167() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule168() { - $this->semValue = new Stmt\Catch_($this->semStack[$this->stackPos-(8-3)], substr($this->semStack[$this->stackPos-(8-4)], 1), $this->semStack[$this->stackPos-(8-7)], $this->startAttributeStack[$this->stackPos-(8-1)] + $this->endAttributes); - } - - protected function reduceRule169() { - $this->semValue = null; - } - - protected function reduceRule170() { - $this->semValue = new Stmt\Finally_($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule171() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule172() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule173() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule174() { - $this->semValue = false; - } - - protected function reduceRule175() { - $this->semValue = true; - } - - protected function reduceRule176() { - $this->semValue = false; - } - - protected function reduceRule177() { - $this->semValue = true; - } - - protected function reduceRule178() { - $this->semValue = new Stmt\Function_($this->semStack[$this->stackPos-(10-3)], ['byRef' => $this->semStack[$this->stackPos-(10-2)], 'params' => $this->semStack[$this->stackPos-(10-5)], 'returnType' => $this->semStack[$this->stackPos-(10-7)], 'stmts' => $this->semStack[$this->stackPos-(10-9)]], $this->startAttributeStack[$this->stackPos-(10-1)] + $this->endAttributes); - } - - protected function reduceRule179() { - $this->semValue = new Stmt\Class_($this->semStack[$this->stackPos-(7-2)], ['type' => $this->semStack[$this->stackPos-(7-1)], 'extends' => $this->semStack[$this->stackPos-(7-3)], 'implements' => $this->semStack[$this->stackPos-(7-4)], 'stmts' => $this->semStack[$this->stackPos-(7-6)]], $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes); - $this->checkClass($this->semValue, $this->stackPos-(7-2)); - } - - protected function reduceRule180() { - $this->semValue = new Stmt\Interface_($this->semStack[$this->stackPos-(6-2)], ['extends' => $this->semStack[$this->stackPos-(6-3)], 'stmts' => $this->semStack[$this->stackPos-(6-5)]], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); - $this->checkInterface($this->semValue, $this->stackPos-(6-2)); - } - - protected function reduceRule181() { - $this->semValue = new Stmt\Trait_($this->semStack[$this->stackPos-(5-2)], ['stmts' => $this->semStack[$this->stackPos-(5-4)]], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule182() { - $this->semValue = 0; - } - - protected function reduceRule183() { - $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; - } - - protected function reduceRule184() { - $this->semValue = Stmt\Class_::MODIFIER_FINAL; - } - - protected function reduceRule185() { - $this->semValue = null; - } - - protected function reduceRule186() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule187() { - $this->semValue = array(); - } - - protected function reduceRule188() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule189() { - $this->semValue = array(); - } - - protected function reduceRule190() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule191() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule192() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule193() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule194() { - $this->semValue = is_array($this->semStack[$this->stackPos-(1-1)]) ? $this->semStack[$this->stackPos-(1-1)] : array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule195() { - $this->semValue = $this->semStack[$this->stackPos-(4-2)]; - } - - protected function reduceRule196() { - $this->semValue = is_array($this->semStack[$this->stackPos-(1-1)]) ? $this->semStack[$this->stackPos-(1-1)] : array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule197() { - $this->semValue = $this->semStack[$this->stackPos-(4-2)]; - } - - protected function reduceRule198() { - $this->semValue = is_array($this->semStack[$this->stackPos-(1-1)]) ? $this->semStack[$this->stackPos-(1-1)] : array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule199() { - $this->semValue = null; - } - - protected function reduceRule200() { - $this->semValue = $this->semStack[$this->stackPos-(4-2)]; - } - - protected function reduceRule201() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule202() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule203() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule204() { - $this->semValue = new Stmt\DeclareDeclare($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule205() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule206() { - $this->semValue = $this->semStack[$this->stackPos-(4-3)]; - } - - protected function reduceRule207() { - $this->semValue = $this->semStack[$this->stackPos-(4-2)]; - } - - protected function reduceRule208() { - $this->semValue = $this->semStack[$this->stackPos-(5-3)]; - } - - protected function reduceRule209() { - $this->semValue = array(); - } - - protected function reduceRule210() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule211() { - $this->semValue = new Stmt\Case_($this->semStack[$this->stackPos-(4-2)], $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule212() { - $this->semValue = new Stmt\Case_(null, $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule213() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule214() { - $this->semValue = $this->semStack[$this->stackPos]; - } - - protected function reduceRule215() { - $this->semValue = is_array($this->semStack[$this->stackPos-(1-1)]) ? $this->semStack[$this->stackPos-(1-1)] : array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule216() { - $this->semValue = $this->semStack[$this->stackPos-(4-2)]; - } - - protected function reduceRule217() { - $this->semValue = array(); - } - - protected function reduceRule218() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule219() { - $this->semValue = new Stmt\ElseIf_($this->semStack[$this->stackPos-(5-3)], is_array($this->semStack[$this->stackPos-(5-5)]) ? $this->semStack[$this->stackPos-(5-5)] : array($this->semStack[$this->stackPos-(5-5)]), $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule220() { - $this->semValue = array(); - } - - protected function reduceRule221() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule222() { - $this->semValue = new Stmt\ElseIf_($this->semStack[$this->stackPos-(6-3)], $this->semStack[$this->stackPos-(6-6)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); - } - - protected function reduceRule223() { - $this->semValue = null; - } - - protected function reduceRule224() { - $this->semValue = new Stmt\Else_(is_array($this->semStack[$this->stackPos-(2-2)]) ? $this->semStack[$this->stackPos-(2-2)] : array($this->semStack[$this->stackPos-(2-2)]), $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule225() { - $this->semValue = null; - } - - protected function reduceRule226() { - $this->semValue = new Stmt\Else_($this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule227() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)], false); - } - - protected function reduceRule228() { - $this->semValue = array($this->semStack[$this->stackPos-(2-2)], true); - } - - protected function reduceRule229() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)], false); - } - - protected function reduceRule230() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)], false); - } - - protected function reduceRule231() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule232() { - $this->semValue = array(); - } - - protected function reduceRule233() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule234() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule235() { - $this->semValue = new Node\Param(substr($this->semStack[$this->stackPos-(4-4)], 1), null, $this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-2)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); $this->checkParam($this->semValue); - } - - protected function reduceRule236() { - $this->semValue = new Node\Param(substr($this->semStack[$this->stackPos-(6-4)], 1), $this->semStack[$this->stackPos-(6-6)], $this->semStack[$this->stackPos-(6-1)], $this->semStack[$this->stackPos-(6-2)], $this->semStack[$this->stackPos-(6-3)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); $this->checkParam($this->semValue); - } - - protected function reduceRule237() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule238() { - $this->semValue = new Node\NullableType($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule239() { - $this->semValue = $this->handleBuiltinTypes($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule240() { - $this->semValue = 'array'; - } - - protected function reduceRule241() { - $this->semValue = 'callable'; - } - - protected function reduceRule242() { - $this->semValue = null; - } - - protected function reduceRule243() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule244() { - $this->semValue = null; - } - - protected function reduceRule245() { - $this->semValue = $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule246() { - $this->semValue = array(); - } - - protected function reduceRule247() { - $this->semValue = $this->semStack[$this->stackPos-(4-2)]; - } - - protected function reduceRule248() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule249() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule250() { - $this->semValue = new Node\Arg($this->semStack[$this->stackPos-(1-1)], false, false, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule251() { - $this->semValue = new Node\Arg($this->semStack[$this->stackPos-(2-2)], true, false, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule252() { - $this->semValue = new Node\Arg($this->semStack[$this->stackPos-(2-2)], false, true, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule253() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule254() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule255() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule256() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule257() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule258() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule259() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule260() { - $this->semValue = new Stmt\StaticVar(substr($this->semStack[$this->stackPos-(1-1)], 1), null, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule261() { - $this->semValue = new Stmt\StaticVar(substr($this->semStack[$this->stackPos-(3-1)], 1), $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule262() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule263() { - $this->semValue = array(); - } - - protected function reduceRule264() { - $this->semValue = new Stmt\Property($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); $this->checkProperty($this->semValue, $this->stackPos-(3-1)); - } - - protected function reduceRule265() { - $this->semValue = new Stmt\ClassConst($this->semStack[$this->stackPos-(4-3)], $this->semStack[$this->stackPos-(4-1)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); $this->checkClassConst($this->semValue, $this->stackPos-(4-1)); - } - - protected function reduceRule266() { - $this->semValue = new Stmt\ClassMethod($this->semStack[$this->stackPos-(9-4)], ['type' => $this->semStack[$this->stackPos-(9-1)], 'byRef' => $this->semStack[$this->stackPos-(9-3)], 'params' => $this->semStack[$this->stackPos-(9-6)], 'returnType' => $this->semStack[$this->stackPos-(9-8)], 'stmts' => $this->semStack[$this->stackPos-(9-9)]], $this->startAttributeStack[$this->stackPos-(9-1)] + $this->endAttributes); - $this->checkClassMethod($this->semValue, $this->stackPos-(9-1)); - } - - protected function reduceRule267() { - $this->semValue = new Stmt\TraitUse($this->semStack[$this->stackPos-(3-2)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule268() { - $this->semValue = array(); - } - - protected function reduceRule269() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule270() { - $this->semValue = array(); - } - - protected function reduceRule271() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule272() { - $this->semValue = new Stmt\TraitUseAdaptation\Precedence($this->semStack[$this->stackPos-(4-1)][0], $this->semStack[$this->stackPos-(4-1)][1], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule273() { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$this->stackPos-(5-1)][0], $this->semStack[$this->stackPos-(5-1)][1], $this->semStack[$this->stackPos-(5-3)], $this->semStack[$this->stackPos-(5-4)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule274() { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$this->stackPos-(4-1)][0], $this->semStack[$this->stackPos-(4-1)][1], $this->semStack[$this->stackPos-(4-3)], null, $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule275() { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$this->stackPos-(4-1)][0], $this->semStack[$this->stackPos-(4-1)][1], null, $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule276() { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$this->stackPos-(4-1)][0], $this->semStack[$this->stackPos-(4-1)][1], null, $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule277() { - $this->semValue = array($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)]); - } - - protected function reduceRule278() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule279() { - $this->semValue = array(null, $this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule280() { - $this->semValue = null; - } - - protected function reduceRule281() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule282() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule283() { - $this->semValue = 0; - } - - protected function reduceRule284() { - $this->semValue = 0; - } - - protected function reduceRule285() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule286() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule287() { - $this->checkModifier($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)], $this->stackPos-(2-2)); $this->semValue = $this->semStack[$this->stackPos-(2-1)] | $this->semStack[$this->stackPos-(2-2)]; - } - - protected function reduceRule288() { - $this->semValue = Stmt\Class_::MODIFIER_PUBLIC; - } - - protected function reduceRule289() { - $this->semValue = Stmt\Class_::MODIFIER_PROTECTED; - } - - protected function reduceRule290() { - $this->semValue = Stmt\Class_::MODIFIER_PRIVATE; - } - - protected function reduceRule291() { - $this->semValue = Stmt\Class_::MODIFIER_STATIC; - } - - protected function reduceRule292() { - $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; - } - - protected function reduceRule293() { - $this->semValue = Stmt\Class_::MODIFIER_FINAL; - } - - protected function reduceRule294() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule295() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule296() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule297() { - $this->semValue = new Stmt\PropertyProperty(substr($this->semStack[$this->stackPos-(1-1)], 1), null, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule298() { - $this->semValue = new Stmt\PropertyProperty(substr($this->semStack[$this->stackPos-(3-1)], 1), $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule299() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule300() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule301() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule302() { - $this->semValue = array(); - } - - protected function reduceRule303() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule304() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule305() { - $this->semValue = new Expr\Assign($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule306() { - $this->semValue = new Expr\Assign($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule307() { - $this->semValue = new Expr\Assign($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule308() { - $this->semValue = new Expr\AssignRef($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule309() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule310() { - $this->semValue = new Expr\Clone_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule311() { - $this->semValue = new Expr\AssignOp\Plus($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule312() { - $this->semValue = new Expr\AssignOp\Minus($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule313() { - $this->semValue = new Expr\AssignOp\Mul($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule314() { - $this->semValue = new Expr\AssignOp\Div($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule315() { - $this->semValue = new Expr\AssignOp\Concat($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule316() { - $this->semValue = new Expr\AssignOp\Mod($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule317() { - $this->semValue = new Expr\AssignOp\BitwiseAnd($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule318() { - $this->semValue = new Expr\AssignOp\BitwiseOr($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule319() { - $this->semValue = new Expr\AssignOp\BitwiseXor($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule320() { - $this->semValue = new Expr\AssignOp\ShiftLeft($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule321() { - $this->semValue = new Expr\AssignOp\ShiftRight($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule322() { - $this->semValue = new Expr\AssignOp\Pow($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule323() { - $this->semValue = new Expr\PostInc($this->semStack[$this->stackPos-(2-1)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule324() { - $this->semValue = new Expr\PreInc($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule325() { - $this->semValue = new Expr\PostDec($this->semStack[$this->stackPos-(2-1)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule326() { - $this->semValue = new Expr\PreDec($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule327() { - $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule328() { - $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule329() { - $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule330() { - $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule331() { - $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule332() { - $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule333() { - $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule334() { - $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule335() { - $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule336() { - $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule337() { - $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule338() { - $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule339() { - $this->semValue = new Expr\BinaryOp\Div($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule340() { - $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule341() { - $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule342() { - $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule343() { - $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule344() { - $this->semValue = new Expr\UnaryPlus($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule345() { - $this->semValue = new Expr\UnaryMinus($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule346() { - $this->semValue = new Expr\BooleanNot($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule347() { - $this->semValue = new Expr\BitwiseNot($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule348() { - $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule349() { - $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule350() { - $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule351() { - $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule352() { - $this->semValue = new Expr\BinaryOp\Spaceship($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule353() { - $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule354() { - $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule355() { - $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule356() { - $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule357() { - $this->semValue = new Expr\Instanceof_($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule358() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule359() { - $this->semValue = new Expr\Ternary($this->semStack[$this->stackPos-(5-1)], $this->semStack[$this->stackPos-(5-3)], $this->semStack[$this->stackPos-(5-5)], $this->startAttributeStack[$this->stackPos-(5-1)] + $this->endAttributes); - } - - protected function reduceRule360() { - $this->semValue = new Expr\Ternary($this->semStack[$this->stackPos-(4-1)], null, $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule361() { - $this->semValue = new Expr\BinaryOp\Coalesce($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule362() { - $this->semValue = new Expr\Isset_($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule363() { - $this->semValue = new Expr\Empty_($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule364() { - $this->semValue = new Expr\Include_($this->semStack[$this->stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule365() { - $this->semValue = new Expr\Include_($this->semStack[$this->stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE_ONCE, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule366() { - $this->semValue = new Expr\Eval_($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule367() { - $this->semValue = new Expr\Include_($this->semStack[$this->stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule368() { - $this->semValue = new Expr\Include_($this->semStack[$this->stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE_ONCE, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule369() { - $this->semValue = new Expr\Cast\Int_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule370() { - $this->semValue = new Expr\Cast\Double($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule371() { - $this->semValue = new Expr\Cast\String_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule372() { - $this->semValue = new Expr\Cast\Array_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule373() { - $this->semValue = new Expr\Cast\Object_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule374() { - $this->semValue = new Expr\Cast\Bool_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule375() { - $this->semValue = new Expr\Cast\Unset_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule376() { - $attrs = $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes; - $attrs['kind'] = strtolower($this->semStack[$this->stackPos-(2-1)]) === 'exit' ? Expr\Exit_::KIND_EXIT : Expr\Exit_::KIND_DIE; - $this->semValue = new Expr\Exit_($this->semStack[$this->stackPos-(2-2)], $attrs); - } - - protected function reduceRule377() { - $this->semValue = new Expr\ErrorSuppress($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule378() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule379() { - $this->semValue = new Expr\ShellExec($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule380() { - $this->semValue = new Expr\Print_($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule381() { - $this->semValue = new Expr\Yield_(null, null, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule382() { - $this->semValue = new Expr\Yield_($this->semStack[$this->stackPos-(2-2)], null, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule383() { - $this->semValue = new Expr\Yield_($this->semStack[$this->stackPos-(4-4)], $this->semStack[$this->stackPos-(4-2)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule384() { - $this->semValue = new Expr\YieldFrom($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule385() { - $this->semValue = new Expr\Closure(['static' => false, 'byRef' => $this->semStack[$this->stackPos-(10-2)], 'params' => $this->semStack[$this->stackPos-(10-4)], 'uses' => $this->semStack[$this->stackPos-(10-6)], 'returnType' => $this->semStack[$this->stackPos-(10-7)], 'stmts' => $this->semStack[$this->stackPos-(10-9)]], $this->startAttributeStack[$this->stackPos-(10-1)] + $this->endAttributes); - } - - protected function reduceRule386() { - $this->semValue = new Expr\Closure(['static' => true, 'byRef' => $this->semStack[$this->stackPos-(11-3)], 'params' => $this->semStack[$this->stackPos-(11-5)], 'uses' => $this->semStack[$this->stackPos-(11-7)], 'returnType' => $this->semStack[$this->stackPos-(11-8)], 'stmts' => $this->semStack[$this->stackPos-(11-10)]], $this->startAttributeStack[$this->stackPos-(11-1)] + $this->endAttributes); - } - - protected function reduceRule387() { - $this->semValue = array(new Stmt\Class_(null, ['type' => 0, 'extends' => $this->semStack[$this->stackPos-(7-3)], 'implements' => $this->semStack[$this->stackPos-(7-4)], 'stmts' => $this->semStack[$this->stackPos-(7-6)]], $this->startAttributeStack[$this->stackPos-(7-1)] + $this->endAttributes), $this->semStack[$this->stackPos-(7-2)]); + }, + 184 => function ($stackPos) { + $this->semValue = array(); + }, + 185 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 186 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 187 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 188 => function ($stackPos) { + $this->semValue = new Stmt\Catch_($this->semStack[$stackPos-(8-3)], $this->semStack[$stackPos-(8-4)], $this->semStack[$stackPos-(8-7)], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); + }, + 189 => function ($stackPos) { + $this->semValue = null; + }, + 190 => function ($stackPos) { + $this->semValue = new Stmt\Finally_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 191 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 192 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 193 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 194 => function ($stackPos) { + $this->semValue = false; + }, + 195 => function ($stackPos) { + $this->semValue = true; + }, + 196 => function ($stackPos) { + $this->semValue = false; + }, + 197 => function ($stackPos) { + $this->semValue = true; + }, + 198 => function ($stackPos) { + $this->semValue = false; + }, + 199 => function ($stackPos) { + $this->semValue = true; + }, + 200 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 201 => function ($stackPos) { + $this->semValue = []; + }, + 202 => function ($stackPos) { + $this->semValue = new Stmt\Function_($this->semStack[$stackPos-(8-3)], ['byRef' => $this->semStack[$stackPos-(8-2)], 'params' => $this->semStack[$stackPos-(8-5)], 'returnType' => $this->semStack[$stackPos-(8-7)], 'stmts' => $this->semStack[$stackPos-(8-8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); + }, + 203 => function ($stackPos) { + $this->semValue = new Stmt\Function_($this->semStack[$stackPos-(9-4)], ['byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-6)], 'returnType' => $this->semStack[$stackPos-(9-8)], 'stmts' => $this->semStack[$stackPos-(9-9)], 'attrGroups' => $this->semStack[$stackPos-(9-1)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + }, + 204 => function ($stackPos) { + $this->semValue = new Stmt\Class_($this->semStack[$stackPos-(8-3)], ['type' => $this->semStack[$stackPos-(8-2)], 'extends' => $this->semStack[$stackPos-(8-4)], 'implements' => $this->semStack[$stackPos-(8-5)], 'stmts' => $this->semStack[$stackPos-(8-7)], 'attrGroups' => $this->semStack[$stackPos-(8-1)]], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); + $this->checkClass($this->semValue, $stackPos-(8-3)); + }, + 205 => function ($stackPos) { + $this->semValue = new Stmt\Interface_($this->semStack[$stackPos-(7-3)], ['extends' => $this->semStack[$stackPos-(7-4)], 'stmts' => $this->semStack[$stackPos-(7-6)], 'attrGroups' => $this->semStack[$stackPos-(7-1)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + $this->checkInterface($this->semValue, $stackPos-(7-3)); + }, + 206 => function ($stackPos) { + $this->semValue = new Stmt\Trait_($this->semStack[$stackPos-(6-3)], ['stmts' => $this->semStack[$stackPos-(6-5)], 'attrGroups' => $this->semStack[$stackPos-(6-1)]], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + }, + 207 => function ($stackPos) { + $this->semValue = new Stmt\Enum_($this->semStack[$stackPos-(8-3)], ['scalarType' => $this->semStack[$stackPos-(8-4)], 'implements' => $this->semStack[$stackPos-(8-5)], 'stmts' => $this->semStack[$stackPos-(8-7)], 'attrGroups' => $this->semStack[$stackPos-(8-1)]], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); + $this->checkEnum($this->semValue, $stackPos-(8-3)); + }, + 208 => function ($stackPos) { + $this->semValue = null; + }, + 209 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; + }, + 210 => function ($stackPos) { + $this->semValue = null; + }, + 211 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; + }, + 212 => function ($stackPos) { + $this->semValue = 0; + }, + 213 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; + }, + 214 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_FINAL; + }, + 215 => function ($stackPos) { + $this->semValue = null; + }, + 216 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; + }, + 217 => function ($stackPos) { + $this->semValue = array(); + }, + 218 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; + }, + 219 => function ($stackPos) { + $this->semValue = array(); + }, + 220 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; + }, + 221 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 222 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 223 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 224 => function ($stackPos) { + $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + }, + 225 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-2)]; + }, + 226 => function ($stackPos) { + $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + }, + 227 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-2)]; + }, + 228 => function ($stackPos) { + $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + }, + 229 => function ($stackPos) { + $this->semValue = null; + }, + 230 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-2)]; + }, + 231 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 232 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 233 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 234 => function ($stackPos) { + $this->semValue = new Stmt\DeclareDeclare($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 235 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 236 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-3)]; + }, + 237 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-2)]; + }, + 238 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(5-3)]; + }, + 239 => function ($stackPos) { + $this->semValue = array(); + }, + 240 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 241 => function ($stackPos) { + $this->semValue = new Stmt\Case_($this->semStack[$stackPos-(4-2)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 242 => function ($stackPos) { + $this->semValue = new Stmt\Case_(null, $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 243 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 244 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 245 => function ($stackPos) { + $this->semValue = new Expr\Match_($this->semStack[$stackPos-(7-3)], $this->semStack[$stackPos-(7-6)], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + }, + 246 => function ($stackPos) { + $this->semValue = []; + }, + 247 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 248 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 249 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 250 => function ($stackPos) { + $this->semValue = new Node\MatchArm($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 251 => function ($stackPos) { + $this->semValue = new Node\MatchArm(null, $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 252 => function ($stackPos) { + $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + }, + 253 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-2)]; + }, + 254 => function ($stackPos) { + $this->semValue = array(); + }, + 255 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 256 => function ($stackPos) { + $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos-(5-3)], is_array($this->semStack[$stackPos-(5-5)]) ? $this->semStack[$stackPos-(5-5)] : array($this->semStack[$stackPos-(5-5)]), $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 257 => function ($stackPos) { + $this->semValue = array(); + }, + 258 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 259 => function ($stackPos) { + $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos-(6-3)], $this->semStack[$stackPos-(6-6)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + }, + 260 => function ($stackPos) { + $this->semValue = null; + }, + 261 => function ($stackPos) { + $this->semValue = new Stmt\Else_(is_array($this->semStack[$stackPos-(2-2)]) ? $this->semStack[$stackPos-(2-2)] : array($this->semStack[$stackPos-(2-2)]), $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 262 => function ($stackPos) { + $this->semValue = null; + }, + 263 => function ($stackPos) { + $this->semValue = new Stmt\Else_($this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 264 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)], false); + }, + 265 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(2-2)], true); + }, + 266 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)], false); + }, + 267 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)], false); + }, + 268 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 269 => function ($stackPos) { + $this->semValue = array(); + }, + 270 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 271 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 272 => function ($stackPos) { + $this->semValue = 0; + }, + 273 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_PUBLIC; + }, + 274 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_PROTECTED; + }, + 275 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_PRIVATE; + }, + 276 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_READONLY; + }, + 277 => function ($stackPos) { + $this->semValue = new Node\Param($this->semStack[$stackPos-(6-6)], null, $this->semStack[$stackPos-(6-3)], $this->semStack[$stackPos-(6-4)], $this->semStack[$stackPos-(6-5)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes, $this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-1)]); + $this->checkParam($this->semValue); + }, + 278 => function ($stackPos) { + $this->semValue = new Node\Param($this->semStack[$stackPos-(8-6)], $this->semStack[$stackPos-(8-8)], $this->semStack[$stackPos-(8-3)], $this->semStack[$stackPos-(8-4)], $this->semStack[$stackPos-(8-5)], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes, $this->semStack[$stackPos-(8-2)], $this->semStack[$stackPos-(8-1)]); + $this->checkParam($this->semValue); + }, + 279 => function ($stackPos) { + $this->semValue = new Node\Param(new Expr\Error($this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes), null, $this->semStack[$stackPos-(6-3)], $this->semStack[$stackPos-(6-4)], $this->semStack[$stackPos-(6-5)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes, $this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-1)]); + }, + 280 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 281 => function ($stackPos) { + $this->semValue = new Node\NullableType($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 282 => function ($stackPos) { + $this->semValue = new Node\UnionType($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 283 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 284 => function ($stackPos) { + $this->semValue = new Node\Name('static', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 285 => function ($stackPos) { + $this->semValue = $this->handleBuiltinTypes($this->semStack[$stackPos-(1-1)]); + }, + 286 => function ($stackPos) { + $this->semValue = new Node\Identifier('array', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 287 => function ($stackPos) { + $this->semValue = new Node\Identifier('callable', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 288 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)]); + }, + 289 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 290 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)]); + }, + 291 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 292 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 293 => function ($stackPos) { + $this->semValue = new Node\NullableType($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 294 => function ($stackPos) { + $this->semValue = new Node\UnionType($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 295 => function ($stackPos) { + $this->semValue = null; + }, + 296 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 297 => function ($stackPos) { + $this->semValue = null; + }, + 298 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-2)]; + }, + 299 => function ($stackPos) { + $this->semValue = null; + }, + 300 => function ($stackPos) { + $this->semValue = array(); + }, + 301 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-2)]; + }, + 302 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 303 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 304 => function ($stackPos) { + $this->semValue = new Node\Arg($this->semStack[$stackPos-(1-1)], false, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 305 => function ($stackPos) { + $this->semValue = new Node\Arg($this->semStack[$stackPos-(2-2)], true, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 306 => function ($stackPos) { + $this->semValue = new Node\Arg($this->semStack[$stackPos-(2-2)], false, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 307 => function ($stackPos) { + $this->semValue = new Node\Arg($this->semStack[$stackPos-(3-3)], false, false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes, $this->semStack[$stackPos-(3-1)]); + }, + 308 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 309 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 310 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 311 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 312 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 313 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 314 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 315 => function ($stackPos) { + $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos-(1-1)], null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 316 => function ($stackPos) { + $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 317 => function ($stackPos) { + if ($this->semStack[$stackPos-(2-2)] !== null) { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; } + }, + 318 => function ($stackPos) { + $this->semValue = array(); + }, + 319 => function ($stackPos) { + $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; + if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 320 => function ($stackPos) { + $this->semValue = new Stmt\Property($this->semStack[$stackPos-(5-2)], $this->semStack[$stackPos-(5-4)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes, $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-1)]); + $this->checkProperty($this->semValue, $stackPos-(5-2)); + }, + 321 => function ($stackPos) { + $this->semValue = new Stmt\ClassConst($this->semStack[$stackPos-(5-4)], $this->semStack[$stackPos-(5-2)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes, $this->semStack[$stackPos-(5-1)]); + $this->checkClassConst($this->semValue, $stackPos-(5-2)); + }, + 322 => function ($stackPos) { + $this->semValue = new Stmt\ClassMethod($this->semStack[$stackPos-(10-5)], ['type' => $this->semStack[$stackPos-(10-2)], 'byRef' => $this->semStack[$stackPos-(10-4)], 'params' => $this->semStack[$stackPos-(10-7)], 'returnType' => $this->semStack[$stackPos-(10-9)], 'stmts' => $this->semStack[$stackPos-(10-10)], 'attrGroups' => $this->semStack[$stackPos-(10-1)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); + $this->checkClassMethod($this->semValue, $stackPos-(10-2)); + }, + 323 => function ($stackPos) { + $this->semValue = new Stmt\TraitUse($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 324 => function ($stackPos) { + $this->semValue = new Stmt\EnumCase($this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-4)], $this->semStack[$stackPos-(5-1)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 325 => function ($stackPos) { + $this->semValue = null; /* will be skipped */ + }, + 326 => function ($stackPos) { + $this->semValue = array(); + }, + 327 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 328 => function ($stackPos) { + $this->semValue = array(); + }, + 329 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 330 => function ($stackPos) { + $this->semValue = new Stmt\TraitUseAdaptation\Precedence($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 331 => function ($stackPos) { + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(5-1)][0], $this->semStack[$stackPos-(5-1)][1], $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-4)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 332 => function ($stackPos) { + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], $this->semStack[$stackPos-(4-3)], null, $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 333 => function ($stackPos) { + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 334 => function ($stackPos) { + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 335 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)]); + }, + 336 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 337 => function ($stackPos) { + $this->semValue = array(null, $this->semStack[$stackPos-(1-1)]); + }, + 338 => function ($stackPos) { + $this->semValue = null; + }, + 339 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 340 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 341 => function ($stackPos) { + $this->semValue = 0; + }, + 342 => function ($stackPos) { + $this->semValue = 0; + }, + 343 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 344 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 345 => function ($stackPos) { + $this->checkModifier($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $this->semValue = $this->semStack[$stackPos-(2-1)] | $this->semStack[$stackPos-(2-2)]; + }, + 346 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_PUBLIC; + }, + 347 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_PROTECTED; + }, + 348 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_PRIVATE; + }, + 349 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_STATIC; + }, + 350 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; + }, + 351 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_FINAL; + }, + 352 => function ($stackPos) { + $this->semValue = Stmt\Class_::MODIFIER_READONLY; + }, + 353 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 354 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 355 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 356 => function ($stackPos) { + $this->semValue = new Node\VarLikeIdentifier(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 357 => function ($stackPos) { + $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos-(1-1)], null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 358 => function ($stackPos) { + $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 359 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 360 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 361 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 362 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 363 => function ($stackPos) { + $this->semValue = array(); + }, + 364 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 365 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 366 => function ($stackPos) { + $this->semValue = new Expr\Assign($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 367 => function ($stackPos) { + $this->semValue = new Expr\Assign($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 368 => function ($stackPos) { + $this->semValue = new Expr\Assign($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 369 => function ($stackPos) { + $this->semValue = new Expr\AssignRef($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 370 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 371 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 372 => function ($stackPos) { + $this->semValue = new Expr\Clone_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 373 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Plus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 374 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Minus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 375 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Mul($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 376 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Div($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 377 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Concat($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 378 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Mod($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 379 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 380 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\BitwiseOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 381 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\BitwiseXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 382 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\ShiftLeft($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 383 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\ShiftRight($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 384 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Pow($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 385 => function ($stackPos) { + $this->semValue = new Expr\AssignOp\Coalesce($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 386 => function ($stackPos) { + $this->semValue = new Expr\PostInc($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 387 => function ($stackPos) { + $this->semValue = new Expr\PreInc($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 388 => function ($stackPos) { + $this->semValue = new Expr\PostDec($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 389 => function ($stackPos) { + $this->semValue = new Expr\PreDec($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 390 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 391 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 392 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 393 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 394 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 395 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 396 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 397 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 398 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 399 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 400 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 401 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 402 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 403 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Div($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 404 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 405 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 406 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 407 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 408 => function ($stackPos) { + $this->semValue = new Expr\UnaryPlus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 409 => function ($stackPos) { + $this->semValue = new Expr\UnaryMinus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 410 => function ($stackPos) { + $this->semValue = new Expr\BooleanNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 411 => function ($stackPos) { + $this->semValue = new Expr\BitwiseNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 412 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 413 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 414 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 415 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 416 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Spaceship($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 417 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 418 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 419 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 420 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 421 => function ($stackPos) { + $this->semValue = new Expr\Instanceof_($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 422 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 423 => function ($stackPos) { + $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(5-1)], $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + }, + 424 => function ($stackPos) { + $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(4-1)], null, $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 425 => function ($stackPos) { + $this->semValue = new Expr\BinaryOp\Coalesce($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 426 => function ($stackPos) { + $this->semValue = new Expr\Isset_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 427 => function ($stackPos) { + $this->semValue = new Expr\Empty_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 428 => function ($stackPos) { + $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 429 => function ($stackPos) { + $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE_ONCE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 430 => function ($stackPos) { + $this->semValue = new Expr\Eval_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 431 => function ($stackPos) { + $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 432 => function ($stackPos) { + $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE_ONCE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 433 => function ($stackPos) { + $this->semValue = new Expr\Cast\Int_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 434 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes; + $attrs['kind'] = $this->getFloatCastKind($this->semStack[$stackPos-(2-1)]); + $this->semValue = new Expr\Cast\Double($this->semStack[$stackPos-(2-2)], $attrs); + }, + 435 => function ($stackPos) { + $this->semValue = new Expr\Cast\String_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 436 => function ($stackPos) { + $this->semValue = new Expr\Cast\Array_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 437 => function ($stackPos) { + $this->semValue = new Expr\Cast\Object_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 438 => function ($stackPos) { + $this->semValue = new Expr\Cast\Bool_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 439 => function ($stackPos) { + $this->semValue = new Expr\Cast\Unset_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 440 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes; + $attrs['kind'] = strtolower($this->semStack[$stackPos-(2-1)]) === 'exit' ? Expr\Exit_::KIND_EXIT : Expr\Exit_::KIND_DIE; + $this->semValue = new Expr\Exit_($this->semStack[$stackPos-(2-2)], $attrs); + }, + 441 => function ($stackPos) { + $this->semValue = new Expr\ErrorSuppress($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 442 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 443 => function ($stackPos) { + $this->semValue = new Expr\ShellExec($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 444 => function ($stackPos) { + $this->semValue = new Expr\Print_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 445 => function ($stackPos) { + $this->semValue = new Expr\Yield_(null, null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 446 => function ($stackPos) { + $this->semValue = new Expr\Yield_($this->semStack[$stackPos-(2-2)], null, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 447 => function ($stackPos) { + $this->semValue = new Expr\Yield_($this->semStack[$stackPos-(4-4)], $this->semStack[$stackPos-(4-2)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 448 => function ($stackPos) { + $this->semValue = new Expr\YieldFrom($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 449 => function ($stackPos) { + $this->semValue = new Expr\Throw_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 450 => function ($stackPos) { + $this->semValue = new Expr\ArrowFunction(['static' => false, 'byRef' => $this->semStack[$stackPos-(8-2)], 'params' => $this->semStack[$stackPos-(8-4)], 'returnType' => $this->semStack[$stackPos-(8-6)], 'expr' => $this->semStack[$stackPos-(8-8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); + }, + 451 => function ($stackPos) { + $this->semValue = new Expr\ArrowFunction(['static' => true, 'byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-5)], 'returnType' => $this->semStack[$stackPos-(9-7)], 'expr' => $this->semStack[$stackPos-(9-9)], 'attrGroups' => []], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + }, + 452 => function ($stackPos) { + $this->semValue = new Expr\Closure(['static' => false, 'byRef' => $this->semStack[$stackPos-(8-2)], 'params' => $this->semStack[$stackPos-(8-4)], 'uses' => $this->semStack[$stackPos-(8-6)], 'returnType' => $this->semStack[$stackPos-(8-7)], 'stmts' => $this->semStack[$stackPos-(8-8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); + }, + 453 => function ($stackPos) { + $this->semValue = new Expr\Closure(['static' => true, 'byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-5)], 'uses' => $this->semStack[$stackPos-(9-7)], 'returnType' => $this->semStack[$stackPos-(9-8)], 'stmts' => $this->semStack[$stackPos-(9-9)], 'attrGroups' => []], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + }, + 454 => function ($stackPos) { + $this->semValue = new Expr\ArrowFunction(['static' => false, 'byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-5)], 'returnType' => $this->semStack[$stackPos-(9-7)], 'expr' => $this->semStack[$stackPos-(9-9)], 'attrGroups' => $this->semStack[$stackPos-(9-1)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + }, + 455 => function ($stackPos) { + $this->semValue = new Expr\ArrowFunction(['static' => true, 'byRef' => $this->semStack[$stackPos-(10-4)], 'params' => $this->semStack[$stackPos-(10-6)], 'returnType' => $this->semStack[$stackPos-(10-8)], 'expr' => $this->semStack[$stackPos-(10-10)], 'attrGroups' => $this->semStack[$stackPos-(10-1)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); + }, + 456 => function ($stackPos) { + $this->semValue = new Expr\Closure(['static' => false, 'byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-5)], 'uses' => $this->semStack[$stackPos-(9-7)], 'returnType' => $this->semStack[$stackPos-(9-8)], 'stmts' => $this->semStack[$stackPos-(9-9)], 'attrGroups' => $this->semStack[$stackPos-(9-1)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + }, + 457 => function ($stackPos) { + $this->semValue = new Expr\Closure(['static' => true, 'byRef' => $this->semStack[$stackPos-(10-4)], 'params' => $this->semStack[$stackPos-(10-6)], 'uses' => $this->semStack[$stackPos-(10-8)], 'returnType' => $this->semStack[$stackPos-(10-9)], 'stmts' => $this->semStack[$stackPos-(10-10)], 'attrGroups' => $this->semStack[$stackPos-(10-1)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); + }, + 458 => function ($stackPos) { + $this->semValue = array(new Stmt\Class_(null, ['type' => 0, 'extends' => $this->semStack[$stackPos-(8-4)], 'implements' => $this->semStack[$stackPos-(8-5)], 'stmts' => $this->semStack[$stackPos-(8-7)], 'attrGroups' => $this->semStack[$stackPos-(8-1)]], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes), $this->semStack[$stackPos-(8-3)]); $this->checkClass($this->semValue[0], -1); - } - - protected function reduceRule388() { - $this->semValue = new Expr\New_($this->semStack[$this->stackPos-(3-2)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule389() { - list($class, $ctorArgs) = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = new Expr\New_($class, $ctorArgs, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule390() { - $this->semValue = array(); - } - - protected function reduceRule391() { - $this->semValue = $this->semStack[$this->stackPos-(4-3)]; - } - - protected function reduceRule392() { - $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule393() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule394() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule395() { - $this->semValue = new Expr\ClosureUse(substr($this->semStack[$this->stackPos-(2-2)], 1), $this->semStack[$this->stackPos-(2-1)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule396() { - $this->semValue = new Expr\FuncCall($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule397() { - $this->semValue = new Expr\FuncCall($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule398() { - $this->semValue = new Expr\StaticCall($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule399() { - $this->semValue = new Name($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule400() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule401() { - $this->semValue = new Name($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule402() { - $this->semValue = new Name\FullyQualified($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule403() { - $this->semValue = new Name\Relative($this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule404() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule405() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule406() { - $this->semValue = new Expr\Error($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); $this->errorState = 2; - } - - protected function reduceRule407() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule408() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule409() { - $this->semValue = null; - } - - protected function reduceRule410() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule411() { - $this->semValue = array(); - } - - protected function reduceRule412() { - $this->semValue = array(new Scalar\EncapsedStringPart(Scalar\String_::parseEscapeSequences($this->semStack[$this->stackPos-(1-1)], '`'), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes)); - } - - protected function reduceRule413() { - foreach ($this->semStack[$this->stackPos-(1-1)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', true); } }; $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule414() { - $this->semValue = array(); - } - - protected function reduceRule415() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule416() { - $this->semValue = new Expr\ConstFetch($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule417() { - $this->semValue = new Expr\ClassConstFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule418() { - $this->semValue = new Expr\ClassConstFetch($this->semStack[$this->stackPos-(3-1)], new Expr\Error($this->startAttributeStack[$this->stackPos-(3-3)] + $this->endAttributeStack[$this->stackPos-(3-3)]), $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); $this->errorState = 2; - } - - protected function reduceRule419() { - $attrs = $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_SHORT; - $this->semValue = new Expr\Array_($this->semStack[$this->stackPos-(3-2)], $attrs); - } - - protected function reduceRule420() { - $attrs = $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_LONG; - $this->semValue = new Expr\Array_($this->semStack[$this->stackPos-(4-3)], $attrs); - } - - protected function reduceRule421() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule422() { - $attrs = $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes; $attrs['kind'] = ($this->semStack[$this->stackPos-(1-1)][0] === "'" || ($this->semStack[$this->stackPos-(1-1)][1] === "'" && ($this->semStack[$this->stackPos-(1-1)][0] === 'b' || $this->semStack[$this->stackPos-(1-1)][0] === 'B')) ? Scalar\String_::KIND_SINGLE_QUOTED : Scalar\String_::KIND_DOUBLE_QUOTED); - $this->semValue = new Scalar\String_(Scalar\String_::parse($this->semStack[$this->stackPos-(1-1)]), $attrs); - } - - protected function reduceRule423() { - $this->semValue = $this->parseLNumber($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule424() { - $this->semValue = new Scalar\DNumber(Scalar\DNumber::parse($this->semStack[$this->stackPos-(1-1)]), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule425() { - $this->semValue = new Scalar\MagicConst\Line($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule426() { - $this->semValue = new Scalar\MagicConst\File($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule427() { - $this->semValue = new Scalar\MagicConst\Dir($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule428() { - $this->semValue = new Scalar\MagicConst\Class_($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule429() { - $this->semValue = new Scalar\MagicConst\Trait_($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule430() { - $this->semValue = new Scalar\MagicConst\Method($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule431() { - $this->semValue = new Scalar\MagicConst\Function_($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule432() { - $this->semValue = new Scalar\MagicConst\Namespace_($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule433() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule434() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule435() { - $attrs = $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = strpos($this->semStack[$this->stackPos-(3-1)], "'") === false ? Scalar\String_::KIND_HEREDOC : Scalar\String_::KIND_NOWDOC; preg_match('/\A[bB]?<<<[ \t]*[\'"]?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[\'"]?(?:\r\n|\n|\r)\z/', $this->semStack[$this->stackPos-(3-1)], $matches); $attrs['docLabel'] = $matches[1];; - $this->semValue = new Scalar\String_(Scalar\String_::parseDocString($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-2)]), $attrs); - } - - protected function reduceRule436() { - $attrs = $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes; $attrs['kind'] = strpos($this->semStack[$this->stackPos-(2-1)], "'") === false ? Scalar\String_::KIND_HEREDOC : Scalar\String_::KIND_NOWDOC; preg_match('/\A[bB]?<<<[ \t]*[\'"]?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[\'"]?(?:\r\n|\n|\r)\z/', $this->semStack[$this->stackPos-(2-1)], $matches); $attrs['docLabel'] = $matches[1];; - $this->semValue = new Scalar\String_('', $attrs); - } - - protected function reduceRule437() { - $attrs = $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; - foreach ($this->semStack[$this->stackPos-(3-2)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '"', true); } }; $this->semValue = new Scalar\Encapsed($this->semStack[$this->stackPos-(3-2)], $attrs); - } - - protected function reduceRule438() { - $attrs = $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = strpos($this->semStack[$this->stackPos-(3-1)], "'") === false ? Scalar\String_::KIND_HEREDOC : Scalar\String_::KIND_NOWDOC; preg_match('/\A[bB]?<<<[ \t]*[\'"]?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[\'"]?(?:\r\n|\n|\r)\z/', $this->semStack[$this->stackPos-(3-1)], $matches); $attrs['docLabel'] = $matches[1];; - foreach ($this->semStack[$this->stackPos-(3-2)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, null, true); } } $s->value = preg_replace('~(\r\n|\n|\r)\z~', '', $s->value); if ('' === $s->value) array_pop($this->semStack[$this->stackPos-(3-2)]);; $this->semValue = new Scalar\Encapsed($this->semStack[$this->stackPos-(3-2)], $attrs); - } - - protected function reduceRule439() { - $this->semValue = null; - } - - protected function reduceRule440() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule441() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule442() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule443() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule444() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule445() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule446() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule447() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule448() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule449() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule450() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule451() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule452() { - $this->semValue = new Expr\MethodCall($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->semStack[$this->stackPos-(4-4)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule453() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule454() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule455() { - $this->semValue = new Expr\PropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule456() { - $this->semValue = substr($this->semStack[$this->stackPos-(1-1)], 1); - } - - protected function reduceRule457() { - $this->semValue = $this->semStack[$this->stackPos-(4-3)]; - } - - protected function reduceRule458() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule459() { - $this->semValue = new Expr\Error($this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); $this->errorState = 2; - } - - protected function reduceRule460() { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule461() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule462() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule463() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule464() { - $this->semValue = new Expr\PropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule465() { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule466() { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule467() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule468() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule469() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule470() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule471() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule472() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule473() { - $this->semValue = new Expr\Error($this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); $this->errorState = 2; - } - - protected function reduceRule474() { - $this->semValue = new Expr\List_($this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule475() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule476() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule477() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(1-1)], null, false, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule478() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(1-1)], null, false, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule479() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(3-3)], $this->semStack[$this->stackPos-(3-1)], false, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule480() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(3-3)], $this->semStack[$this->stackPos-(3-1)], false, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule481() { - $this->semValue = null; - } - - protected function reduceRule482() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; $end = count($this->semValue)-1; if ($this->semValue[$end] === null) unset($this->semValue[$end]); - } - - protected function reduceRule483() { - $this->semStack[$this->stackPos-(3-1)][] = $this->semStack[$this->stackPos-(3-3)]; $this->semValue = $this->semStack[$this->stackPos-(3-1)]; - } - - protected function reduceRule484() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule485() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(3-3)], $this->semStack[$this->stackPos-(3-1)], false, $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule486() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(1-1)], null, false, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule487() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(4-4)], $this->semStack[$this->stackPos-(4-1)], true, $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule488() { - $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(2-2)], null, true, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule489() { - $this->semValue = null; - } - - protected function reduceRule490() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule491() { - $this->semStack[$this->stackPos-(2-1)][] = $this->semStack[$this->stackPos-(2-2)]; $this->semValue = $this->semStack[$this->stackPos-(2-1)]; - } - - protected function reduceRule492() { - $this->semValue = array($this->semStack[$this->stackPos-(1-1)]); - } - - protected function reduceRule493() { - $this->semValue = array($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)]); - } - - protected function reduceRule494() { - $this->semValue = new Scalar\EncapsedStringPart($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule495() { - $this->semValue = new Expr\Variable(substr($this->semStack[$this->stackPos-(1-1)], 1), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule496() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; - } - - protected function reduceRule497() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); - } - - protected function reduceRule498() { - $this->semValue = new Expr\PropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule499() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule500() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); - } - - protected function reduceRule501() { - $this->semValue = new Expr\ArrayDimFetch(new Expr\Variable($this->semStack[$this->stackPos-(6-2)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes), $this->semStack[$this->stackPos-(6-4)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); - } - - protected function reduceRule502() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; - } - - protected function reduceRule503() { - $this->semValue = new Scalar\String_($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule504() { - $this->semValue = $this->parseNumString($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); - } - - protected function reduceRule505() { - $this->semValue = $this->parseNumString('-' . $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } - - protected function reduceRule506() { - $this->semValue = new Expr\Variable(substr($this->semStack[$this->stackPos-(1-1)], 1), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); + }, + 459 => function ($stackPos) { + $this->semValue = new Expr\New_($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 460 => function ($stackPos) { + list($class, $ctorArgs) = $this->semStack[$stackPos-(2-2)]; $this->semValue = new Expr\New_($class, $ctorArgs, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 461 => function ($stackPos) { + $this->semValue = array(); + }, + 462 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(4-3)]; + }, + 463 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 464 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 465 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 466 => function ($stackPos) { + $this->semValue = new Expr\ClosureUse($this->semStack[$stackPos-(2-2)], $this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 467 => function ($stackPos) { + $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 468 => function ($stackPos) { + $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 469 => function ($stackPos) { + $this->semValue = new Expr\StaticCall($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 470 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 471 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 472 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 473 => function ($stackPos) { + $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 474 => function ($stackPos) { + $this->semValue = new Name\FullyQualified(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 475 => function ($stackPos) { + $this->semValue = new Name\Relative(substr($this->semStack[$stackPos-(1-1)], 10), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 476 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 477 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 478 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 479 => function ($stackPos) { + $this->semValue = new Expr\Error($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->errorState = 2; + }, + 480 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 481 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 482 => function ($stackPos) { + $this->semValue = null; + }, + 483 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 484 => function ($stackPos) { + $this->semValue = array(); + }, + 485 => function ($stackPos) { + $this->semValue = array(new Scalar\EncapsedStringPart(Scalar\String_::parseEscapeSequences($this->semStack[$stackPos-(1-1)], '`'), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes)); + }, + 486 => function ($stackPos) { + foreach ($this->semStack[$stackPos-(1-1)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', true); } }; $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 487 => function ($stackPos) { + $this->semValue = array(); + }, + 488 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 489 => function ($stackPos) { + $this->semValue = new Expr\ConstFetch($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 490 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Line($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 491 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\File($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 492 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Dir($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 493 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Class_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 494 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Trait_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 495 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Method($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 496 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Function_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 497 => function ($stackPos) { + $this->semValue = new Scalar\MagicConst\Namespace_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 498 => function ($stackPos) { + $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 499 => function ($stackPos) { + $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos-(3-1)], new Expr\Error($this->startAttributeStack[$stackPos-(3-3)] + $this->endAttributeStack[$stackPos-(3-3)]), $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->errorState = 2; + }, + 500 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_SHORT; + $this->semValue = new Expr\Array_($this->semStack[$stackPos-(3-2)], $attrs); + }, + 501 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_LONG; + $this->semValue = new Expr\Array_($this->semStack[$stackPos-(4-3)], $attrs); + }, + 502 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 503 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes; $attrs['kind'] = ($this->semStack[$stackPos-(1-1)][0] === "'" || ($this->semStack[$stackPos-(1-1)][1] === "'" && ($this->semStack[$stackPos-(1-1)][0] === 'b' || $this->semStack[$stackPos-(1-1)][0] === 'B')) ? Scalar\String_::KIND_SINGLE_QUOTED : Scalar\String_::KIND_DOUBLE_QUOTED); + $this->semValue = new Scalar\String_(Scalar\String_::parse($this->semStack[$stackPos-(1-1)]), $attrs); + }, + 504 => function ($stackPos) { + $attrs = $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; + foreach ($this->semStack[$stackPos-(3-2)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '"', true); } }; $this->semValue = new Scalar\Encapsed($this->semStack[$stackPos-(3-2)], $attrs); + }, + 505 => function ($stackPos) { + $this->semValue = $this->parseLNumber($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 506 => function ($stackPos) { + $this->semValue = new Scalar\DNumber(Scalar\DNumber::parse($this->semStack[$stackPos-(1-1)]), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 507 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 508 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 509 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 510 => function ($stackPos) { + $this->semValue = $this->parseDocString($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(3-3)] + $this->endAttributeStack[$stackPos-(3-3)], true); + }, + 511 => function ($stackPos) { + $this->semValue = $this->parseDocString($this->semStack[$stackPos-(2-1)], '', $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(2-2)] + $this->endAttributeStack[$stackPos-(2-2)], true); + }, + 512 => function ($stackPos) { + $this->semValue = $this->parseDocString($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(3-3)] + $this->endAttributeStack[$stackPos-(3-3)], true); + }, + 513 => function ($stackPos) { + $this->semValue = null; + }, + 514 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 515 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 516 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 517 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 518 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 519 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 520 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 521 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 522 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 523 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 524 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 525 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 526 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 527 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 528 => function ($stackPos) { + $this->semValue = new Expr\MethodCall($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 529 => function ($stackPos) { + $this->semValue = new Expr\NullsafeMethodCall($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 530 => function ($stackPos) { + $this->semValue = null; + }, + 531 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 532 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 533 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 534 => function ($stackPos) { + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 535 => function ($stackPos) { + $this->semValue = new Expr\NullsafePropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 536 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 537 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 538 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 539 => function ($stackPos) { + $this->semValue = new Expr\Variable(new Expr\Error($this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes), $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); $this->errorState = 2; + }, + 540 => function ($stackPos) { + $var = $this->semStack[$stackPos-(1-1)]->name; $this->semValue = \is_string($var) ? new Node\VarLikeIdentifier($var, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes) : $var; + }, + 541 => function ($stackPos) { + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 542 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 543 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 544 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 545 => function ($stackPos) { + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 546 => function ($stackPos) { + $this->semValue = new Expr\NullsafePropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 547 => function ($stackPos) { + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 548 => function ($stackPos) { + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 549 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 550 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 551 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 552 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 553 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 554 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 555 => function ($stackPos) { + $this->semValue = new Expr\Error($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->errorState = 2; + }, + 556 => function ($stackPos) { + $this->semValue = new Expr\List_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 557 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; $end = count($this->semValue)-1; if ($this->semValue[$end] === null) array_pop($this->semValue); + }, + 558 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos]; + }, + 559 => function ($stackPos) { + /* do nothing -- prevent default action of $$=$this->semStack[$1]. See $551. */ + }, + 560 => function ($stackPos) { + $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + }, + 561 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 562 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 563 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(2-2)], null, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 564 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 565 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(3-3)], $this->semStack[$stackPos-(3-1)], false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 566 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(4-4)], $this->semStack[$stackPos-(4-1)], true, $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 567 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(3-3)], $this->semStack[$stackPos-(3-1)], false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 568 => function ($stackPos) { + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(2-2)], null, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 569 => function ($stackPos) { + $this->semValue = null; + }, + 570 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 571 => function ($stackPos) { + $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + }, + 572 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(1-1)]); + }, + 573 => function ($stackPos) { + $this->semValue = array($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); + }, + 574 => function ($stackPos) { + $this->semValue = new Scalar\EncapsedStringPart($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 575 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 576 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + 577 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + }, + 578 => function ($stackPos) { + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 579 => function ($stackPos) { + $this->semValue = new Expr\NullsafePropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 580 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 581 => function ($stackPos) { + $this->semValue = new Expr\Variable($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + }, + 582 => function ($stackPos) { + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-4)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + }, + 583 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(3-2)]; + }, + 584 => function ($stackPos) { + $this->semValue = new Scalar\String_($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 585 => function ($stackPos) { + $this->semValue = $this->parseNumString($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + }, + 586 => function ($stackPos) { + $this->semValue = $this->parseNumString('-' . $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + }, + 587 => function ($stackPos) { + $this->semValue = $this->semStack[$stackPos-(1-1)]; + }, + ]; } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Parser/Tokens.php b/lib/nikic/php-parser/lib/PhpParser/Parser/Tokens.php index 861663fae..b76a5d94c 100644 --- a/lib/nikic/php-parser/lib/PhpParser/Parser/Tokens.php +++ b/lib/nikic/php-parser/lib/PhpParser/Parser/Tokens.php @@ -6,131 +6,131 @@ namespace PhpParser\Parser; final class Tokens { const YYERRTOK = 256; - const T_INCLUDE = 257; - const T_INCLUDE_ONCE = 258; - const T_EVAL = 259; - const T_REQUIRE = 260; - const T_REQUIRE_ONCE = 261; - const T_LOGICAL_OR = 262; - const T_LOGICAL_XOR = 263; - const T_LOGICAL_AND = 264; - const T_PRINT = 265; - const T_YIELD = 266; - const T_DOUBLE_ARROW = 267; - const T_YIELD_FROM = 268; - const T_PLUS_EQUAL = 269; - const T_MINUS_EQUAL = 270; - const T_MUL_EQUAL = 271; - const T_DIV_EQUAL = 272; - const T_CONCAT_EQUAL = 273; - const T_MOD_EQUAL = 274; - const T_AND_EQUAL = 275; - const T_OR_EQUAL = 276; - const T_XOR_EQUAL = 277; - const T_SL_EQUAL = 278; - const T_SR_EQUAL = 279; - const T_POW_EQUAL = 280; - const T_COALESCE = 281; - const T_BOOLEAN_OR = 282; - const T_BOOLEAN_AND = 283; - const T_IS_EQUAL = 284; - const T_IS_NOT_EQUAL = 285; - const T_IS_IDENTICAL = 286; - const T_IS_NOT_IDENTICAL = 287; - const T_SPACESHIP = 288; - const T_IS_SMALLER_OR_EQUAL = 289; - const T_IS_GREATER_OR_EQUAL = 290; - const T_SL = 291; - const T_SR = 292; - const T_INSTANCEOF = 293; - const T_INC = 294; - const T_DEC = 295; - const T_INT_CAST = 296; - const T_DOUBLE_CAST = 297; - const T_STRING_CAST = 298; - const T_ARRAY_CAST = 299; - const T_OBJECT_CAST = 300; - const T_BOOL_CAST = 301; - const T_UNSET_CAST = 302; - const T_POW = 303; - const T_NEW = 304; - const T_CLONE = 305; - const T_EXIT = 306; - const T_IF = 307; - const T_ELSEIF = 308; - const T_ELSE = 309; - const T_ENDIF = 310; - const T_LNUMBER = 311; - const T_DNUMBER = 312; - const T_STRING = 313; - const T_STRING_VARNAME = 314; - const T_VARIABLE = 315; - const T_NUM_STRING = 316; - const T_INLINE_HTML = 317; - const T_CHARACTER = 318; - const T_BAD_CHARACTER = 319; - const T_ENCAPSED_AND_WHITESPACE = 320; - const T_CONSTANT_ENCAPSED_STRING = 321; - const T_ECHO = 322; - const T_DO = 323; - const T_WHILE = 324; - const T_ENDWHILE = 325; - const T_FOR = 326; - const T_ENDFOR = 327; - const T_FOREACH = 328; - const T_ENDFOREACH = 329; - const T_DECLARE = 330; - const T_ENDDECLARE = 331; - const T_AS = 332; - const T_SWITCH = 333; - const T_ENDSWITCH = 334; - const T_CASE = 335; - const T_DEFAULT = 336; - const T_BREAK = 337; - const T_CONTINUE = 338; - const T_GOTO = 339; - const T_FUNCTION = 340; - const T_CONST = 341; - const T_RETURN = 342; - const T_TRY = 343; - const T_CATCH = 344; - const T_FINALLY = 345; - const T_THROW = 346; - const T_USE = 347; - const T_INSTEADOF = 348; - const T_GLOBAL = 349; - const T_STATIC = 350; - const T_ABSTRACT = 351; - const T_FINAL = 352; - const T_PRIVATE = 353; - const T_PROTECTED = 354; - const T_PUBLIC = 355; - const T_VAR = 356; - const T_UNSET = 357; - const T_ISSET = 358; - const T_EMPTY = 359; - const T_HALT_COMPILER = 360; - const T_CLASS = 361; - const T_TRAIT = 362; - const T_INTERFACE = 363; - const T_EXTENDS = 364; - const T_IMPLEMENTS = 365; - const T_OBJECT_OPERATOR = 366; - const T_LIST = 367; - const T_ARRAY = 368; - const T_CALLABLE = 369; - const T_CLASS_C = 370; - const T_TRAIT_C = 371; - const T_METHOD_C = 372; - const T_FUNC_C = 373; - const T_LINE = 374; - const T_FILE = 375; - const T_COMMENT = 376; - const T_DOC_COMMENT = 377; - const T_OPEN_TAG = 378; - const T_OPEN_TAG_WITH_ECHO = 379; - const T_CLOSE_TAG = 380; - const T_WHITESPACE = 381; + const T_THROW = 257; + const T_INCLUDE = 258; + const T_INCLUDE_ONCE = 259; + const T_EVAL = 260; + const T_REQUIRE = 261; + const T_REQUIRE_ONCE = 262; + const T_LOGICAL_OR = 263; + const T_LOGICAL_XOR = 264; + const T_LOGICAL_AND = 265; + const T_PRINT = 266; + const T_YIELD = 267; + const T_DOUBLE_ARROW = 268; + const T_YIELD_FROM = 269; + const T_PLUS_EQUAL = 270; + const T_MINUS_EQUAL = 271; + const T_MUL_EQUAL = 272; + const T_DIV_EQUAL = 273; + const T_CONCAT_EQUAL = 274; + const T_MOD_EQUAL = 275; + const T_AND_EQUAL = 276; + const T_OR_EQUAL = 277; + const T_XOR_EQUAL = 278; + const T_SL_EQUAL = 279; + const T_SR_EQUAL = 280; + const T_POW_EQUAL = 281; + const T_COALESCE_EQUAL = 282; + const T_COALESCE = 283; + const T_BOOLEAN_OR = 284; + const T_BOOLEAN_AND = 285; + const T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG = 286; + const T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG = 287; + const T_IS_EQUAL = 288; + const T_IS_NOT_EQUAL = 289; + const T_IS_IDENTICAL = 290; + const T_IS_NOT_IDENTICAL = 291; + const T_SPACESHIP = 292; + const T_IS_SMALLER_OR_EQUAL = 293; + const T_IS_GREATER_OR_EQUAL = 294; + const T_SL = 295; + const T_SR = 296; + const T_INSTANCEOF = 297; + const T_INC = 298; + const T_DEC = 299; + const T_INT_CAST = 300; + const T_DOUBLE_CAST = 301; + const T_STRING_CAST = 302; + const T_ARRAY_CAST = 303; + const T_OBJECT_CAST = 304; + const T_BOOL_CAST = 305; + const T_UNSET_CAST = 306; + const T_POW = 307; + const T_NEW = 308; + const T_CLONE = 309; + const T_EXIT = 310; + const T_IF = 311; + const T_ELSEIF = 312; + const T_ELSE = 313; + const T_ENDIF = 314; + const T_LNUMBER = 315; + const T_DNUMBER = 316; + const T_STRING = 317; + const T_STRING_VARNAME = 318; + const T_VARIABLE = 319; + const T_NUM_STRING = 320; + const T_INLINE_HTML = 321; + const T_ENCAPSED_AND_WHITESPACE = 322; + const T_CONSTANT_ENCAPSED_STRING = 323; + const T_ECHO = 324; + const T_DO = 325; + const T_WHILE = 326; + const T_ENDWHILE = 327; + const T_FOR = 328; + const T_ENDFOR = 329; + const T_FOREACH = 330; + const T_ENDFOREACH = 331; + const T_DECLARE = 332; + const T_ENDDECLARE = 333; + const T_AS = 334; + const T_SWITCH = 335; + const T_MATCH = 336; + const T_ENDSWITCH = 337; + const T_CASE = 338; + const T_DEFAULT = 339; + const T_BREAK = 340; + const T_CONTINUE = 341; + const T_GOTO = 342; + const T_FUNCTION = 343; + const T_FN = 344; + const T_CONST = 345; + const T_RETURN = 346; + const T_TRY = 347; + const T_CATCH = 348; + const T_FINALLY = 349; + const T_USE = 350; + const T_INSTEADOF = 351; + const T_GLOBAL = 352; + const T_STATIC = 353; + const T_ABSTRACT = 354; + const T_FINAL = 355; + const T_PRIVATE = 356; + const T_PROTECTED = 357; + const T_PUBLIC = 358; + const T_READONLY = 359; + const T_VAR = 360; + const T_UNSET = 361; + const T_ISSET = 362; + const T_EMPTY = 363; + const T_HALT_COMPILER = 364; + const T_CLASS = 365; + const T_TRAIT = 366; + const T_INTERFACE = 367; + const T_ENUM = 368; + const T_EXTENDS = 369; + const T_IMPLEMENTS = 370; + const T_OBJECT_OPERATOR = 371; + const T_NULLSAFE_OBJECT_OPERATOR = 372; + const T_LIST = 373; + const T_ARRAY = 374; + const T_CALLABLE = 375; + const T_CLASS_C = 376; + const T_TRAIT_C = 377; + const T_METHOD_C = 378; + const T_FUNC_C = 379; + const T_LINE = 380; + const T_FILE = 381; const T_START_HEREDOC = 382; const T_END_HEREDOC = 383; const T_DOLLAR_OPEN_CURLY_BRACES = 384; @@ -141,4 +141,8 @@ final class Tokens const T_DIR = 389; const T_NS_SEPARATOR = 390; const T_ELLIPSIS = 391; + const T_NAME_FULLY_QUALIFIED = 392; + const T_NAME_QUALIFIED = 393; + const T_NAME_RELATIVE = 394; + const T_ATTRIBUTE = 395; } diff --git a/lib/nikic/php-parser/lib/PhpParser/ParserAbstract.php b/lib/nikic/php-parser/lib/PhpParser/ParserAbstract.php index e0f6e2592..5ee5a64bb 100644 --- a/lib/nikic/php-parser/lib/PhpParser/ParserAbstract.php +++ b/lib/nikic/php-parser/lib/PhpParser/ParserAbstract.php @@ -1,4 +1,4 @@ -lexer = $lexer; - $this->errors = array(); if (isset($options['throwOnError'])) { throw new \LogicException( '"throwOnError" is no longer supported, use "errorHandler" instead'); } + + $this->initReduceCallbacks(); } /** @@ -137,45 +149,56 @@ abstract class ParserAbstract implements Parser * @param ErrorHandler|null $errorHandler Error handler to use for lexer/parser errors, defaults * to ErrorHandler\Throwing. * - * @return Node[]|null Array of statements (or null if the 'throwOnError' option is disabled and the parser was - * unable to recover from an error). + * @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 $this->lexer->startLexing($code, $this->errorHandler); + $result = $this->doParse(); + // Clear out some of the interior state, so we don't hold onto unnecessary + // memory between uses of the parser + $this->startAttributeStack = []; + $this->endAttributeStack = []; + $this->semStack = []; + $this->semValue = null; + + return $result; + } + + protected function doParse() { // We start off with no lookahead-token $symbol = self::SYMBOL_NONE; // The attributes for a node are taken from the first and last token of the node. // From the first token only the startAttributes are taken and from the last only // the endAttributes. Both are merged using the array union operator (+). - $startAttributes = '*POISON'; - $endAttributes = '*POISON'; + $startAttributes = []; + $endAttributes = []; $this->endAttributes = $endAttributes; // Keep stack of start and end attributes - $this->startAttributeStack = array(); - $this->endAttributeStack = array($endAttributes); + $this->startAttributeStack = []; + $this->endAttributeStack = [$endAttributes]; // Start off in the initial state and keep a stack of previous states $state = 0; - $stateStack = array($state); + $stateStack = [$state]; // Semantic value stack (contains values of tokens and semantic action results) - $this->semStack = array(); + $this->semStack = []; // Current position in the stack(s) - $this->stackPos = 0; + $stackPos = 0; $this->errorState = 0; for (;;) { //$this->traceNewState($state, $symbol); - if ($this->actionBase[$state] == 0) { + if ($this->actionBase[$state] === 0) { $rule = $this->actionDefault[$state]; } else { if ($symbol === self::SYMBOL_NONE) { @@ -197,23 +220,20 @@ abstract class ParserAbstract implements Parser )); } - // This is necessary to assign some meaningful attributes to /* empty */ productions. They'll get - // the attributes of the next token, even though they don't contain it themselves. - $this->startAttributeStack[$this->stackPos+1] = $startAttributes; - $this->endAttributeStack[$this->stackPos+1] = $endAttributes; + // Allow productions to access the start attributes of the lookahead token. $this->lookaheadStartAttributes = $startAttributes; //$this->traceRead($symbol); } $idx = $this->actionBase[$state] + $symbol; - if ((($idx >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] == $symbol) + if ((($idx >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol) || ($state < $this->YY2TBLSTATE - && ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $symbol) >= 0 - && $idx < $this->actionTableSize && $this->actionCheck[$idx] == $symbol)) - && ($action = $this->action[$idx]) != $this->defaultAction) { + && ($idx = $this->actionBase[$state + $this->numNonLeafStates] + $symbol) >= 0 + && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol)) + && ($action = $this->action[$idx]) !== $this->defaultAction) { /* - * >= YYNLSTATES: shift and reduce + * >= numNonLeafStates: shift and reduce * > 0: shift * = 0: accept * < 0: reduce @@ -223,11 +243,11 @@ abstract class ParserAbstract implements Parser /* shift */ //$this->traceShift($symbol); - ++$this->stackPos; - $stateStack[$this->stackPos] = $state = $action; - $this->semStack[$this->stackPos] = $tokenValue; - $this->startAttributeStack[$this->stackPos] = $startAttributes; - $this->endAttributeStack[$this->stackPos] = $endAttributes; + ++$stackPos; + $stateStack[$stackPos] = $state = $action; + $this->semStack[$stackPos] = $tokenValue; + $this->startAttributeStack[$stackPos] = $startAttributes; + $this->endAttributeStack[$stackPos] = $endAttributes; $this->endAttributes = $endAttributes; $symbol = self::SYMBOL_NONE; @@ -235,12 +255,12 @@ abstract class ParserAbstract implements Parser --$this->errorState; } - if ($action < $this->YYNLSTATES) { + if ($action < $this->numNonLeafStates) { continue; } - /* $yyn >= YYNLSTATES means shift-and-reduce */ - $rule = $action - $this->YYNLSTATES; + /* $yyn >= numNonLeafStates means shift-and-reduce */ + $rule = $action - $this->numNonLeafStates; } else { $rule = -$action; } @@ -259,7 +279,7 @@ abstract class ParserAbstract implements Parser //$this->traceReduce($rule); try { - $this->{'reduceRule' . $rule}(); + $this->reduceCallbacks[$rule]($stackPos); } catch (Error $e) { if (-1 === $e->getStartLine() && isset($startAttributes['startLine'])) { $e->setStartLine($startAttributes['startLine']); @@ -271,20 +291,25 @@ abstract class ParserAbstract implements Parser } /* Goto - shift nonterminal */ - $lastEndAttributes = $this->endAttributeStack[$this->stackPos]; - $this->stackPos -= $this->ruleToLength[$rule]; + $lastEndAttributes = $this->endAttributeStack[$stackPos]; + $ruleLength = $this->ruleToLength[$rule]; + $stackPos -= $ruleLength; $nonTerminal = $this->ruleToNonTerminal[$rule]; - $idx = $this->gotoBase[$nonTerminal] + $stateStack[$this->stackPos]; - if ($idx >= 0 && $idx < $this->gotoTableSize && $this->gotoCheck[$idx] == $nonTerminal) { + $idx = $this->gotoBase[$nonTerminal] + $stateStack[$stackPos]; + if ($idx >= 0 && $idx < $this->gotoTableSize && $this->gotoCheck[$idx] === $nonTerminal) { $state = $this->goto[$idx]; } else { $state = $this->gotoDefault[$nonTerminal]; } - ++$this->stackPos; - $stateStack[$this->stackPos] = $state; - $this->semStack[$this->stackPos] = $this->semValue; - $this->endAttributeStack[$this->stackPos] = $lastEndAttributes; + ++$stackPos; + $stateStack[$stackPos] = $state; + $this->semStack[$stackPos] = $this->semValue; + $this->endAttributeStack[$stackPos] = $lastEndAttributes; + if ($ruleLength === 0) { + // Empty productions use the start attributes of the lookahead token. + $this->startAttributeStack[$stackPos] = $this->lookaheadStartAttributes; + } } else { /* error */ switch ($this->errorState) { @@ -299,27 +324,28 @@ abstract class ParserAbstract implements Parser // Pop until error-expecting state uncovered while (!( (($idx = $this->actionBase[$state] + $this->errorSymbol) >= 0 - && $idx < $this->actionTableSize && $this->actionCheck[$idx] == $this->errorSymbol) + && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $this->errorSymbol) || ($state < $this->YY2TBLSTATE - && ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $this->errorSymbol) >= 0 - && $idx < $this->actionTableSize && $this->actionCheck[$idx] == $this->errorSymbol) - ) || ($action = $this->action[$idx]) == $this->defaultAction) { // Not totally sure about this - if ($this->stackPos <= 0) { + && ($idx = $this->actionBase[$state + $this->numNonLeafStates] + $this->errorSymbol) >= 0 + && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $this->errorSymbol) + ) || ($action = $this->action[$idx]) === $this->defaultAction) { // Not totally sure about this + if ($stackPos <= 0) { // Could not recover from error return null; } - $state = $stateStack[--$this->stackPos]; + $state = $stateStack[--$stackPos]; //$this->tracePop($state); } //$this->traceShift($this->errorSymbol); - ++$this->stackPos; - $stateStack[$this->stackPos] = $state = $action; + ++$stackPos; + $stateStack[$stackPos] = $state = $action; // We treat the error symbol as being empty, so we reset the end attributes // to the end attributes of the last non-error symbol - $this->endAttributeStack[$this->stackPos] = $this->endAttributeStack[$this->stackPos - 1]; - $this->endAttributes = $this->endAttributeStack[$this->stackPos - 1]; + $this->startAttributeStack[$stackPos] = $this->lookaheadStartAttributes; + $this->endAttributeStack[$stackPos] = $this->endAttributeStack[$stackPos - 1]; + $this->endAttributes = $this->endAttributeStack[$stackPos - 1]; break; case 3: @@ -334,12 +360,12 @@ abstract class ParserAbstract implements Parser } } - if ($state < $this->YYNLSTATES) { + if ($state < $this->numNonLeafStates) { break; } - /* >= YYNLSTATES means shift-and-reduce */ - $rule = $state - $this->YYNLSTATES; + /* >= numNonLeafStates means shift-and-reduce */ + $rule = $state - $this->numNonLeafStates; } } @@ -350,7 +376,15 @@ abstract class ParserAbstract implements Parser $this->errorHandler->handleError($error); } - protected function getErrorMessage($symbol, $state) { + /** + * Format error message including expected tokens. + * + * @param int $symbol Unexpected symbol + * @param int $state State at time of error + * + * @return string Formatted error message + */ + protected function getErrorMessage(int $symbol, int $state) : string { $expectedString = ''; if ($expected = $this->getExpectedTokens($state)) { $expectedString = ', expecting ' . implode(' or ', $expected); @@ -359,24 +393,31 @@ abstract class ParserAbstract implements Parser return 'Syntax error, unexpected ' . $this->symbolToName[$symbol] . $expectedString; } - protected function getExpectedTokens($state) { - $expected = array(); + /** + * Get limited number of expected tokens in given state. + * + * @param int $state State + * + * @return string[] Expected tokens. If too many, an empty array is returned. + */ + protected function getExpectedTokens(int $state) : array { + $expected = []; $base = $this->actionBase[$state]; foreach ($this->symbolToName as $symbol => $name) { $idx = $base + $symbol; if ($idx >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol || $state < $this->YY2TBLSTATE - && ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $symbol) >= 0 + && ($idx = $this->actionBase[$state + $this->numNonLeafStates] + $symbol) >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol ) { - if ($this->action[$idx] != $this->unexpectedTokenRule - && $this->action[$idx] != $this->defaultAction - && $symbol != $this->errorSymbol + if ($this->action[$idx] !== $this->unexpectedTokenRule + && $this->action[$idx] !== $this->defaultAction + && $symbol !== $this->errorSymbol ) { - if (count($expected) == 4) { + if (count($expected) === 4) { /* Too many expected tokens */ - return array(); + return []; } $expected[] = $name; @@ -429,10 +470,10 @@ abstract class ParserAbstract implements Parser /** * Moves statements of semicolon-style namespaces into $ns->stmts and checks various error conditions. * - * @param Node[] $stmts - * @return Node[] + * @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) { @@ -455,12 +496,16 @@ abstract class ParserAbstract implements Parser return $stmts; } else { // For semicolon namespaces we have to move the statements after a namespace declaration into ->stmts - $resultStmts = array(); + $resultStmts = []; $targetStmts =& $resultStmts; + $lastNs = null; foreach ($stmts as $stmt) { if ($stmt instanceof Node\Stmt\Namespace_) { + if ($lastNs !== null) { + $this->fixupNamespaceAttributes($lastNs); + } if ($stmt->stmts === null) { - $stmt->stmts = array(); + $stmt->stmts = []; $targetStmts =& $stmt->stmts; $resultStmts[] = $stmt; } else { @@ -468,6 +513,7 @@ abstract class ParserAbstract implements Parser $resultStmts[] = $stmt; $targetStmts =& $resultStmts; } + $lastNs = $stmt; } elseif ($stmt instanceof Node\Stmt\HaltCompiler) { // __halt_compiler() is not moved into the namespace $resultStmts[] = $stmt; @@ -475,10 +521,38 @@ abstract class ParserAbstract implements Parser $targetStmts[] = $stmt; } } + if ($lastNs !== null) { + $this->fixupNamespaceAttributes($lastNs); + } return $resultStmts; } } + private function fixupNamespaceAttributes(Node\Stmt\Namespace_ $stmt) { + // We moved the statements into the namespace node, as such the end of the namespace node + // needs to be extended to the end of the statements. + if (empty($stmt->stmts)) { + return; + } + + // We only move the builtin end attributes here. This is the best we can do with the + // knowledge we have. + $endAttributes = ['endLine', 'endFilePos', 'endTokenPos']; + $lastStmt = $stmt->stmts[count($stmt->stmts) - 1]; + foreach ($endAttributes as $endAttribute) { + if ($lastStmt->hasAttribute($endAttribute)) { + $stmt->setAttribute($endAttribute, $lastStmt->getAttribute($endAttribute)); + } + } + } + + /** + * Determine namespacing style (semicolon or brace) + * + * @param Node[] $stmts Top-level statements. + * + * @return null|string One of "semicolon", "brace" or null (no namespaces) + */ private function getNamespacingStyle(array $stmts) { $style = null; $hasNotAllowedStmts = false; @@ -512,7 +586,7 @@ abstract class ParserAbstract implements Parser } /* There may be a hashbang line at the very start of the file */ - if ($i == 0 && $stmt instanceof Node\Stmt\InlineHTML && preg_match('/\A#!.*\r?\n\z/', $stmt->value)) { + if ($i === 0 && $stmt instanceof Node\Stmt\InlineHTML && preg_match('/\A#!.*\r?\n\z/', $stmt->value)) { continue; } @@ -522,8 +596,63 @@ abstract class ParserAbstract implements Parser return $style; } + /** + * Fix up parsing of static property calls in PHP 5. + * + * In PHP 5 A::$b[c][d] and A::$b[c][d]() have very different interpretation. The former is + * interpreted as (A::$b)[c][d], while the latter is the same as A::{$b[c][d]}(). We parse the + * latter as the former initially and this method fixes the AST into the correct form when we + * encounter the "()". + * + * @param Node\Expr\StaticPropertyFetch|Node\Expr\ArrayDimFetch $prop + * @param Node\Arg[] $args + * @param array $attributes + * + * @return Expr\StaticCall + */ + protected function fixupPhp5StaticPropCall($prop, array $args, array $attributes) : Expr\StaticCall { + if ($prop instanceof Node\Expr\StaticPropertyFetch) { + $name = $prop->name instanceof VarLikeIdentifier + ? $prop->name->toString() : $prop->name; + $var = new Expr\Variable($name, $prop->name->getAttributes()); + return new Expr\StaticCall($prop->class, $var, $args, $attributes); + } elseif ($prop instanceof Node\Expr\ArrayDimFetch) { + $tmp = $prop; + while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { + $tmp = $tmp->var; + } + + /** @var Expr\StaticPropertyFetch $staticProp */ + $staticProp = $tmp->var; + + // Set start attributes to attributes of innermost node + $tmp = $prop; + $this->fixupStartAttributes($tmp, $staticProp->name); + while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { + $tmp = $tmp->var; + $this->fixupStartAttributes($tmp, $staticProp->name); + } + + $name = $staticProp->name instanceof VarLikeIdentifier + ? $staticProp->name->toString() : $staticProp->name; + $tmp->var = new Expr\Variable($name, $staticProp->name->getAttributes()); + return new Expr\StaticCall($staticProp->class, $prop, $args, $attributes); + } else { + throw new \Exception; + } + } + + protected function fixupStartAttributes(Node $to, Node $from) { + $startAttributes = ['startLine', 'startFilePos', 'startTokenPos']; + foreach ($startAttributes as $startAttribute) { + if ($from->hasAttribute($startAttribute)) { + $to->setAttribute($startAttribute, $from->getAttribute($startAttribute)); + } + } + } + protected function handleBuiltinTypes(Name $name) { - $scalarTypes = [ + $builtinTypes = [ 'bool' => true, 'int' => true, 'float' => true, @@ -531,26 +660,49 @@ abstract class ParserAbstract implements Parser 'iterable' => true, 'void' => true, 'object' => true, + 'null' => true, + 'false' => true, + 'mixed' => true, + 'never' => true, ]; if (!$name->isUnqualified()) { return $name; } - $lowerName = strtolower($name->toString()); - return isset($scalarTypes[$lowerName]) ? $lowerName : $name; + $lowerName = $name->toLowerString(); + if (!isset($builtinTypes[$lowerName])) { + return $name; + } + + return new Node\Identifier($lowerName, $name->getAttributes()); } - protected static $specialNames = array( - 'self' => true, - 'parent' => true, - 'static' => true, - ); - - protected function getAttributesAt($pos) { + /** + * Get combined start and end attributes at a stack location + * + * @param int $pos Stack location + * + * @return array Combined start and end attributes + */ + protected function getAttributesAt(int $pos) : array { return $this->startAttributeStack[$pos] + $this->endAttributeStack[$pos]; } + protected function getFloatCastKind(string $cast): int + { + $cast = strtolower($cast); + if (strpos($cast, 'float') !== false) { + return Double::KIND_FLOAT; + } + + if (strpos($cast, 'real') !== false) { + return Double::KIND_REAL; + } + + return Double::KIND_DOUBLE; + } + protected function parseLNumber($str, $attributes, $allowInvalidOctal = false) { try { return LNumber::fromString($str, $attributes, $allowInvalidOctal); @@ -561,7 +713,15 @@ abstract class ParserAbstract implements Parser } } - protected function parseNumString($str, $attributes) { + /** + * Parse a T_NUM_STRING token into either an integer or string node. + * + * @param string $str Number string + * @param array $attributes Attributes + * + * @return LNumber|String_ Integer or string node. + */ + protected function parseNumString(string $str, array $attributes) { if (!preg_match('/^(?:0|-?[1-9][0-9]*)$/', $str)) { return new String_($str, $attributes); } @@ -574,6 +734,147 @@ abstract class ParserAbstract implements Parser return new LNumber($num, $attributes); } + protected function stripIndentation( + string $string, int $indentLen, string $indentChar, + bool $newlineAtStart, bool $newlineAtEnd, array $attributes + ) { + if ($indentLen === 0) { + return $string; + } + + $start = $newlineAtStart ? '(?:(?<=\n)|\A)' : '(?<=\n)'; + $end = $newlineAtEnd ? '(?:(?=[\r\n])|\z)' : '(?=[\r\n])'; + $regex = '/' . $start . '([ \t]*)(' . $end . ')?/'; + return preg_replace_callback( + $regex, + function ($matches) use ($indentLen, $indentChar, $attributes) { + $prefix = substr($matches[1], 0, $indentLen); + if (false !== strpos($prefix, $indentChar === " " ? "\t" : " ")) { + $this->emitError(new Error( + 'Invalid indentation - tabs and spaces cannot be mixed', $attributes + )); + } elseif (strlen($prefix) < $indentLen && !isset($matches[2])) { + $this->emitError(new Error( + 'Invalid body indentation level ' . + '(expecting an indentation level of at least ' . $indentLen . ')', + $attributes + )); + } + return substr($matches[0], strlen($prefix)); + }, + $string + ); + } + + protected function parseDocString( + string $startToken, $contents, string $endToken, + array $attributes, array $endTokenAttributes, bool $parseUnicodeEscape + ) { + $kind = strpos($startToken, "'") === false + ? String_::KIND_HEREDOC : String_::KIND_NOWDOC; + + $regex = '/\A[bB]?<<<[ \t]*[\'"]?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[\'"]?(?:\r\n|\n|\r)\z/'; + $result = preg_match($regex, $startToken, $matches); + assert($result === 1); + $label = $matches[1]; + + $result = preg_match('/\A[ \t]*/', $endToken, $matches); + assert($result === 1); + $indentation = $matches[0]; + + $attributes['kind'] = $kind; + $attributes['docLabel'] = $label; + $attributes['docIndentation'] = $indentation; + + $indentHasSpaces = false !== strpos($indentation, " "); + $indentHasTabs = false !== strpos($indentation, "\t"); + if ($indentHasSpaces && $indentHasTabs) { + $this->emitError(new Error( + 'Invalid indentation - tabs and spaces cannot be mixed', + $endTokenAttributes + )); + + // Proceed processing as if this doc string is not indented + $indentation = ''; + } + + $indentLen = \strlen($indentation); + $indentChar = $indentHasSpaces ? " " : "\t"; + + if (\is_string($contents)) { + if ($contents === '') { + return new String_('', $attributes); + } + + $contents = $this->stripIndentation( + $contents, $indentLen, $indentChar, true, true, $attributes + ); + $contents = preg_replace('~(\r\n|\n|\r)\z~', '', $contents); + + if ($kind === String_::KIND_HEREDOC) { + $contents = String_::parseEscapeSequences($contents, null, $parseUnicodeEscape); + } + + return new String_($contents, $attributes); + } else { + assert(count($contents) > 0); + if (!$contents[0] instanceof Node\Scalar\EncapsedStringPart) { + // If there is no leading encapsed string part, pretend there is an empty one + $this->stripIndentation( + '', $indentLen, $indentChar, true, false, $contents[0]->getAttributes() + ); + } + + $newContents = []; + foreach ($contents as $i => $part) { + if ($part instanceof Node\Scalar\EncapsedStringPart) { + $isLast = $i === \count($contents) - 1; + $part->value = $this->stripIndentation( + $part->value, $indentLen, $indentChar, + $i === 0, $isLast, $part->getAttributes() + ); + $part->value = String_::parseEscapeSequences($part->value, null, $parseUnicodeEscape); + if ($isLast) { + $part->value = preg_replace('~(\r\n|\n|\r)\z~', '', $part->value); + } + if ('' === $part->value) { + continue; + } + } + $newContents[] = $part; + } + return new Encapsed($newContents, $attributes); + } + } + + /** + * Create attributes for a zero-length common-capturing nop. + * + * @param Comment[] $comments + * @return array + */ + protected function createCommentNopAttributes(array $comments) { + $comment = $comments[count($comments) - 1]; + $commentEndLine = $comment->getEndLine(); + $commentEndFilePos = $comment->getEndFilePos(); + $commentEndTokenPos = $comment->getEndTokenPos(); + + $attributes = ['comments' => $comments]; + if (-1 !== $commentEndLine) { + $attributes['startLine'] = $commentEndLine; + $attributes['endLine'] = $commentEndLine; + } + if (-1 !== $commentEndFilePos) { + $attributes['startFilePos'] = $commentEndFilePos + 1; + $attributes['endFilePos'] = $commentEndFilePos; + } + if (-1 !== $commentEndTokenPos) { + $attributes['startTokenPos'] = $commentEndTokenPos + 1; + $attributes['endTokenPos'] = $commentEndTokenPos; + } + return $attributes; + } + protected function checkModifier($a, $b, $modifierPos) { // Jumping through some hoops here because verifyModifier() is also used elsewhere try { @@ -602,13 +903,6 @@ abstract class ParserAbstract implements Parser } protected function checkNamespace(Namespace_ $node) { - if (isset(self::$specialNames[strtolower($node->name)])) { - $this->emitError(new Error( - sprintf('Cannot use \'%s\' as namespace name', $node->name), - $node->name->getAttributes() - )); - } - if (null !== $node->stmts) { foreach ($node->stmts as $stmt) { if ($stmt instanceof Namespace_) { @@ -620,52 +914,52 @@ abstract class ParserAbstract implements Parser } } - protected function checkClass(Class_ $node, $namePos) { - if (null !== $node->name && isset(self::$specialNames[strtolower($node->name)])) { + private function checkClassName($name, $namePos) { + if (null !== $name && $name->isSpecialClassName()) { $this->emitError(new Error( - sprintf('Cannot use \'%s\' as class name as it is reserved', $node->name), + sprintf('Cannot use \'%s\' as class name as it is reserved', $name), $this->getAttributesAt($namePos) )); } + } - if (isset(self::$specialNames[strtolower($node->extends)])) { + private function checkImplementedInterfaces(array $interfaces) { + foreach ($interfaces as $interface) { + if ($interface->isSpecialClassName()) { + $this->emitError(new Error( + sprintf('Cannot use \'%s\' as interface name as it is reserved', $interface), + $interface->getAttributes() + )); + } + } + } + + protected function checkClass(Class_ $node, $namePos) { + $this->checkClassName($node->name, $namePos); + + if ($node->extends && $node->extends->isSpecialClassName()) { $this->emitError(new Error( sprintf('Cannot use \'%s\' as class name as it is reserved', $node->extends), $node->extends->getAttributes() )); } - foreach ($node->implements as $interface) { - if (isset(self::$specialNames[strtolower($interface)])) { - $this->emitError(new Error( - sprintf('Cannot use \'%s\' as interface name as it is reserved', $interface), - $interface->getAttributes() - )); - } - } + $this->checkImplementedInterfaces($node->implements); } protected function checkInterface(Interface_ $node, $namePos) { - if (null !== $node->name && isset(self::$specialNames[strtolower($node->name)])) { - $this->emitError(new Error( - sprintf('Cannot use \'%s\' as class name as it is reserved', $node->name), - $this->getAttributesAt($namePos) - )); - } + $this->checkClassName($node->name, $namePos); + $this->checkImplementedInterfaces($node->extends); + } - foreach ($node->extends as $interface) { - if (isset(self::$specialNames[strtolower($interface)])) { - $this->emitError(new Error( - sprintf('Cannot use \'%s\' as interface name as it is reserved', $interface), - $interface->getAttributes() - )); - } - } + protected function checkEnum(Enum_ $node, $namePos) { + $this->checkClassName($node->name, $namePos); + $this->checkImplementedInterfaces($node->implements); } protected function checkClassMethod(ClassMethod $node, $modifierPos) { if ($node->flags & Class_::MODIFIER_STATIC) { - switch (strtolower($node->name)) { + switch ($node->name->toLowerString()) { case '__construct': $this->emitError(new Error( sprintf('Constructor %s() cannot be static', $node->name), @@ -683,6 +977,12 @@ abstract class ParserAbstract implements Parser break; } } + + if ($node->flags & Class_::MODIFIER_READONLY) { + $this->emitError(new Error( + sprintf('Method %s() cannot be readonly', $node->name), + $this->getAttributesAt($modifierPos))); + } } protected function checkClassConst(ClassConst $node, $modifierPos) { @@ -696,9 +996,9 @@ abstract class ParserAbstract implements Parser "Cannot use 'abstract' as constant modifier", $this->getAttributesAt($modifierPos))); } - if ($node->flags & Class_::MODIFIER_FINAL) { + if ($node->flags & Class_::MODIFIER_READONLY) { $this->emitError(new Error( - "Cannot use 'final' as constant modifier", + "Cannot use 'readonly' as constant modifier", $this->getAttributesAt($modifierPos))); } } @@ -716,7 +1016,7 @@ abstract class ParserAbstract implements Parser } protected function checkUseUse(UseUse $node, $namePos) { - if ('self' == strtolower($node->alias) || 'parent' == strtolower($node->alias)) { + if ($node->alias && $node->alias->isSpecialClassName()) { $this->emitError(new Error( sprintf( 'Cannot use %s as %s because \'%2$s\' is a special class name', diff --git a/lib/nikic/php-parser/lib/PhpParser/ParserFactory.php b/lib/nikic/php-parser/lib/PhpParser/ParserFactory.php index 28b9070d4..f041e7ffe 100644 --- a/lib/nikic/php-parser/lib/PhpParser/ParserFactory.php +++ b/lib/nikic/php-parser/lib/PhpParser/ParserFactory.php @@ -1,8 +1,9 @@ -type ? $this->pType($node->type) . ' ' : '') + return $this->pAttrGroups($node->attrGroups, true) + . $this->pModifiers($node->flags) + . ($node->type ? $this->p($node->type) . ' ' : '') . ($node->byRef ? '&' : '') . ($node->variadic ? '...' : '') - . '$' . $node->name + . $this->p($node->var) . ($node->default ? ' = ' . $this->p($node->default) : ''); } protected function pArg(Node\Arg $node) { - return ($node->byRef ? '&' : '') . ($node->unpack ? '...' : '') . $this->p($node->value); + return ($node->name ? $node->name->toString() . ': ' : '') + . ($node->byRef ? '&' : '') . ($node->unpack ? '...' : '') + . $this->p($node->value); } protected function pConst(Node\Const_ $node) { @@ -34,7 +38,28 @@ class Standard extends PrettyPrinterAbstract } protected function pNullableType(Node\NullableType $node) { - return '?' . $this->pType($node->type); + return '?' . $this->p($node->type); + } + + protected function pUnionType(Node\UnionType $node) { + return $this->pImplode($node->types, '|'); + } + + protected function pIdentifier(Node\Identifier $node) { + return $node->name; + } + + protected function pVarLikeIdentifier(Node\VarLikeIdentifier $node) { + return '$' . $node->name; + } + + protected function pAttribute(Node\Attribute $node) { + return $this->p($node->name) + . ($node->args ? '(' . $this->pCommaSeparated($node->args) . ')' : ''); + } + + protected function pAttributeGroup(Node\AttributeGroup $node) { + return '#[' . $this->pCommaSeparated($node->attrs) . ']'; } // Names @@ -94,24 +119,24 @@ class Standard extends PrettyPrinterAbstract $label = $node->getAttribute('docLabel'); if ($label && !$this->containsEndLabel($node->value, $label)) { if ($node->value === '') { - return $this->pNoIndent("<<<'$label'\n$label") . $this->docStringEndToken; + return "<<<'$label'\n$label" . $this->docStringEndToken; } - return $this->pNoIndent("<<<'$label'\n$node->value\n$label") + return "<<<'$label'\n$node->value\n$label" . $this->docStringEndToken; } /* break missing intentionally */ case Scalar\String_::KIND_SINGLE_QUOTED: - return '\'' . $this->pNoIndent(addcslashes($node->value, '\'\\')) . '\''; + return $this->pSingleQuotedString($node->value); case Scalar\String_::KIND_HEREDOC: $label = $node->getAttribute('docLabel'); if ($label && !$this->containsEndLabel($node->value, $label)) { if ($node->value === '') { - return $this->pNoIndent("<<<$label\n$label") . $this->docStringEndToken; + return "<<<$label\n$label" . $this->docStringEndToken; } $escaped = $this->escapeString($node->value, null); - return $this->pNoIndent("<<<$label\n" . $escaped ."\n$label") + return "<<<$label\n" . $escaped . "\n$label" . $this->docStringEndToken; } /* break missing intentionally */ @@ -129,12 +154,11 @@ class Standard extends PrettyPrinterAbstract && $node->parts[0] instanceof Scalar\EncapsedStringPart && $node->parts[0]->value === '' ) { - return $this->pNoIndent("<<<$label\n$label") . $this->docStringEndToken; + return "<<<$label\n$label" . $this->docStringEndToken; } - return $this->pNoIndent( - "<<<$label\n" . $this->pEncapsList($node->parts, null) . "\n$label" - ) . $this->docStringEndToken; + return "<<<$label\n" . $this->pEncapsList($node->parts, null) . "\n$label" + . $this->docStringEndToken; } } return '"' . $this->pEncapsList($node->parts, '"') . '"'; @@ -152,8 +176,13 @@ class Standard extends PrettyPrinterAbstract return (string) $node->value; } - $sign = $node->value < 0 ? '-' : ''; - $str = (string) $node->value; + if ($node->value < 0) { + $sign = '-'; + $str = (string) -$node->value; + } else { + $sign = ''; + $str = (string) $node->value; + } switch ($kind) { case Scalar\LNumber::KIND_BIN: return $sign . '0b' . base_convert($str, 10, 2); @@ -191,186 +220,197 @@ class Standard extends PrettyPrinterAbstract return preg_match('/^-?[0-9]+$/', $stringValue) ? $stringValue . '.0' : $stringValue; } + protected function pScalar_EncapsedStringPart(Scalar\EncapsedStringPart $node) { + throw new \LogicException('Cannot directly print EncapsedStringPart'); + } + // Assignments protected function pExpr_Assign(Expr\Assign $node) { - return $this->pInfixOp('Expr_Assign', $node->var, ' = ', $node->expr); + return $this->pInfixOp(Expr\Assign::class, $node->var, ' = ', $node->expr); } protected function pExpr_AssignRef(Expr\AssignRef $node) { - return $this->pInfixOp('Expr_AssignRef', $node->var, ' =& ', $node->expr); + return $this->pInfixOp(Expr\AssignRef::class, $node->var, ' =& ', $node->expr); } protected function pExpr_AssignOp_Plus(AssignOp\Plus $node) { - return $this->pInfixOp('Expr_AssignOp_Plus', $node->var, ' += ', $node->expr); + return $this->pInfixOp(AssignOp\Plus::class, $node->var, ' += ', $node->expr); } protected function pExpr_AssignOp_Minus(AssignOp\Minus $node) { - return $this->pInfixOp('Expr_AssignOp_Minus', $node->var, ' -= ', $node->expr); + return $this->pInfixOp(AssignOp\Minus::class, $node->var, ' -= ', $node->expr); } protected function pExpr_AssignOp_Mul(AssignOp\Mul $node) { - return $this->pInfixOp('Expr_AssignOp_Mul', $node->var, ' *= ', $node->expr); + return $this->pInfixOp(AssignOp\Mul::class, $node->var, ' *= ', $node->expr); } protected function pExpr_AssignOp_Div(AssignOp\Div $node) { - return $this->pInfixOp('Expr_AssignOp_Div', $node->var, ' /= ', $node->expr); + return $this->pInfixOp(AssignOp\Div::class, $node->var, ' /= ', $node->expr); } protected function pExpr_AssignOp_Concat(AssignOp\Concat $node) { - return $this->pInfixOp('Expr_AssignOp_Concat', $node->var, ' .= ', $node->expr); + return $this->pInfixOp(AssignOp\Concat::class, $node->var, ' .= ', $node->expr); } protected function pExpr_AssignOp_Mod(AssignOp\Mod $node) { - return $this->pInfixOp('Expr_AssignOp_Mod', $node->var, ' %= ', $node->expr); + return $this->pInfixOp(AssignOp\Mod::class, $node->var, ' %= ', $node->expr); } protected function pExpr_AssignOp_BitwiseAnd(AssignOp\BitwiseAnd $node) { - return $this->pInfixOp('Expr_AssignOp_BitwiseAnd', $node->var, ' &= ', $node->expr); + return $this->pInfixOp(AssignOp\BitwiseAnd::class, $node->var, ' &= ', $node->expr); } protected function pExpr_AssignOp_BitwiseOr(AssignOp\BitwiseOr $node) { - return $this->pInfixOp('Expr_AssignOp_BitwiseOr', $node->var, ' |= ', $node->expr); + return $this->pInfixOp(AssignOp\BitwiseOr::class, $node->var, ' |= ', $node->expr); } protected function pExpr_AssignOp_BitwiseXor(AssignOp\BitwiseXor $node) { - return $this->pInfixOp('Expr_AssignOp_BitwiseXor', $node->var, ' ^= ', $node->expr); + return $this->pInfixOp(AssignOp\BitwiseXor::class, $node->var, ' ^= ', $node->expr); } protected function pExpr_AssignOp_ShiftLeft(AssignOp\ShiftLeft $node) { - return $this->pInfixOp('Expr_AssignOp_ShiftLeft', $node->var, ' <<= ', $node->expr); + return $this->pInfixOp(AssignOp\ShiftLeft::class, $node->var, ' <<= ', $node->expr); } protected function pExpr_AssignOp_ShiftRight(AssignOp\ShiftRight $node) { - return $this->pInfixOp('Expr_AssignOp_ShiftRight', $node->var, ' >>= ', $node->expr); + return $this->pInfixOp(AssignOp\ShiftRight::class, $node->var, ' >>= ', $node->expr); } protected function pExpr_AssignOp_Pow(AssignOp\Pow $node) { - return $this->pInfixOp('Expr_AssignOp_Pow', $node->var, ' **= ', $node->expr); + return $this->pInfixOp(AssignOp\Pow::class, $node->var, ' **= ', $node->expr); + } + + protected function pExpr_AssignOp_Coalesce(AssignOp\Coalesce $node) { + return $this->pInfixOp(AssignOp\Coalesce::class, $node->var, ' ??= ', $node->expr); } // Binary expressions protected function pExpr_BinaryOp_Plus(BinaryOp\Plus $node) { - return $this->pInfixOp('Expr_BinaryOp_Plus', $node->left, ' + ', $node->right); + return $this->pInfixOp(BinaryOp\Plus::class, $node->left, ' + ', $node->right); } protected function pExpr_BinaryOp_Minus(BinaryOp\Minus $node) { - return $this->pInfixOp('Expr_BinaryOp_Minus', $node->left, ' - ', $node->right); + return $this->pInfixOp(BinaryOp\Minus::class, $node->left, ' - ', $node->right); } protected function pExpr_BinaryOp_Mul(BinaryOp\Mul $node) { - return $this->pInfixOp('Expr_BinaryOp_Mul', $node->left, ' * ', $node->right); + return $this->pInfixOp(BinaryOp\Mul::class, $node->left, ' * ', $node->right); } protected function pExpr_BinaryOp_Div(BinaryOp\Div $node) { - return $this->pInfixOp('Expr_BinaryOp_Div', $node->left, ' / ', $node->right); + return $this->pInfixOp(BinaryOp\Div::class, $node->left, ' / ', $node->right); } protected function pExpr_BinaryOp_Concat(BinaryOp\Concat $node) { - return $this->pInfixOp('Expr_BinaryOp_Concat', $node->left, ' . ', $node->right); + return $this->pInfixOp(BinaryOp\Concat::class, $node->left, ' . ', $node->right); } protected function pExpr_BinaryOp_Mod(BinaryOp\Mod $node) { - return $this->pInfixOp('Expr_BinaryOp_Mod', $node->left, ' % ', $node->right); + return $this->pInfixOp(BinaryOp\Mod::class, $node->left, ' % ', $node->right); } protected function pExpr_BinaryOp_BooleanAnd(BinaryOp\BooleanAnd $node) { - return $this->pInfixOp('Expr_BinaryOp_BooleanAnd', $node->left, ' && ', $node->right); + return $this->pInfixOp(BinaryOp\BooleanAnd::class, $node->left, ' && ', $node->right); } protected function pExpr_BinaryOp_BooleanOr(BinaryOp\BooleanOr $node) { - return $this->pInfixOp('Expr_BinaryOp_BooleanOr', $node->left, ' || ', $node->right); + return $this->pInfixOp(BinaryOp\BooleanOr::class, $node->left, ' || ', $node->right); } protected function pExpr_BinaryOp_BitwiseAnd(BinaryOp\BitwiseAnd $node) { - return $this->pInfixOp('Expr_BinaryOp_BitwiseAnd', $node->left, ' & ', $node->right); + return $this->pInfixOp(BinaryOp\BitwiseAnd::class, $node->left, ' & ', $node->right); } protected function pExpr_BinaryOp_BitwiseOr(BinaryOp\BitwiseOr $node) { - return $this->pInfixOp('Expr_BinaryOp_BitwiseOr', $node->left, ' | ', $node->right); + return $this->pInfixOp(BinaryOp\BitwiseOr::class, $node->left, ' | ', $node->right); } protected function pExpr_BinaryOp_BitwiseXor(BinaryOp\BitwiseXor $node) { - return $this->pInfixOp('Expr_BinaryOp_BitwiseXor', $node->left, ' ^ ', $node->right); + return $this->pInfixOp(BinaryOp\BitwiseXor::class, $node->left, ' ^ ', $node->right); } protected function pExpr_BinaryOp_ShiftLeft(BinaryOp\ShiftLeft $node) { - return $this->pInfixOp('Expr_BinaryOp_ShiftLeft', $node->left, ' << ', $node->right); + return $this->pInfixOp(BinaryOp\ShiftLeft::class, $node->left, ' << ', $node->right); } protected function pExpr_BinaryOp_ShiftRight(BinaryOp\ShiftRight $node) { - return $this->pInfixOp('Expr_BinaryOp_ShiftRight', $node->left, ' >> ', $node->right); + return $this->pInfixOp(BinaryOp\ShiftRight::class, $node->left, ' >> ', $node->right); } protected function pExpr_BinaryOp_Pow(BinaryOp\Pow $node) { - return $this->pInfixOp('Expr_BinaryOp_Pow', $node->left, ' ** ', $node->right); + return $this->pInfixOp(BinaryOp\Pow::class, $node->left, ' ** ', $node->right); } protected function pExpr_BinaryOp_LogicalAnd(BinaryOp\LogicalAnd $node) { - return $this->pInfixOp('Expr_BinaryOp_LogicalAnd', $node->left, ' and ', $node->right); + return $this->pInfixOp(BinaryOp\LogicalAnd::class, $node->left, ' and ', $node->right); } protected function pExpr_BinaryOp_LogicalOr(BinaryOp\LogicalOr $node) { - return $this->pInfixOp('Expr_BinaryOp_LogicalOr', $node->left, ' or ', $node->right); + return $this->pInfixOp(BinaryOp\LogicalOr::class, $node->left, ' or ', $node->right); } protected function pExpr_BinaryOp_LogicalXor(BinaryOp\LogicalXor $node) { - return $this->pInfixOp('Expr_BinaryOp_LogicalXor', $node->left, ' xor ', $node->right); + return $this->pInfixOp(BinaryOp\LogicalXor::class, $node->left, ' xor ', $node->right); } protected function pExpr_BinaryOp_Equal(BinaryOp\Equal $node) { - return $this->pInfixOp('Expr_BinaryOp_Equal', $node->left, ' == ', $node->right); + return $this->pInfixOp(BinaryOp\Equal::class, $node->left, ' == ', $node->right); } protected function pExpr_BinaryOp_NotEqual(BinaryOp\NotEqual $node) { - return $this->pInfixOp('Expr_BinaryOp_NotEqual', $node->left, ' != ', $node->right); + return $this->pInfixOp(BinaryOp\NotEqual::class, $node->left, ' != ', $node->right); } protected function pExpr_BinaryOp_Identical(BinaryOp\Identical $node) { - return $this->pInfixOp('Expr_BinaryOp_Identical', $node->left, ' === ', $node->right); + return $this->pInfixOp(BinaryOp\Identical::class, $node->left, ' === ', $node->right); } protected function pExpr_BinaryOp_NotIdentical(BinaryOp\NotIdentical $node) { - return $this->pInfixOp('Expr_BinaryOp_NotIdentical', $node->left, ' !== ', $node->right); + return $this->pInfixOp(BinaryOp\NotIdentical::class, $node->left, ' !== ', $node->right); } protected function pExpr_BinaryOp_Spaceship(BinaryOp\Spaceship $node) { - return $this->pInfixOp('Expr_BinaryOp_Spaceship', $node->left, ' <=> ', $node->right); + return $this->pInfixOp(BinaryOp\Spaceship::class, $node->left, ' <=> ', $node->right); } protected function pExpr_BinaryOp_Greater(BinaryOp\Greater $node) { - return $this->pInfixOp('Expr_BinaryOp_Greater', $node->left, ' > ', $node->right); + return $this->pInfixOp(BinaryOp\Greater::class, $node->left, ' > ', $node->right); } protected function pExpr_BinaryOp_GreaterOrEqual(BinaryOp\GreaterOrEqual $node) { - return $this->pInfixOp('Expr_BinaryOp_GreaterOrEqual', $node->left, ' >= ', $node->right); + return $this->pInfixOp(BinaryOp\GreaterOrEqual::class, $node->left, ' >= ', $node->right); } protected function pExpr_BinaryOp_Smaller(BinaryOp\Smaller $node) { - return $this->pInfixOp('Expr_BinaryOp_Smaller', $node->left, ' < ', $node->right); + return $this->pInfixOp(BinaryOp\Smaller::class, $node->left, ' < ', $node->right); } protected function pExpr_BinaryOp_SmallerOrEqual(BinaryOp\SmallerOrEqual $node) { - return $this->pInfixOp('Expr_BinaryOp_SmallerOrEqual', $node->left, ' <= ', $node->right); + return $this->pInfixOp(BinaryOp\SmallerOrEqual::class, $node->left, ' <= ', $node->right); } protected function pExpr_BinaryOp_Coalesce(BinaryOp\Coalesce $node) { - return $this->pInfixOp('Expr_BinaryOp_Coalesce', $node->left, ' ?? ', $node->right); + return $this->pInfixOp(BinaryOp\Coalesce::class, $node->left, ' ?? ', $node->right); } protected function pExpr_Instanceof(Expr\Instanceof_ $node) { - return $this->pInfixOp('Expr_Instanceof', $node->expr, ' instanceof ', $node->class); + list($precedence, $associativity) = $this->precedenceMap[Expr\Instanceof_::class]; + return $this->pPrec($node->expr, $precedence, $associativity, -1) + . ' instanceof ' + . $this->pNewVariable($node->class); } // Unary expressions protected function pExpr_BooleanNot(Expr\BooleanNot $node) { - return $this->pPrefixOp('Expr_BooleanNot', '!', $node->expr); + return $this->pPrefixOp(Expr\BooleanNot::class, '!', $node->expr); } protected function pExpr_BitwiseNot(Expr\BitwiseNot $node) { - return $this->pPrefixOp('Expr_BitwiseNot', '~', $node->expr); + return $this->pPrefixOp(Expr\BitwiseNot::class, '~', $node->expr); } protected function pExpr_UnaryMinus(Expr\UnaryMinus $node) { @@ -378,7 +418,7 @@ class Standard extends PrettyPrinterAbstract // Enforce -(-$expr) instead of --$expr return '-(' . $this->p($node->expr) . ')'; } - return $this->pPrefixOp('Expr_UnaryMinus', '-', $node->expr); + return $this->pPrefixOp(Expr\UnaryMinus::class, '-', $node->expr); } protected function pExpr_UnaryPlus(Expr\UnaryPlus $node) { @@ -386,65 +426,73 @@ class Standard extends PrettyPrinterAbstract // Enforce +(+$expr) instead of ++$expr return '+(' . $this->p($node->expr) . ')'; } - return $this->pPrefixOp('Expr_UnaryPlus', '+', $node->expr); + return $this->pPrefixOp(Expr\UnaryPlus::class, '+', $node->expr); } protected function pExpr_PreInc(Expr\PreInc $node) { - return $this->pPrefixOp('Expr_PreInc', '++', $node->var); + return $this->pPrefixOp(Expr\PreInc::class, '++', $node->var); } protected function pExpr_PreDec(Expr\PreDec $node) { - return $this->pPrefixOp('Expr_PreDec', '--', $node->var); + return $this->pPrefixOp(Expr\PreDec::class, '--', $node->var); } protected function pExpr_PostInc(Expr\PostInc $node) { - return $this->pPostfixOp('Expr_PostInc', $node->var, '++'); + return $this->pPostfixOp(Expr\PostInc::class, $node->var, '++'); } protected function pExpr_PostDec(Expr\PostDec $node) { - return $this->pPostfixOp('Expr_PostDec', $node->var, '--'); + return $this->pPostfixOp(Expr\PostDec::class, $node->var, '--'); } protected function pExpr_ErrorSuppress(Expr\ErrorSuppress $node) { - return $this->pPrefixOp('Expr_ErrorSuppress', '@', $node->expr); + return $this->pPrefixOp(Expr\ErrorSuppress::class, '@', $node->expr); } protected function pExpr_YieldFrom(Expr\YieldFrom $node) { - return $this->pPrefixOp('Expr_YieldFrom', 'yield from ', $node->expr); + return $this->pPrefixOp(Expr\YieldFrom::class, 'yield from ', $node->expr); } protected function pExpr_Print(Expr\Print_ $node) { - return $this->pPrefixOp('Expr_Print', 'print ', $node->expr); + return $this->pPrefixOp(Expr\Print_::class, 'print ', $node->expr); } // Casts protected function pExpr_Cast_Int(Cast\Int_ $node) { - return $this->pPrefixOp('Expr_Cast_Int', '(int) ', $node->expr); + return $this->pPrefixOp(Cast\Int_::class, '(int) ', $node->expr); } protected function pExpr_Cast_Double(Cast\Double $node) { - return $this->pPrefixOp('Expr_Cast_Double', '(double) ', $node->expr); + $kind = $node->getAttribute('kind', Cast\Double::KIND_DOUBLE); + if ($kind === Cast\Double::KIND_DOUBLE) { + $cast = '(double)'; + } elseif ($kind === Cast\Double::KIND_FLOAT) { + $cast = '(float)'; + } elseif ($kind === Cast\Double::KIND_REAL) { + $cast = '(real)'; + } + return $this->pPrefixOp(Cast\Double::class, $cast . ' ', $node->expr); } protected function pExpr_Cast_String(Cast\String_ $node) { - return $this->pPrefixOp('Expr_Cast_String', '(string) ', $node->expr); + return $this->pPrefixOp(Cast\String_::class, '(string) ', $node->expr); } protected function pExpr_Cast_Array(Cast\Array_ $node) { - return $this->pPrefixOp('Expr_Cast_Array', '(array) ', $node->expr); + return $this->pPrefixOp(Cast\Array_::class, '(array) ', $node->expr); } protected function pExpr_Cast_Object(Cast\Object_ $node) { - return $this->pPrefixOp('Expr_Cast_Object', '(object) ', $node->expr); + return $this->pPrefixOp(Cast\Object_::class, '(object) ', $node->expr); } protected function pExpr_Cast_Bool(Cast\Bool_ $node) { - return $this->pPrefixOp('Expr_Cast_Bool', '(bool) ', $node->expr); + return $this->pPrefixOp(Cast\Bool_::class, '(bool) ', $node->expr); } protected function pExpr_Cast_Unset(Cast\Unset_ $node) { - return $this->pPrefixOp('Expr_Cast_Unset', '(unset) ', $node->expr); + return $this->pPrefixOp(Cast\Unset_::class, '(unset) ', $node->expr); } // Function calls and similar constructs @@ -459,6 +507,11 @@ class Standard extends PrettyPrinterAbstract . '(' . $this->pMaybeMultiline($node->args) . ')'; } + protected function pExpr_NullsafeMethodCall(Expr\NullsafeMethodCall $node) { + return $this->pDereferenceLhs($node->var) . '?->' . $this->pObjectProperty($node->name) + . '(' . $this->pMaybeMultiline($node->args) . ')'; + } + protected function pExpr_StaticCall(Expr\StaticCall $node) { return $this->pDereferenceLhs($node->class) . '::' . ($node->name instanceof Expr @@ -482,12 +535,12 @@ class Standard extends PrettyPrinterAbstract } protected function pExpr_Include(Expr\Include_ $node) { - static $map = array( + static $map = [ Expr\Include_::TYPE_INCLUDE => 'include', Expr\Include_::TYPE_INCLUDE_ONCE => 'include_once', Expr\Include_::TYPE_REQUIRE => 'require', Expr\Include_::TYPE_REQUIRE_ONCE => 'require_once', - ); + ]; return $map[$node->type] . ' ' . $this->p($node->expr); } @@ -522,7 +575,9 @@ class Standard extends PrettyPrinterAbstract protected function pExpr_ArrayItem(Expr\ArrayItem $node) { return (null !== $node->key ? $this->p($node->key) . ' => ' : '') - . ($node->byRef ? '&' : '') . $this->p($node->value); + . ($node->byRef ? '&' : '') + . ($node->unpack ? '...' : '') + . $this->p($node->value); } protected function pExpr_ArrayDimFetch(Expr\ArrayDimFetch $node) { @@ -535,14 +590,17 @@ class Standard extends PrettyPrinterAbstract } protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node) { - return $this->p($node->class) . '::' - . (is_string($node->name) ? $node->name : $this->p($node->name)); + return $this->pDereferenceLhs($node->class) . '::' . $this->p($node->name); } protected function pExpr_PropertyFetch(Expr\PropertyFetch $node) { return $this->pDereferenceLhs($node->var) . '->' . $this->pObjectProperty($node->name); } + protected function pExpr_NullsafePropertyFetch(Expr\NullsafePropertyFetch $node) { + return $this->pDereferenceLhs($node->var) . '?->' . $this->pObjectProperty($node->name); + } + protected function pExpr_StaticPropertyFetch(Expr\StaticPropertyFetch $node) { return $this->pDereferenceLhs($node->class) . '::$' . $this->pObjectProperty($node->name); } @@ -552,16 +610,39 @@ class Standard extends PrettyPrinterAbstract } protected function pExpr_Closure(Expr\Closure $node) { - return ($node->static ? 'static ' : '') + return $this->pAttrGroups($node->attrGroups, true) + . ($node->static ? 'static ' : '') . 'function ' . ($node->byRef ? '&' : '') . '(' . $this->pCommaSeparated($node->params) . ')' - . (!empty($node->uses) ? ' use(' . $this->pCommaSeparated($node->uses) . ')': '') - . (null !== $node->returnType ? ' : ' . $this->pType($node->returnType) : '') - . ' {' . $this->pStmts($node->stmts) . "\n" . '}'; + . (!empty($node->uses) ? ' use(' . $this->pCommaSeparated($node->uses) . ')' : '') + . (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '') + . ' {' . $this->pStmts($node->stmts) . $this->nl . '}'; + } + + protected function pExpr_Match(Expr\Match_ $node) { + return 'match (' . $this->p($node->cond) . ') {' + . $this->pCommaSeparatedMultiline($node->arms, true) + . $this->nl + . '}'; + } + + protected function pMatchArm(Node\MatchArm $node) { + return ($node->conds ? $this->pCommaSeparated($node->conds) : 'default') + . ' => ' . $this->p($node->body); + } + + protected function pExpr_ArrowFunction(Expr\ArrowFunction $node) { + return $this->pAttrGroups($node->attrGroups, true) + . ($node->static ? 'static ' : '') + . 'fn' . ($node->byRef ? '&' : '') + . '(' . $this->pCommaSeparated($node->params) . ')' + . (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '') + . ' => ' + . $this->p($node->expr); } protected function pExpr_ClosureUse(Expr\ClosureUse $node) { - return ($node->byRef ? '&' : '') . '$' . $node->var; + return ($node->byRef ? '&' : '') . $this->p($node->var); } protected function pExpr_New(Expr\New_ $node) { @@ -569,7 +650,8 @@ class Standard extends PrettyPrinterAbstract $args = $node->args ? '(' . $this->pMaybeMultiline($node->args) . ')' : ''; return 'new ' . $this->pClassCommon($node->class, $args); } - return 'new ' . $this->p($node->class) . '(' . $this->pMaybeMultiline($node->args) . ')'; + return 'new ' . $this->pNewVariable($node->class) + . '(' . $this->pMaybeMultiline($node->args) . ')'; } protected function pExpr_Clone(Expr\Clone_ $node) { @@ -579,7 +661,7 @@ class Standard extends PrettyPrinterAbstract protected function pExpr_Ternary(Expr\Ternary $node) { // a bit of cheating: we treat the ternary as a binary op where the ?...: part is the operator. // this is okay because the part between ? and : never needs parentheses. - return $this->pInfixOp('Expr_Ternary', + return $this->pInfixOp(Expr\Ternary::class, $node->cond, ' ?' . (null !== $node->if ? ' ' . $this->p($node->if) . ' ' : '') . ': ', $node->else ); } @@ -590,6 +672,10 @@ class Standard extends PrettyPrinterAbstract . (null !== $node->expr ? '(' . $this->p($node->expr) . ')' : ''); } + protected function pExpr_Throw(Expr\Throw_ $node) { + return 'throw ' . $this->p($node->expr); + } + protected function pExpr_Yield(Expr\Yield_ $node) { if ($node->value === null) { return 'yield'; @@ -606,10 +692,11 @@ class Standard extends PrettyPrinterAbstract protected function pStmt_Namespace(Stmt\Namespace_ $node) { if ($this->canUseSemicolonNamespaces) { - return 'namespace ' . $this->p($node->name) . ';' . "\n" . $this->pStmts($node->stmts, false); + return 'namespace ' . $this->p($node->name) . ';' + . $this->nl . $this->pStmts($node->stmts, false); } else { return 'namespace' . (null !== $node->name ? ' ' . $this->p($node->name) : '') - . ' {' . $this->pStmts($node->stmts) . "\n" . '}'; + . ' {' . $this->pStmts($node->stmts) . $this->nl . '}'; } } @@ -625,7 +712,7 @@ class Standard extends PrettyPrinterAbstract protected function pStmt_UseUse(Stmt\UseUse $node) { return $this->pUseType($node->type) . $this->p($node->name) - . ($node->name->getLast() !== $node->alias ? ' as ' . $node->alias : ''); + . (null !== $node->alias ? ' as ' . $node->alias : ''); } protected function pUseType($type) { @@ -634,9 +721,18 @@ class Standard extends PrettyPrinterAbstract } protected function pStmt_Interface(Stmt\Interface_ $node) { - return 'interface ' . $node->name + return $this->pAttrGroups($node->attrGroups) + . 'interface ' . $node->name . (!empty($node->extends) ? ' extends ' . $this->pCommaSeparated($node->extends) : '') - . "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}'; + . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; + } + + protected function pStmt_Enum(Stmt\Enum_ $node) { + return $this->pAttrGroups($node->attrGroups) + . 'enum ' . $node->name + . ($node->scalarType ? " : $node->scalarType" : '') + . (!empty($node->implements) ? ' implements ' . $this->pCommaSeparated($node->implements) : '') + . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } protected function pStmt_Class(Stmt\Class_ $node) { @@ -644,15 +740,23 @@ class Standard extends PrettyPrinterAbstract } protected function pStmt_Trait(Stmt\Trait_ $node) { - return 'trait ' . $node->name - . "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}'; + return $this->pAttrGroups($node->attrGroups) + . 'trait ' . $node->name + . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; + } + + protected function pStmt_EnumCase(Stmt\EnumCase $node) { + return $this->pAttrGroups($node->attrGroups) + . 'case ' . $node->name + . ($node->expr ? ' = ' . $this->p($node->expr) : '') + . ';'; } protected function pStmt_TraitUse(Stmt\TraitUse $node) { return 'use ' . $this->pCommaSeparated($node->traits) . (empty($node->adaptations) ? ';' - : ' {' . $this->pStmts($node->adaptations) . "\n" . '}'); + : ' {' . $this->pStmts($node->adaptations) . $this->nl . '}'); } protected function pStmt_TraitUseAdaptation_Precedence(Stmt\TraitUseAdaptation\Precedence $node) { @@ -669,7 +773,10 @@ class Standard extends PrettyPrinterAbstract } protected function pStmt_Property(Stmt\Property $node) { - return (0 === $node->flags ? 'var ' : $this->pModifiers($node->flags)) . $this->pCommaSeparated($node->props) . ';'; + return $this->pAttrGroups($node->attrGroups) + . (0 === $node->flags ? 'var ' : $this->pModifiers($node->flags)) + . ($node->type ? $this->p($node->type) . ' ' : '') + . $this->pCommaSeparated($node->props) . ';'; } protected function pStmt_PropertyProperty(Stmt\PropertyProperty $node) { @@ -678,25 +785,28 @@ class Standard extends PrettyPrinterAbstract } protected function pStmt_ClassMethod(Stmt\ClassMethod $node) { - return $this->pModifiers($node->flags) + return $this->pAttrGroups($node->attrGroups) + . $this->pModifiers($node->flags) . 'function ' . ($node->byRef ? '&' : '') . $node->name - . '(' . $this->pCommaSeparated($node->params) . ')' - . (null !== $node->returnType ? ' : ' . $this->pType($node->returnType) : '') + . '(' . $this->pMaybeMultiline($node->params) . ')' + . (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '') . (null !== $node->stmts - ? "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}' + ? $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}' : ';'); } protected function pStmt_ClassConst(Stmt\ClassConst $node) { - return $this->pModifiers($node->flags) + return $this->pAttrGroups($node->attrGroups) + . $this->pModifiers($node->flags) . 'const ' . $this->pCommaSeparated($node->consts) . ';'; } protected function pStmt_Function(Stmt\Function_ $node) { - return 'function ' . ($node->byRef ? '&' : '') . $node->name + return $this->pAttrGroups($node->attrGroups) + . 'function ' . ($node->byRef ? '&' : '') . $node->name . '(' . $this->pCommaSeparated($node->params) . ')' - . (null !== $node->returnType ? ' : ' . $this->pType($node->returnType) : '') - . "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}'; + . (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '') + . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } protected function pStmt_Const(Stmt\Const_ $node) { @@ -705,7 +815,7 @@ class Standard extends PrettyPrinterAbstract protected function pStmt_Declare(Stmt\Declare_ $node) { return 'declare (' . $this->pCommaSeparated($node->declares) . ')' - . (null !== $node->stmts ? ' {' . $this->pStmts($node->stmts) . "\n" . '}' : ';'); + . (null !== $node->stmts ? ' {' . $this->pStmts($node->stmts) . $this->nl . '}' : ';'); } protected function pStmt_DeclareDeclare(Stmt\DeclareDeclare $node) { @@ -716,18 +826,18 @@ class Standard extends PrettyPrinterAbstract protected function pStmt_If(Stmt\If_ $node) { return 'if (' . $this->p($node->cond) . ') {' - . $this->pStmts($node->stmts) . "\n" . '}' - . $this->pImplode($node->elseifs) - . (null !== $node->else ? $this->p($node->else) : ''); + . $this->pStmts($node->stmts) . $this->nl . '}' + . ($node->elseifs ? ' ' . $this->pImplode($node->elseifs, ' ') : '') + . (null !== $node->else ? ' ' . $this->p($node->else) : ''); } protected function pStmt_ElseIf(Stmt\ElseIf_ $node) { - return ' elseif (' . $this->p($node->cond) . ') {' - . $this->pStmts($node->stmts) . "\n" . '}'; + return 'elseif (' . $this->p($node->cond) . ') {' + . $this->pStmts($node->stmts) . $this->nl . '}'; } protected function pStmt_Else(Stmt\Else_ $node) { - return ' else {' . $this->pStmts($node->stmts) . "\n" . '}'; + return 'else {' . $this->pStmts($node->stmts) . $this->nl . '}'; } protected function pStmt_For(Stmt\For_ $node) { @@ -735,29 +845,29 @@ class Standard extends PrettyPrinterAbstract . $this->pCommaSeparated($node->init) . ';' . (!empty($node->cond) ? ' ' : '') . $this->pCommaSeparated($node->cond) . ';' . (!empty($node->loop) ? ' ' : '') . $this->pCommaSeparated($node->loop) - . ') {' . $this->pStmts($node->stmts) . "\n" . '}'; + . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } protected function pStmt_Foreach(Stmt\Foreach_ $node) { return 'foreach (' . $this->p($node->expr) . ' as ' . (null !== $node->keyVar ? $this->p($node->keyVar) . ' => ' : '') . ($node->byRef ? '&' : '') . $this->p($node->valueVar) . ') {' - . $this->pStmts($node->stmts) . "\n" . '}'; + . $this->pStmts($node->stmts) . $this->nl . '}'; } protected function pStmt_While(Stmt\While_ $node) { return 'while (' . $this->p($node->cond) . ') {' - . $this->pStmts($node->stmts) . "\n" . '}'; + . $this->pStmts($node->stmts) . $this->nl . '}'; } protected function pStmt_Do(Stmt\Do_ $node) { - return 'do {' . $this->pStmts($node->stmts) . "\n" + return 'do {' . $this->pStmts($node->stmts) . $this->nl . '} while (' . $this->p($node->cond) . ');'; } protected function pStmt_Switch(Stmt\Switch_ $node) { return 'switch (' . $this->p($node->cond) . ') {' - . $this->pStmts($node->cases) . "\n" . '}'; + . $this->pStmts($node->cases) . $this->nl . '}'; } protected function pStmt_Case(Stmt\Case_ $node) { @@ -766,18 +876,19 @@ class Standard extends PrettyPrinterAbstract } protected function pStmt_TryCatch(Stmt\TryCatch $node) { - return 'try {' . $this->pStmts($node->stmts) . "\n" . '}' - . $this->pImplode($node->catches) - . ($node->finally !== null ? $this->p($node->finally) : ''); + return 'try {' . $this->pStmts($node->stmts) . $this->nl . '}' + . ($node->catches ? ' ' . $this->pImplode($node->catches, ' ') : '') + . ($node->finally !== null ? ' ' . $this->p($node->finally) : ''); } protected function pStmt_Catch(Stmt\Catch_ $node) { - return ' catch (' . $this->pImplode($node->types, '|') . ' $' . $node->var . ') {' - . $this->pStmts($node->stmts) . "\n" . '}'; + return 'catch (' . $this->pImplode($node->types, '|') + . ($node->var !== null ? ' ' . $this->p($node->var) : '') + . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } protected function pStmt_Finally(Stmt\Finally_ $node) { - return ' finally {' . $this->pStmts($node->stmts) . "\n" . '}'; + return 'finally {' . $this->pStmts($node->stmts) . $this->nl . '}'; } protected function pStmt_Break(Stmt\Break_ $node) { @@ -806,6 +917,10 @@ class Standard extends PrettyPrinterAbstract // Other + protected function pStmt_Expression(Stmt\Expression $node) { + return $this->p($node->expr) . ';'; + } + protected function pStmt_Echo(Stmt\Echo_ $node) { return 'echo ' . $this->pCommaSeparated($node->exprs) . ';'; } @@ -819,7 +934,7 @@ class Standard extends PrettyPrinterAbstract } protected function pStmt_StaticVar(Stmt\StaticVar $node) { - return '$' . $node->name + return $this->p($node->var) . (null !== $node->default ? ' = ' . $this->p($node->default) : ''); } @@ -829,7 +944,7 @@ class Standard extends PrettyPrinterAbstract protected function pStmt_InlineHTML(Stmt\InlineHTML $node) { $newline = $node->getAttribute('hasLeadingNewline', true) ? "\n" : ''; - return '?>' . $this->pNoIndent($newline . $node->value) . '' . $newline . $node->value . 'p($node); - } - protected function pClassCommon(Stmt\Class_ $node, $afterClassToken) { - return $this->pModifiers($node->flags) - . 'class' . $afterClassToken - . (null !== $node->extends ? ' extends ' . $this->p($node->extends) : '') - . (!empty($node->implements) ? ' implements ' . $this->pCommaSeparated($node->implements) : '') - . "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}'; + return $this->pAttrGroups($node->attrGroups, $node->name === null) + . $this->pModifiers($node->flags) + . 'class' . $afterClassToken + . (null !== $node->extends ? ' extends ' . $this->p($node->extends) : '') + . (!empty($node->implements) ? ' implements ' . $this->pCommaSeparated($node->implements) : '') + . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } protected function pObjectProperty($node) { @@ -862,15 +974,6 @@ class Standard extends PrettyPrinterAbstract } } - protected function pModifiers($modifiers) { - return ($modifiers & Stmt\Class_::MODIFIER_PUBLIC ? 'public ' : '') - . ($modifiers & Stmt\Class_::MODIFIER_PROTECTED ? 'protected ' : '') - . ($modifiers & Stmt\Class_::MODIFIER_PRIVATE ? 'private ' : '') - . ($modifiers & Stmt\Class_::MODIFIER_STATIC ? 'static ' : '') - . ($modifiers & Stmt\Class_::MODIFIER_ABSTRACT ? 'abstract ' : '') - . ($modifiers & Stmt\Class_::MODIFIER_FINAL ? 'final ' : ''); - } - protected function pEncapsList(array $encapsList, $quote) { $return = ''; foreach ($encapsList as $element) { @@ -884,6 +987,10 @@ class Standard extends PrettyPrinterAbstract return $return; } + protected function pSingleQuotedString(string $string) { + return '\'' . addcslashes($string, '\'\\') . '\''; + } + protected function escapeString($string, $quote) { if (null === $quote) { // For doc strings, don't escape newlines @@ -892,14 +999,27 @@ class Standard extends PrettyPrinterAbstract $escaped = addcslashes($string, "\n\r\t\f\v$" . $quote . "\\"); } - // Escape other control characters - return preg_replace_callback('/([\0-\10\16-\37])(?=([0-7]?))/', function ($matches) { - $oct = decoct(ord($matches[1])); - if ($matches[2] !== '') { - // If there is a trailing digit, use the full three character form - return '\\' . str_pad($oct, 3, '0', STR_PAD_LEFT); - } - return '\\' . $oct; + // Escape control characters and non-UTF-8 characters. + // Regex based on https://stackoverflow.com/a/11709412/385378. + $regex = '/( + [\x00-\x08\x0E-\x1F] # Control characters + | [\xC0-\xC1] # Invalid UTF-8 Bytes + | [\xF5-\xFF] # Invalid UTF-8 Bytes + | \xE0(?=[\x80-\x9F]) # Overlong encoding of prior code point + | \xF0(?=[\x80-\x8F]) # Overlong encoding of prior code point + | [\xC2-\xDF](?![\x80-\xBF]) # Invalid UTF-8 Sequence Start + | [\xE0-\xEF](?![\x80-\xBF]{2}) # Invalid UTF-8 Sequence Start + | [\xF0-\xF4](?![\x80-\xBF]{3}) # Invalid UTF-8 Sequence Start + | (?<=[\x00-\x7F\xF5-\xFF])[\x80-\xBF] # Invalid UTF-8 Sequence Middle + | (?dereferenceLhsRequiresParens($node)) { return $this->p($node); } else { return '(' . $this->p($node) . ')'; @@ -944,34 +1052,46 @@ class Standard extends PrettyPrinterAbstract } protected function pCallLhs(Node $node) { - if ($node instanceof Name - || $node instanceof Expr\Variable - || $node instanceof Expr\ArrayDimFetch - || $node instanceof Expr\FuncCall - || $node instanceof Expr\MethodCall - || $node instanceof Expr\StaticCall - || $node instanceof Expr\Array_ - ) { + if (!$this->callLhsRequiresParens($node)) { return $this->p($node); } else { return '(' . $this->p($node) . ')'; } } - private function hasNodeWithComments(array $nodes) { + protected function pNewVariable(Node $node) { + // TODO: This is not fully accurate. + return $this->pDereferenceLhs($node); + } + + /** + * @param Node[] $nodes + * @return bool + */ + protected function hasNodeWithComments(array $nodes) { foreach ($nodes as $node) { - if ($node && $node->getAttribute('comments')) { + if ($node && $node->getComments()) { return true; } } return false; } - private function pMaybeMultiline(array $nodes, $trailingComma = false) { + protected function pMaybeMultiline(array $nodes, bool $trailingComma = false) { if (!$this->hasNodeWithComments($nodes)) { return $this->pCommaSeparated($nodes); } else { - return $this->pCommaSeparatedMultiline($nodes, $trailingComma) . "\n"; + return $this->pCommaSeparatedMultiline($nodes, $trailingComma) . $this->nl; } } + + protected function pAttrGroups(array $nodes, bool $inline = false): string { + $result = ''; + $sep = $inline ? ' ' : $this->nl; + foreach ($nodes as $node) { + $result .= $this->p($node) . $sep; + } + + return $result; + } } diff --git a/lib/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php b/lib/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php index 24bae5936..8a3565f1c 100644 --- a/lib/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +++ b/lib/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php @@ -1,84 +1,140 @@ - array( 0, 1), - 'Expr_BitwiseNot' => array( 10, 1), - 'Expr_PreInc' => array( 10, 1), - 'Expr_PreDec' => array( 10, 1), - 'Expr_PostInc' => array( 10, -1), - 'Expr_PostDec' => array( 10, -1), - 'Expr_UnaryPlus' => array( 10, 1), - 'Expr_UnaryMinus' => array( 10, 1), - 'Expr_Cast_Int' => array( 10, 1), - 'Expr_Cast_Double' => array( 10, 1), - 'Expr_Cast_String' => array( 10, 1), - 'Expr_Cast_Array' => array( 10, 1), - 'Expr_Cast_Object' => array( 10, 1), - 'Expr_Cast_Bool' => array( 10, 1), - 'Expr_Cast_Unset' => array( 10, 1), - 'Expr_ErrorSuppress' => array( 10, 1), - 'Expr_Instanceof' => array( 20, 0), - 'Expr_BooleanNot' => array( 30, 1), - 'Expr_BinaryOp_Mul' => array( 40, -1), - 'Expr_BinaryOp_Div' => array( 40, -1), - 'Expr_BinaryOp_Mod' => array( 40, -1), - 'Expr_BinaryOp_Plus' => array( 50, -1), - 'Expr_BinaryOp_Minus' => array( 50, -1), - 'Expr_BinaryOp_Concat' => array( 50, -1), - 'Expr_BinaryOp_ShiftLeft' => array( 60, -1), - 'Expr_BinaryOp_ShiftRight' => array( 60, -1), - 'Expr_BinaryOp_Smaller' => array( 70, 0), - 'Expr_BinaryOp_SmallerOrEqual' => array( 70, 0), - 'Expr_BinaryOp_Greater' => array( 70, 0), - 'Expr_BinaryOp_GreaterOrEqual' => array( 70, 0), - 'Expr_BinaryOp_Equal' => array( 80, 0), - 'Expr_BinaryOp_NotEqual' => array( 80, 0), - 'Expr_BinaryOp_Identical' => array( 80, 0), - 'Expr_BinaryOp_NotIdentical' => array( 80, 0), - 'Expr_BinaryOp_Spaceship' => array( 80, 0), - 'Expr_BinaryOp_BitwiseAnd' => array( 90, -1), - 'Expr_BinaryOp_BitwiseXor' => array(100, -1), - 'Expr_BinaryOp_BitwiseOr' => array(110, -1), - 'Expr_BinaryOp_BooleanAnd' => array(120, -1), - 'Expr_BinaryOp_BooleanOr' => array(130, -1), - 'Expr_BinaryOp_Coalesce' => array(140, 1), - 'Expr_Ternary' => array(150, -1), - // parser uses %left for assignments, but they really behave as %right - 'Expr_Assign' => array(160, 1), - 'Expr_AssignRef' => array(160, 1), - 'Expr_AssignOp_Plus' => array(160, 1), - 'Expr_AssignOp_Minus' => array(160, 1), - 'Expr_AssignOp_Mul' => array(160, 1), - 'Expr_AssignOp_Div' => array(160, 1), - 'Expr_AssignOp_Concat' => array(160, 1), - 'Expr_AssignOp_Mod' => array(160, 1), - 'Expr_AssignOp_BitwiseAnd' => array(160, 1), - 'Expr_AssignOp_BitwiseOr' => array(160, 1), - 'Expr_AssignOp_BitwiseXor' => array(160, 1), - 'Expr_AssignOp_ShiftLeft' => array(160, 1), - 'Expr_AssignOp_ShiftRight' => array(160, 1), - 'Expr_AssignOp_Pow' => array(160, 1), - 'Expr_YieldFrom' => array(165, 1), - 'Expr_Print' => array(168, 1), - 'Expr_BinaryOp_LogicalAnd' => array(170, -1), - 'Expr_BinaryOp_LogicalXor' => array(180, -1), - 'Expr_BinaryOp_LogicalOr' => array(190, -1), - 'Expr_Include' => array(200, -1), - ); + const FIXUP_PREC_LEFT = 0; // LHS operand affected by precedence + const FIXUP_PREC_RIGHT = 1; // RHS operand affected by precedence + const FIXUP_CALL_LHS = 2; // LHS of call + const FIXUP_DEREF_LHS = 3; // LHS of dereferencing operation + const FIXUP_BRACED_NAME = 4; // Name operand that may require bracing + const FIXUP_VAR_BRACED_NAME = 5; // Name operand that may require ${} bracing + const FIXUP_ENCAPSED = 6; // Encapsed string part - protected $noIndentToken; + protected $precedenceMap = [ + // [precedence, associativity] + // where for precedence -1 is %left, 0 is %nonassoc and 1 is %right + BinaryOp\Pow::class => [ 0, 1], + Expr\BitwiseNot::class => [ 10, 1], + Expr\PreInc::class => [ 10, 1], + Expr\PreDec::class => [ 10, 1], + Expr\PostInc::class => [ 10, -1], + Expr\PostDec::class => [ 10, -1], + Expr\UnaryPlus::class => [ 10, 1], + Expr\UnaryMinus::class => [ 10, 1], + Cast\Int_::class => [ 10, 1], + Cast\Double::class => [ 10, 1], + Cast\String_::class => [ 10, 1], + Cast\Array_::class => [ 10, 1], + Cast\Object_::class => [ 10, 1], + Cast\Bool_::class => [ 10, 1], + Cast\Unset_::class => [ 10, 1], + Expr\ErrorSuppress::class => [ 10, 1], + Expr\Instanceof_::class => [ 20, 0], + Expr\BooleanNot::class => [ 30, 1], + BinaryOp\Mul::class => [ 40, -1], + BinaryOp\Div::class => [ 40, -1], + BinaryOp\Mod::class => [ 40, -1], + BinaryOp\Plus::class => [ 50, -1], + BinaryOp\Minus::class => [ 50, -1], + BinaryOp\Concat::class => [ 50, -1], + BinaryOp\ShiftLeft::class => [ 60, -1], + BinaryOp\ShiftRight::class => [ 60, -1], + BinaryOp\Smaller::class => [ 70, 0], + BinaryOp\SmallerOrEqual::class => [ 70, 0], + BinaryOp\Greater::class => [ 70, 0], + BinaryOp\GreaterOrEqual::class => [ 70, 0], + BinaryOp\Equal::class => [ 80, 0], + BinaryOp\NotEqual::class => [ 80, 0], + BinaryOp\Identical::class => [ 80, 0], + BinaryOp\NotIdentical::class => [ 80, 0], + BinaryOp\Spaceship::class => [ 80, 0], + BinaryOp\BitwiseAnd::class => [ 90, -1], + BinaryOp\BitwiseXor::class => [100, -1], + BinaryOp\BitwiseOr::class => [110, -1], + BinaryOp\BooleanAnd::class => [120, -1], + BinaryOp\BooleanOr::class => [130, -1], + BinaryOp\Coalesce::class => [140, 1], + Expr\Ternary::class => [150, 0], + // parser uses %left for assignments, but they really behave as %right + Expr\Assign::class => [160, 1], + Expr\AssignRef::class => [160, 1], + AssignOp\Plus::class => [160, 1], + AssignOp\Minus::class => [160, 1], + AssignOp\Mul::class => [160, 1], + AssignOp\Div::class => [160, 1], + AssignOp\Concat::class => [160, 1], + AssignOp\Mod::class => [160, 1], + AssignOp\BitwiseAnd::class => [160, 1], + AssignOp\BitwiseOr::class => [160, 1], + AssignOp\BitwiseXor::class => [160, 1], + AssignOp\ShiftLeft::class => [160, 1], + AssignOp\ShiftRight::class => [160, 1], + AssignOp\Pow::class => [160, 1], + AssignOp\Coalesce::class => [160, 1], + Expr\YieldFrom::class => [165, 1], + Expr\Print_::class => [168, 1], + BinaryOp\LogicalAnd::class => [170, -1], + BinaryOp\LogicalXor::class => [180, -1], + BinaryOp\LogicalOr::class => [190, -1], + Expr\Include_::class => [200, -1], + ]; + + /** @var int Current indentation level. */ + protected $indentLevel; + /** @var string Newline including current indentation. */ + protected $nl; + /** @var string Token placed at end of doc string to ensure it is followed by a newline. */ protected $docStringEndToken; + /** @var bool Whether semicolon namespaces can be used (i.e. no global namespace is used) */ protected $canUseSemicolonNamespaces; + /** @var array Pretty printer options */ protected $options; + /** @var TokenStream Original tokens for use in format-preserving pretty print */ + protected $origTokens; + /** @var Internal\Differ Differ for node lists */ + protected $nodeListDiffer; + /** @var bool[] Map determining whether a certain character is a label character */ + protected $labelCharMap; + /** + * @var int[][] Map from token classes and subnode names to FIXUP_* constants. This is used + * during format-preserving prints to place additional parens/braces if necessary. + */ + protected $fixupMap; + /** + * @var int[][] Map from "{$node->getType()}->{$subNode}" to ['left' => $l, 'right' => $r], + * where $l and $r specify the token type that needs to be stripped when removing + * this node. + */ + protected $removalMap; + /** + * @var mixed[] Map from "{$node->getType()}->{$subNode}" to [$find, $beforeToken, $extraLeft, $extraRight]. + * $find is an optional token after which the insertion occurs. $extraLeft/Right + * are optionally added before/after the main insertions. + */ + protected $insertionMap; + /** + * @var string[] Map From "{$node->getType()}->{$subNode}" to string that should be inserted + * between elements of this list subnode. + */ + protected $listInsertionMap; + protected $emptyListInsertionMap; + /** @var int[] Map from "{$node->getType()}->{$subNode}" to token before which the modifiers + * should be reprinted. */ + protected $modifierChangeMap; + /** * Creates a pretty printer instance using the given options. * @@ -89,13 +145,48 @@ abstract class PrettyPrinterAbstract * @param array $options Dictionary of formatting options */ public function __construct(array $options = []) { - $this->noIndentToken = '_NO_INDENT_' . mt_rand(); $this->docStringEndToken = '_DOC_STRING_END_' . mt_rand(); $defaultOptions = ['shortArraySyntax' => false]; $this->options = $options + $defaultOptions; } + /** + * Reset pretty printing state. + */ + protected function resetState() { + $this->indentLevel = 0; + $this->nl = "\n"; + $this->origTokens = null; + } + + /** + * Set indentation level + * + * @param int $level Level in number of spaces + */ + protected function setIndentLevel(int $level) { + $this->indentLevel = $level; + $this->nl = "\n" . \str_repeat(' ', $level); + } + + /** + * Increase indentation level. + */ + protected function indent() { + $this->indentLevel += 4; + $this->nl .= ' '; + } + + /** + * Decrease indentation level. + */ + protected function outdent() { + assert($this->indentLevel >= 4); + $this->indentLevel -= 4; + $this->nl = "\n" . str_repeat(' ', $this->indentLevel); + } + /** * Pretty prints an array of statements. * @@ -103,7 +194,8 @@ abstract class PrettyPrinterAbstract * * @return string Pretty printed statements */ - public function prettyPrint(array $stmts) { + public function prettyPrint(array $stmts) : string { + $this->resetState(); $this->preprocessNodes($stmts); return ltrim($this->handleMagicTokens($this->pStmts($stmts, false))); @@ -116,7 +208,8 @@ abstract class PrettyPrinterAbstract * * @return string Pretty printed node */ - public function prettyPrintExpr(Expr $node) { + public function prettyPrintExpr(Expr $node) : string { + $this->resetState(); return $this->handleMagicTokens($this->p($node)); } @@ -127,7 +220,7 @@ abstract class PrettyPrinterAbstract * * @return string Pretty printed statements */ - public function prettyPrintFile(array $stmts) { + public function prettyPrintFile(array $stmts) : string { if (!$stmts) { return "name) { $this->canUseSemicolonNamespaces = false; + break; } } } - protected function handleMagicTokens($str) { - // Drop no-indent tokens - $str = str_replace($this->noIndentToken, '', $str); - + /** + * Handles (and removes) no-indent and doc-string-end tokens. + * + * @param string $str + * @return string + */ + protected function handleMagicTokens(string $str) : string { // Replace doc-string-end tokens with nothing or a newline $str = str_replace($this->docStringEndToken . ";\n", ";\n", $str); $str = str_replace($this->docStringEndToken, "\n", $str); @@ -178,53 +275,74 @@ abstract class PrettyPrinterAbstract * * @return string Pretty printed statements */ - protected function pStmts(array $nodes, $indent = true) { + protected function pStmts(array $nodes, bool $indent = true) : string { + if ($indent) { + $this->indent(); + } + $result = ''; foreach ($nodes as $node) { - $comments = $node->getAttribute('comments', array()); + $comments = $node->getComments(); if ($comments) { - $result .= "\n" . $this->pComments($comments); + $result .= $this->nl . $this->pComments($comments); if ($node instanceof Stmt\Nop) { continue; } } - $result .= "\n" . $this->p($node) . ($node instanceof Expr ? ';' : ''); + $result .= $this->nl . $this->p($node); } if ($indent) { - return preg_replace('~\n(?!$|' . $this->noIndentToken . ')~', "\n ", $result); - } else { - return $result; + $this->outdent(); } + + return $result; } /** - * Pretty prints a node. + * Pretty-print an infix operation while taking precedence into account. * - * @param Node $node Node to be pretty printed + * @param string $class Node class of operator + * @param Node $leftNode Left-hand side node + * @param string $operatorString String representation of the operator + * @param Node $rightNode Right-hand side node * - * @return string Pretty printed node + * @return string Pretty printed infix operation */ - protected function p(Node $node) { - return $this->{'p' . $node->getType()}($node); - } - - protected function pInfixOp($type, Node $leftNode, $operatorString, Node $rightNode) { - list($precedence, $associativity) = $this->precedenceMap[$type]; + protected function pInfixOp(string $class, Node $leftNode, string $operatorString, Node $rightNode) : string { + list($precedence, $associativity) = $this->precedenceMap[$class]; return $this->pPrec($leftNode, $precedence, $associativity, -1) . $operatorString . $this->pPrec($rightNode, $precedence, $associativity, 1); } - protected function pPrefixOp($type, $operatorString, Node $node) { - list($precedence, $associativity) = $this->precedenceMap[$type]; + /** + * Pretty-print a prefix operation while taking precedence into account. + * + * @param string $class Node class of operator + * @param string $operatorString String representation of the operator + * @param Node $node Node + * + * @return string Pretty printed prefix operation + */ + protected function pPrefixOp(string $class, string $operatorString, Node $node) : string { + list($precedence, $associativity) = $this->precedenceMap[$class]; return $operatorString . $this->pPrec($node, $precedence, $associativity, 1); } - protected function pPostfixOp($type, Node $node, $operatorString) { - list($precedence, $associativity) = $this->precedenceMap[$type]; + /** + * Pretty-print a postfix operation while taking precedence into account. + * + * @param string $class Node class of operator + * @param string $operatorString String representation of the operator + * @param Node $node Node + * + * @return string Pretty printed postfix operation + */ + protected function pPostfixOp(string $class, Node $node, string $operatorString) : string { + list($precedence, $associativity) = $this->precedenceMap[$class]; return $this->pPrec($node, $precedence, $associativity, -1) . $operatorString; } @@ -240,12 +358,12 @@ abstract class PrettyPrinterAbstract * * @return string The pretty printed node */ - protected function pPrec(Node $node, $parentPrecedence, $parentAssociativity, $childPosition) { - $type = $node->getType(); - if (isset($this->precedenceMap[$type])) { - $childPrecedence = $this->precedenceMap[$type][0]; + protected function pPrec(Node $node, int $parentPrecedence, int $parentAssociativity, int $childPosition) : string { + $class = \get_class($node); + if (isset($this->precedenceMap[$class])) { + $childPrecedence = $this->precedenceMap[$class][0]; if ($childPrecedence > $parentPrecedence - || ($parentPrecedence == $childPrecedence && $parentAssociativity != $childPosition) + || ($parentPrecedence === $childPrecedence && $parentAssociativity !== $childPosition) ) { return '(' . $this->p($node) . ')'; } @@ -262,8 +380,8 @@ abstract class PrettyPrinterAbstract * * @return string Imploded pretty printed nodes */ - protected function pImplode(array $nodes, $glue = '') { - $pNodes = array(); + protected function pImplode(array $nodes, string $glue = '') : string { + $pNodes = []; foreach ($nodes as $node) { if (null === $node) { $pNodes[] = ''; @@ -282,7 +400,7 @@ abstract class PrettyPrinterAbstract * * @return string Comma separated pretty printed nodes */ - protected function pCommaSeparated(array $nodes) { + protected function pCommaSeparated(array $nodes) : string { return $this->pImplode($nodes, ', '); } @@ -296,37 +414,29 @@ abstract class PrettyPrinterAbstract * * @return string Comma separated pretty printed nodes in multiline style */ - protected function pCommaSeparatedMultiline(array $nodes, $trailingComma) { + protected function pCommaSeparatedMultiline(array $nodes, bool $trailingComma) : string { + $this->indent(); + $result = ''; $lastIdx = count($nodes) - 1; foreach ($nodes as $idx => $node) { if ($node !== null) { - $comments = $node->getAttribute('comments', array()); + $comments = $node->getComments(); if ($comments) { - $result .= "\n" . $this->pComments($comments); + $result .= $this->nl . $this->pComments($comments); } - $result .= "\n" . $this->p($node); + $result .= $this->nl . $this->p($node); } else { - $result .= "\n"; + $result .= $this->nl; } if ($trailingComma || $idx !== $lastIdx) { $result .= ','; } } - return preg_replace('~\n(?!$|' . $this->noIndentToken . ')~', "\n ", $result); - } - - /** - * Signals the pretty printer that a string shall not be indented. - * - * @param string $string Not to be indented string - * - * @return string String marked with $this->noIndentToken's. - */ - protected function pNoIndent($string) { - return str_replace("\n", "\n" . $this->noIndentToken, $string); + $this->outdent(); + return $result; } /** @@ -336,13 +446,1056 @@ abstract class PrettyPrinterAbstract * * @return string Reformatted text of comments */ - protected function pComments(array $comments) { + protected function pComments(array $comments) : string { $formattedComments = []; foreach ($comments as $comment) { - $formattedComments[] = $comment->getReformattedText(); + $formattedComments[] = str_replace("\n", $this->nl, $comment->getReformattedText()); } - return implode("\n", $formattedComments); + return implode($this->nl, $formattedComments); + } + + /** + * Perform a format-preserving pretty print of an AST. + * + * The format preservation is best effort. For some changes to the AST the formatting will not + * be preserved (at least not locally). + * + * In order to use this method a number of prerequisites must be satisfied: + * * The startTokenPos and endTokenPos attributes in the lexer must be enabled. + * * The CloningVisitor must be run on the AST prior to modification. + * * The original tokens must be provided, using the getTokens() method on the lexer. + * + * @param Node[] $stmts Modified AST with links to original AST + * @param Node[] $origStmts Original AST with token offset information + * @param array $origTokens Tokens of the original code + * + * @return string + */ + public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens) : string { + $this->initializeNodeListDiffer(); + $this->initializeLabelCharMap(); + $this->initializeFixupMap(); + $this->initializeRemovalMap(); + $this->initializeInsertionMap(); + $this->initializeListInsertionMap(); + $this->initializeEmptyListInsertionMap(); + $this->initializeModifierChangeMap(); + + $this->resetState(); + $this->origTokens = new TokenStream($origTokens); + + $this->preprocessNodes($stmts); + + $pos = 0; + $result = $this->pArray($stmts, $origStmts, $pos, 0, 'File', 'stmts', null); + if (null !== $result) { + $result .= $this->origTokens->getTokenCode($pos, count($origTokens), 0); + } else { + // Fallback + // TODO Add pStmts($stmts, false); + } + + return ltrim($this->handleMagicTokens($result)); + } + + protected function pFallback(Node $node) { + return $this->{'p' . $node->getType()}($node); + } + + /** + * Pretty prints a node. + * + * This method also handles formatting preservation for nodes. + * + * @param Node $node Node to be pretty printed + * @param bool $parentFormatPreserved Whether parent node has preserved formatting + * + * @return string Pretty printed node + */ + protected function p(Node $node, $parentFormatPreserved = false) : string { + // No orig tokens means this is a normal pretty print without preservation of formatting + if (!$this->origTokens) { + return $this->{'p' . $node->getType()}($node); + } + + /** @var Node $origNode */ + $origNode = $node->getAttribute('origNode'); + if (null === $origNode) { + return $this->pFallback($node); + } + + $class = \get_class($node); + \assert($class === \get_class($origNode)); + + $startPos = $origNode->getStartTokenPos(); + $endPos = $origNode->getEndTokenPos(); + \assert($startPos >= 0 && $endPos >= 0); + + $fallbackNode = $node; + if ($node instanceof Expr\New_ && $node->class instanceof Stmt\Class_) { + // Normalize node structure of anonymous classes + $node = PrintableNewAnonClassNode::fromNewNode($node); + $origNode = PrintableNewAnonClassNode::fromNewNode($origNode); + } + + // InlineHTML node does not contain closing and opening PHP tags. If the parent formatting + // is not preserved, then we need to use the fallback code to make sure the tags are + // printed. + if ($node instanceof Stmt\InlineHTML && !$parentFormatPreserved) { + return $this->pFallback($fallbackNode); + } + + $indentAdjustment = $this->indentLevel - $this->origTokens->getIndentationBefore($startPos); + + $type = $node->getType(); + $fixupInfo = $this->fixupMap[$class] ?? null; + + $result = ''; + $pos = $startPos; + foreach ($node->getSubNodeNames() as $subNodeName) { + $subNode = $node->$subNodeName; + $origSubNode = $origNode->$subNodeName; + + if ((!$subNode instanceof Node && $subNode !== null) + || (!$origSubNode instanceof Node && $origSubNode !== null) + ) { + if ($subNode === $origSubNode) { + // Unchanged, can reuse old code + continue; + } + + if (is_array($subNode) && is_array($origSubNode)) { + // Array subnode changed, we might be able to reconstruct it + $listResult = $this->pArray( + $subNode, $origSubNode, $pos, $indentAdjustment, $type, $subNodeName, + $fixupInfo[$subNodeName] ?? null + ); + if (null === $listResult) { + return $this->pFallback($fallbackNode); + } + + $result .= $listResult; + continue; + } + + if (is_int($subNode) && is_int($origSubNode)) { + // Check if this is a modifier change + $key = $type . '->' . $subNodeName; + if (!isset($this->modifierChangeMap[$key])) { + return $this->pFallback($fallbackNode); + } + + $findToken = $this->modifierChangeMap[$key]; + $result .= $this->pModifiers($subNode); + $pos = $this->origTokens->findRight($pos, $findToken); + continue; + } + + // If a non-node, non-array subnode changed, we don't be able to do a partial + // reconstructions, as we don't have enough offset information. Pretty print the + // whole node instead. + return $this->pFallback($fallbackNode); + } + + $extraLeft = ''; + $extraRight = ''; + if ($origSubNode !== null) { + $subStartPos = $origSubNode->getStartTokenPos(); + $subEndPos = $origSubNode->getEndTokenPos(); + \assert($subStartPos >= 0 && $subEndPos >= 0); + } else { + if ($subNode === null) { + // Both null, nothing to do + continue; + } + + // A node has been inserted, check if we have insertion information for it + $key = $type . '->' . $subNodeName; + if (!isset($this->insertionMap[$key])) { + return $this->pFallback($fallbackNode); + } + + list($findToken, $beforeToken, $extraLeft, $extraRight) = $this->insertionMap[$key]; + if (null !== $findToken) { + $subStartPos = $this->origTokens->findRight($pos, $findToken) + + (int) !$beforeToken; + } else { + $subStartPos = $pos; + } + + if (null === $extraLeft && null !== $extraRight) { + // If inserting on the right only, skipping whitespace looks better + $subStartPos = $this->origTokens->skipRightWhitespace($subStartPos); + } + $subEndPos = $subStartPos - 1; + } + + if (null === $subNode) { + // A node has been removed, check if we have removal information for it + $key = $type . '->' . $subNodeName; + if (!isset($this->removalMap[$key])) { + return $this->pFallback($fallbackNode); + } + + // Adjust positions to account for additional tokens that must be skipped + $removalInfo = $this->removalMap[$key]; + if (isset($removalInfo['left'])) { + $subStartPos = $this->origTokens->skipLeft($subStartPos - 1, $removalInfo['left']) + 1; + } + if (isset($removalInfo['right'])) { + $subEndPos = $this->origTokens->skipRight($subEndPos + 1, $removalInfo['right']) - 1; + } + } + + $result .= $this->origTokens->getTokenCode($pos, $subStartPos, $indentAdjustment); + + if (null !== $subNode) { + $result .= $extraLeft; + + $origIndentLevel = $this->indentLevel; + $this->setIndentLevel($this->origTokens->getIndentationBefore($subStartPos) + $indentAdjustment); + + // If it's the same node that was previously in this position, it certainly doesn't + // need fixup. It's important to check this here, because our fixup checks are more + // conservative than strictly necessary. + if (isset($fixupInfo[$subNodeName]) + && $subNode->getAttribute('origNode') !== $origSubNode + ) { + $fixup = $fixupInfo[$subNodeName]; + $res = $this->pFixup($fixup, $subNode, $class, $subStartPos, $subEndPos); + } else { + $res = $this->p($subNode, true); + } + + $this->safeAppend($result, $res); + $this->setIndentLevel($origIndentLevel); + + $result .= $extraRight; + } + + $pos = $subEndPos + 1; + } + + $result .= $this->origTokens->getTokenCode($pos, $endPos + 1, $indentAdjustment); + return $result; + } + + /** + * Perform a format-preserving pretty print of an array. + * + * @param array $nodes New nodes + * @param array $origNodes Original nodes + * @param int $pos Current token position (updated by reference) + * @param int $indentAdjustment Adjustment for indentation + * @param string $parentNodeType Type of the containing node. + * @param string $subNodeName Name of array subnode. + * @param null|int $fixup Fixup information for array item nodes + * + * @return null|string Result of pretty print or null if cannot preserve formatting + */ + protected function pArray( + array $nodes, array $origNodes, int &$pos, int $indentAdjustment, + string $parentNodeType, string $subNodeName, $fixup + ) { + $diff = $this->nodeListDiffer->diffWithReplacements($origNodes, $nodes); + + $mapKey = $parentNodeType . '->' . $subNodeName; + $insertStr = $this->listInsertionMap[$mapKey] ?? null; + $isStmtList = $subNodeName === 'stmts'; + + $beforeFirstKeepOrReplace = true; + $skipRemovedNode = false; + $delayedAdd = []; + $lastElemIndentLevel = $this->indentLevel; + + $insertNewline = false; + if ($insertStr === "\n") { + $insertStr = ''; + $insertNewline = true; + } + + if ($isStmtList && \count($origNodes) === 1 && \count($nodes) !== 1) { + $startPos = $origNodes[0]->getStartTokenPos(); + $endPos = $origNodes[0]->getEndTokenPos(); + \assert($startPos >= 0 && $endPos >= 0); + if (!$this->origTokens->haveBraces($startPos, $endPos)) { + // This was a single statement without braces, but either additional statements + // have been added, or the single statement has been removed. This requires the + // addition of braces. For now fall back. + // TODO: Try to preserve formatting + return null; + } + } + + $result = ''; + foreach ($diff as $i => $diffElem) { + $diffType = $diffElem->type; + /** @var Node|null $arrItem */ + $arrItem = $diffElem->new; + /** @var Node|null $origArrItem */ + $origArrItem = $diffElem->old; + + if ($diffType === DiffElem::TYPE_KEEP || $diffType === DiffElem::TYPE_REPLACE) { + $beforeFirstKeepOrReplace = false; + + if ($origArrItem === null || $arrItem === null) { + // We can only handle the case where both are null + if ($origArrItem === $arrItem) { + continue; + } + return null; + } + + if (!$arrItem instanceof Node || !$origArrItem instanceof Node) { + // We can only deal with nodes. This can occur for Names, which use string arrays. + return null; + } + + $itemStartPos = $origArrItem->getStartTokenPos(); + $itemEndPos = $origArrItem->getEndTokenPos(); + \assert($itemStartPos >= 0 && $itemEndPos >= 0 && $itemStartPos >= $pos); + + $origIndentLevel = $this->indentLevel; + $lastElemIndentLevel = $this->origTokens->getIndentationBefore($itemStartPos) + $indentAdjustment; + $this->setIndentLevel($lastElemIndentLevel); + + $comments = $arrItem->getComments(); + $origComments = $origArrItem->getComments(); + $commentStartPos = $origComments ? $origComments[0]->getStartTokenPos() : $itemStartPos; + \assert($commentStartPos >= 0); + + if ($commentStartPos < $pos) { + // Comments may be assigned to multiple nodes if they start at the same position. + // Make sure we don't try to print them multiple times. + $commentStartPos = $itemStartPos; + } + + if ($skipRemovedNode) { + if ($isStmtList && $this->origTokens->haveBracesInRange($pos, $itemStartPos)) { + // We'd remove the brace of a code block. + // TODO: Preserve formatting. + $this->setIndentLevel($origIndentLevel); + return null; + } + } else { + $result .= $this->origTokens->getTokenCode( + $pos, $commentStartPos, $indentAdjustment); + } + + if (!empty($delayedAdd)) { + /** @var Node $delayedAddNode */ + foreach ($delayedAdd as $delayedAddNode) { + if ($insertNewline) { + $delayedAddComments = $delayedAddNode->getComments(); + if ($delayedAddComments) { + $result .= $this->pComments($delayedAddComments) . $this->nl; + } + } + + $this->safeAppend($result, $this->p($delayedAddNode, true)); + + if ($insertNewline) { + $result .= $insertStr . $this->nl; + } else { + $result .= $insertStr; + } + } + + $delayedAdd = []; + } + + if ($comments !== $origComments) { + if ($comments) { + $result .= $this->pComments($comments) . $this->nl; + } + } else { + $result .= $this->origTokens->getTokenCode( + $commentStartPos, $itemStartPos, $indentAdjustment); + } + + // If we had to remove anything, we have done so now. + $skipRemovedNode = false; + } elseif ($diffType === DiffElem::TYPE_ADD) { + if (null === $insertStr) { + // We don't have insertion information for this list type + return null; + } + + if ($insertStr === ', ' && $this->isMultiline($origNodes)) { + $insertStr = ','; + $insertNewline = true; + } + + if ($beforeFirstKeepOrReplace) { + // Will be inserted at the next "replace" or "keep" element + $delayedAdd[] = $arrItem; + continue; + } + + $itemStartPos = $pos; + $itemEndPos = $pos - 1; + + $origIndentLevel = $this->indentLevel; + $this->setIndentLevel($lastElemIndentLevel); + + if ($insertNewline) { + $comments = $arrItem->getComments(); + if ($comments) { + $result .= $this->nl . $this->pComments($comments); + } + $result .= $insertStr . $this->nl; + } else { + $result .= $insertStr; + } + } elseif ($diffType === DiffElem::TYPE_REMOVE) { + if (!$origArrItem instanceof Node) { + // We only support removal for nodes + return null; + } + + $itemStartPos = $origArrItem->getStartTokenPos(); + $itemEndPos = $origArrItem->getEndTokenPos(); + \assert($itemStartPos >= 0 && $itemEndPos >= 0); + + // Consider comments part of the node. + $origComments = $origArrItem->getComments(); + if ($origComments) { + $itemStartPos = $origComments[0]->getStartTokenPos(); + } + + if ($i === 0) { + // If we're removing from the start, keep the tokens before the node and drop those after it, + // instead of the other way around. + $result .= $this->origTokens->getTokenCode( + $pos, $itemStartPos, $indentAdjustment); + $skipRemovedNode = true; + } else { + if ($isStmtList && $this->origTokens->haveBracesInRange($pos, $itemStartPos)) { + // We'd remove the brace of a code block. + // TODO: Preserve formatting. + return null; + } + } + + $pos = $itemEndPos + 1; + continue; + } else { + throw new \Exception("Shouldn't happen"); + } + + if (null !== $fixup && $arrItem->getAttribute('origNode') !== $origArrItem) { + $res = $this->pFixup($fixup, $arrItem, null, $itemStartPos, $itemEndPos); + } else { + $res = $this->p($arrItem, true); + } + $this->safeAppend($result, $res); + + $this->setIndentLevel($origIndentLevel); + $pos = $itemEndPos + 1; + } + + if ($skipRemovedNode) { + // TODO: Support removing single node. + return null; + } + + if (!empty($delayedAdd)) { + if (!isset($this->emptyListInsertionMap[$mapKey])) { + return null; + } + + list($findToken, $extraLeft, $extraRight) = $this->emptyListInsertionMap[$mapKey]; + if (null !== $findToken) { + $insertPos = $this->origTokens->findRight($pos, $findToken) + 1; + $result .= $this->origTokens->getTokenCode($pos, $insertPos, $indentAdjustment); + $pos = $insertPos; + } + + $first = true; + $result .= $extraLeft; + foreach ($delayedAdd as $delayedAddNode) { + if (!$first) { + $result .= $insertStr; + } + $result .= $this->p($delayedAddNode, true); + $first = false; + } + $result .= $extraRight; + } + + return $result; + } + + /** + * Print node with fixups. + * + * Fixups here refer to the addition of extra parentheses, braces or other characters, that + * are required to preserve program semantics in a certain context (e.g. to maintain precedence + * or because only certain expressions are allowed in certain places). + * + * @param int $fixup Fixup type + * @param Node $subNode Subnode to print + * @param string|null $parentClass Class of parent node + * @param int $subStartPos Original start pos of subnode + * @param int $subEndPos Original end pos of subnode + * + * @return string Result of fixed-up print of subnode + */ + protected function pFixup(int $fixup, Node $subNode, $parentClass, int $subStartPos, int $subEndPos) : string { + switch ($fixup) { + case self::FIXUP_PREC_LEFT: + case self::FIXUP_PREC_RIGHT: + if (!$this->origTokens->haveParens($subStartPos, $subEndPos)) { + list($precedence, $associativity) = $this->precedenceMap[$parentClass]; + return $this->pPrec($subNode, $precedence, $associativity, + $fixup === self::FIXUP_PREC_LEFT ? -1 : 1); + } + break; + case self::FIXUP_CALL_LHS: + if ($this->callLhsRequiresParens($subNode) + && !$this->origTokens->haveParens($subStartPos, $subEndPos) + ) { + return '(' . $this->p($subNode) . ')'; + } + break; + case self::FIXUP_DEREF_LHS: + if ($this->dereferenceLhsRequiresParens($subNode) + && !$this->origTokens->haveParens($subStartPos, $subEndPos) + ) { + return '(' . $this->p($subNode) . ')'; + } + break; + case self::FIXUP_BRACED_NAME: + case self::FIXUP_VAR_BRACED_NAME: + if ($subNode instanceof Expr + && !$this->origTokens->haveBraces($subStartPos, $subEndPos) + ) { + return ($fixup === self::FIXUP_VAR_BRACED_NAME ? '$' : '') + . '{' . $this->p($subNode) . '}'; + } + break; + case self::FIXUP_ENCAPSED: + if (!$subNode instanceof Scalar\EncapsedStringPart + && !$this->origTokens->haveBraces($subStartPos, $subEndPos) + ) { + return '{' . $this->p($subNode) . '}'; + } + break; + default: + throw new \Exception('Cannot happen'); + } + + // Nothing special to do + return $this->p($subNode); + } + + /** + * Appends to a string, ensuring whitespace between label characters. + * + * Example: "echo" and "$x" result in "echo$x", but "echo" and "x" result in "echo x". + * Without safeAppend the result would be "echox", which does not preserve semantics. + * + * @param string $str + * @param string $append + */ + protected function safeAppend(string &$str, string $append) { + if ($str === "") { + $str = $append; + return; + } + + if ($append === "") { + return; + } + + if (!$this->labelCharMap[$append[0]] + || !$this->labelCharMap[$str[\strlen($str) - 1]]) { + $str .= $append; + } else { + $str .= " " . $append; + } + } + + /** + * Determines whether the LHS of a call must be wrapped in parenthesis. + * + * @param Node $node LHS of a call + * + * @return bool Whether parentheses are required + */ + protected function callLhsRequiresParens(Node $node) : bool { + return !($node instanceof Node\Name + || $node instanceof Expr\Variable + || $node instanceof Expr\ArrayDimFetch + || $node instanceof Expr\FuncCall + || $node instanceof Expr\MethodCall + || $node instanceof Expr\NullsafeMethodCall + || $node instanceof Expr\StaticCall + || $node instanceof Expr\Array_); + } + + /** + * Determines whether the LHS of a dereferencing operation must be wrapped in parenthesis. + * + * @param Node $node LHS of dereferencing operation + * + * @return bool Whether parentheses are required + */ + protected function dereferenceLhsRequiresParens(Node $node) : bool { + return !($node instanceof Expr\Variable + || $node instanceof Node\Name + || $node instanceof Expr\ArrayDimFetch + || $node instanceof Expr\PropertyFetch + || $node instanceof Expr\NullsafePropertyFetch + || $node instanceof Expr\StaticPropertyFetch + || $node instanceof Expr\FuncCall + || $node instanceof Expr\MethodCall + || $node instanceof Expr\NullsafeMethodCall + || $node instanceof Expr\StaticCall + || $node instanceof Expr\Array_ + || $node instanceof Scalar\String_ + || $node instanceof Expr\ConstFetch + || $node instanceof Expr\ClassConstFetch); + } + + /** + * Print modifiers, including trailing whitespace. + * + * @param int $modifiers Modifier mask to print + * + * @return string Printed modifiers + */ + protected function pModifiers(int $modifiers) { + return ($modifiers & Stmt\Class_::MODIFIER_PUBLIC ? 'public ' : '') + . ($modifiers & Stmt\Class_::MODIFIER_PROTECTED ? 'protected ' : '') + . ($modifiers & Stmt\Class_::MODIFIER_PRIVATE ? 'private ' : '') + . ($modifiers & Stmt\Class_::MODIFIER_STATIC ? 'static ' : '') + . ($modifiers & Stmt\Class_::MODIFIER_ABSTRACT ? 'abstract ' : '') + . ($modifiers & Stmt\Class_::MODIFIER_FINAL ? 'final ' : '') + . ($modifiers & Stmt\Class_::MODIFIER_READONLY ? 'readonly ' : ''); + } + + /** + * Determine whether a list of nodes uses multiline formatting. + * + * @param (Node|null)[] $nodes Node list + * + * @return bool Whether multiline formatting is used + */ + protected function isMultiline(array $nodes) : bool { + if (\count($nodes) < 2) { + return false; + } + + $pos = -1; + foreach ($nodes as $node) { + if (null === $node) { + continue; + } + + $endPos = $node->getEndTokenPos() + 1; + if ($pos >= 0) { + $text = $this->origTokens->getTokenCode($pos, $endPos, 0); + if (false === strpos($text, "\n")) { + // We require that a newline is present between *every* item. If the formatting + // is inconsistent, with only some items having newlines, we don't consider it + // as multiline + return false; + } + } + $pos = $endPos; + } + + return true; + } + + /** + * Lazily initializes label char map. + * + * The label char map determines whether a certain character may occur in a label. + */ + protected function initializeLabelCharMap() { + if ($this->labelCharMap) return; + + $this->labelCharMap = []; + for ($i = 0; $i < 256; $i++) { + // Since PHP 7.1 The lower range is 0x80. However, we also want to support code for + // older versions. + $chr = chr($i); + $this->labelCharMap[$chr] = $i >= 0x7f || ctype_alnum($chr); + } + } + + /** + * Lazily initializes node list differ. + * + * The node list differ is used to determine differences between two array subnodes. + */ + protected function initializeNodeListDiffer() { + if ($this->nodeListDiffer) return; + + $this->nodeListDiffer = new Internal\Differ(function ($a, $b) { + if ($a instanceof Node && $b instanceof Node) { + return $a === $b->getAttribute('origNode'); + } + // Can happen for array destructuring + return $a === null && $b === null; + }); + } + + /** + * Lazily initializes fixup map. + * + * The fixup map is used to determine whether a certain subnode of a certain node may require + * some kind of "fixup" operation, e.g. the addition of parenthesis or braces. + */ + protected function initializeFixupMap() { + if ($this->fixupMap) return; + + $this->fixupMap = [ + Expr\PreInc::class => ['var' => self::FIXUP_PREC_RIGHT], + Expr\PreDec::class => ['var' => self::FIXUP_PREC_RIGHT], + Expr\PostInc::class => ['var' => self::FIXUP_PREC_LEFT], + Expr\PostDec::class => ['var' => self::FIXUP_PREC_LEFT], + Expr\Instanceof_::class => [ + 'expr' => self::FIXUP_PREC_LEFT, + 'class' => self::FIXUP_PREC_RIGHT, // TODO: FIXUP_NEW_VARIABLE + ], + Expr\Ternary::class => [ + 'cond' => self::FIXUP_PREC_LEFT, + 'else' => self::FIXUP_PREC_RIGHT, + ], + + Expr\FuncCall::class => ['name' => self::FIXUP_CALL_LHS], + Expr\StaticCall::class => ['class' => self::FIXUP_DEREF_LHS], + Expr\ArrayDimFetch::class => ['var' => self::FIXUP_DEREF_LHS], + Expr\ClassConstFetch::class => ['var' => self::FIXUP_DEREF_LHS], + Expr\New_::class => ['class' => self::FIXUP_DEREF_LHS], // TODO: FIXUP_NEW_VARIABLE + Expr\MethodCall::class => [ + 'var' => self::FIXUP_DEREF_LHS, + 'name' => self::FIXUP_BRACED_NAME, + ], + Expr\NullsafeMethodCall::class => [ + 'var' => self::FIXUP_DEREF_LHS, + 'name' => self::FIXUP_BRACED_NAME, + ], + Expr\StaticPropertyFetch::class => [ + 'class' => self::FIXUP_DEREF_LHS, + 'name' => self::FIXUP_VAR_BRACED_NAME, + ], + Expr\PropertyFetch::class => [ + 'var' => self::FIXUP_DEREF_LHS, + 'name' => self::FIXUP_BRACED_NAME, + ], + Expr\NullsafePropertyFetch::class => [ + 'var' => self::FIXUP_DEREF_LHS, + 'name' => self::FIXUP_BRACED_NAME, + ], + Scalar\Encapsed::class => [ + 'parts' => self::FIXUP_ENCAPSED, + ], + ]; + + $binaryOps = [ + BinaryOp\Pow::class, BinaryOp\Mul::class, BinaryOp\Div::class, BinaryOp\Mod::class, + BinaryOp\Plus::class, BinaryOp\Minus::class, BinaryOp\Concat::class, + BinaryOp\ShiftLeft::class, BinaryOp\ShiftRight::class, BinaryOp\Smaller::class, + BinaryOp\SmallerOrEqual::class, BinaryOp\Greater::class, BinaryOp\GreaterOrEqual::class, + BinaryOp\Equal::class, BinaryOp\NotEqual::class, BinaryOp\Identical::class, + BinaryOp\NotIdentical::class, BinaryOp\Spaceship::class, BinaryOp\BitwiseAnd::class, + BinaryOp\BitwiseXor::class, BinaryOp\BitwiseOr::class, BinaryOp\BooleanAnd::class, + BinaryOp\BooleanOr::class, BinaryOp\Coalesce::class, BinaryOp\LogicalAnd::class, + BinaryOp\LogicalXor::class, BinaryOp\LogicalOr::class, + ]; + foreach ($binaryOps as $binaryOp) { + $this->fixupMap[$binaryOp] = [ + 'left' => self::FIXUP_PREC_LEFT, + 'right' => self::FIXUP_PREC_RIGHT + ]; + } + + $assignOps = [ + Expr\Assign::class, Expr\AssignRef::class, AssignOp\Plus::class, AssignOp\Minus::class, + AssignOp\Mul::class, AssignOp\Div::class, AssignOp\Concat::class, AssignOp\Mod::class, + AssignOp\BitwiseAnd::class, AssignOp\BitwiseOr::class, AssignOp\BitwiseXor::class, + AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class, AssignOp\Coalesce::class + ]; + foreach ($assignOps as $assignOp) { + $this->fixupMap[$assignOp] = [ + 'var' => self::FIXUP_PREC_LEFT, + 'expr' => self::FIXUP_PREC_RIGHT, + ]; + } + + $prefixOps = [ + Expr\BitwiseNot::class, Expr\BooleanNot::class, Expr\UnaryPlus::class, Expr\UnaryMinus::class, + Cast\Int_::class, Cast\Double::class, Cast\String_::class, Cast\Array_::class, + Cast\Object_::class, Cast\Bool_::class, Cast\Unset_::class, Expr\ErrorSuppress::class, + Expr\YieldFrom::class, Expr\Print_::class, Expr\Include_::class, + ]; + foreach ($prefixOps as $prefixOp) { + $this->fixupMap[$prefixOp] = ['expr' => self::FIXUP_PREC_RIGHT]; + } + } + + /** + * Lazily initializes the removal map. + * + * The removal map is used to determine which additional tokens should be removed when a + * certain node is replaced by null. + */ + protected function initializeRemovalMap() { + if ($this->removalMap) return; + + $stripBoth = ['left' => \T_WHITESPACE, 'right' => \T_WHITESPACE]; + $stripLeft = ['left' => \T_WHITESPACE]; + $stripRight = ['right' => \T_WHITESPACE]; + $stripDoubleArrow = ['right' => \T_DOUBLE_ARROW]; + $stripColon = ['left' => ':']; + $stripEquals = ['left' => '=']; + $this->removalMap = [ + 'Expr_ArrayDimFetch->dim' => $stripBoth, + 'Expr_ArrayItem->key' => $stripDoubleArrow, + 'Expr_ArrowFunction->returnType' => $stripColon, + 'Expr_Closure->returnType' => $stripColon, + 'Expr_Exit->expr' => $stripBoth, + 'Expr_Ternary->if' => $stripBoth, + 'Expr_Yield->key' => $stripDoubleArrow, + 'Expr_Yield->value' => $stripBoth, + 'Param->type' => $stripRight, + 'Param->default' => $stripEquals, + 'Stmt_Break->num' => $stripBoth, + 'Stmt_Catch->var' => $stripLeft, + 'Stmt_ClassMethod->returnType' => $stripColon, + 'Stmt_Class->extends' => ['left' => \T_EXTENDS], + 'Stmt_Enum->scalarType' => $stripColon, + 'Stmt_EnumCase->expr' => $stripEquals, + 'Expr_PrintableNewAnonClass->extends' => ['left' => \T_EXTENDS], + 'Stmt_Continue->num' => $stripBoth, + 'Stmt_Foreach->keyVar' => $stripDoubleArrow, + 'Stmt_Function->returnType' => $stripColon, + 'Stmt_If->else' => $stripLeft, + 'Stmt_Namespace->name' => $stripLeft, + 'Stmt_Property->type' => $stripRight, + 'Stmt_PropertyProperty->default' => $stripEquals, + 'Stmt_Return->expr' => $stripBoth, + 'Stmt_StaticVar->default' => $stripEquals, + 'Stmt_TraitUseAdaptation_Alias->newName' => $stripLeft, + 'Stmt_TryCatch->finally' => $stripLeft, + // 'Stmt_Case->cond': Replace with "default" + // 'Stmt_Class->name': Unclear what to do + // 'Stmt_Declare->stmts': Not a plain node + // 'Stmt_TraitUseAdaptation_Alias->newModifier': Not a plain node + ]; + } + + protected function initializeInsertionMap() { + if ($this->insertionMap) return; + + // TODO: "yield" where both key and value are inserted doesn't work + // [$find, $beforeToken, $extraLeft, $extraRight] + $this->insertionMap = [ + 'Expr_ArrayDimFetch->dim' => ['[', false, null, null], + 'Expr_ArrayItem->key' => [null, false, null, ' => '], + 'Expr_ArrowFunction->returnType' => [')', false, ' : ', null], + 'Expr_Closure->returnType' => [')', false, ' : ', null], + 'Expr_Ternary->if' => ['?', false, ' ', ' '], + 'Expr_Yield->key' => [\T_YIELD, false, null, ' => '], + 'Expr_Yield->value' => [\T_YIELD, false, ' ', null], + 'Param->type' => [null, false, null, ' '], + 'Param->default' => [null, false, ' = ', null], + 'Stmt_Break->num' => [\T_BREAK, false, ' ', null], + 'Stmt_Catch->var' => [null, false, ' ', null], + 'Stmt_ClassMethod->returnType' => [')', false, ' : ', null], + 'Stmt_Class->extends' => [null, false, ' extends ', null], + 'Stmt_Enum->scalarType' => [null, false, ' : ', null], + 'Stmt_EnumCase->expr' => [null, false, ' = ', null], + 'Expr_PrintableNewAnonClass->extends' => [null, ' extends ', null], + 'Stmt_Continue->num' => [\T_CONTINUE, false, ' ', null], + 'Stmt_Foreach->keyVar' => [\T_AS, false, null, ' => '], + 'Stmt_Function->returnType' => [')', false, ' : ', null], + 'Stmt_If->else' => [null, false, ' ', null], + 'Stmt_Namespace->name' => [\T_NAMESPACE, false, ' ', null], + 'Stmt_Property->type' => [\T_VARIABLE, true, null, ' '], + 'Stmt_PropertyProperty->default' => [null, false, ' = ', null], + 'Stmt_Return->expr' => [\T_RETURN, false, ' ', null], + 'Stmt_StaticVar->default' => [null, false, ' = ', null], + //'Stmt_TraitUseAdaptation_Alias->newName' => [T_AS, false, ' ', null], // TODO + 'Stmt_TryCatch->finally' => [null, false, ' ', null], + + // 'Expr_Exit->expr': Complicated due to optional () + // 'Stmt_Case->cond': Conversion from default to case + // 'Stmt_Class->name': Unclear + // 'Stmt_Declare->stmts': Not a proper node + // 'Stmt_TraitUseAdaptation_Alias->newModifier': Not a proper node + ]; + } + + protected function initializeListInsertionMap() { + if ($this->listInsertionMap) return; + + $this->listInsertionMap = [ + // special + //'Expr_ShellExec->parts' => '', // TODO These need to be treated more carefully + //'Scalar_Encapsed->parts' => '', + 'Stmt_Catch->types' => '|', + 'UnionType->types' => '|', + 'Stmt_If->elseifs' => ' ', + 'Stmt_TryCatch->catches' => ' ', + + // comma-separated lists + 'Expr_Array->items' => ', ', + 'Expr_ArrowFunction->params' => ', ', + 'Expr_Closure->params' => ', ', + 'Expr_Closure->uses' => ', ', + 'Expr_FuncCall->args' => ', ', + 'Expr_Isset->vars' => ', ', + 'Expr_List->items' => ', ', + 'Expr_MethodCall->args' => ', ', + 'Expr_NullsafeMethodCall->args' => ', ', + 'Expr_New->args' => ', ', + 'Expr_PrintableNewAnonClass->args' => ', ', + 'Expr_StaticCall->args' => ', ', + 'Stmt_ClassConst->consts' => ', ', + 'Stmt_ClassMethod->params' => ', ', + 'Stmt_Class->implements' => ', ', + 'Stmt_Enum->implements' => ', ', + 'Expr_PrintableNewAnonClass->implements' => ', ', + 'Stmt_Const->consts' => ', ', + 'Stmt_Declare->declares' => ', ', + 'Stmt_Echo->exprs' => ', ', + 'Stmt_For->init' => ', ', + 'Stmt_For->cond' => ', ', + 'Stmt_For->loop' => ', ', + 'Stmt_Function->params' => ', ', + 'Stmt_Global->vars' => ', ', + 'Stmt_GroupUse->uses' => ', ', + 'Stmt_Interface->extends' => ', ', + 'Stmt_Match->arms' => ', ', + 'Stmt_Property->props' => ', ', + 'Stmt_StaticVar->vars' => ', ', + 'Stmt_TraitUse->traits' => ', ', + 'Stmt_TraitUseAdaptation_Precedence->insteadof' => ', ', + 'Stmt_Unset->vars' => ', ', + 'Stmt_Use->uses' => ', ', + 'MatchArm->conds' => ', ', + 'AttributeGroup->attrs' => ', ', + + // statement lists + 'Expr_Closure->stmts' => "\n", + 'Stmt_Case->stmts' => "\n", + 'Stmt_Catch->stmts' => "\n", + 'Stmt_Class->stmts' => "\n", + 'Stmt_Enum->stmts' => "\n", + 'Expr_PrintableNewAnonClass->stmts' => "\n", + 'Stmt_Interface->stmts' => "\n", + 'Stmt_Trait->stmts' => "\n", + 'Stmt_ClassMethod->stmts' => "\n", + 'Stmt_Declare->stmts' => "\n", + 'Stmt_Do->stmts' => "\n", + 'Stmt_ElseIf->stmts' => "\n", + 'Stmt_Else->stmts' => "\n", + 'Stmt_Finally->stmts' => "\n", + 'Stmt_Foreach->stmts' => "\n", + 'Stmt_For->stmts' => "\n", + 'Stmt_Function->stmts' => "\n", + 'Stmt_If->stmts' => "\n", + 'Stmt_Namespace->stmts' => "\n", + 'Stmt_Class->attrGroups' => "\n", + 'Stmt_Enum->attrGroups' => "\n", + 'Stmt_EnumCase->attrGroups' => "\n", + 'Stmt_Interface->attrGroups' => "\n", + 'Stmt_Trait->attrGroups' => "\n", + 'Stmt_Function->attrGroups' => "\n", + 'Stmt_ClassMethod->attrGroups' => "\n", + 'Stmt_ClassConst->attrGroups' => "\n", + 'Stmt_Property->attrGroups' => "\n", + 'Expr_PrintableNewAnonClass->attrGroups' => ' ', + 'Expr_Closure->attrGroups' => ' ', + 'Expr_ArrowFunction->attrGroups' => ' ', + 'Param->attrGroups' => ' ', + 'Stmt_Switch->cases' => "\n", + 'Stmt_TraitUse->adaptations' => "\n", + 'Stmt_TryCatch->stmts' => "\n", + 'Stmt_While->stmts' => "\n", + + // dummy for top-level context + 'File->stmts' => "\n", + ]; + } + + protected function initializeEmptyListInsertionMap() { + if ($this->emptyListInsertionMap) return; + + // TODO Insertion into empty statement lists. + + // [$find, $extraLeft, $extraRight] + $this->emptyListInsertionMap = [ + 'Expr_ArrowFunction->params' => ['(', '', ''], + 'Expr_Closure->uses' => [')', ' use(', ')'], + 'Expr_Closure->params' => ['(', '', ''], + 'Expr_FuncCall->args' => ['(', '', ''], + 'Expr_MethodCall->args' => ['(', '', ''], + 'Expr_NullsafeMethodCall->args' => ['(', '', ''], + 'Expr_New->args' => ['(', '', ''], + 'Expr_PrintableNewAnonClass->args' => ['(', '', ''], + 'Expr_PrintableNewAnonClass->implements' => [null, ' implements ', ''], + 'Expr_StaticCall->args' => ['(', '', ''], + 'Stmt_Class->implements' => [null, ' implements ', ''], + 'Stmt_Enum->implements' => [null, ' implements ', ''], + 'Stmt_ClassMethod->params' => ['(', '', ''], + 'Stmt_Interface->extends' => [null, ' extends ', ''], + 'Stmt_Function->params' => ['(', '', ''], + + /* These cannot be empty to start with: + * Expr_Isset->vars + * Stmt_Catch->types + * Stmt_Const->consts + * Stmt_ClassConst->consts + * Stmt_Declare->declares + * Stmt_Echo->exprs + * Stmt_Global->vars + * Stmt_GroupUse->uses + * Stmt_Property->props + * Stmt_StaticVar->vars + * Stmt_TraitUse->traits + * Stmt_TraitUseAdaptation_Precedence->insteadof + * Stmt_Unset->vars + * Stmt_Use->uses + * UnionType->types + */ + + /* TODO + * Stmt_If->elseifs + * Stmt_TryCatch->catches + * Expr_Array->items + * Expr_List->items + * Stmt_For->init + * Stmt_For->cond + * Stmt_For->loop + */ + ]; + } + + protected function initializeModifierChangeMap() { + if ($this->modifierChangeMap) return; + + $this->modifierChangeMap = [ + 'Stmt_ClassConst->flags' => \T_CONST, + 'Stmt_ClassMethod->flags' => \T_FUNCTION, + 'Stmt_Class->flags' => \T_CLASS, + 'Stmt_Property->flags' => \T_VARIABLE, + 'Param->flags' => \T_VARIABLE, + //'Stmt_TraitUseAdaptation_Alias->newModifier' => 0, // TODO + ]; + + // List of integer subnodes that are not modifiers: + // Expr_Include->type + // Stmt_GroupUse->type + // Stmt_Use->type + // Stmt_UseUse->type } } diff --git a/lib/nikic/php-parser/lib/PhpParser/Serializer.php b/lib/nikic/php-parser/lib/PhpParser/Serializer.php deleted file mode 100644 index 1dd790666..000000000 --- a/lib/nikic/php-parser/lib/PhpParser/Serializer.php +++ /dev/null @@ -1,18 +0,0 @@ -writer = new XMLWriter; - $this->writer->openMemory(); - $this->writer->setIndent(true); - } - - public function serialize(array $nodes) { - $this->writer->flush(); - $this->writer->startDocument('1.0', 'UTF-8'); - - $this->writer->startElement('AST'); - $this->writer->writeAttribute('xmlns:node', 'http://nikic.github.com/PHPParser/XML/node'); - $this->writer->writeAttribute('xmlns:subNode', 'http://nikic.github.com/PHPParser/XML/subNode'); - $this->writer->writeAttribute('xmlns:attribute', 'http://nikic.github.com/PHPParser/XML/attribute'); - $this->writer->writeAttribute('xmlns:scalar', 'http://nikic.github.com/PHPParser/XML/scalar'); - - $this->_serialize($nodes); - - $this->writer->endElement(); - - return $this->writer->outputMemory(); - } - - protected function _serialize($node) { - if ($node instanceof Node) { - $this->writer->startElement('node:' . $node->getType()); - - foreach ($node->getAttributes() as $name => $value) { - $this->writer->startElement('attribute:' . $name); - $this->_serialize($value); - $this->writer->endElement(); - } - - foreach ($node as $name => $subNode) { - $this->writer->startElement('subNode:' . $name); - $this->_serialize($subNode); - $this->writer->endElement(); - } - - $this->writer->endElement(); - } elseif ($node instanceof Comment) { - $this->writer->startElement('comment'); - $this->writer->writeAttribute('isDocComment', $node instanceof Comment\Doc ? 'true' : 'false'); - $this->writer->writeAttribute('line', (string) $node->getLine()); - $this->writer->text($node->getText()); - $this->writer->endElement(); - } elseif (is_array($node)) { - $this->writer->startElement('scalar:array'); - foreach ($node as $subNode) { - $this->_serialize($subNode); - } - $this->writer->endElement(); - } elseif (is_string($node)) { - $this->writer->writeElement('scalar:string', $node); - } elseif (is_int($node)) { - $this->writer->writeElement('scalar:int', (string) $node); - } elseif (is_float($node)) { - // TODO Higher precision conversion? - $this->writer->writeElement('scalar:float', (string) $node); - } elseif (true === $node) { - $this->writer->writeElement('scalar:true'); - } elseif (false === $node) { - $this->writer->writeElement('scalar:false'); - } elseif (null === $node) { - $this->writer->writeElement('scalar:null'); - } else { - throw new \InvalidArgumentException('Unexpected node type'); - } - } -} diff --git a/lib/nikic/php-parser/lib/PhpParser/Unserializer.php b/lib/nikic/php-parser/lib/PhpParser/Unserializer.php deleted file mode 100644 index 9c221a141..000000000 --- a/lib/nikic/php-parser/lib/PhpParser/Unserializer.php +++ /dev/null @@ -1,18 +0,0 @@ -reader = new XMLReader; - } - - public function unserialize($string) { - $this->reader->XML($string); - - $this->reader->read(); - if ('AST' !== $this->reader->name) { - throw new DomainException('AST root element not found'); - } - - return $this->read($this->reader->depth); - } - - protected function read($depthLimit, $throw = true, &$nodeFound = null) { - $nodeFound = true; - while ($this->reader->read() && $depthLimit < $this->reader->depth) { - if (XMLReader::ELEMENT !== $this->reader->nodeType) { - continue; - } - - if ('node' === $this->reader->prefix) { - return $this->readNode(); - } elseif ('scalar' === $this->reader->prefix) { - return $this->readScalar(); - } elseif ('comment' === $this->reader->name) { - return $this->readComment(); - } else { - throw new DomainException(sprintf('Unexpected node of type "%s"', $this->reader->name)); - } - } - - $nodeFound = false; - if ($throw) { - throw new DomainException('Expected node or scalar'); - } - } - - protected function readNode() { - $className = $this->getClassNameFromType($this->reader->localName); - - // create the node without calling it's constructor - $node = unserialize( - sprintf( - "O:%d:\"%s\":1:{s:13:\"\0*\0attributes\";a:0:{}}", - strlen($className), $className - ) - ); - - $depthLimit = $this->reader->depth; - while ($this->reader->read() && $depthLimit < $this->reader->depth) { - if (XMLReader::ELEMENT !== $this->reader->nodeType) { - continue; - } - - $type = $this->reader->prefix; - if ('subNode' !== $type && 'attribute' !== $type) { - throw new DomainException( - sprintf('Expected sub node or attribute, got node of type "%s"', $this->reader->name) - ); - } - - $name = $this->reader->localName; - $value = $this->read($this->reader->depth); - - if ('subNode' === $type) { - $node->$name = $value; - } else { - $node->setAttribute($name, $value); - } - } - - return $node; - } - - protected function readScalar() { - switch ($name = $this->reader->localName) { - case 'array': - $depth = $this->reader->depth; - $array = array(); - while (true) { - $node = $this->read($depth, false, $nodeFound); - if (!$nodeFound) { - break; - } - $array[] = $node; - } - return $array; - case 'string': - return $this->reader->readString(); - case 'int': - return $this->parseInt($this->reader->readString()); - case 'float': - $text = $this->reader->readString(); - if (false === $float = filter_var($text, FILTER_VALIDATE_FLOAT)) { - throw new DomainException(sprintf('"%s" is not a valid float', $text)); - } - return $float; - case 'true': - case 'false': - case 'null': - if (!$this->reader->isEmptyElement) { - throw new DomainException(sprintf('"%s" scalar must be empty', $name)); - } - return constant($name); - default: - throw new DomainException(sprintf('Unknown scalar type "%s"', $name)); - } - } - - private function parseInt($text) { - if (false === $int = filter_var($text, FILTER_VALIDATE_INT)) { - throw new DomainException(sprintf('"%s" is not a valid integer', $text)); - } - return $int; - } - - protected function readComment() { - $className = $this->reader->getAttribute('isDocComment') === 'true' - ? 'PhpParser\Comment\Doc' - : 'PhpParser\Comment' - ; - return new $className( - $this->reader->readString(), - $this->parseInt($this->reader->getAttribute('line')) - ); - } - - protected function getClassNameFromType($type) { - $className = 'PhpParser\\Node\\' . strtr($type, '_', '\\'); - if (!class_exists($className)) { - $className .= '_'; - } - if (!class_exists($className)) { - throw new DomainException(sprintf('Unknown node type "%s"', $type)); - } - return $className; - } -} diff --git a/lib/nikic/php-parser/lib/bootstrap.php b/lib/nikic/php-parser/lib/bootstrap.php deleted file mode 100644 index b0f517822..000000000 --- a/lib/nikic/php-parser/lib/bootstrap.php +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - ./test/ - - - - - - ./lib/PhpParser/ - - - diff --git a/lib/nikic/php-parser/test_old/run-php-src.sh b/lib/nikic/php-parser/test_old/run-php-src.sh deleted file mode 100644 index 0d37f851d..000000000 --- a/lib/nikic/php-parser/test_old/run-php-src.sh +++ /dev/null @@ -1,4 +0,0 @@ -wget -q https://github.com/php/php-src/archive/php-7.1.0.tar.gz -mkdir -p ./data/php-src -tar -xzf ./php-7.1.0.tar.gz -C ./data/php-src --strip-components=1 -php -n test_old/run.php --verbose --no-progress PHP7 ./data/php-src diff --git a/lib/nikic/php-parser/test_old/run.php b/lib/nikic/php-parser/test_old/run.php deleted file mode 100644 index bc14d893a..000000000 --- a/lib/nikic/php-parser/test_old/run.php +++ /dev/null @@ -1,220 +0,0 @@ -parse($code); - $parseTime += microtime(true) - $startTime; - - $startTime = microtime(true); - $code = 'prettyPrint($stmts); - $ppTime += microtime(true) - $startTime; - - try { - $startTime = microtime(true); - $ppStmts = $parser->parse($code); - $reparseTime += microtime(true) - $startTime; - - $startTime = microtime(true); - $same = $nodeDumper->dump($stmts) == $nodeDumper->dump($ppStmts); - $compareTime += microtime(true) - $startTime; - - if (!$same) { - echo $file, ":\n Result of initial parse and parse after pretty print differ\n"; - if ($verbose) { - echo "Pretty printer output:\n=====\n$code\n=====\n\n"; - } - - ++$compareFail; - } - } catch (PhpParser\Error $e) { - echo $file, ":\n Parse of pretty print failed with message: {$e->getMessage()}\n"; - if ($verbose) { - echo "Pretty printer output:\n=====\n$code\n=====\n\n"; - } - - ++$ppFail; - } - } catch (PhpParser\Error $e) { - echo $file, ":\n Parse failed with message: {$e->getMessage()}\n"; - - ++$parseFail; - } -} - -if (0 === $parseFail && 0 === $ppFail && 0 === $compareFail) { - $exit = 0; - echo "\n\n", 'All tests passed.', "\n"; -} else { - $exit = 1; - echo "\n\n", '==========', "\n\n", 'There were: ', "\n"; - if (0 !== $parseFail) { - echo ' ', $parseFail, ' parse failures.', "\n"; - } - if (0 !== $ppFail) { - echo ' ', $ppFail, ' pretty print failures.', "\n"; - } - if (0 !== $compareFail) { - echo ' ', $compareFail, ' compare failures.', "\n"; - } -} - -echo "\n", - 'Tested files: ', $count, "\n", - "\n", - 'Reading files took: ', $readTime, "\n", - 'Parsing took: ', $parseTime, "\n", - 'Pretty printing took: ', $ppTime, "\n", - 'Reparsing took: ', $reparseTime, "\n", - 'Comparing took: ', $compareTime, "\n", - "\n", - 'Total time: ', microtime(true) - $totalStartTime, "\n", - 'Maximum memory usage: ', memory_get_peak_usage(true), "\n"; - -exit($exit);