@appthreat/atom 1.8.1 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/phpastgen.js +7 -1
- package/plugins/autoload.php +1 -1
- package/plugins/bin/atom +1 -1
- package/plugins/bin/atom.bat +1 -1
- package/plugins/composer/autoload_classmap.php +18 -18
- package/plugins/composer/autoload_real.php +4 -4
- package/plugins/composer/autoload_static.php +22 -22
- package/plugins/composer/installed.json +10 -12
- package/plugins/composer/installed.php +9 -9
- package/plugins/lib/io.appthreat.atom-1.8.2-classpath.jar +0 -0
- package/plugins/lib/{io.appthreat.atom-1.8.1.jar → io.appthreat.atom-1.8.2.jar} +0 -0
- package/plugins/lib/{io.appthreat.c2cpg_3-1.1.3.jar → io.appthreat.c2cpg_3-1.1.4.jar} +0 -0
- package/plugins/lib/{io.appthreat.dataflowengineoss_3-1.1.3.jar → io.appthreat.dataflowengineoss_3-1.1.4.jar} +0 -0
- package/plugins/lib/{io.appthreat.javasrc2cpg_3-1.1.3.jar → io.appthreat.javasrc2cpg_3-1.1.4.jar} +0 -0
- package/plugins/lib/{io.appthreat.jimple2cpg_3-1.1.3.jar → io.appthreat.jimple2cpg_3-1.1.4.jar} +0 -0
- package/plugins/lib/{io.appthreat.jssrc2cpg_3-1.1.3.jar → io.appthreat.jssrc2cpg_3-1.1.4.jar} +0 -0
- package/plugins/lib/{io.appthreat.php2atom_3-1.1.3.jar → io.appthreat.php2atom_3-1.1.4.jar} +0 -0
- package/plugins/lib/{io.appthreat.pysrc2cpg_3-1.1.3.jar → io.appthreat.pysrc2cpg_3-1.1.4.jar} +0 -0
- package/plugins/lib/{io.appthreat.semanticcpg_3-1.1.3.jar → io.appthreat.semanticcpg_3-1.1.4.jar} +0 -0
- package/plugins/lib/{io.appthreat.x2cpg_3-1.1.3.jar → io.appthreat.x2cpg_3-1.1.4.jar} +0 -0
- package/plugins/nikic/php-parser/README.md +12 -20
- package/plugins/nikic/php-parser/bin/php-parse +10 -11
- package/plugins/nikic/php-parser/composer.json +4 -6
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php +15 -17
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Class_.php +30 -35
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Declaration.php +4 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php +7 -9
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Enum_.php +27 -26
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php +7 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Function_.php +7 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Interface_.php +10 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Method.php +15 -16
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php +5 -5
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Param.php +35 -16
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Property.php +19 -19
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php +5 -6
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php +28 -25
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Trait_.php +11 -16
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Use_.php +8 -8
- package/plugins/nikic/php-parser/lib/PhpParser/Builder.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/BuilderFactory.php +69 -45
- package/plugins/nikic/php-parser/lib/PhpParser/BuilderHelpers.php +19 -17
- package/plugins/nikic/php-parser/lib/PhpParser/Comment/Doc.php +2 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Comment.php +67 -35
- package/plugins/nikic/php-parser/lib/PhpParser/ConstExprEvaluationException.php +3 -3
- package/plugins/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php +10 -15
- package/plugins/nikic/php-parser/lib/PhpParser/Error.php +33 -24
- package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php +9 -6
- package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Internal/DiffElem.php +7 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Internal/Differ.php +22 -36
- package/plugins/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php +13 -20
- package/plugins/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php +70 -55
- package/plugins/nikic/php-parser/lib/PhpParser/JsonDecoder.php +10 -15
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php +93 -68
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php +18 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php +47 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php +15 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php +11 -12
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php +76 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php +23 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php +25 -19
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php +10 -6
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php +29 -22
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php +105 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyFunctionTokenEmulator.php +3 -3
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php +15 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php +5 -6
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php +5 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer.php +513 -69
- package/plugins/nikic/php-parser/lib/PhpParser/NameContext.php +24 -23
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Arg.php +15 -13
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Attribute.php +10 -9
- package/plugins/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php +7 -5
- package/plugins/nikic/php-parser/lib/PhpParser/Node/ComplexType.php +2 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Const_.php +10 -9
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php +11 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php +39 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php +11 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php +28 -33
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php +10 -9
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php +10 -9
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php +11 -8
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php +7 -3
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php +6 -5
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php +6 -5
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php +10 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php +26 -33
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php +32 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php +6 -5
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php +11 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php +11 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php +14 -13
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php +11 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php +8 -12
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php +7 -8
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php +12 -12
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php +11 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php +12 -12
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php +10 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php +7 -6
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php +10 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php +9 -9
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php +13 -12
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +11 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php +13 -12
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php +7 -6
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php +7 -6
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php +11 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr.php +2 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php +8 -5
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Identifier.php +13 -13
- package/plugins/nikic/php-parser/lib/PhpParser/Node/IntersectionType.php +9 -6
- package/plugins/nikic/php-parser/lib/PhpParser/Node/MatchArm.php +9 -8
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php +9 -8
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php +9 -8
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Name.php +56 -71
- package/plugins/nikic/php-parser/lib/PhpParser/Node/NullableType.php +10 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Param.php +22 -46
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php +75 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php +29 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +28 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php +78 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php +26 -30
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar.php +2 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php +9 -8
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php +11 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php +12 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php +32 -24
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php +13 -13
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php +54 -47
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php +89 -46
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php +9 -8
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php +32 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php +12 -12
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php +10 -9
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php +10 -9
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php +12 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php +13 -17
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php +15 -19
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php +17 -20
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php +24 -28
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php +14 -16
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php +15 -18
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php +10 -13
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php +12 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php +37 -28
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php +32 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php +9 -8
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php +35 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php +8 -8
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php +10 -9
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php +30 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php +9 -8
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +13 -12
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +10 -9
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php +4 -3
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php +8 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php +12 -11
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php +50 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php +16 -16
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php +10 -9
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt.php +2 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Node/UnionType.php +8 -7
- package/plugins/nikic/php-parser/lib/PhpParser/Node/VarLikeIdentifier.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php +2 -2
- package/plugins/nikic/php-parser/lib/PhpParser/Node.php +29 -24
- package/plugins/nikic/php-parser/lib/PhpParser/NodeAbstract.php +20 -20
- package/plugins/nikic/php-parser/lib/PhpParser/NodeDumper.php +84 -168
- package/plugins/nikic/php-parser/lib/PhpParser/NodeFinder.php +19 -28
- package/plugins/nikic/php-parser/lib/PhpParser/NodeTraverser.php +84 -71
- package/plugins/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php +7 -4
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php +2 -1
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php +5 -4
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php +7 -6
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php +28 -30
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php +3 -2
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php +11 -8
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor.php +7 -59
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php +2 -1
- package/plugins/nikic/php-parser/lib/PhpParser/Parser/Multiple.php +55 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php5.php +2682 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php7.php +1522 -1323
- package/plugins/nikic/php-parser/lib/PhpParser/Parser/Tokens.php +148 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Parser.php +3 -9
- package/plugins/nikic/php-parser/lib/PhpParser/ParserAbstract.php +252 -433
- package/plugins/nikic/php-parser/lib/PhpParser/ParserFactory.php +49 -15
- package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php +335 -386
- package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +438 -517
- package/plugins/lib/io.appthreat.atom-1.8.1-classpath.jar +0 -0
- package/plugins/nikic/php-parser/.php-cs-fixer.dist.php +0 -31
- package/plugins/nikic/php-parser/Makefile +0 -10
- package/plugins/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php +0 -237
- package/plugins/nikic/php-parser/lib/PhpParser/Modifiers.php +0 -69
- package/plugins/nikic/php-parser/lib/PhpParser/Node/ArrayItem.php +0 -43
- package/plugins/nikic/php-parser/lib/PhpParser/Node/ClosureUse.php +0 -36
- package/plugins/nikic/php-parser/lib/PhpParser/Node/DeclareItem.php +0 -37
- package/plugins/nikic/php-parser/lib/PhpParser/Node/InterpolatedStringPart.php +0 -32
- package/plugins/nikic/php-parser/lib/PhpParser/Node/PropertyItem.php +0 -37
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/Float_.php +0 -78
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/Int_.php +0 -82
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/InterpolatedString.php +0 -34
- package/plugins/nikic/php-parser/lib/PhpParser/Node/StaticVar.php +0 -39
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Block.php +0 -29
- package/plugins/nikic/php-parser/lib/PhpParser/Node/UseItem.php +0 -55
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php +0 -82
- package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php8.php +0 -2717
- package/plugins/nikic/php-parser/lib/PhpParser/PhpVersion.php +0 -164
- package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinter.php +0 -51
- package/plugins/nikic/php-parser/lib/PhpParser/Token.php +0 -18
- package/plugins/nikic/php-parser/lib/PhpParser/compatibility_tokens.php +0 -56
- package/plugins/nikic/php-parser/phpstan-baseline.neon +0 -236
- package/plugins/nikic/php-parser/phpstan.neon.dist +0 -8
|
@@ -6,18 +6,13 @@ namespace PhpParser;
|
|
|
6
6
|
* This parser is based on a skeleton written by Moriyoshi Koizumi, which in
|
|
7
7
|
* turn is based on work by Masato Bito.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
9
|
use PhpParser\Node\Expr;
|
|
11
|
-
use PhpParser\Node\Expr\Array_;
|
|
12
10
|
use PhpParser\Node\Expr\Cast\Double;
|
|
13
|
-
use PhpParser\Node\Identifier;
|
|
14
|
-
use PhpParser\Node\InterpolatedStringPart;
|
|
15
11
|
use PhpParser\Node\Name;
|
|
16
12
|
use PhpParser\Node\Param;
|
|
17
|
-
use PhpParser\Node\Scalar\
|
|
18
|
-
use PhpParser\Node\Scalar\
|
|
13
|
+
use PhpParser\Node\Scalar\Encapsed;
|
|
14
|
+
use PhpParser\Node\Scalar\LNumber;
|
|
19
15
|
use PhpParser\Node\Scalar\String_;
|
|
20
|
-
use PhpParser\Node\Stmt;
|
|
21
16
|
use PhpParser\Node\Stmt\Class_;
|
|
22
17
|
use PhpParser\Node\Stmt\ClassConst;
|
|
23
18
|
use PhpParser\Node\Stmt\ClassMethod;
|
|
@@ -29,137 +24,122 @@ use PhpParser\Node\Stmt\Namespace_;
|
|
|
29
24
|
use PhpParser\Node\Stmt\Nop;
|
|
30
25
|
use PhpParser\Node\Stmt\Property;
|
|
31
26
|
use PhpParser\Node\Stmt\TryCatch;
|
|
32
|
-
use PhpParser\Node\
|
|
33
|
-
use PhpParser\
|
|
34
|
-
|
|
35
|
-
abstract class ParserAbstract implements Parser {
|
|
36
|
-
private const SYMBOL_NONE = -1;
|
|
27
|
+
use PhpParser\Node\Stmt\UseUse;
|
|
28
|
+
use PhpParser\Node\VarLikeIdentifier;
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
protected PhpVersion $phpVersion;
|
|
30
|
+
abstract class ParserAbstract implements Parser
|
|
31
|
+
{
|
|
32
|
+
const SYMBOL_NONE = -1;
|
|
42
33
|
|
|
43
34
|
/*
|
|
44
35
|
* The following members will be filled with generated parsing data:
|
|
45
36
|
*/
|
|
46
37
|
|
|
47
38
|
/** @var int Size of $tokenToSymbol map */
|
|
48
|
-
protected
|
|
39
|
+
protected $tokenToSymbolMapSize;
|
|
49
40
|
/** @var int Size of $action table */
|
|
50
|
-
protected
|
|
41
|
+
protected $actionTableSize;
|
|
51
42
|
/** @var int Size of $goto table */
|
|
52
|
-
protected
|
|
43
|
+
protected $gotoTableSize;
|
|
53
44
|
|
|
54
45
|
/** @var int Symbol number signifying an invalid token */
|
|
55
|
-
protected
|
|
46
|
+
protected $invalidSymbol;
|
|
56
47
|
/** @var int Symbol number of error recovery token */
|
|
57
|
-
protected
|
|
48
|
+
protected $errorSymbol;
|
|
58
49
|
/** @var int Action number signifying default action */
|
|
59
|
-
protected
|
|
50
|
+
protected $defaultAction;
|
|
60
51
|
/** @var int Rule number signifying that an unexpected token was encountered */
|
|
61
|
-
protected
|
|
52
|
+
protected $unexpectedTokenRule;
|
|
62
53
|
|
|
63
|
-
protected
|
|
54
|
+
protected $YY2TBLSTATE;
|
|
64
55
|
/** @var int Number of non-leaf states */
|
|
65
|
-
protected
|
|
66
|
-
|
|
67
|
-
/** @var int[] Map of
|
|
68
|
-
protected
|
|
69
|
-
/** @var array<int, bool> Map of PHP token IDs to drop */
|
|
70
|
-
protected array $dropTokens;
|
|
71
|
-
/** @var int[] Map of external symbols (static::T_*) to internal symbols */
|
|
72
|
-
protected array $tokenToSymbol;
|
|
56
|
+
protected $numNonLeafStates;
|
|
57
|
+
|
|
58
|
+
/** @var int[] Map of lexer tokens to internal symbols */
|
|
59
|
+
protected $tokenToSymbol;
|
|
73
60
|
/** @var string[] Map of symbols to their names */
|
|
74
|
-
protected
|
|
75
|
-
/** @var array
|
|
76
|
-
protected
|
|
61
|
+
protected $symbolToName;
|
|
62
|
+
/** @var array Names of the production rules (only necessary for debugging) */
|
|
63
|
+
protected $productions;
|
|
77
64
|
|
|
78
65
|
/** @var int[] Map of states to a displacement into the $action table. The corresponding action for this
|
|
79
66
|
* state/symbol pair is $action[$actionBase[$state] + $symbol]. If $actionBase[$state] is 0, the
|
|
80
67
|
* action is defaulted, i.e. $actionDefault[$state] should be used instead. */
|
|
81
|
-
protected
|
|
68
|
+
protected $actionBase;
|
|
82
69
|
/** @var int[] Table of actions. Indexed according to $actionBase comment. */
|
|
83
|
-
protected
|
|
70
|
+
protected $action;
|
|
84
71
|
/** @var int[] Table indexed analogously to $action. If $actionCheck[$actionBase[$state] + $symbol] != $symbol
|
|
85
72
|
* then the action is defaulted, i.e. $actionDefault[$state] should be used instead. */
|
|
86
|
-
protected
|
|
73
|
+
protected $actionCheck;
|
|
87
74
|
/** @var int[] Map of states to their default action */
|
|
88
|
-
protected
|
|
75
|
+
protected $actionDefault;
|
|
89
76
|
/** @var callable[] Semantic action callbacks */
|
|
90
|
-
protected
|
|
77
|
+
protected $reduceCallbacks;
|
|
91
78
|
|
|
92
79
|
/** @var int[] Map of non-terminals to a displacement into the $goto table. The corresponding goto state for this
|
|
93
80
|
* non-terminal/state pair is $goto[$gotoBase[$nonTerminal] + $state] (unless defaulted) */
|
|
94
|
-
protected
|
|
81
|
+
protected $gotoBase;
|
|
95
82
|
/** @var int[] Table of states to goto after reduction. Indexed according to $gotoBase comment. */
|
|
96
|
-
protected
|
|
83
|
+
protected $goto;
|
|
97
84
|
/** @var int[] Table indexed analogously to $goto. If $gotoCheck[$gotoBase[$nonTerminal] + $state] != $nonTerminal
|
|
98
85
|
* then the goto state is defaulted, i.e. $gotoDefault[$nonTerminal] should be used. */
|
|
99
|
-
protected
|
|
86
|
+
protected $gotoCheck;
|
|
100
87
|
/** @var int[] Map of non-terminals to the default state to goto after their reduction */
|
|
101
|
-
protected
|
|
88
|
+
protected $gotoDefault;
|
|
102
89
|
|
|
103
90
|
/** @var int[] Map of rules to the non-terminal on their left-hand side, i.e. the non-terminal to use for
|
|
104
91
|
* determining the state to goto after reduction. */
|
|
105
|
-
protected
|
|
92
|
+
protected $ruleToNonTerminal;
|
|
106
93
|
/** @var int[] Map of rules to the length of their right-hand side, which is the number of elements that have to
|
|
107
94
|
* be popped from the stack(s) on reduction. */
|
|
108
|
-
protected
|
|
95
|
+
protected $ruleToLength;
|
|
109
96
|
|
|
110
97
|
/*
|
|
111
98
|
* The following members are part of the parser state:
|
|
112
99
|
*/
|
|
113
100
|
|
|
101
|
+
/** @var Lexer Lexer that is used when parsing */
|
|
102
|
+
protected $lexer;
|
|
114
103
|
/** @var mixed Temporary value containing the result of last semantic action (reduction) */
|
|
115
104
|
protected $semValue;
|
|
116
|
-
/** @var
|
|
117
|
-
protected
|
|
118
|
-
/** @var
|
|
119
|
-
protected
|
|
120
|
-
/** @var
|
|
121
|
-
protected
|
|
105
|
+
/** @var array Semantic value stack (contains values of tokens and semantic action results) */
|
|
106
|
+
protected $semStack;
|
|
107
|
+
/** @var array[] Start attribute stack */
|
|
108
|
+
protected $startAttributeStack;
|
|
109
|
+
/** @var array[] End attribute stack */
|
|
110
|
+
protected $endAttributeStack;
|
|
111
|
+
/** @var array End attributes of last *shifted* token */
|
|
112
|
+
protected $endAttributes;
|
|
113
|
+
/** @var array Start attributes of last *read* token */
|
|
114
|
+
protected $lookaheadStartAttributes;
|
|
122
115
|
|
|
123
116
|
/** @var ErrorHandler Error handler */
|
|
124
|
-
protected
|
|
117
|
+
protected $errorHandler;
|
|
125
118
|
/** @var int Error state, used to avoid error floods */
|
|
126
|
-
protected
|
|
127
|
-
|
|
128
|
-
/** @var \SplObjectStorage<Array_, null>|null Array nodes created during parsing, for postprocessing of empty elements. */
|
|
129
|
-
protected ?\SplObjectStorage $createdArrays;
|
|
130
|
-
|
|
131
|
-
/** @var Token[] Tokens for the current parse */
|
|
132
|
-
protected array $tokens;
|
|
133
|
-
/** @var int Current position in token array */
|
|
134
|
-
protected int $tokenPos;
|
|
119
|
+
protected $errorState;
|
|
135
120
|
|
|
136
121
|
/**
|
|
137
122
|
* Initialize $reduceCallbacks map.
|
|
138
123
|
*/
|
|
139
|
-
abstract protected function initReduceCallbacks()
|
|
124
|
+
abstract protected function initReduceCallbacks();
|
|
140
125
|
|
|
141
126
|
/**
|
|
142
127
|
* Creates a parser instance.
|
|
143
128
|
*
|
|
144
|
-
* Options:
|
|
145
|
-
* * phpVersion: ?PhpVersion,
|
|
129
|
+
* Options: Currently none.
|
|
146
130
|
*
|
|
147
131
|
* @param Lexer $lexer A lexer
|
|
148
|
-
* @param
|
|
149
|
-
* option is best-effort: Even if specified, parsing will generally assume the latest
|
|
150
|
-
* supported version and only adjust behavior in minor ways, for example by omitting
|
|
151
|
-
* errors in older versions and interpreting type hints as a name or identifier depending
|
|
152
|
-
* on version.
|
|
132
|
+
* @param array $options Options array.
|
|
153
133
|
*/
|
|
154
|
-
public function __construct(Lexer $lexer,
|
|
134
|
+
public function __construct(Lexer $lexer, array $options = []) {
|
|
155
135
|
$this->lexer = $lexer;
|
|
156
|
-
|
|
136
|
+
|
|
137
|
+
if (isset($options['throwOnError'])) {
|
|
138
|
+
throw new \LogicException(
|
|
139
|
+
'"throwOnError" is no longer supported, use "errorHandler" instead');
|
|
140
|
+
}
|
|
157
141
|
|
|
158
142
|
$this->initReduceCallbacks();
|
|
159
|
-
$this->phpTokenToSymbol = $this->createTokenMap();
|
|
160
|
-
$this->dropTokens = array_fill_keys(
|
|
161
|
-
[\T_WHITESPACE, \T_OPEN_TAG, \T_COMMENT, \T_DOC_COMMENT, \T_BAD_CHARACTER], true
|
|
162
|
-
);
|
|
163
143
|
}
|
|
164
144
|
|
|
165
145
|
/**
|
|
@@ -175,55 +155,36 @@ abstract class ParserAbstract implements Parser {
|
|
|
175
155
|
* @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and
|
|
176
156
|
* the parser was unable to recover from an error).
|
|
177
157
|
*/
|
|
178
|
-
public function parse(string $code,
|
|
179
|
-
$this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing
|
|
180
|
-
$this->createdArrays = new \SplObjectStorage();
|
|
158
|
+
public function parse(string $code, ErrorHandler $errorHandler = null) {
|
|
159
|
+
$this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing;
|
|
181
160
|
|
|
182
|
-
$this->
|
|
161
|
+
$this->lexer->startLexing($code, $this->errorHandler);
|
|
183
162
|
$result = $this->doParse();
|
|
184
163
|
|
|
185
|
-
// Report errors for any empty elements used inside arrays. This is delayed until after the main parse,
|
|
186
|
-
// because we don't know a priori whether a given array expression will be used in a destructuring context
|
|
187
|
-
// or not.
|
|
188
|
-
foreach ($this->createdArrays as $node) {
|
|
189
|
-
foreach ($node->items as $item) {
|
|
190
|
-
if ($item->value instanceof Expr\Error) {
|
|
191
|
-
$this->errorHandler->handleError(
|
|
192
|
-
new Error('Cannot use empty array elements in arrays', $item->getAttributes()));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
164
|
// Clear out some of the interior state, so we don't hold onto unnecessary
|
|
198
165
|
// memory between uses of the parser
|
|
199
|
-
$this->
|
|
200
|
-
$this->
|
|
166
|
+
$this->startAttributeStack = [];
|
|
167
|
+
$this->endAttributeStack = [];
|
|
201
168
|
$this->semStack = [];
|
|
202
169
|
$this->semValue = null;
|
|
203
|
-
$this->createdArrays = null;
|
|
204
|
-
|
|
205
|
-
if ($result !== null) {
|
|
206
|
-
$traverser = new NodeTraverser(new CommentAnnotatingVisitor($this->tokens));
|
|
207
|
-
$traverser->traverse($result);
|
|
208
|
-
}
|
|
209
170
|
|
|
210
171
|
return $result;
|
|
211
172
|
}
|
|
212
173
|
|
|
213
|
-
|
|
214
|
-
return $this->tokens;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/** @return Stmt[]|null */
|
|
218
|
-
protected function doParse(): ?array {
|
|
174
|
+
protected function doParse() {
|
|
219
175
|
// We start off with no lookahead-token
|
|
220
176
|
$symbol = self::SYMBOL_NONE;
|
|
221
|
-
|
|
222
|
-
|
|
177
|
+
|
|
178
|
+
// The attributes for a node are taken from the first and last token of the node.
|
|
179
|
+
// From the first token only the startAttributes are taken and from the last only
|
|
180
|
+
// the endAttributes. Both are merged using the array union operator (+).
|
|
181
|
+
$startAttributes = [];
|
|
182
|
+
$endAttributes = [];
|
|
183
|
+
$this->endAttributes = $endAttributes;
|
|
223
184
|
|
|
224
185
|
// Keep stack of start and end attributes
|
|
225
|
-
$this->
|
|
226
|
-
$this->
|
|
186
|
+
$this->startAttributeStack = [];
|
|
187
|
+
$this->endAttributeStack = [$endAttributes];
|
|
227
188
|
|
|
228
189
|
// Start off in the initial state and keep a stack of previous states
|
|
229
190
|
$state = 0;
|
|
@@ -244,20 +205,26 @@ abstract class ParserAbstract implements Parser {
|
|
|
244
205
|
$rule = $this->actionDefault[$state];
|
|
245
206
|
} else {
|
|
246
207
|
if ($symbol === self::SYMBOL_NONE) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
208
|
+
// Fetch the next token id from the lexer and fetch additional info by-ref.
|
|
209
|
+
// The end attributes are fetched into a temporary variable and only set once the token is really
|
|
210
|
+
// shifted (not during read). Otherwise you would sometimes get off-by-one errors, when a rule is
|
|
211
|
+
// reduced after a token was read but not yet shifted.
|
|
212
|
+
$tokenId = $this->lexer->getNextToken($tokenValue, $startAttributes, $endAttributes);
|
|
213
|
+
|
|
214
|
+
// map the lexer token id to the internally used symbols
|
|
215
|
+
$symbol = $tokenId >= 0 && $tokenId < $this->tokenToSymbolMapSize
|
|
216
|
+
? $this->tokenToSymbol[$tokenId]
|
|
217
|
+
: $this->invalidSymbol;
|
|
218
|
+
|
|
219
|
+
if ($symbol === $this->invalidSymbol) {
|
|
255
220
|
throw new \RangeException(sprintf(
|
|
256
221
|
'The lexer returned an invalid token (id=%d, value=%s)',
|
|
257
222
|
$tokenId, $tokenValue
|
|
258
223
|
));
|
|
259
224
|
}
|
|
260
|
-
|
|
225
|
+
|
|
226
|
+
// Allow productions to access the start attributes of the lookahead token.
|
|
227
|
+
$this->lookaheadStartAttributes = $startAttributes;
|
|
261
228
|
|
|
262
229
|
//$this->traceRead($symbol);
|
|
263
230
|
}
|
|
@@ -282,8 +249,9 @@ abstract class ParserAbstract implements Parser {
|
|
|
282
249
|
++$stackPos;
|
|
283
250
|
$stateStack[$stackPos] = $state = $action;
|
|
284
251
|
$this->semStack[$stackPos] = $tokenValue;
|
|
285
|
-
$this->
|
|
286
|
-
$this->
|
|
252
|
+
$this->startAttributeStack[$stackPos] = $startAttributes;
|
|
253
|
+
$this->endAttributeStack[$stackPos] = $endAttributes;
|
|
254
|
+
$this->endAttributes = $endAttributes;
|
|
287
255
|
$symbol = self::SYMBOL_NONE;
|
|
288
256
|
|
|
289
257
|
if ($this->errorState) {
|
|
@@ -309,22 +277,15 @@ abstract class ParserAbstract implements Parser {
|
|
|
309
277
|
/* accept */
|
|
310
278
|
//$this->traceAccept();
|
|
311
279
|
return $this->semValue;
|
|
312
|
-
}
|
|
313
|
-
if ($rule !== $this->unexpectedTokenRule) {
|
|
280
|
+
} elseif ($rule !== $this->unexpectedTokenRule) {
|
|
314
281
|
/* reduce */
|
|
315
282
|
//$this->traceReduce($rule);
|
|
316
283
|
|
|
317
|
-
$ruleLength = $this->ruleToLength[$rule];
|
|
318
284
|
try {
|
|
319
|
-
$
|
|
320
|
-
if ($callback !== null) {
|
|
321
|
-
$callback($stackPos);
|
|
322
|
-
} elseif ($ruleLength > 0) {
|
|
323
|
-
$this->semValue = $this->semStack[$stackPos - $ruleLength + 1];
|
|
324
|
-
}
|
|
285
|
+
$this->reduceCallbacks[$rule]($stackPos);
|
|
325
286
|
} catch (Error $e) {
|
|
326
|
-
if (-1 === $e->getStartLine()) {
|
|
327
|
-
$e->setStartLine($
|
|
287
|
+
if (-1 === $e->getStartLine() && isset($startAttributes['startLine'])) {
|
|
288
|
+
$e->setStartLine($startAttributes['startLine']);
|
|
328
289
|
}
|
|
329
290
|
|
|
330
291
|
$this->emitError($e);
|
|
@@ -333,7 +294,8 @@ abstract class ParserAbstract implements Parser {
|
|
|
333
294
|
}
|
|
334
295
|
|
|
335
296
|
/* Goto - shift nonterminal */
|
|
336
|
-
$
|
|
297
|
+
$lastEndAttributes = $this->endAttributeStack[$stackPos];
|
|
298
|
+
$ruleLength = $this->ruleToLength[$rule];
|
|
337
299
|
$stackPos -= $ruleLength;
|
|
338
300
|
$nonTerminal = $this->ruleToNonTerminal[$rule];
|
|
339
301
|
$idx = $this->gotoBase[$nonTerminal] + $stateStack[$stackPos];
|
|
@@ -346,19 +308,18 @@ abstract class ParserAbstract implements Parser {
|
|
|
346
308
|
++$stackPos;
|
|
347
309
|
$stateStack[$stackPos] = $state;
|
|
348
310
|
$this->semStack[$stackPos] = $this->semValue;
|
|
349
|
-
$this->
|
|
311
|
+
$this->endAttributeStack[$stackPos] = $lastEndAttributes;
|
|
350
312
|
if ($ruleLength === 0) {
|
|
351
313
|
// Empty productions use the start attributes of the lookahead token.
|
|
352
|
-
$this->
|
|
314
|
+
$this->startAttributeStack[$stackPos] = $this->lookaheadStartAttributes;
|
|
353
315
|
}
|
|
354
316
|
} else {
|
|
355
317
|
/* error */
|
|
356
318
|
switch ($this->errorState) {
|
|
357
319
|
case 0:
|
|
358
320
|
$msg = $this->getErrorMessage($symbol, $state);
|
|
359
|
-
$this->emitError(new Error($msg, $
|
|
321
|
+
$this->emitError(new Error($msg, $startAttributes + $endAttributes));
|
|
360
322
|
// Break missing intentionally
|
|
361
|
-
// no break
|
|
362
323
|
case 1:
|
|
363
324
|
case 2:
|
|
364
325
|
$this->errorState = 3;
|
|
@@ -385,8 +346,9 @@ abstract class ParserAbstract implements Parser {
|
|
|
385
346
|
|
|
386
347
|
// We treat the error symbol as being empty, so we reset the end attributes
|
|
387
348
|
// to the end attributes of the last non-error symbol
|
|
388
|
-
$this->
|
|
389
|
-
$this->
|
|
349
|
+
$this->startAttributeStack[$stackPos] = $this->lookaheadStartAttributes;
|
|
350
|
+
$this->endAttributeStack[$stackPos] = $this->endAttributeStack[$stackPos - 1];
|
|
351
|
+
$this->endAttributes = $this->endAttributeStack[$stackPos - 1];
|
|
390
352
|
break;
|
|
391
353
|
|
|
392
354
|
case 3:
|
|
@@ -413,7 +375,7 @@ abstract class ParserAbstract implements Parser {
|
|
|
413
375
|
throw new \RuntimeException('Reached end of parser loop');
|
|
414
376
|
}
|
|
415
377
|
|
|
416
|
-
protected function emitError(Error $error)
|
|
378
|
+
protected function emitError(Error $error) {
|
|
417
379
|
$this->errorHandler->handleError($error);
|
|
418
380
|
}
|
|
419
381
|
|
|
@@ -421,11 +383,11 @@ abstract class ParserAbstract implements Parser {
|
|
|
421
383
|
* Format error message including expected tokens.
|
|
422
384
|
*
|
|
423
385
|
* @param int $symbol Unexpected symbol
|
|
424
|
-
* @param int $state
|
|
386
|
+
* @param int $state State at time of error
|
|
425
387
|
*
|
|
426
388
|
* @return string Formatted error message
|
|
427
389
|
*/
|
|
428
|
-
protected function getErrorMessage(int $symbol, int $state): string {
|
|
390
|
+
protected function getErrorMessage(int $symbol, int $state) : string {
|
|
429
391
|
$expectedString = '';
|
|
430
392
|
if ($expected = $this->getExpectedTokens($state)) {
|
|
431
393
|
$expectedString = ', expecting ' . implode(' or ', $expected);
|
|
@@ -441,7 +403,7 @@ abstract class ParserAbstract implements Parser {
|
|
|
441
403
|
*
|
|
442
404
|
* @return string[] Expected tokens. If too many, an empty array is returned.
|
|
443
405
|
*/
|
|
444
|
-
protected function getExpectedTokens(int $state): array {
|
|
406
|
+
protected function getExpectedTokens(int $state) : array {
|
|
445
407
|
$expected = [];
|
|
446
408
|
|
|
447
409
|
$base = $this->actionBase[$state];
|
|
@@ -469,79 +431,37 @@ abstract class ParserAbstract implements Parser {
|
|
|
469
431
|
return $expected;
|
|
470
432
|
}
|
|
471
433
|
|
|
472
|
-
/**
|
|
473
|
-
* Get attributes for a node with the given start and end token positions.
|
|
474
|
-
*
|
|
475
|
-
* @param int $tokenStartPos Token position the node starts at
|
|
476
|
-
* @param int $tokenEndPos Token position the node ends at
|
|
477
|
-
* @return array<string, mixed> Attributes
|
|
478
|
-
*/
|
|
479
|
-
protected function getAttributes(int $tokenStartPos, int $tokenEndPos): array {
|
|
480
|
-
$startToken = $this->tokens[$tokenStartPos];
|
|
481
|
-
$afterEndToken = $this->tokens[$tokenEndPos + 1];
|
|
482
|
-
return [
|
|
483
|
-
'startLine' => $startToken->line,
|
|
484
|
-
'startTokenPos' => $tokenStartPos,
|
|
485
|
-
'startFilePos' => $startToken->pos,
|
|
486
|
-
'endLine' => $afterEndToken->line,
|
|
487
|
-
'endTokenPos' => $tokenEndPos,
|
|
488
|
-
'endFilePos' => $afterEndToken->pos - 1,
|
|
489
|
-
];
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* Get attributes for a single token at the given token position.
|
|
494
|
-
*
|
|
495
|
-
* @return array<string, mixed> Attributes
|
|
496
|
-
*/
|
|
497
|
-
protected function getAttributesForToken(int $tokenPos): array {
|
|
498
|
-
if ($tokenPos < \count($this->tokens) - 1) {
|
|
499
|
-
return $this->getAttributes($tokenPos, $tokenPos);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
// Get attributes for the sentinel token.
|
|
503
|
-
$token = $this->tokens[$tokenPos];
|
|
504
|
-
return [
|
|
505
|
-
'startLine' => $token->line,
|
|
506
|
-
'startTokenPos' => $tokenPos,
|
|
507
|
-
'startFilePos' => $token->pos,
|
|
508
|
-
'endLine' => $token->line,
|
|
509
|
-
'endTokenPos' => $tokenPos,
|
|
510
|
-
'endFilePos' => $token->pos,
|
|
511
|
-
];
|
|
512
|
-
}
|
|
513
|
-
|
|
514
434
|
/*
|
|
515
435
|
* Tracing functions used for debugging the parser.
|
|
516
436
|
*/
|
|
517
437
|
|
|
518
438
|
/*
|
|
519
|
-
protected function traceNewState($state, $symbol)
|
|
439
|
+
protected function traceNewState($state, $symbol) {
|
|
520
440
|
echo '% State ' . $state
|
|
521
441
|
. ', Lookahead ' . ($symbol == self::SYMBOL_NONE ? '--none--' : $this->symbolToName[$symbol]) . "\n";
|
|
522
442
|
}
|
|
523
443
|
|
|
524
|
-
protected function traceRead($symbol)
|
|
444
|
+
protected function traceRead($symbol) {
|
|
525
445
|
echo '% Reading ' . $this->symbolToName[$symbol] . "\n";
|
|
526
446
|
}
|
|
527
447
|
|
|
528
|
-
protected function traceShift($symbol)
|
|
448
|
+
protected function traceShift($symbol) {
|
|
529
449
|
echo '% Shift ' . $this->symbolToName[$symbol] . "\n";
|
|
530
450
|
}
|
|
531
451
|
|
|
532
|
-
protected function traceAccept()
|
|
452
|
+
protected function traceAccept() {
|
|
533
453
|
echo "% Accepted.\n";
|
|
534
454
|
}
|
|
535
455
|
|
|
536
|
-
protected function traceReduce($n)
|
|
456
|
+
protected function traceReduce($n) {
|
|
537
457
|
echo '% Reduce by (' . $n . ') ' . $this->productions[$n] . "\n";
|
|
538
458
|
}
|
|
539
459
|
|
|
540
|
-
protected function tracePop($state)
|
|
460
|
+
protected function tracePop($state) {
|
|
541
461
|
echo '% Recovering, uncovered state ' . $state . "\n";
|
|
542
462
|
}
|
|
543
463
|
|
|
544
|
-
protected function traceDiscard($symbol)
|
|
464
|
+
protected function traceDiscard($symbol) {
|
|
545
465
|
echo '% Discard ' . $this->symbolToName[$symbol] . "\n";
|
|
546
466
|
}
|
|
547
467
|
*/
|
|
@@ -556,14 +476,13 @@ abstract class ParserAbstract implements Parser {
|
|
|
556
476
|
* @param Node\Stmt[] $stmts
|
|
557
477
|
* @return Node\Stmt[]
|
|
558
478
|
*/
|
|
559
|
-
protected function handleNamespaces(array $stmts): array {
|
|
479
|
+
protected function handleNamespaces(array $stmts) : array {
|
|
560
480
|
$hasErrored = false;
|
|
561
481
|
$style = $this->getNamespacingStyle($stmts);
|
|
562
482
|
if (null === $style) {
|
|
563
483
|
// not namespaced, nothing to do
|
|
564
484
|
return $stmts;
|
|
565
|
-
}
|
|
566
|
-
if ('brace' === $style) {
|
|
485
|
+
} elseif ('brace' === $style) {
|
|
567
486
|
// For braced namespaces we only have to check that there are no invalid statements between the namespaces
|
|
568
487
|
$afterFirstNamespace = false;
|
|
569
488
|
foreach ($stmts as $stmt) {
|
|
@@ -581,7 +500,7 @@ abstract class ParserAbstract implements Parser {
|
|
|
581
500
|
} else {
|
|
582
501
|
// For semicolon namespaces we have to move the statements after a namespace declaration into ->stmts
|
|
583
502
|
$resultStmts = [];
|
|
584
|
-
$targetStmts
|
|
503
|
+
$targetStmts =& $resultStmts;
|
|
585
504
|
$lastNs = null;
|
|
586
505
|
foreach ($stmts as $stmt) {
|
|
587
506
|
if ($stmt instanceof Node\Stmt\Namespace_) {
|
|
@@ -590,12 +509,12 @@ abstract class ParserAbstract implements Parser {
|
|
|
590
509
|
}
|
|
591
510
|
if ($stmt->stmts === null) {
|
|
592
511
|
$stmt->stmts = [];
|
|
593
|
-
$targetStmts
|
|
512
|
+
$targetStmts =& $stmt->stmts;
|
|
594
513
|
$resultStmts[] = $stmt;
|
|
595
514
|
} else {
|
|
596
515
|
// This handles the invalid case of mixed style namespaces
|
|
597
516
|
$resultStmts[] = $stmt;
|
|
598
|
-
$targetStmts
|
|
517
|
+
$targetStmts =& $resultStmts;
|
|
599
518
|
}
|
|
600
519
|
$lastNs = $stmt;
|
|
601
520
|
} elseif ($stmt instanceof Node\Stmt\HaltCompiler) {
|
|
@@ -612,7 +531,7 @@ abstract class ParserAbstract implements Parser {
|
|
|
612
531
|
}
|
|
613
532
|
}
|
|
614
533
|
|
|
615
|
-
private function fixupNamespaceAttributes(Node\Stmt\Namespace_ $stmt)
|
|
534
|
+
private function fixupNamespaceAttributes(Node\Stmt\Namespace_ $stmt) {
|
|
616
535
|
// We moved the statements into the namespace node, as such the end of the namespace node
|
|
617
536
|
// needs to be extended to the end of the statements.
|
|
618
537
|
if (empty($stmt->stmts)) {
|
|
@@ -630,22 +549,6 @@ abstract class ParserAbstract implements Parser {
|
|
|
630
549
|
}
|
|
631
550
|
}
|
|
632
551
|
|
|
633
|
-
/** @return array<string, mixed> */
|
|
634
|
-
private function getNamespaceErrorAttributes(Namespace_ $node): array {
|
|
635
|
-
$attrs = $node->getAttributes();
|
|
636
|
-
// Adjust end attributes to only cover the "namespace" keyword, not the whole namespace.
|
|
637
|
-
if (isset($attrs['startLine'])) {
|
|
638
|
-
$attrs['endLine'] = $attrs['startLine'];
|
|
639
|
-
}
|
|
640
|
-
if (isset($attrs['startTokenPos'])) {
|
|
641
|
-
$attrs['endTokenPos'] = $attrs['startTokenPos'];
|
|
642
|
-
}
|
|
643
|
-
if (isset($attrs['startFilePos'])) {
|
|
644
|
-
$attrs['endFilePos'] = $attrs['startFilePos'] + \strlen('namespace') - 1;
|
|
645
|
-
}
|
|
646
|
-
return $attrs;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
552
|
/**
|
|
650
553
|
* Determine namespacing style (semicolon or brace)
|
|
651
554
|
*
|
|
@@ -653,7 +556,7 @@ abstract class ParserAbstract implements Parser {
|
|
|
653
556
|
*
|
|
654
557
|
* @return null|string One of "semicolon", "brace" or null (no namespaces)
|
|
655
558
|
*/
|
|
656
|
-
private function getNamespacingStyle(array $stmts)
|
|
559
|
+
private function getNamespacingStyle(array $stmts) {
|
|
657
560
|
$style = null;
|
|
658
561
|
$hasNotAllowedStmts = false;
|
|
659
562
|
foreach ($stmts as $i => $stmt) {
|
|
@@ -664,13 +567,13 @@ abstract class ParserAbstract implements Parser {
|
|
|
664
567
|
if ($hasNotAllowedStmts) {
|
|
665
568
|
$this->emitError(new Error(
|
|
666
569
|
'Namespace declaration statement has to be the very first statement in the script',
|
|
667
|
-
$
|
|
570
|
+
$stmt->getLine() // Avoid marking the entire namespace as an error
|
|
668
571
|
));
|
|
669
572
|
}
|
|
670
573
|
} elseif ($style !== $currentStyle) {
|
|
671
574
|
$this->emitError(new Error(
|
|
672
575
|
'Cannot mix bracketed namespace declarations with unbracketed namespace declarations',
|
|
673
|
-
$
|
|
576
|
+
$stmt->getLine() // Avoid marking the entire namespace as an error
|
|
674
577
|
));
|
|
675
578
|
// Treat like semicolon style for namespace normalization
|
|
676
579
|
return 'semicolon';
|
|
@@ -696,14 +599,83 @@ abstract class ParserAbstract implements Parser {
|
|
|
696
599
|
return $style;
|
|
697
600
|
}
|
|
698
601
|
|
|
699
|
-
/**
|
|
602
|
+
/**
|
|
603
|
+
* Fix up parsing of static property calls in PHP 5.
|
|
604
|
+
*
|
|
605
|
+
* In PHP 5 A::$b[c][d] and A::$b[c][d]() have very different interpretation. The former is
|
|
606
|
+
* interpreted as (A::$b)[c][d], while the latter is the same as A::{$b[c][d]}(). We parse the
|
|
607
|
+
* latter as the former initially and this method fixes the AST into the correct form when we
|
|
608
|
+
* encounter the "()".
|
|
609
|
+
*
|
|
610
|
+
* @param Node\Expr\StaticPropertyFetch|Node\Expr\ArrayDimFetch $prop
|
|
611
|
+
* @param Node\Arg[] $args
|
|
612
|
+
* @param array $attributes
|
|
613
|
+
*
|
|
614
|
+
* @return Expr\StaticCall
|
|
615
|
+
*/
|
|
616
|
+
protected function fixupPhp5StaticPropCall($prop, array $args, array $attributes) : Expr\StaticCall {
|
|
617
|
+
if ($prop instanceof Node\Expr\StaticPropertyFetch) {
|
|
618
|
+
$name = $prop->name instanceof VarLikeIdentifier
|
|
619
|
+
? $prop->name->toString() : $prop->name;
|
|
620
|
+
$var = new Expr\Variable($name, $prop->name->getAttributes());
|
|
621
|
+
return new Expr\StaticCall($prop->class, $var, $args, $attributes);
|
|
622
|
+
} elseif ($prop instanceof Node\Expr\ArrayDimFetch) {
|
|
623
|
+
$tmp = $prop;
|
|
624
|
+
while ($tmp->var instanceof Node\Expr\ArrayDimFetch) {
|
|
625
|
+
$tmp = $tmp->var;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/** @var Expr\StaticPropertyFetch $staticProp */
|
|
629
|
+
$staticProp = $tmp->var;
|
|
630
|
+
|
|
631
|
+
// Set start attributes to attributes of innermost node
|
|
632
|
+
$tmp = $prop;
|
|
633
|
+
$this->fixupStartAttributes($tmp, $staticProp->name);
|
|
634
|
+
while ($tmp->var instanceof Node\Expr\ArrayDimFetch) {
|
|
635
|
+
$tmp = $tmp->var;
|
|
636
|
+
$this->fixupStartAttributes($tmp, $staticProp->name);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
$name = $staticProp->name instanceof VarLikeIdentifier
|
|
640
|
+
? $staticProp->name->toString() : $staticProp->name;
|
|
641
|
+
$tmp->var = new Expr\Variable($name, $staticProp->name->getAttributes());
|
|
642
|
+
return new Expr\StaticCall($staticProp->class, $prop, $args, $attributes);
|
|
643
|
+
} else {
|
|
644
|
+
throw new \Exception;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
protected function fixupStartAttributes(Node $to, Node $from) {
|
|
649
|
+
$startAttributes = ['startLine', 'startFilePos', 'startTokenPos'];
|
|
650
|
+
foreach ($startAttributes as $startAttribute) {
|
|
651
|
+
if ($from->hasAttribute($startAttribute)) {
|
|
652
|
+
$to->setAttribute($startAttribute, $from->getAttribute($startAttribute));
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
700
657
|
protected function handleBuiltinTypes(Name $name) {
|
|
658
|
+
$builtinTypes = [
|
|
659
|
+
'bool' => true,
|
|
660
|
+
'int' => true,
|
|
661
|
+
'float' => true,
|
|
662
|
+
'string' => true,
|
|
663
|
+
'iterable' => true,
|
|
664
|
+
'void' => true,
|
|
665
|
+
'object' => true,
|
|
666
|
+
'null' => true,
|
|
667
|
+
'false' => true,
|
|
668
|
+
'mixed' => true,
|
|
669
|
+
'never' => true,
|
|
670
|
+
'true' => true,
|
|
671
|
+
];
|
|
672
|
+
|
|
701
673
|
if (!$name->isUnqualified()) {
|
|
702
674
|
return $name;
|
|
703
675
|
}
|
|
704
676
|
|
|
705
677
|
$lowerName = $name->toLowerString();
|
|
706
|
-
if (
|
|
678
|
+
if (!isset($builtinTypes[$lowerName])) {
|
|
707
679
|
return $name;
|
|
708
680
|
}
|
|
709
681
|
|
|
@@ -713,15 +685,16 @@ abstract class ParserAbstract implements Parser {
|
|
|
713
685
|
/**
|
|
714
686
|
* Get combined start and end attributes at a stack location
|
|
715
687
|
*
|
|
716
|
-
* @param int $
|
|
688
|
+
* @param int $pos Stack location
|
|
717
689
|
*
|
|
718
|
-
* @return array
|
|
690
|
+
* @return array Combined start and end attributes
|
|
719
691
|
*/
|
|
720
|
-
protected function getAttributesAt(int $
|
|
721
|
-
return $this->
|
|
692
|
+
protected function getAttributesAt(int $pos) : array {
|
|
693
|
+
return $this->startAttributeStack[$pos] + $this->endAttributeStack[$pos];
|
|
722
694
|
}
|
|
723
695
|
|
|
724
|
-
protected function getFloatCastKind(string $cast): int
|
|
696
|
+
protected function getFloatCastKind(string $cast): int
|
|
697
|
+
{
|
|
725
698
|
$cast = strtolower($cast);
|
|
726
699
|
if (strpos($cast, 'float') !== false) {
|
|
727
700
|
return Double::KIND_FLOAT;
|
|
@@ -734,24 +707,23 @@ abstract class ParserAbstract implements Parser {
|
|
|
734
707
|
return Double::KIND_DOUBLE;
|
|
735
708
|
}
|
|
736
709
|
|
|
737
|
-
|
|
738
|
-
protected function parseLNumber(string $str, array $attributes, bool $allowInvalidOctal = false): Int_ {
|
|
710
|
+
protected function parseLNumber($str, $attributes, $allowInvalidOctal = false) {
|
|
739
711
|
try {
|
|
740
|
-
return
|
|
712
|
+
return LNumber::fromString($str, $attributes, $allowInvalidOctal);
|
|
741
713
|
} catch (Error $error) {
|
|
742
714
|
$this->emitError($error);
|
|
743
715
|
// Use dummy value
|
|
744
|
-
return new
|
|
716
|
+
return new LNumber(0, $attributes);
|
|
745
717
|
}
|
|
746
718
|
}
|
|
747
719
|
|
|
748
720
|
/**
|
|
749
721
|
* Parse a T_NUM_STRING token into either an integer or string node.
|
|
750
722
|
*
|
|
751
|
-
* @param string $str
|
|
752
|
-
* @param array
|
|
723
|
+
* @param string $str Number string
|
|
724
|
+
* @param array $attributes Attributes
|
|
753
725
|
*
|
|
754
|
-
* @return
|
|
726
|
+
* @return LNumber|String_ Integer or string node.
|
|
755
727
|
*/
|
|
756
728
|
protected function parseNumString(string $str, array $attributes) {
|
|
757
729
|
if (!preg_match('/^(?:0|-?[1-9][0-9]*)$/', $str)) {
|
|
@@ -763,14 +735,13 @@ abstract class ParserAbstract implements Parser {
|
|
|
763
735
|
return new String_($str, $attributes);
|
|
764
736
|
}
|
|
765
737
|
|
|
766
|
-
return new
|
|
738
|
+
return new LNumber($num, $attributes);
|
|
767
739
|
}
|
|
768
740
|
|
|
769
|
-
/** @param array<string, mixed> $attributes */
|
|
770
741
|
protected function stripIndentation(
|
|
771
742
|
string $string, int $indentLen, string $indentChar,
|
|
772
743
|
bool $newlineAtStart, bool $newlineAtEnd, array $attributes
|
|
773
|
-
)
|
|
744
|
+
) {
|
|
774
745
|
if ($indentLen === 0) {
|
|
775
746
|
return $string;
|
|
776
747
|
}
|
|
@@ -799,15 +770,10 @@ abstract class ParserAbstract implements Parser {
|
|
|
799
770
|
);
|
|
800
771
|
}
|
|
801
772
|
|
|
802
|
-
/**
|
|
803
|
-
* @param string|(Expr|InterpolatedStringPart)[] $contents
|
|
804
|
-
* @param array<string, mixed> $attributes
|
|
805
|
-
* @param array<string, mixed> $endTokenAttributes
|
|
806
|
-
*/
|
|
807
773
|
protected function parseDocString(
|
|
808
774
|
string $startToken, $contents, string $endToken,
|
|
809
775
|
array $attributes, array $endTokenAttributes, bool $parseUnicodeEscape
|
|
810
|
-
)
|
|
776
|
+
) {
|
|
811
777
|
$kind = strpos($startToken, "'") === false
|
|
812
778
|
? String_::KIND_HEREDOC : String_::KIND_NOWDOC;
|
|
813
779
|
|
|
@@ -841,7 +807,6 @@ abstract class ParserAbstract implements Parser {
|
|
|
841
807
|
|
|
842
808
|
if (\is_string($contents)) {
|
|
843
809
|
if ($contents === '') {
|
|
844
|
-
$attributes['rawValue'] = $contents;
|
|
845
810
|
return new String_('', $attributes);
|
|
846
811
|
}
|
|
847
812
|
|
|
@@ -849,7 +814,6 @@ abstract class ParserAbstract implements Parser {
|
|
|
849
814
|
$contents, $indentLen, $indentChar, true, true, $attributes
|
|
850
815
|
);
|
|
851
816
|
$contents = preg_replace('~(\r\n|\n|\r)\z~', '', $contents);
|
|
852
|
-
$attributes['rawValue'] = $contents;
|
|
853
817
|
|
|
854
818
|
if ($kind === String_::KIND_HEREDOC) {
|
|
855
819
|
$contents = String_::parseEscapeSequences($contents, null, $parseUnicodeEscape);
|
|
@@ -858,7 +822,7 @@ abstract class ParserAbstract implements Parser {
|
|
|
858
822
|
return new String_($contents, $attributes);
|
|
859
823
|
} else {
|
|
860
824
|
assert(count($contents) > 0);
|
|
861
|
-
if (!$contents[0] instanceof Node\
|
|
825
|
+
if (!$contents[0] instanceof Node\Scalar\EncapsedStringPart) {
|
|
862
826
|
// If there is no leading encapsed string part, pretend there is an empty one
|
|
863
827
|
$this->stripIndentation(
|
|
864
828
|
'', $indentLen, $indentChar, true, false, $contents[0]->getAttributes()
|
|
@@ -867,139 +831,56 @@ abstract class ParserAbstract implements Parser {
|
|
|
867
831
|
|
|
868
832
|
$newContents = [];
|
|
869
833
|
foreach ($contents as $i => $part) {
|
|
870
|
-
if ($part instanceof Node\
|
|
834
|
+
if ($part instanceof Node\Scalar\EncapsedStringPart) {
|
|
871
835
|
$isLast = $i === \count($contents) - 1;
|
|
872
836
|
$part->value = $this->stripIndentation(
|
|
873
837
|
$part->value, $indentLen, $indentChar,
|
|
874
838
|
$i === 0, $isLast, $part->getAttributes()
|
|
875
839
|
);
|
|
840
|
+
$part->value = String_::parseEscapeSequences($part->value, null, $parseUnicodeEscape);
|
|
876
841
|
if ($isLast) {
|
|
877
842
|
$part->value = preg_replace('~(\r\n|\n|\r)\z~', '', $part->value);
|
|
878
843
|
}
|
|
879
|
-
$part->setAttribute('rawValue', $part->value);
|
|
880
|
-
$part->value = String_::parseEscapeSequences($part->value, null, $parseUnicodeEscape);
|
|
881
844
|
if ('' === $part->value) {
|
|
882
845
|
continue;
|
|
883
846
|
}
|
|
884
847
|
}
|
|
885
848
|
$newContents[] = $part;
|
|
886
849
|
}
|
|
887
|
-
return new
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
protected function createCommentFromToken(Token $token, int $tokenPos): Comment {
|
|
892
|
-
assert($token->id === \T_COMMENT || $token->id == \T_DOC_COMMENT);
|
|
893
|
-
return \T_DOC_COMMENT === $token->id
|
|
894
|
-
? new Comment\Doc($token->text, $token->line, $token->pos, $tokenPos,
|
|
895
|
-
$token->getEndLine(), $token->getEndPos() - 1, $tokenPos)
|
|
896
|
-
: new Comment($token->text, $token->line, $token->pos, $tokenPos,
|
|
897
|
-
$token->getEndLine(), $token->getEndPos() - 1, $tokenPos);
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Get last comment before the given token position, if any
|
|
902
|
-
*/
|
|
903
|
-
protected function getCommentBeforeToken(int $tokenPos): ?Comment {
|
|
904
|
-
while (--$tokenPos >= 0) {
|
|
905
|
-
$token = $this->tokens[$tokenPos];
|
|
906
|
-
if (!isset($this->dropTokens[$token->id])) {
|
|
907
|
-
break;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
if ($token->id === \T_COMMENT || $token->id === \T_DOC_COMMENT) {
|
|
911
|
-
return $this->createCommentFromToken($token, $tokenPos);
|
|
912
|
-
}
|
|
850
|
+
return new Encapsed($newContents, $attributes);
|
|
913
851
|
}
|
|
914
|
-
return null;
|
|
915
852
|
}
|
|
916
853
|
|
|
917
854
|
/**
|
|
918
|
-
* Create a zero-length nop
|
|
855
|
+
* Create attributes for a zero-length common-capturing nop.
|
|
856
|
+
*
|
|
857
|
+
* @param Comment[] $comments
|
|
858
|
+
* @return array
|
|
919
859
|
*/
|
|
920
|
-
protected function
|
|
921
|
-
$comment = $
|
|
922
|
-
if ($comment === null) {
|
|
923
|
-
return null;
|
|
924
|
-
}
|
|
925
|
-
|
|
860
|
+
protected function createCommentNopAttributes(array $comments) {
|
|
861
|
+
$comment = $comments[count($comments) - 1];
|
|
926
862
|
$commentEndLine = $comment->getEndLine();
|
|
927
863
|
$commentEndFilePos = $comment->getEndFilePos();
|
|
928
864
|
$commentEndTokenPos = $comment->getEndTokenPos();
|
|
929
|
-
$attributes = [
|
|
930
|
-
'startLine' => $commentEndLine,
|
|
931
|
-
'endLine' => $commentEndLine,
|
|
932
|
-
'startFilePos' => $commentEndFilePos + 1,
|
|
933
|
-
'endFilePos' => $commentEndFilePos,
|
|
934
|
-
'startTokenPos' => $commentEndTokenPos + 1,
|
|
935
|
-
'endTokenPos' => $commentEndTokenPos,
|
|
936
|
-
];
|
|
937
|
-
return new Nop($attributes);
|
|
938
|
-
}
|
|
939
865
|
|
|
940
|
-
|
|
941
|
-
if (
|
|
942
|
-
|
|
866
|
+
$attributes = ['comments' => $comments];
|
|
867
|
+
if (-1 !== $commentEndLine) {
|
|
868
|
+
$attributes['startLine'] = $commentEndLine;
|
|
869
|
+
$attributes['endLine'] = $commentEndLine;
|
|
943
870
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
protected function handleHaltCompiler(): string {
|
|
948
|
-
// Prevent the lexer from returning any further tokens.
|
|
949
|
-
$nextToken = $this->tokens[$this->tokenPos + 1];
|
|
950
|
-
$this->tokenPos = \count($this->tokens) - 2;
|
|
951
|
-
|
|
952
|
-
// Return text after __halt_compiler.
|
|
953
|
-
return $nextToken->id === \T_INLINE_HTML ? $nextToken->text : '';
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
protected function inlineHtmlHasLeadingNewline(int $stackPos): bool {
|
|
957
|
-
$tokenPos = $this->tokenStartStack[$stackPos];
|
|
958
|
-
$token = $this->tokens[$tokenPos];
|
|
959
|
-
assert($token->id == \T_INLINE_HTML);
|
|
960
|
-
if ($tokenPos > 0) {
|
|
961
|
-
$prevToken = $this->tokens[$tokenPos - 1];
|
|
962
|
-
assert($prevToken->id == \T_CLOSE_TAG);
|
|
963
|
-
return false !== strpos($prevToken->text, "\n")
|
|
964
|
-
|| false !== strpos($prevToken->text, "\r");
|
|
871
|
+
if (-1 !== $commentEndFilePos) {
|
|
872
|
+
$attributes['startFilePos'] = $commentEndFilePos + 1;
|
|
873
|
+
$attributes['endFilePos'] = $commentEndFilePos;
|
|
965
874
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
/**
|
|
970
|
-
* @return array<string, mixed>
|
|
971
|
-
*/
|
|
972
|
-
protected function createEmptyElemAttributes(int $tokenPos): array {
|
|
973
|
-
return $this->getAttributesForToken($tokenPos);
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
protected function fixupArrayDestructuring(Array_ $node): Expr\List_ {
|
|
977
|
-
$this->createdArrays->detach($node);
|
|
978
|
-
return new Expr\List_(array_map(function (Node\ArrayItem $item) {
|
|
979
|
-
if ($item->value instanceof Expr\Error) {
|
|
980
|
-
// We used Error as a placeholder for empty elements, which are legal for destructuring.
|
|
981
|
-
return null;
|
|
982
|
-
}
|
|
983
|
-
if ($item->value instanceof Array_) {
|
|
984
|
-
return new Node\ArrayItem(
|
|
985
|
-
$this->fixupArrayDestructuring($item->value),
|
|
986
|
-
$item->key, $item->byRef, $item->getAttributes());
|
|
987
|
-
}
|
|
988
|
-
return $item;
|
|
989
|
-
}, $node->items), ['kind' => Expr\List_::KIND_ARRAY] + $node->getAttributes());
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
protected function postprocessList(Expr\List_ $node): void {
|
|
993
|
-
foreach ($node->items as $i => $item) {
|
|
994
|
-
if ($item->value instanceof Expr\Error) {
|
|
995
|
-
// We used Error as a placeholder for empty elements, which are legal for destructuring.
|
|
996
|
-
$node->items[$i] = null;
|
|
997
|
-
}
|
|
875
|
+
if (-1 !== $commentEndTokenPos) {
|
|
876
|
+
$attributes['startTokenPos'] = $commentEndTokenPos + 1;
|
|
877
|
+
$attributes['endTokenPos'] = $commentEndTokenPos;
|
|
998
878
|
}
|
|
879
|
+
return $attributes;
|
|
999
880
|
}
|
|
1000
881
|
|
|
1001
882
|
/** @param ElseIf_|Else_ $node */
|
|
1002
|
-
protected function fixupAlternativeElse($node)
|
|
883
|
+
protected function fixupAlternativeElse($node) {
|
|
1003
884
|
// Make sure a trailing nop statement carrying comments is part of the node.
|
|
1004
885
|
$numStmts = \count($node->stmts);
|
|
1005
886
|
if ($numStmts !== 0 && $node->stmts[$numStmts - 1] instanceof Nop) {
|
|
@@ -1016,26 +897,26 @@ abstract class ParserAbstract implements Parser {
|
|
|
1016
897
|
}
|
|
1017
898
|
}
|
|
1018
899
|
|
|
1019
|
-
protected function checkClassModifier(
|
|
900
|
+
protected function checkClassModifier($a, $b, $modifierPos) {
|
|
1020
901
|
try {
|
|
1021
|
-
|
|
902
|
+
Class_::verifyClassModifier($a, $b);
|
|
1022
903
|
} catch (Error $error) {
|
|
1023
904
|
$error->setAttributes($this->getAttributesAt($modifierPos));
|
|
1024
905
|
$this->emitError($error);
|
|
1025
906
|
}
|
|
1026
907
|
}
|
|
1027
908
|
|
|
1028
|
-
protected function checkModifier(
|
|
909
|
+
protected function checkModifier($a, $b, $modifierPos) {
|
|
1029
910
|
// Jumping through some hoops here because verifyModifier() is also used elsewhere
|
|
1030
911
|
try {
|
|
1031
|
-
|
|
912
|
+
Class_::verifyModifier($a, $b);
|
|
1032
913
|
} catch (Error $error) {
|
|
1033
914
|
$error->setAttributes($this->getAttributesAt($modifierPos));
|
|
1034
915
|
$this->emitError($error);
|
|
1035
916
|
}
|
|
1036
917
|
}
|
|
1037
918
|
|
|
1038
|
-
protected function checkParam(Param $node)
|
|
919
|
+
protected function checkParam(Param $node) {
|
|
1039
920
|
if ($node->variadic && null !== $node->default) {
|
|
1040
921
|
$this->emitError(new Error(
|
|
1041
922
|
'Variadic parameter cannot have a default value',
|
|
@@ -1044,7 +925,7 @@ abstract class ParserAbstract implements Parser {
|
|
|
1044
925
|
}
|
|
1045
926
|
}
|
|
1046
927
|
|
|
1047
|
-
protected function checkTryCatch(TryCatch $node)
|
|
928
|
+
protected function checkTryCatch(TryCatch $node) {
|
|
1048
929
|
if (empty($node->catches) && null === $node->finally) {
|
|
1049
930
|
$this->emitError(new Error(
|
|
1050
931
|
'Cannot use try without catch or finally', $node->getAttributes()
|
|
@@ -1052,7 +933,7 @@ abstract class ParserAbstract implements Parser {
|
|
|
1052
933
|
}
|
|
1053
934
|
}
|
|
1054
935
|
|
|
1055
|
-
protected function checkNamespace(Namespace_ $node)
|
|
936
|
+
protected function checkNamespace(Namespace_ $node) {
|
|
1056
937
|
if (null !== $node->stmts) {
|
|
1057
938
|
foreach ($node->stmts as $stmt) {
|
|
1058
939
|
if ($stmt instanceof Namespace_) {
|
|
@@ -1064,7 +945,7 @@ abstract class ParserAbstract implements Parser {
|
|
|
1064
945
|
}
|
|
1065
946
|
}
|
|
1066
947
|
|
|
1067
|
-
private function checkClassName(
|
|
948
|
+
private function checkClassName($name, $namePos) {
|
|
1068
949
|
if (null !== $name && $name->isSpecialClassName()) {
|
|
1069
950
|
$this->emitError(new Error(
|
|
1070
951
|
sprintf('Cannot use \'%s\' as class name as it is reserved', $name),
|
|
@@ -1073,8 +954,7 @@ abstract class ParserAbstract implements Parser {
|
|
|
1073
954
|
}
|
|
1074
955
|
}
|
|
1075
956
|
|
|
1076
|
-
|
|
1077
|
-
private function checkImplementedInterfaces(array $interfaces): void {
|
|
957
|
+
private function checkImplementedInterfaces(array $interfaces) {
|
|
1078
958
|
foreach ($interfaces as $interface) {
|
|
1079
959
|
if ($interface->isSpecialClassName()) {
|
|
1080
960
|
$this->emitError(new Error(
|
|
@@ -1085,7 +965,7 @@ abstract class ParserAbstract implements Parser {
|
|
|
1085
965
|
}
|
|
1086
966
|
}
|
|
1087
967
|
|
|
1088
|
-
protected function checkClass(Class_ $node,
|
|
968
|
+
protected function checkClass(Class_ $node, $namePos) {
|
|
1089
969
|
$this->checkClassName($node->name, $namePos);
|
|
1090
970
|
|
|
1091
971
|
if ($node->extends && $node->extends->isSpecialClassName()) {
|
|
@@ -1098,18 +978,18 @@ abstract class ParserAbstract implements Parser {
|
|
|
1098
978
|
$this->checkImplementedInterfaces($node->implements);
|
|
1099
979
|
}
|
|
1100
980
|
|
|
1101
|
-
protected function checkInterface(Interface_ $node,
|
|
981
|
+
protected function checkInterface(Interface_ $node, $namePos) {
|
|
1102
982
|
$this->checkClassName($node->name, $namePos);
|
|
1103
983
|
$this->checkImplementedInterfaces($node->extends);
|
|
1104
984
|
}
|
|
1105
985
|
|
|
1106
|
-
protected function checkEnum(Enum_ $node,
|
|
986
|
+
protected function checkEnum(Enum_ $node, $namePos) {
|
|
1107
987
|
$this->checkClassName($node->name, $namePos);
|
|
1108
988
|
$this->checkImplementedInterfaces($node->implements);
|
|
1109
989
|
}
|
|
1110
990
|
|
|
1111
|
-
protected function checkClassMethod(ClassMethod $node,
|
|
1112
|
-
if ($node->flags &
|
|
991
|
+
protected function checkClassMethod(ClassMethod $node, $modifierPos) {
|
|
992
|
+
if ($node->flags & Class_::MODIFIER_STATIC) {
|
|
1113
993
|
switch ($node->name->toLowerString()) {
|
|
1114
994
|
case '__construct':
|
|
1115
995
|
$this->emitError(new Error(
|
|
@@ -1129,44 +1009,44 @@ abstract class ParserAbstract implements Parser {
|
|
|
1129
1009
|
}
|
|
1130
1010
|
}
|
|
1131
1011
|
|
|
1132
|
-
if ($node->flags &
|
|
1012
|
+
if ($node->flags & Class_::MODIFIER_READONLY) {
|
|
1133
1013
|
$this->emitError(new Error(
|
|
1134
1014
|
sprintf('Method %s() cannot be readonly', $node->name),
|
|
1135
1015
|
$this->getAttributesAt($modifierPos)));
|
|
1136
1016
|
}
|
|
1137
1017
|
}
|
|
1138
1018
|
|
|
1139
|
-
protected function checkClassConst(ClassConst $node,
|
|
1140
|
-
if ($node->flags &
|
|
1019
|
+
protected function checkClassConst(ClassConst $node, $modifierPos) {
|
|
1020
|
+
if ($node->flags & Class_::MODIFIER_STATIC) {
|
|
1141
1021
|
$this->emitError(new Error(
|
|
1142
1022
|
"Cannot use 'static' as constant modifier",
|
|
1143
1023
|
$this->getAttributesAt($modifierPos)));
|
|
1144
1024
|
}
|
|
1145
|
-
if ($node->flags &
|
|
1025
|
+
if ($node->flags & Class_::MODIFIER_ABSTRACT) {
|
|
1146
1026
|
$this->emitError(new Error(
|
|
1147
1027
|
"Cannot use 'abstract' as constant modifier",
|
|
1148
1028
|
$this->getAttributesAt($modifierPos)));
|
|
1149
1029
|
}
|
|
1150
|
-
if ($node->flags &
|
|
1030
|
+
if ($node->flags & Class_::MODIFIER_READONLY) {
|
|
1151
1031
|
$this->emitError(new Error(
|
|
1152
1032
|
"Cannot use 'readonly' as constant modifier",
|
|
1153
1033
|
$this->getAttributesAt($modifierPos)));
|
|
1154
1034
|
}
|
|
1155
1035
|
}
|
|
1156
1036
|
|
|
1157
|
-
protected function checkProperty(Property $node,
|
|
1158
|
-
if ($node->flags &
|
|
1037
|
+
protected function checkProperty(Property $node, $modifierPos) {
|
|
1038
|
+
if ($node->flags & Class_::MODIFIER_ABSTRACT) {
|
|
1159
1039
|
$this->emitError(new Error('Properties cannot be declared abstract',
|
|
1160
1040
|
$this->getAttributesAt($modifierPos)));
|
|
1161
1041
|
}
|
|
1162
1042
|
|
|
1163
|
-
if ($node->flags &
|
|
1043
|
+
if ($node->flags & Class_::MODIFIER_FINAL) {
|
|
1164
1044
|
$this->emitError(new Error('Properties cannot be declared final',
|
|
1165
1045
|
$this->getAttributesAt($modifierPos)));
|
|
1166
1046
|
}
|
|
1167
1047
|
}
|
|
1168
1048
|
|
|
1169
|
-
protected function checkUseUse(
|
|
1049
|
+
protected function checkUseUse(UseUse $node, $namePos) {
|
|
1170
1050
|
if ($node->alias && $node->alias->isSpecialClassName()) {
|
|
1171
1051
|
$this->emitError(new Error(
|
|
1172
1052
|
sprintf(
|
|
@@ -1177,65 +1057,4 @@ abstract class ParserAbstract implements Parser {
|
|
|
1177
1057
|
));
|
|
1178
1058
|
}
|
|
1179
1059
|
}
|
|
1180
|
-
|
|
1181
|
-
/**
|
|
1182
|
-
* Creates the token map.
|
|
1183
|
-
*
|
|
1184
|
-
* The token map maps the PHP internal token identifiers
|
|
1185
|
-
* to the identifiers used by the Parser. Additionally it
|
|
1186
|
-
* maps T_OPEN_TAG_WITH_ECHO to T_ECHO and T_CLOSE_TAG to ';'.
|
|
1187
|
-
*
|
|
1188
|
-
* @return array<int, int> The token map
|
|
1189
|
-
*/
|
|
1190
|
-
protected function createTokenMap(): array {
|
|
1191
|
-
$tokenMap = [];
|
|
1192
|
-
|
|
1193
|
-
for ($i = 0; $i < 1000; ++$i) {
|
|
1194
|
-
if ($i < 256) {
|
|
1195
|
-
// Single-char tokens use an identity mapping.
|
|
1196
|
-
$tokenMap[$i] = $i;
|
|
1197
|
-
} elseif (\T_DOUBLE_COLON === $i) {
|
|
1198
|
-
// T_DOUBLE_COLON is equivalent to T_PAAMAYIM_NEKUDOTAYIM
|
|
1199
|
-
$tokenMap[$i] = static::T_PAAMAYIM_NEKUDOTAYIM;
|
|
1200
|
-
} elseif (\T_OPEN_TAG_WITH_ECHO === $i) {
|
|
1201
|
-
// T_OPEN_TAG_WITH_ECHO with dropped T_OPEN_TAG results in T_ECHO
|
|
1202
|
-
$tokenMap[$i] = static::T_ECHO;
|
|
1203
|
-
} elseif (\T_CLOSE_TAG === $i) {
|
|
1204
|
-
// T_CLOSE_TAG is equivalent to ';'
|
|
1205
|
-
$tokenMap[$i] = ord(';');
|
|
1206
|
-
} elseif ('UNKNOWN' !== $name = token_name($i)) {
|
|
1207
|
-
if (defined($name = static::class . '::' . $name)) {
|
|
1208
|
-
// Other tokens can be mapped directly
|
|
1209
|
-
$tokenMap[$i] = constant($name);
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
// Assign tokens for which we define compatibility constants, as token_name() does not know them.
|
|
1215
|
-
$tokenMap[\T_FN] = static::T_FN;
|
|
1216
|
-
$tokenMap[\T_COALESCE_EQUAL] = static::T_COALESCE_EQUAL;
|
|
1217
|
-
$tokenMap[\T_NAME_QUALIFIED] = static::T_NAME_QUALIFIED;
|
|
1218
|
-
$tokenMap[\T_NAME_FULLY_QUALIFIED] = static::T_NAME_FULLY_QUALIFIED;
|
|
1219
|
-
$tokenMap[\T_NAME_RELATIVE] = static::T_NAME_RELATIVE;
|
|
1220
|
-
$tokenMap[\T_MATCH] = static::T_MATCH;
|
|
1221
|
-
$tokenMap[\T_NULLSAFE_OBJECT_OPERATOR] = static::T_NULLSAFE_OBJECT_OPERATOR;
|
|
1222
|
-
$tokenMap[\T_ATTRIBUTE] = static::T_ATTRIBUTE;
|
|
1223
|
-
$tokenMap[\T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG] = static::T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG;
|
|
1224
|
-
$tokenMap[\T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG] = static::T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG;
|
|
1225
|
-
$tokenMap[\T_ENUM] = static::T_ENUM;
|
|
1226
|
-
$tokenMap[\T_READONLY] = static::T_READONLY;
|
|
1227
|
-
|
|
1228
|
-
// We have create a map from PHP token IDs to external symbol IDs.
|
|
1229
|
-
// Now map them to the internal symbol ID.
|
|
1230
|
-
$fullTokenMap = [];
|
|
1231
|
-
foreach ($tokenMap as $phpToken => $extSymbol) {
|
|
1232
|
-
$intSymbol = $this->tokenToSymbol[$extSymbol];
|
|
1233
|
-
if ($intSymbol === $this->invalidSymbol) {
|
|
1234
|
-
continue;
|
|
1235
|
-
}
|
|
1236
|
-
$fullTokenMap[$phpToken] = $intSymbol;
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
return $fullTokenMap;
|
|
1240
|
-
}
|
|
1241
1060
|
}
|