@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
|
@@ -13,10 +13,11 @@ use PhpParser\Node\Scalar\MagicConst;
|
|
|
13
13
|
use PhpParser\Node\Stmt;
|
|
14
14
|
use PhpParser\PrettyPrinterAbstract;
|
|
15
15
|
|
|
16
|
-
class Standard extends PrettyPrinterAbstract
|
|
16
|
+
class Standard extends PrettyPrinterAbstract
|
|
17
|
+
{
|
|
17
18
|
// Special nodes
|
|
18
19
|
|
|
19
|
-
protected function pParam(Node\Param $node)
|
|
20
|
+
protected function pParam(Node\Param $node) {
|
|
20
21
|
return $this->pAttrGroups($node->attrGroups, true)
|
|
21
22
|
. $this->pModifiers($node->flags)
|
|
22
23
|
. ($node->type ? $this->p($node->type) . ' ' : '')
|
|
@@ -26,25 +27,25 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
26
27
|
. ($node->default ? ' = ' . $this->p($node->default) : '');
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
protected function pArg(Node\Arg $node)
|
|
30
|
+
protected function pArg(Node\Arg $node) {
|
|
30
31
|
return ($node->name ? $node->name->toString() . ': ' : '')
|
|
31
32
|
. ($node->byRef ? '&' : '') . ($node->unpack ? '...' : '')
|
|
32
33
|
. $this->p($node->value);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
protected function pVariadicPlaceholder(Node\VariadicPlaceholder $node)
|
|
36
|
+
protected function pVariadicPlaceholder(Node\VariadicPlaceholder $node) {
|
|
36
37
|
return '...';
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
protected function pConst(Node\Const_ $node)
|
|
40
|
+
protected function pConst(Node\Const_ $node) {
|
|
40
41
|
return $node->name . ' = ' . $this->p($node->value);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
protected function pNullableType(Node\NullableType $node)
|
|
44
|
+
protected function pNullableType(Node\NullableType $node) {
|
|
44
45
|
return '?' . $this->p($node->type);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
protected function pUnionType(Node\UnionType $node)
|
|
48
|
+
protected function pUnionType(Node\UnionType $node) {
|
|
48
49
|
$types = [];
|
|
49
50
|
foreach ($node->types as $typeNode) {
|
|
50
51
|
if ($typeNode instanceof Node\IntersectionType) {
|
|
@@ -56,150 +57,138 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
56
57
|
return implode('|', $types);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
protected function pIntersectionType(Node\IntersectionType $node)
|
|
60
|
+
protected function pIntersectionType(Node\IntersectionType $node) {
|
|
60
61
|
return $this->pImplode($node->types, '&');
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
protected function pIdentifier(Node\Identifier $node)
|
|
64
|
+
protected function pIdentifier(Node\Identifier $node) {
|
|
64
65
|
return $node->name;
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
protected function pVarLikeIdentifier(Node\VarLikeIdentifier $node)
|
|
68
|
+
protected function pVarLikeIdentifier(Node\VarLikeIdentifier $node) {
|
|
68
69
|
return '$' . $node->name;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
protected function pAttribute(Node\Attribute $node)
|
|
72
|
+
protected function pAttribute(Node\Attribute $node) {
|
|
72
73
|
return $this->p($node->name)
|
|
73
74
|
. ($node->args ? '(' . $this->pCommaSeparated($node->args) . ')' : '');
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
protected function pAttributeGroup(Node\AttributeGroup $node)
|
|
77
|
+
protected function pAttributeGroup(Node\AttributeGroup $node) {
|
|
77
78
|
return '#[' . $this->pCommaSeparated($node->attrs) . ']';
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
// Names
|
|
81
82
|
|
|
82
|
-
protected function pName(Name $node)
|
|
83
|
-
return $node->
|
|
83
|
+
protected function pName(Name $node) {
|
|
84
|
+
return implode('\\', $node->parts);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
protected function pName_FullyQualified(Name\FullyQualified $node)
|
|
87
|
-
return '\\' . $node->
|
|
87
|
+
protected function pName_FullyQualified(Name\FullyQualified $node) {
|
|
88
|
+
return '\\' . implode('\\', $node->parts);
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
protected function pName_Relative(Name\Relative $node)
|
|
91
|
-
return 'namespace\\' . $node->
|
|
91
|
+
protected function pName_Relative(Name\Relative $node) {
|
|
92
|
+
return 'namespace\\' . implode('\\', $node->parts);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
// Magic Constants
|
|
95
96
|
|
|
96
|
-
protected function pScalar_MagicConst_Class(MagicConst\Class_ $node)
|
|
97
|
+
protected function pScalar_MagicConst_Class(MagicConst\Class_ $node) {
|
|
97
98
|
return '__CLASS__';
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
protected function pScalar_MagicConst_Dir(MagicConst\Dir $node)
|
|
101
|
+
protected function pScalar_MagicConst_Dir(MagicConst\Dir $node) {
|
|
101
102
|
return '__DIR__';
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
protected function pScalar_MagicConst_File(MagicConst\File $node)
|
|
105
|
+
protected function pScalar_MagicConst_File(MagicConst\File $node) {
|
|
105
106
|
return '__FILE__';
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
protected function pScalar_MagicConst_Function(MagicConst\Function_ $node)
|
|
109
|
+
protected function pScalar_MagicConst_Function(MagicConst\Function_ $node) {
|
|
109
110
|
return '__FUNCTION__';
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
protected function pScalar_MagicConst_Line(MagicConst\Line $node)
|
|
113
|
+
protected function pScalar_MagicConst_Line(MagicConst\Line $node) {
|
|
113
114
|
return '__LINE__';
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
protected function pScalar_MagicConst_Method(MagicConst\Method $node)
|
|
117
|
+
protected function pScalar_MagicConst_Method(MagicConst\Method $node) {
|
|
117
118
|
return '__METHOD__';
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
protected function pScalar_MagicConst_Namespace(MagicConst\Namespace_ $node)
|
|
121
|
+
protected function pScalar_MagicConst_Namespace(MagicConst\Namespace_ $node) {
|
|
121
122
|
return '__NAMESPACE__';
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
protected function pScalar_MagicConst_Trait(MagicConst\Trait_ $node)
|
|
125
|
+
protected function pScalar_MagicConst_Trait(MagicConst\Trait_ $node) {
|
|
125
126
|
return '__TRAIT__';
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
// Scalars
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
return str_replace("\n", $this->nl, $str);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
protected function pScalar_String(Scalar\String_ $node): string {
|
|
131
|
+
protected function pScalar_String(Scalar\String_ $node) {
|
|
135
132
|
$kind = $node->getAttribute('kind', Scalar\String_::KIND_SINGLE_QUOTED);
|
|
136
133
|
switch ($kind) {
|
|
137
134
|
case Scalar\String_::KIND_NOWDOC:
|
|
138
135
|
$label = $node->getAttribute('docLabel');
|
|
139
136
|
if ($label && !$this->containsEndLabel($node->value, $label)) {
|
|
140
|
-
$shouldIdent = $this->phpVersion->supportsFlexibleHeredoc();
|
|
141
|
-
$nl = $shouldIdent ? $this->nl : $this->newline;
|
|
142
137
|
if ($node->value === '') {
|
|
143
|
-
return "<<<'$label'$
|
|
138
|
+
return "<<<'$label'\n$label" . $this->docStringEndToken;
|
|
144
139
|
}
|
|
145
140
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
$value = $shouldIdent ? $this->indentString($node->value) : $node->value;
|
|
149
|
-
return "<<<'$label'$nl$value$nl$label{$this->docStringEndToken}";
|
|
150
|
-
}
|
|
141
|
+
return "<<<'$label'\n$node->value\n$label"
|
|
142
|
+
. $this->docStringEndToken;
|
|
151
143
|
}
|
|
152
144
|
/* break missing intentionally */
|
|
153
|
-
// no break
|
|
154
145
|
case Scalar\String_::KIND_SINGLE_QUOTED:
|
|
155
146
|
return $this->pSingleQuotedString($node->value);
|
|
156
147
|
case Scalar\String_::KIND_HEREDOC:
|
|
157
148
|
$label = $node->getAttribute('docLabel');
|
|
158
|
-
$
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if ($escaped === '') {
|
|
162
|
-
return "<<<$label$nl$label{$this->docStringEndToken}";
|
|
149
|
+
if ($label && !$this->containsEndLabel($node->value, $label)) {
|
|
150
|
+
if ($node->value === '') {
|
|
151
|
+
return "<<<$label\n$label" . $this->docStringEndToken;
|
|
163
152
|
}
|
|
164
153
|
|
|
165
|
-
|
|
154
|
+
$escaped = $this->escapeString($node->value, null);
|
|
155
|
+
return "<<<$label\n" . $escaped . "\n$label"
|
|
156
|
+
. $this->docStringEndToken;
|
|
166
157
|
}
|
|
167
|
-
|
|
168
|
-
// no break
|
|
158
|
+
/* break missing intentionally */
|
|
169
159
|
case Scalar\String_::KIND_DOUBLE_QUOTED:
|
|
170
160
|
return '"' . $this->escapeString($node->value, '"') . '"';
|
|
171
161
|
}
|
|
172
162
|
throw new \Exception('Invalid string kind');
|
|
173
163
|
}
|
|
174
164
|
|
|
175
|
-
protected function
|
|
165
|
+
protected function pScalar_Encapsed(Scalar\Encapsed $node) {
|
|
176
166
|
if ($node->getAttribute('kind') === Scalar\String_::KIND_HEREDOC) {
|
|
177
167
|
$label = $node->getAttribute('docLabel');
|
|
178
168
|
if ($label && !$this->encapsedContainsEndLabel($node->parts, $label)) {
|
|
179
|
-
$nl = $this->phpVersion->supportsFlexibleHeredoc() ? $this->nl : $this->newline;
|
|
180
169
|
if (count($node->parts) === 1
|
|
181
|
-
&& $node->parts[0] instanceof
|
|
170
|
+
&& $node->parts[0] instanceof Scalar\EncapsedStringPart
|
|
182
171
|
&& $node->parts[0]->value === ''
|
|
183
172
|
) {
|
|
184
|
-
return "<<<$label$
|
|
173
|
+
return "<<<$label\n$label" . $this->docStringEndToken;
|
|
185
174
|
}
|
|
186
175
|
|
|
187
|
-
return "<<<$label
|
|
188
|
-
.
|
|
176
|
+
return "<<<$label\n" . $this->pEncapsList($node->parts, null) . "\n$label"
|
|
177
|
+
. $this->docStringEndToken;
|
|
189
178
|
}
|
|
190
179
|
}
|
|
191
180
|
return '"' . $this->pEncapsList($node->parts, '"') . '"';
|
|
192
181
|
}
|
|
193
182
|
|
|
194
|
-
protected function
|
|
195
|
-
if ($node->value === -\PHP_INT_MAX
|
|
183
|
+
protected function pScalar_LNumber(Scalar\LNumber $node) {
|
|
184
|
+
if ($node->value === -\PHP_INT_MAX-1) {
|
|
196
185
|
// PHP_INT_MIN cannot be represented as a literal,
|
|
197
186
|
// because the sign is not part of the literal
|
|
198
187
|
return '(-' . \PHP_INT_MAX . '-1)';
|
|
199
188
|
}
|
|
200
189
|
|
|
201
|
-
$kind = $node->getAttribute('kind', Scalar\
|
|
202
|
-
if (Scalar\
|
|
190
|
+
$kind = $node->getAttribute('kind', Scalar\LNumber::KIND_DEC);
|
|
191
|
+
if (Scalar\LNumber::KIND_DEC === $kind) {
|
|
203
192
|
return (string) $node->value;
|
|
204
193
|
}
|
|
205
194
|
|
|
@@ -211,23 +200,22 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
211
200
|
$str = (string) $node->value;
|
|
212
201
|
}
|
|
213
202
|
switch ($kind) {
|
|
214
|
-
case Scalar\
|
|
203
|
+
case Scalar\LNumber::KIND_BIN:
|
|
215
204
|
return $sign . '0b' . base_convert($str, 10, 2);
|
|
216
|
-
case Scalar\
|
|
205
|
+
case Scalar\LNumber::KIND_OCT:
|
|
217
206
|
return $sign . '0' . base_convert($str, 10, 8);
|
|
218
|
-
case Scalar\
|
|
207
|
+
case Scalar\LNumber::KIND_HEX:
|
|
219
208
|
return $sign . '0x' . base_convert($str, 10, 16);
|
|
220
209
|
}
|
|
221
210
|
throw new \Exception('Invalid number kind');
|
|
222
211
|
}
|
|
223
212
|
|
|
224
|
-
protected function
|
|
213
|
+
protected function pScalar_DNumber(Scalar\DNumber $node) {
|
|
225
214
|
if (!is_finite($node->value)) {
|
|
226
215
|
if ($node->value === \INF) {
|
|
227
|
-
return '
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return '-1.0E+1000';
|
|
216
|
+
return '\INF';
|
|
217
|
+
} elseif ($node->value === -\INF) {
|
|
218
|
+
return '-\INF';
|
|
231
219
|
} else {
|
|
232
220
|
return '\NAN';
|
|
233
221
|
}
|
|
@@ -235,7 +223,7 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
235
223
|
|
|
236
224
|
// Try to find a short full-precision representation
|
|
237
225
|
$stringValue = sprintf('%.16G', $node->value);
|
|
238
|
-
if ($node->value !== (
|
|
226
|
+
if ($node->value !== (double) $stringValue) {
|
|
239
227
|
$stringValue = sprintf('%.17G', $node->value);
|
|
240
228
|
}
|
|
241
229
|
|
|
@@ -248,288 +236,299 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
248
236
|
return preg_match('/^-?[0-9]+$/', $stringValue) ? $stringValue . '.0' : $stringValue;
|
|
249
237
|
}
|
|
250
238
|
|
|
239
|
+
protected function pScalar_EncapsedStringPart(Scalar\EncapsedStringPart $node) {
|
|
240
|
+
throw new \LogicException('Cannot directly print EncapsedStringPart');
|
|
241
|
+
}
|
|
242
|
+
|
|
251
243
|
// Assignments
|
|
252
244
|
|
|
253
|
-
protected function pExpr_Assign(Expr\Assign $node
|
|
254
|
-
return $this->
|
|
245
|
+
protected function pExpr_Assign(Expr\Assign $node) {
|
|
246
|
+
return $this->pInfixOp(Expr\Assign::class, $node->var, ' = ', $node->expr);
|
|
255
247
|
}
|
|
256
248
|
|
|
257
|
-
protected function pExpr_AssignRef(Expr\AssignRef $node
|
|
258
|
-
return $this->
|
|
249
|
+
protected function pExpr_AssignRef(Expr\AssignRef $node) {
|
|
250
|
+
return $this->pInfixOp(Expr\AssignRef::class, $node->var, ' =& ', $node->expr);
|
|
259
251
|
}
|
|
260
252
|
|
|
261
|
-
protected function pExpr_AssignOp_Plus(AssignOp\Plus $node
|
|
262
|
-
return $this->
|
|
253
|
+
protected function pExpr_AssignOp_Plus(AssignOp\Plus $node) {
|
|
254
|
+
return $this->pInfixOp(AssignOp\Plus::class, $node->var, ' += ', $node->expr);
|
|
263
255
|
}
|
|
264
256
|
|
|
265
|
-
protected function pExpr_AssignOp_Minus(AssignOp\Minus $node
|
|
266
|
-
return $this->
|
|
257
|
+
protected function pExpr_AssignOp_Minus(AssignOp\Minus $node) {
|
|
258
|
+
return $this->pInfixOp(AssignOp\Minus::class, $node->var, ' -= ', $node->expr);
|
|
267
259
|
}
|
|
268
260
|
|
|
269
|
-
protected function pExpr_AssignOp_Mul(AssignOp\Mul $node
|
|
270
|
-
return $this->
|
|
261
|
+
protected function pExpr_AssignOp_Mul(AssignOp\Mul $node) {
|
|
262
|
+
return $this->pInfixOp(AssignOp\Mul::class, $node->var, ' *= ', $node->expr);
|
|
271
263
|
}
|
|
272
264
|
|
|
273
|
-
protected function pExpr_AssignOp_Div(AssignOp\Div $node
|
|
274
|
-
return $this->
|
|
265
|
+
protected function pExpr_AssignOp_Div(AssignOp\Div $node) {
|
|
266
|
+
return $this->pInfixOp(AssignOp\Div::class, $node->var, ' /= ', $node->expr);
|
|
275
267
|
}
|
|
276
268
|
|
|
277
|
-
protected function pExpr_AssignOp_Concat(AssignOp\Concat $node
|
|
278
|
-
return $this->
|
|
269
|
+
protected function pExpr_AssignOp_Concat(AssignOp\Concat $node) {
|
|
270
|
+
return $this->pInfixOp(AssignOp\Concat::class, $node->var, ' .= ', $node->expr);
|
|
279
271
|
}
|
|
280
272
|
|
|
281
|
-
protected function pExpr_AssignOp_Mod(AssignOp\Mod $node
|
|
282
|
-
return $this->
|
|
273
|
+
protected function pExpr_AssignOp_Mod(AssignOp\Mod $node) {
|
|
274
|
+
return $this->pInfixOp(AssignOp\Mod::class, $node->var, ' %= ', $node->expr);
|
|
283
275
|
}
|
|
284
276
|
|
|
285
|
-
protected function pExpr_AssignOp_BitwiseAnd(AssignOp\BitwiseAnd $node
|
|
286
|
-
return $this->
|
|
277
|
+
protected function pExpr_AssignOp_BitwiseAnd(AssignOp\BitwiseAnd $node) {
|
|
278
|
+
return $this->pInfixOp(AssignOp\BitwiseAnd::class, $node->var, ' &= ', $node->expr);
|
|
287
279
|
}
|
|
288
280
|
|
|
289
|
-
protected function pExpr_AssignOp_BitwiseOr(AssignOp\BitwiseOr $node
|
|
290
|
-
return $this->
|
|
281
|
+
protected function pExpr_AssignOp_BitwiseOr(AssignOp\BitwiseOr $node) {
|
|
282
|
+
return $this->pInfixOp(AssignOp\BitwiseOr::class, $node->var, ' |= ', $node->expr);
|
|
291
283
|
}
|
|
292
284
|
|
|
293
|
-
protected function pExpr_AssignOp_BitwiseXor(AssignOp\BitwiseXor $node
|
|
294
|
-
return $this->
|
|
285
|
+
protected function pExpr_AssignOp_BitwiseXor(AssignOp\BitwiseXor $node) {
|
|
286
|
+
return $this->pInfixOp(AssignOp\BitwiseXor::class, $node->var, ' ^= ', $node->expr);
|
|
295
287
|
}
|
|
296
288
|
|
|
297
|
-
protected function pExpr_AssignOp_ShiftLeft(AssignOp\ShiftLeft $node
|
|
298
|
-
return $this->
|
|
289
|
+
protected function pExpr_AssignOp_ShiftLeft(AssignOp\ShiftLeft $node) {
|
|
290
|
+
return $this->pInfixOp(AssignOp\ShiftLeft::class, $node->var, ' <<= ', $node->expr);
|
|
299
291
|
}
|
|
300
292
|
|
|
301
|
-
protected function pExpr_AssignOp_ShiftRight(AssignOp\ShiftRight $node
|
|
302
|
-
return $this->
|
|
293
|
+
protected function pExpr_AssignOp_ShiftRight(AssignOp\ShiftRight $node) {
|
|
294
|
+
return $this->pInfixOp(AssignOp\ShiftRight::class, $node->var, ' >>= ', $node->expr);
|
|
303
295
|
}
|
|
304
296
|
|
|
305
|
-
protected function pExpr_AssignOp_Pow(AssignOp\Pow $node
|
|
306
|
-
return $this->
|
|
297
|
+
protected function pExpr_AssignOp_Pow(AssignOp\Pow $node) {
|
|
298
|
+
return $this->pInfixOp(AssignOp\Pow::class, $node->var, ' **= ', $node->expr);
|
|
307
299
|
}
|
|
308
300
|
|
|
309
|
-
protected function pExpr_AssignOp_Coalesce(AssignOp\Coalesce $node
|
|
310
|
-
return $this->
|
|
301
|
+
protected function pExpr_AssignOp_Coalesce(AssignOp\Coalesce $node) {
|
|
302
|
+
return $this->pInfixOp(AssignOp\Coalesce::class, $node->var, ' ??= ', $node->expr);
|
|
311
303
|
}
|
|
312
304
|
|
|
313
305
|
// Binary expressions
|
|
314
306
|
|
|
315
|
-
protected function pExpr_BinaryOp_Plus(BinaryOp\Plus $node
|
|
316
|
-
return $this->pInfixOp(BinaryOp\Plus::class, $node->left, ' + ', $node->right
|
|
307
|
+
protected function pExpr_BinaryOp_Plus(BinaryOp\Plus $node) {
|
|
308
|
+
return $this->pInfixOp(BinaryOp\Plus::class, $node->left, ' + ', $node->right);
|
|
317
309
|
}
|
|
318
310
|
|
|
319
|
-
protected function pExpr_BinaryOp_Minus(BinaryOp\Minus $node
|
|
320
|
-
return $this->pInfixOp(BinaryOp\Minus::class, $node->left, ' - ', $node->right
|
|
311
|
+
protected function pExpr_BinaryOp_Minus(BinaryOp\Minus $node) {
|
|
312
|
+
return $this->pInfixOp(BinaryOp\Minus::class, $node->left, ' - ', $node->right);
|
|
321
313
|
}
|
|
322
314
|
|
|
323
|
-
protected function pExpr_BinaryOp_Mul(BinaryOp\Mul $node
|
|
324
|
-
return $this->pInfixOp(BinaryOp\Mul::class, $node->left, ' * ', $node->right
|
|
315
|
+
protected function pExpr_BinaryOp_Mul(BinaryOp\Mul $node) {
|
|
316
|
+
return $this->pInfixOp(BinaryOp\Mul::class, $node->left, ' * ', $node->right);
|
|
325
317
|
}
|
|
326
318
|
|
|
327
|
-
protected function pExpr_BinaryOp_Div(BinaryOp\Div $node
|
|
328
|
-
return $this->pInfixOp(BinaryOp\Div::class, $node->left, ' / ', $node->right
|
|
319
|
+
protected function pExpr_BinaryOp_Div(BinaryOp\Div $node) {
|
|
320
|
+
return $this->pInfixOp(BinaryOp\Div::class, $node->left, ' / ', $node->right);
|
|
329
321
|
}
|
|
330
322
|
|
|
331
|
-
protected function pExpr_BinaryOp_Concat(BinaryOp\Concat $node
|
|
332
|
-
return $this->pInfixOp(BinaryOp\Concat::class, $node->left, ' . ', $node->right
|
|
323
|
+
protected function pExpr_BinaryOp_Concat(BinaryOp\Concat $node) {
|
|
324
|
+
return $this->pInfixOp(BinaryOp\Concat::class, $node->left, ' . ', $node->right);
|
|
333
325
|
}
|
|
334
326
|
|
|
335
|
-
protected function pExpr_BinaryOp_Mod(BinaryOp\Mod $node
|
|
336
|
-
return $this->pInfixOp(BinaryOp\Mod::class, $node->left, ' % ', $node->right
|
|
327
|
+
protected function pExpr_BinaryOp_Mod(BinaryOp\Mod $node) {
|
|
328
|
+
return $this->pInfixOp(BinaryOp\Mod::class, $node->left, ' % ', $node->right);
|
|
337
329
|
}
|
|
338
330
|
|
|
339
|
-
protected function pExpr_BinaryOp_BooleanAnd(BinaryOp\BooleanAnd $node
|
|
340
|
-
return $this->pInfixOp(BinaryOp\BooleanAnd::class, $node->left, ' && ', $node->right
|
|
331
|
+
protected function pExpr_BinaryOp_BooleanAnd(BinaryOp\BooleanAnd $node) {
|
|
332
|
+
return $this->pInfixOp(BinaryOp\BooleanAnd::class, $node->left, ' && ', $node->right);
|
|
341
333
|
}
|
|
342
334
|
|
|
343
|
-
protected function pExpr_BinaryOp_BooleanOr(BinaryOp\BooleanOr $node
|
|
344
|
-
return $this->pInfixOp(BinaryOp\BooleanOr::class, $node->left, ' || ', $node->right
|
|
335
|
+
protected function pExpr_BinaryOp_BooleanOr(BinaryOp\BooleanOr $node) {
|
|
336
|
+
return $this->pInfixOp(BinaryOp\BooleanOr::class, $node->left, ' || ', $node->right);
|
|
345
337
|
}
|
|
346
338
|
|
|
347
|
-
protected function pExpr_BinaryOp_BitwiseAnd(BinaryOp\BitwiseAnd $node
|
|
348
|
-
return $this->pInfixOp(BinaryOp\BitwiseAnd::class, $node->left, ' & ', $node->right
|
|
339
|
+
protected function pExpr_BinaryOp_BitwiseAnd(BinaryOp\BitwiseAnd $node) {
|
|
340
|
+
return $this->pInfixOp(BinaryOp\BitwiseAnd::class, $node->left, ' & ', $node->right);
|
|
349
341
|
}
|
|
350
342
|
|
|
351
|
-
protected function pExpr_BinaryOp_BitwiseOr(BinaryOp\BitwiseOr $node
|
|
352
|
-
return $this->pInfixOp(BinaryOp\BitwiseOr::class, $node->left, ' | ', $node->right
|
|
343
|
+
protected function pExpr_BinaryOp_BitwiseOr(BinaryOp\BitwiseOr $node) {
|
|
344
|
+
return $this->pInfixOp(BinaryOp\BitwiseOr::class, $node->left, ' | ', $node->right);
|
|
353
345
|
}
|
|
354
346
|
|
|
355
|
-
protected function pExpr_BinaryOp_BitwiseXor(BinaryOp\BitwiseXor $node
|
|
356
|
-
return $this->pInfixOp(BinaryOp\BitwiseXor::class, $node->left, ' ^ ', $node->right
|
|
347
|
+
protected function pExpr_BinaryOp_BitwiseXor(BinaryOp\BitwiseXor $node) {
|
|
348
|
+
return $this->pInfixOp(BinaryOp\BitwiseXor::class, $node->left, ' ^ ', $node->right);
|
|
357
349
|
}
|
|
358
350
|
|
|
359
|
-
protected function pExpr_BinaryOp_ShiftLeft(BinaryOp\ShiftLeft $node
|
|
360
|
-
return $this->pInfixOp(BinaryOp\ShiftLeft::class, $node->left, ' << ', $node->right
|
|
351
|
+
protected function pExpr_BinaryOp_ShiftLeft(BinaryOp\ShiftLeft $node) {
|
|
352
|
+
return $this->pInfixOp(BinaryOp\ShiftLeft::class, $node->left, ' << ', $node->right);
|
|
361
353
|
}
|
|
362
354
|
|
|
363
|
-
protected function pExpr_BinaryOp_ShiftRight(BinaryOp\ShiftRight $node
|
|
364
|
-
return $this->pInfixOp(BinaryOp\ShiftRight::class, $node->left, ' >> ', $node->right
|
|
355
|
+
protected function pExpr_BinaryOp_ShiftRight(BinaryOp\ShiftRight $node) {
|
|
356
|
+
return $this->pInfixOp(BinaryOp\ShiftRight::class, $node->left, ' >> ', $node->right);
|
|
365
357
|
}
|
|
366
358
|
|
|
367
|
-
protected function pExpr_BinaryOp_Pow(BinaryOp\Pow $node
|
|
368
|
-
return $this->pInfixOp(BinaryOp\Pow::class, $node->left, ' ** ', $node->right
|
|
359
|
+
protected function pExpr_BinaryOp_Pow(BinaryOp\Pow $node) {
|
|
360
|
+
return $this->pInfixOp(BinaryOp\Pow::class, $node->left, ' ** ', $node->right);
|
|
369
361
|
}
|
|
370
362
|
|
|
371
|
-
protected function pExpr_BinaryOp_LogicalAnd(BinaryOp\LogicalAnd $node
|
|
372
|
-
return $this->pInfixOp(BinaryOp\LogicalAnd::class, $node->left, ' and ', $node->right
|
|
363
|
+
protected function pExpr_BinaryOp_LogicalAnd(BinaryOp\LogicalAnd $node) {
|
|
364
|
+
return $this->pInfixOp(BinaryOp\LogicalAnd::class, $node->left, ' and ', $node->right);
|
|
373
365
|
}
|
|
374
366
|
|
|
375
|
-
protected function pExpr_BinaryOp_LogicalOr(BinaryOp\LogicalOr $node
|
|
376
|
-
return $this->pInfixOp(BinaryOp\LogicalOr::class, $node->left, ' or ', $node->right
|
|
367
|
+
protected function pExpr_BinaryOp_LogicalOr(BinaryOp\LogicalOr $node) {
|
|
368
|
+
return $this->pInfixOp(BinaryOp\LogicalOr::class, $node->left, ' or ', $node->right);
|
|
377
369
|
}
|
|
378
370
|
|
|
379
|
-
protected function pExpr_BinaryOp_LogicalXor(BinaryOp\LogicalXor $node
|
|
380
|
-
return $this->pInfixOp(BinaryOp\LogicalXor::class, $node->left, ' xor ', $node->right
|
|
371
|
+
protected function pExpr_BinaryOp_LogicalXor(BinaryOp\LogicalXor $node) {
|
|
372
|
+
return $this->pInfixOp(BinaryOp\LogicalXor::class, $node->left, ' xor ', $node->right);
|
|
381
373
|
}
|
|
382
374
|
|
|
383
|
-
protected function pExpr_BinaryOp_Equal(BinaryOp\Equal $node
|
|
384
|
-
return $this->pInfixOp(BinaryOp\Equal::class, $node->left, ' == ', $node->right
|
|
375
|
+
protected function pExpr_BinaryOp_Equal(BinaryOp\Equal $node) {
|
|
376
|
+
return $this->pInfixOp(BinaryOp\Equal::class, $node->left, ' == ', $node->right);
|
|
385
377
|
}
|
|
386
378
|
|
|
387
|
-
protected function pExpr_BinaryOp_NotEqual(BinaryOp\NotEqual $node
|
|
388
|
-
return $this->pInfixOp(BinaryOp\NotEqual::class, $node->left, ' != ', $node->right
|
|
379
|
+
protected function pExpr_BinaryOp_NotEqual(BinaryOp\NotEqual $node) {
|
|
380
|
+
return $this->pInfixOp(BinaryOp\NotEqual::class, $node->left, ' != ', $node->right);
|
|
389
381
|
}
|
|
390
382
|
|
|
391
|
-
protected function pExpr_BinaryOp_Identical(BinaryOp\Identical $node
|
|
392
|
-
return $this->pInfixOp(BinaryOp\Identical::class, $node->left, ' === ', $node->right
|
|
383
|
+
protected function pExpr_BinaryOp_Identical(BinaryOp\Identical $node) {
|
|
384
|
+
return $this->pInfixOp(BinaryOp\Identical::class, $node->left, ' === ', $node->right);
|
|
393
385
|
}
|
|
394
386
|
|
|
395
|
-
protected function pExpr_BinaryOp_NotIdentical(BinaryOp\NotIdentical $node
|
|
396
|
-
return $this->pInfixOp(BinaryOp\NotIdentical::class, $node->left, ' !== ', $node->right
|
|
387
|
+
protected function pExpr_BinaryOp_NotIdentical(BinaryOp\NotIdentical $node) {
|
|
388
|
+
return $this->pInfixOp(BinaryOp\NotIdentical::class, $node->left, ' !== ', $node->right);
|
|
397
389
|
}
|
|
398
390
|
|
|
399
|
-
protected function pExpr_BinaryOp_Spaceship(BinaryOp\Spaceship $node
|
|
400
|
-
return $this->pInfixOp(BinaryOp\Spaceship::class, $node->left, ' <=> ', $node->right
|
|
391
|
+
protected function pExpr_BinaryOp_Spaceship(BinaryOp\Spaceship $node) {
|
|
392
|
+
return $this->pInfixOp(BinaryOp\Spaceship::class, $node->left, ' <=> ', $node->right);
|
|
401
393
|
}
|
|
402
394
|
|
|
403
|
-
protected function pExpr_BinaryOp_Greater(BinaryOp\Greater $node
|
|
404
|
-
return $this->pInfixOp(BinaryOp\Greater::class, $node->left, ' > ', $node->right
|
|
395
|
+
protected function pExpr_BinaryOp_Greater(BinaryOp\Greater $node) {
|
|
396
|
+
return $this->pInfixOp(BinaryOp\Greater::class, $node->left, ' > ', $node->right);
|
|
405
397
|
}
|
|
406
398
|
|
|
407
|
-
protected function pExpr_BinaryOp_GreaterOrEqual(BinaryOp\GreaterOrEqual $node
|
|
408
|
-
return $this->pInfixOp(BinaryOp\GreaterOrEqual::class, $node->left, ' >= ', $node->right
|
|
399
|
+
protected function pExpr_BinaryOp_GreaterOrEqual(BinaryOp\GreaterOrEqual $node) {
|
|
400
|
+
return $this->pInfixOp(BinaryOp\GreaterOrEqual::class, $node->left, ' >= ', $node->right);
|
|
409
401
|
}
|
|
410
402
|
|
|
411
|
-
protected function pExpr_BinaryOp_Smaller(BinaryOp\Smaller $node
|
|
412
|
-
return $this->pInfixOp(BinaryOp\Smaller::class, $node->left, ' < ', $node->right
|
|
403
|
+
protected function pExpr_BinaryOp_Smaller(BinaryOp\Smaller $node) {
|
|
404
|
+
return $this->pInfixOp(BinaryOp\Smaller::class, $node->left, ' < ', $node->right);
|
|
413
405
|
}
|
|
414
406
|
|
|
415
|
-
protected function pExpr_BinaryOp_SmallerOrEqual(BinaryOp\SmallerOrEqual $node
|
|
416
|
-
return $this->pInfixOp(BinaryOp\SmallerOrEqual::class, $node->left, ' <= ', $node->right
|
|
407
|
+
protected function pExpr_BinaryOp_SmallerOrEqual(BinaryOp\SmallerOrEqual $node) {
|
|
408
|
+
return $this->pInfixOp(BinaryOp\SmallerOrEqual::class, $node->left, ' <= ', $node->right);
|
|
417
409
|
}
|
|
418
410
|
|
|
419
|
-
protected function pExpr_BinaryOp_Coalesce(BinaryOp\Coalesce $node
|
|
420
|
-
return $this->pInfixOp(BinaryOp\Coalesce::class, $node->left, ' ?? ', $node->right
|
|
411
|
+
protected function pExpr_BinaryOp_Coalesce(BinaryOp\Coalesce $node) {
|
|
412
|
+
return $this->pInfixOp(BinaryOp\Coalesce::class, $node->left, ' ?? ', $node->right);
|
|
421
413
|
}
|
|
422
414
|
|
|
423
|
-
protected function pExpr_Instanceof(Expr\Instanceof_ $node
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
415
|
+
protected function pExpr_Instanceof(Expr\Instanceof_ $node) {
|
|
416
|
+
list($precedence, $associativity) = $this->precedenceMap[Expr\Instanceof_::class];
|
|
417
|
+
return $this->pPrec($node->expr, $precedence, $associativity, -1)
|
|
418
|
+
. ' instanceof '
|
|
419
|
+
. $this->pNewVariable($node->class);
|
|
428
420
|
}
|
|
429
421
|
|
|
430
422
|
// Unary expressions
|
|
431
423
|
|
|
432
|
-
protected function pExpr_BooleanNot(Expr\BooleanNot $node
|
|
433
|
-
return $this->pPrefixOp(Expr\BooleanNot::class, '!', $node->expr
|
|
424
|
+
protected function pExpr_BooleanNot(Expr\BooleanNot $node) {
|
|
425
|
+
return $this->pPrefixOp(Expr\BooleanNot::class, '!', $node->expr);
|
|
434
426
|
}
|
|
435
427
|
|
|
436
|
-
protected function pExpr_BitwiseNot(Expr\BitwiseNot $node
|
|
437
|
-
return $this->pPrefixOp(Expr\BitwiseNot::class, '~', $node->expr
|
|
428
|
+
protected function pExpr_BitwiseNot(Expr\BitwiseNot $node) {
|
|
429
|
+
return $this->pPrefixOp(Expr\BitwiseNot::class, '~', $node->expr);
|
|
438
430
|
}
|
|
439
431
|
|
|
440
|
-
protected function pExpr_UnaryMinus(Expr\UnaryMinus $node
|
|
441
|
-
|
|
432
|
+
protected function pExpr_UnaryMinus(Expr\UnaryMinus $node) {
|
|
433
|
+
if ($node->expr instanceof Expr\UnaryMinus || $node->expr instanceof Expr\PreDec) {
|
|
434
|
+
// Enforce -(-$expr) instead of --$expr
|
|
435
|
+
return '-(' . $this->p($node->expr) . ')';
|
|
436
|
+
}
|
|
437
|
+
return $this->pPrefixOp(Expr\UnaryMinus::class, '-', $node->expr);
|
|
442
438
|
}
|
|
443
439
|
|
|
444
|
-
protected function pExpr_UnaryPlus(Expr\UnaryPlus $node
|
|
445
|
-
|
|
440
|
+
protected function pExpr_UnaryPlus(Expr\UnaryPlus $node) {
|
|
441
|
+
if ($node->expr instanceof Expr\UnaryPlus || $node->expr instanceof Expr\PreInc) {
|
|
442
|
+
// Enforce +(+$expr) instead of ++$expr
|
|
443
|
+
return '+(' . $this->p($node->expr) . ')';
|
|
444
|
+
}
|
|
445
|
+
return $this->pPrefixOp(Expr\UnaryPlus::class, '+', $node->expr);
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
-
protected function pExpr_PreInc(Expr\PreInc $node)
|
|
449
|
-
return '++'
|
|
448
|
+
protected function pExpr_PreInc(Expr\PreInc $node) {
|
|
449
|
+
return $this->pPrefixOp(Expr\PreInc::class, '++', $node->var);
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
-
protected function pExpr_PreDec(Expr\PreDec $node)
|
|
453
|
-
return '--'
|
|
452
|
+
protected function pExpr_PreDec(Expr\PreDec $node) {
|
|
453
|
+
return $this->pPrefixOp(Expr\PreDec::class, '--', $node->var);
|
|
454
454
|
}
|
|
455
455
|
|
|
456
|
-
protected function pExpr_PostInc(Expr\PostInc $node)
|
|
457
|
-
return $this->
|
|
456
|
+
protected function pExpr_PostInc(Expr\PostInc $node) {
|
|
457
|
+
return $this->pPostfixOp(Expr\PostInc::class, $node->var, '++');
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
protected function pExpr_PostDec(Expr\PostDec $node)
|
|
461
|
-
return $this->
|
|
460
|
+
protected function pExpr_PostDec(Expr\PostDec $node) {
|
|
461
|
+
return $this->pPostfixOp(Expr\PostDec::class, $node->var, '--');
|
|
462
462
|
}
|
|
463
463
|
|
|
464
|
-
protected function pExpr_ErrorSuppress(Expr\ErrorSuppress $node
|
|
465
|
-
return $this->pPrefixOp(Expr\ErrorSuppress::class, '@', $node->expr
|
|
464
|
+
protected function pExpr_ErrorSuppress(Expr\ErrorSuppress $node) {
|
|
465
|
+
return $this->pPrefixOp(Expr\ErrorSuppress::class, '@', $node->expr);
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
-
protected function pExpr_YieldFrom(Expr\YieldFrom $node
|
|
469
|
-
return $this->pPrefixOp(Expr\YieldFrom::class, 'yield from ', $node->expr
|
|
468
|
+
protected function pExpr_YieldFrom(Expr\YieldFrom $node) {
|
|
469
|
+
return $this->pPrefixOp(Expr\YieldFrom::class, 'yield from ', $node->expr);
|
|
470
470
|
}
|
|
471
471
|
|
|
472
|
-
protected function pExpr_Print(Expr\Print_ $node
|
|
473
|
-
return $this->pPrefixOp(Expr\Print_::class, 'print ', $node->expr
|
|
472
|
+
protected function pExpr_Print(Expr\Print_ $node) {
|
|
473
|
+
return $this->pPrefixOp(Expr\Print_::class, 'print ', $node->expr);
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
// Casts
|
|
477
477
|
|
|
478
|
-
protected function pExpr_Cast_Int(Cast\Int_ $node
|
|
479
|
-
return $this->pPrefixOp(Cast\Int_::class, '(int) ', $node->expr
|
|
478
|
+
protected function pExpr_Cast_Int(Cast\Int_ $node) {
|
|
479
|
+
return $this->pPrefixOp(Cast\Int_::class, '(int) ', $node->expr);
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
protected function pExpr_Cast_Double(Cast\Double $node
|
|
482
|
+
protected function pExpr_Cast_Double(Cast\Double $node) {
|
|
483
483
|
$kind = $node->getAttribute('kind', Cast\Double::KIND_DOUBLE);
|
|
484
484
|
if ($kind === Cast\Double::KIND_DOUBLE) {
|
|
485
485
|
$cast = '(double)';
|
|
486
486
|
} elseif ($kind === Cast\Double::KIND_FLOAT) {
|
|
487
487
|
$cast = '(float)';
|
|
488
|
-
}
|
|
489
|
-
assert($kind === Cast\Double::KIND_REAL);
|
|
488
|
+
} elseif ($kind === Cast\Double::KIND_REAL) {
|
|
490
489
|
$cast = '(real)';
|
|
491
490
|
}
|
|
492
|
-
return $this->pPrefixOp(Cast\Double::class, $cast . ' ', $node->expr
|
|
491
|
+
return $this->pPrefixOp(Cast\Double::class, $cast . ' ', $node->expr);
|
|
493
492
|
}
|
|
494
493
|
|
|
495
|
-
protected function pExpr_Cast_String(Cast\String_ $node
|
|
496
|
-
return $this->pPrefixOp(Cast\String_::class, '(string) ', $node->expr
|
|
494
|
+
protected function pExpr_Cast_String(Cast\String_ $node) {
|
|
495
|
+
return $this->pPrefixOp(Cast\String_::class, '(string) ', $node->expr);
|
|
497
496
|
}
|
|
498
497
|
|
|
499
|
-
protected function pExpr_Cast_Array(Cast\Array_ $node
|
|
500
|
-
return $this->pPrefixOp(Cast\Array_::class, '(array) ', $node->expr
|
|
498
|
+
protected function pExpr_Cast_Array(Cast\Array_ $node) {
|
|
499
|
+
return $this->pPrefixOp(Cast\Array_::class, '(array) ', $node->expr);
|
|
501
500
|
}
|
|
502
501
|
|
|
503
|
-
protected function pExpr_Cast_Object(Cast\Object_ $node
|
|
504
|
-
return $this->pPrefixOp(Cast\Object_::class, '(object) ', $node->expr
|
|
502
|
+
protected function pExpr_Cast_Object(Cast\Object_ $node) {
|
|
503
|
+
return $this->pPrefixOp(Cast\Object_::class, '(object) ', $node->expr);
|
|
505
504
|
}
|
|
506
505
|
|
|
507
|
-
protected function pExpr_Cast_Bool(Cast\Bool_ $node
|
|
508
|
-
return $this->pPrefixOp(Cast\Bool_::class, '(bool) ', $node->expr
|
|
506
|
+
protected function pExpr_Cast_Bool(Cast\Bool_ $node) {
|
|
507
|
+
return $this->pPrefixOp(Cast\Bool_::class, '(bool) ', $node->expr);
|
|
509
508
|
}
|
|
510
509
|
|
|
511
|
-
protected function pExpr_Cast_Unset(Cast\Unset_ $node
|
|
512
|
-
return $this->pPrefixOp(Cast\Unset_::class, '(unset) ', $node->expr
|
|
510
|
+
protected function pExpr_Cast_Unset(Cast\Unset_ $node) {
|
|
511
|
+
return $this->pPrefixOp(Cast\Unset_::class, '(unset) ', $node->expr);
|
|
513
512
|
}
|
|
514
513
|
|
|
515
514
|
// Function calls and similar constructs
|
|
516
515
|
|
|
517
|
-
protected function pExpr_FuncCall(Expr\FuncCall $node)
|
|
516
|
+
protected function pExpr_FuncCall(Expr\FuncCall $node) {
|
|
518
517
|
return $this->pCallLhs($node->name)
|
|
519
518
|
. '(' . $this->pMaybeMultiline($node->args) . ')';
|
|
520
519
|
}
|
|
521
520
|
|
|
522
|
-
protected function pExpr_MethodCall(Expr\MethodCall $node)
|
|
521
|
+
protected function pExpr_MethodCall(Expr\MethodCall $node) {
|
|
523
522
|
return $this->pDereferenceLhs($node->var) . '->' . $this->pObjectProperty($node->name)
|
|
524
523
|
. '(' . $this->pMaybeMultiline($node->args) . ')';
|
|
525
524
|
}
|
|
526
525
|
|
|
527
|
-
protected function pExpr_NullsafeMethodCall(Expr\NullsafeMethodCall $node)
|
|
526
|
+
protected function pExpr_NullsafeMethodCall(Expr\NullsafeMethodCall $node) {
|
|
528
527
|
return $this->pDereferenceLhs($node->var) . '?->' . $this->pObjectProperty($node->name)
|
|
529
528
|
. '(' . $this->pMaybeMultiline($node->args) . ')';
|
|
530
529
|
}
|
|
531
530
|
|
|
532
|
-
protected function pExpr_StaticCall(Expr\StaticCall $node)
|
|
531
|
+
protected function pExpr_StaticCall(Expr\StaticCall $node) {
|
|
533
532
|
return $this->pStaticDereferenceLhs($node->class) . '::'
|
|
534
533
|
. ($node->name instanceof Expr
|
|
535
534
|
? ($node->name instanceof Expr\Variable
|
|
@@ -539,19 +538,19 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
539
538
|
. '(' . $this->pMaybeMultiline($node->args) . ')';
|
|
540
539
|
}
|
|
541
540
|
|
|
542
|
-
protected function pExpr_Empty(Expr\Empty_ $node)
|
|
541
|
+
protected function pExpr_Empty(Expr\Empty_ $node) {
|
|
543
542
|
return 'empty(' . $this->p($node->expr) . ')';
|
|
544
543
|
}
|
|
545
544
|
|
|
546
|
-
protected function pExpr_Isset(Expr\Isset_ $node)
|
|
545
|
+
protected function pExpr_Isset(Expr\Isset_ $node) {
|
|
547
546
|
return 'isset(' . $this->pCommaSeparated($node->vars) . ')';
|
|
548
547
|
}
|
|
549
548
|
|
|
550
|
-
protected function pExpr_Eval(Expr\Eval_ $node)
|
|
549
|
+
protected function pExpr_Eval(Expr\Eval_ $node) {
|
|
551
550
|
return 'eval(' . $this->p($node->expr) . ')';
|
|
552
551
|
}
|
|
553
552
|
|
|
554
|
-
protected function pExpr_Include(Expr\Include_ $node
|
|
553
|
+
protected function pExpr_Include(Expr\Include_ $node) {
|
|
555
554
|
static $map = [
|
|
556
555
|
Expr\Include_::TYPE_INCLUDE => 'include',
|
|
557
556
|
Expr\Include_::TYPE_INCLUDE_ONCE => 'include_once',
|
|
@@ -559,26 +558,20 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
559
558
|
Expr\Include_::TYPE_REQUIRE_ONCE => 'require_once',
|
|
560
559
|
];
|
|
561
560
|
|
|
562
|
-
return $
|
|
561
|
+
return $map[$node->type] . ' ' . $this->p($node->expr);
|
|
563
562
|
}
|
|
564
563
|
|
|
565
|
-
protected function pExpr_List(Expr\List_ $node)
|
|
566
|
-
|
|
567
|
-
$this->phpVersion->supportsShortArrayDestructuring() ? Expr\List_::KIND_ARRAY : Expr\List_::KIND_LIST);
|
|
568
|
-
if ($syntax === Expr\List_::KIND_ARRAY) {
|
|
569
|
-
return '[' . $this->pMaybeMultiline($node->items, true) . ']';
|
|
570
|
-
} else {
|
|
571
|
-
return 'list(' . $this->pMaybeMultiline($node->items, true) . ')';
|
|
572
|
-
}
|
|
564
|
+
protected function pExpr_List(Expr\List_ $node) {
|
|
565
|
+
return 'list(' . $this->pCommaSeparated($node->items) . ')';
|
|
573
566
|
}
|
|
574
567
|
|
|
575
568
|
// Other
|
|
576
569
|
|
|
577
|
-
protected function pExpr_Error(Expr\Error $node)
|
|
570
|
+
protected function pExpr_Error(Expr\Error $node) {
|
|
578
571
|
throw new \LogicException('Cannot pretty-print AST with Error nodes');
|
|
579
572
|
}
|
|
580
573
|
|
|
581
|
-
protected function pExpr_Variable(Expr\Variable $node)
|
|
574
|
+
protected function pExpr_Variable(Expr\Variable $node) {
|
|
582
575
|
if ($node->name instanceof Expr) {
|
|
583
576
|
return '${' . $this->p($node->name) . '}';
|
|
584
577
|
} else {
|
|
@@ -586,9 +579,9 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
586
579
|
}
|
|
587
580
|
}
|
|
588
581
|
|
|
589
|
-
protected function pExpr_Array(Expr\Array_ $node)
|
|
582
|
+
protected function pExpr_Array(Expr\Array_ $node) {
|
|
590
583
|
$syntax = $node->getAttribute('kind',
|
|
591
|
-
$this->shortArraySyntax ? Expr\Array_::KIND_SHORT : Expr\Array_::KIND_LONG);
|
|
584
|
+
$this->options['shortArraySyntax'] ? Expr\Array_::KIND_SHORT : Expr\Array_::KIND_LONG);
|
|
592
585
|
if ($syntax === Expr\Array_::KIND_SHORT) {
|
|
593
586
|
return '[' . $this->pMaybeMultiline($node->items, true) . ']';
|
|
594
587
|
} else {
|
|
@@ -596,152 +589,124 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
596
589
|
}
|
|
597
590
|
}
|
|
598
591
|
|
|
599
|
-
protected function
|
|
600
|
-
|
|
601
|
-
return '';
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
// => is not really an operator and does not typically participate in precedence resolution.
|
|
605
|
-
// However, there is an exception if yield expressions with keys are involved:
|
|
606
|
-
// [yield $a => $b] is interpreted as [(yield $a => $b)], so we need to ensure that
|
|
607
|
-
// [(yield $a) => $b] is printed with parentheses. We approximate this by lowering the LHS
|
|
608
|
-
// precedence to that of yield (which will also print unnecessary parentheses for rare low
|
|
609
|
-
// precedence unary operators like include).
|
|
610
|
-
$yieldPrecedence = $this->precedenceMap[Expr\Yield_::class][0];
|
|
611
|
-
return $this->p($node, self::MAX_PRECEDENCE, $yieldPrecedence) . ' => ';
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
protected function pArrayItem(Node\ArrayItem $node): string {
|
|
615
|
-
return $this->pKey($node->key)
|
|
592
|
+
protected function pExpr_ArrayItem(Expr\ArrayItem $node) {
|
|
593
|
+
return (null !== $node->key ? $this->p($node->key) . ' => ' : '')
|
|
616
594
|
. ($node->byRef ? '&' : '')
|
|
617
595
|
. ($node->unpack ? '...' : '')
|
|
618
596
|
. $this->p($node->value);
|
|
619
597
|
}
|
|
620
598
|
|
|
621
|
-
protected function pExpr_ArrayDimFetch(Expr\ArrayDimFetch $node)
|
|
599
|
+
protected function pExpr_ArrayDimFetch(Expr\ArrayDimFetch $node) {
|
|
622
600
|
return $this->pDereferenceLhs($node->var)
|
|
623
601
|
. '[' . (null !== $node->dim ? $this->p($node->dim) : '') . ']';
|
|
624
602
|
}
|
|
625
603
|
|
|
626
|
-
protected function pExpr_ConstFetch(Expr\ConstFetch $node)
|
|
604
|
+
protected function pExpr_ConstFetch(Expr\ConstFetch $node) {
|
|
627
605
|
return $this->p($node->name);
|
|
628
606
|
}
|
|
629
607
|
|
|
630
|
-
protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node)
|
|
608
|
+
protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node) {
|
|
631
609
|
return $this->pStaticDereferenceLhs($node->class) . '::' . $this->pObjectProperty($node->name);
|
|
632
610
|
}
|
|
633
611
|
|
|
634
|
-
protected function pExpr_PropertyFetch(Expr\PropertyFetch $node)
|
|
612
|
+
protected function pExpr_PropertyFetch(Expr\PropertyFetch $node) {
|
|
635
613
|
return $this->pDereferenceLhs($node->var) . '->' . $this->pObjectProperty($node->name);
|
|
636
614
|
}
|
|
637
615
|
|
|
638
|
-
protected function pExpr_NullsafePropertyFetch(Expr\NullsafePropertyFetch $node)
|
|
616
|
+
protected function pExpr_NullsafePropertyFetch(Expr\NullsafePropertyFetch $node) {
|
|
639
617
|
return $this->pDereferenceLhs($node->var) . '?->' . $this->pObjectProperty($node->name);
|
|
640
618
|
}
|
|
641
619
|
|
|
642
|
-
protected function pExpr_StaticPropertyFetch(Expr\StaticPropertyFetch $node)
|
|
620
|
+
protected function pExpr_StaticPropertyFetch(Expr\StaticPropertyFetch $node) {
|
|
643
621
|
return $this->pStaticDereferenceLhs($node->class) . '::$' . $this->pObjectProperty($node->name);
|
|
644
622
|
}
|
|
645
623
|
|
|
646
|
-
protected function pExpr_ShellExec(Expr\ShellExec $node)
|
|
624
|
+
protected function pExpr_ShellExec(Expr\ShellExec $node) {
|
|
647
625
|
return '`' . $this->pEncapsList($node->parts, '`') . '`';
|
|
648
626
|
}
|
|
649
627
|
|
|
650
|
-
protected function pExpr_Closure(Expr\Closure $node)
|
|
628
|
+
protected function pExpr_Closure(Expr\Closure $node) {
|
|
651
629
|
return $this->pAttrGroups($node->attrGroups, true)
|
|
652
|
-
.
|
|
630
|
+
. ($node->static ? 'static ' : '')
|
|
653
631
|
. 'function ' . ($node->byRef ? '&' : '')
|
|
654
|
-
. '(' . $this->
|
|
655
|
-
. (!empty($node->uses) ? ' use
|
|
656
|
-
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
|
632
|
+
. '(' . $this->pCommaSeparated($node->params) . ')'
|
|
633
|
+
. (!empty($node->uses) ? ' use(' . $this->pCommaSeparated($node->uses) . ')' : '')
|
|
634
|
+
. (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '')
|
|
657
635
|
. ' {' . $this->pStmts($node->stmts) . $this->nl . '}';
|
|
658
636
|
}
|
|
659
637
|
|
|
660
|
-
protected function pExpr_Match(Expr\Match_ $node)
|
|
638
|
+
protected function pExpr_Match(Expr\Match_ $node) {
|
|
661
639
|
return 'match (' . $this->p($node->cond) . ') {'
|
|
662
640
|
. $this->pCommaSeparatedMultiline($node->arms, true)
|
|
663
641
|
. $this->nl
|
|
664
642
|
. '}';
|
|
665
643
|
}
|
|
666
644
|
|
|
667
|
-
protected function pMatchArm(Node\MatchArm $node)
|
|
668
|
-
$
|
|
669
|
-
|
|
670
|
-
for ($i = 0, $c = \count($node->conds); $i + 1 < $c; $i++) {
|
|
671
|
-
$result .= $this->p($node->conds[$i]) . ', ';
|
|
672
|
-
}
|
|
673
|
-
$result .= $this->pKey($node->conds[$i]);
|
|
674
|
-
} else {
|
|
675
|
-
$result = 'default => ';
|
|
676
|
-
}
|
|
677
|
-
return $result . $this->p($node->body);
|
|
645
|
+
protected function pMatchArm(Node\MatchArm $node) {
|
|
646
|
+
return ($node->conds ? $this->pCommaSeparated($node->conds) : 'default')
|
|
647
|
+
. ' => ' . $this->p($node->body);
|
|
678
648
|
}
|
|
679
649
|
|
|
680
|
-
protected function pExpr_ArrowFunction(Expr\ArrowFunction $node
|
|
681
|
-
return $this->
|
|
682
|
-
|
|
683
|
-
$this->pAttrGroups($node->attrGroups, true)
|
|
684
|
-
. $this->pStatic($node->static)
|
|
650
|
+
protected function pExpr_ArrowFunction(Expr\ArrowFunction $node) {
|
|
651
|
+
return $this->pAttrGroups($node->attrGroups, true)
|
|
652
|
+
. ($node->static ? 'static ' : '')
|
|
685
653
|
. 'fn' . ($node->byRef ? '&' : '')
|
|
686
|
-
. '(' . $this->
|
|
654
|
+
. '(' . $this->pCommaSeparated($node->params) . ')'
|
|
687
655
|
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
|
688
|
-
. ' => '
|
|
689
|
-
$node->expr
|
|
656
|
+
. ' => '
|
|
657
|
+
. $this->p($node->expr);
|
|
690
658
|
}
|
|
691
659
|
|
|
692
|
-
protected function
|
|
660
|
+
protected function pExpr_ClosureUse(Expr\ClosureUse $node) {
|
|
693
661
|
return ($node->byRef ? '&' : '') . $this->p($node->var);
|
|
694
662
|
}
|
|
695
663
|
|
|
696
|
-
protected function pExpr_New(Expr\New_ $node)
|
|
664
|
+
protected function pExpr_New(Expr\New_ $node) {
|
|
697
665
|
if ($node->class instanceof Stmt\Class_) {
|
|
698
666
|
$args = $node->args ? '(' . $this->pMaybeMultiline($node->args) . ')' : '';
|
|
699
667
|
return 'new ' . $this->pClassCommon($node->class, $args);
|
|
700
668
|
}
|
|
701
|
-
return 'new ' . $this->
|
|
669
|
+
return 'new ' . $this->pNewVariable($node->class)
|
|
702
670
|
. '(' . $this->pMaybeMultiline($node->args) . ')';
|
|
703
671
|
}
|
|
704
672
|
|
|
705
|
-
protected function pExpr_Clone(Expr\Clone_ $node
|
|
706
|
-
return
|
|
673
|
+
protected function pExpr_Clone(Expr\Clone_ $node) {
|
|
674
|
+
return 'clone ' . $this->p($node->expr);
|
|
707
675
|
}
|
|
708
676
|
|
|
709
|
-
protected function pExpr_Ternary(Expr\Ternary $node
|
|
677
|
+
protected function pExpr_Ternary(Expr\Ternary $node) {
|
|
710
678
|
// a bit of cheating: we treat the ternary as a binary op where the ?...: part is the operator.
|
|
711
679
|
// this is okay because the part between ? and : never needs parentheses.
|
|
712
680
|
return $this->pInfixOp(Expr\Ternary::class,
|
|
713
|
-
$node->cond, ' ?' . (null !== $node->if ? ' ' . $this->p($node->if) . ' ' : '') . ': ', $node->else
|
|
714
|
-
$precedence, $lhsPrecedence
|
|
681
|
+
$node->cond, ' ?' . (null !== $node->if ? ' ' . $this->p($node->if) . ' ' : '') . ': ', $node->else
|
|
715
682
|
);
|
|
716
683
|
}
|
|
717
684
|
|
|
718
|
-
protected function pExpr_Exit(Expr\Exit_ $node)
|
|
685
|
+
protected function pExpr_Exit(Expr\Exit_ $node) {
|
|
719
686
|
$kind = $node->getAttribute('kind', Expr\Exit_::KIND_DIE);
|
|
720
687
|
return ($kind === Expr\Exit_::KIND_EXIT ? 'exit' : 'die')
|
|
721
688
|
. (null !== $node->expr ? '(' . $this->p($node->expr) . ')' : '');
|
|
722
689
|
}
|
|
723
690
|
|
|
724
|
-
protected function pExpr_Throw(Expr\Throw_ $node
|
|
725
|
-
return
|
|
691
|
+
protected function pExpr_Throw(Expr\Throw_ $node) {
|
|
692
|
+
return 'throw ' . $this->p($node->expr);
|
|
726
693
|
}
|
|
727
694
|
|
|
728
|
-
protected function pExpr_Yield(Expr\Yield_ $node
|
|
695
|
+
protected function pExpr_Yield(Expr\Yield_ $node) {
|
|
729
696
|
if ($node->value === null) {
|
|
730
|
-
|
|
731
|
-
return $opPrecedence >= $lhsPrecedence ? '(yield)' : 'yield';
|
|
697
|
+
return 'yield';
|
|
732
698
|
} else {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
$node->value, $precedence, $lhsPrecedence);
|
|
699
|
+
// this is a bit ugly, but currently there is no way to detect whether the parentheses are necessary
|
|
700
|
+
return '(yield '
|
|
701
|
+
. ($node->key !== null ? $this->p($node->key) . ' => ' : '')
|
|
702
|
+
. $this->p($node->value)
|
|
703
|
+
. ')';
|
|
739
704
|
}
|
|
740
705
|
}
|
|
741
706
|
|
|
742
707
|
// Declarations
|
|
743
708
|
|
|
744
|
-
protected function pStmt_Namespace(Stmt\Namespace_ $node)
|
|
709
|
+
protected function pStmt_Namespace(Stmt\Namespace_ $node) {
|
|
745
710
|
if ($this->canUseSemicolonNamespaces) {
|
|
746
711
|
return 'namespace ' . $this->p($node->name) . ';'
|
|
747
712
|
. $this->nl . $this->pStmts($node->stmts, false);
|
|
@@ -751,102 +716,102 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
751
716
|
}
|
|
752
717
|
}
|
|
753
718
|
|
|
754
|
-
protected function pStmt_Use(Stmt\Use_ $node)
|
|
719
|
+
protected function pStmt_Use(Stmt\Use_ $node) {
|
|
755
720
|
return 'use ' . $this->pUseType($node->type)
|
|
756
721
|
. $this->pCommaSeparated($node->uses) . ';';
|
|
757
722
|
}
|
|
758
723
|
|
|
759
|
-
protected function pStmt_GroupUse(Stmt\GroupUse $node)
|
|
724
|
+
protected function pStmt_GroupUse(Stmt\GroupUse $node) {
|
|
760
725
|
return 'use ' . $this->pUseType($node->type) . $this->pName($node->prefix)
|
|
761
726
|
. '\{' . $this->pCommaSeparated($node->uses) . '};';
|
|
762
727
|
}
|
|
763
728
|
|
|
764
|
-
protected function
|
|
729
|
+
protected function pStmt_UseUse(Stmt\UseUse $node) {
|
|
765
730
|
return $this->pUseType($node->type) . $this->p($node->name)
|
|
766
731
|
. (null !== $node->alias ? ' as ' . $node->alias : '');
|
|
767
732
|
}
|
|
768
733
|
|
|
769
|
-
protected function pUseType(
|
|
734
|
+
protected function pUseType($type) {
|
|
770
735
|
return $type === Stmt\Use_::TYPE_FUNCTION ? 'function '
|
|
771
736
|
: ($type === Stmt\Use_::TYPE_CONSTANT ? 'const ' : '');
|
|
772
737
|
}
|
|
773
738
|
|
|
774
|
-
protected function pStmt_Interface(Stmt\Interface_ $node)
|
|
739
|
+
protected function pStmt_Interface(Stmt\Interface_ $node) {
|
|
775
740
|
return $this->pAttrGroups($node->attrGroups)
|
|
776
741
|
. 'interface ' . $node->name
|
|
777
742
|
. (!empty($node->extends) ? ' extends ' . $this->pCommaSeparated($node->extends) : '')
|
|
778
743
|
. $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
|
|
779
744
|
}
|
|
780
745
|
|
|
781
|
-
protected function pStmt_Enum(Stmt\Enum_ $node)
|
|
746
|
+
protected function pStmt_Enum(Stmt\Enum_ $node) {
|
|
782
747
|
return $this->pAttrGroups($node->attrGroups)
|
|
783
748
|
. 'enum ' . $node->name
|
|
784
|
-
. ($node->scalarType ?
|
|
749
|
+
. ($node->scalarType ? " : $node->scalarType" : '')
|
|
785
750
|
. (!empty($node->implements) ? ' implements ' . $this->pCommaSeparated($node->implements) : '')
|
|
786
751
|
. $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
|
|
787
752
|
}
|
|
788
753
|
|
|
789
|
-
protected function pStmt_Class(Stmt\Class_ $node)
|
|
754
|
+
protected function pStmt_Class(Stmt\Class_ $node) {
|
|
790
755
|
return $this->pClassCommon($node, ' ' . $node->name);
|
|
791
756
|
}
|
|
792
757
|
|
|
793
|
-
protected function pStmt_Trait(Stmt\Trait_ $node)
|
|
758
|
+
protected function pStmt_Trait(Stmt\Trait_ $node) {
|
|
794
759
|
return $this->pAttrGroups($node->attrGroups)
|
|
795
760
|
. 'trait ' . $node->name
|
|
796
761
|
. $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
|
|
797
762
|
}
|
|
798
763
|
|
|
799
|
-
protected function pStmt_EnumCase(Stmt\EnumCase $node)
|
|
764
|
+
protected function pStmt_EnumCase(Stmt\EnumCase $node) {
|
|
800
765
|
return $this->pAttrGroups($node->attrGroups)
|
|
801
766
|
. 'case ' . $node->name
|
|
802
767
|
. ($node->expr ? ' = ' . $this->p($node->expr) : '')
|
|
803
768
|
. ';';
|
|
804
769
|
}
|
|
805
770
|
|
|
806
|
-
protected function pStmt_TraitUse(Stmt\TraitUse $node)
|
|
771
|
+
protected function pStmt_TraitUse(Stmt\TraitUse $node) {
|
|
807
772
|
return 'use ' . $this->pCommaSeparated($node->traits)
|
|
808
773
|
. (empty($node->adaptations)
|
|
809
774
|
? ';'
|
|
810
775
|
: ' {' . $this->pStmts($node->adaptations) . $this->nl . '}');
|
|
811
776
|
}
|
|
812
777
|
|
|
813
|
-
protected function pStmt_TraitUseAdaptation_Precedence(Stmt\TraitUseAdaptation\Precedence $node)
|
|
778
|
+
protected function pStmt_TraitUseAdaptation_Precedence(Stmt\TraitUseAdaptation\Precedence $node) {
|
|
814
779
|
return $this->p($node->trait) . '::' . $node->method
|
|
815
780
|
. ' insteadof ' . $this->pCommaSeparated($node->insteadof) . ';';
|
|
816
781
|
}
|
|
817
782
|
|
|
818
|
-
protected function pStmt_TraitUseAdaptation_Alias(Stmt\TraitUseAdaptation\Alias $node)
|
|
783
|
+
protected function pStmt_TraitUseAdaptation_Alias(Stmt\TraitUseAdaptation\Alias $node) {
|
|
819
784
|
return (null !== $node->trait ? $this->p($node->trait) . '::' : '')
|
|
820
785
|
. $node->method . ' as'
|
|
821
786
|
. (null !== $node->newModifier ? ' ' . rtrim($this->pModifiers($node->newModifier), ' ') : '')
|
|
822
|
-
. (null !== $node->newName
|
|
787
|
+
. (null !== $node->newName ? ' ' . $node->newName : '')
|
|
823
788
|
. ';';
|
|
824
789
|
}
|
|
825
790
|
|
|
826
|
-
protected function pStmt_Property(Stmt\Property $node)
|
|
791
|
+
protected function pStmt_Property(Stmt\Property $node) {
|
|
827
792
|
return $this->pAttrGroups($node->attrGroups)
|
|
828
793
|
. (0 === $node->flags ? 'var ' : $this->pModifiers($node->flags))
|
|
829
794
|
. ($node->type ? $this->p($node->type) . ' ' : '')
|
|
830
795
|
. $this->pCommaSeparated($node->props) . ';';
|
|
831
796
|
}
|
|
832
797
|
|
|
833
|
-
protected function
|
|
798
|
+
protected function pStmt_PropertyProperty(Stmt\PropertyProperty $node) {
|
|
834
799
|
return '$' . $node->name
|
|
835
800
|
. (null !== $node->default ? ' = ' . $this->p($node->default) : '');
|
|
836
801
|
}
|
|
837
802
|
|
|
838
|
-
protected function pStmt_ClassMethod(Stmt\ClassMethod $node)
|
|
803
|
+
protected function pStmt_ClassMethod(Stmt\ClassMethod $node) {
|
|
839
804
|
return $this->pAttrGroups($node->attrGroups)
|
|
840
805
|
. $this->pModifiers($node->flags)
|
|
841
806
|
. 'function ' . ($node->byRef ? '&' : '') . $node->name
|
|
842
|
-
. '(' . $this->pMaybeMultiline($node->params
|
|
843
|
-
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
|
807
|
+
. '(' . $this->pMaybeMultiline($node->params) . ')'
|
|
808
|
+
. (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '')
|
|
844
809
|
. (null !== $node->stmts
|
|
845
810
|
? $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'
|
|
846
811
|
: ';');
|
|
847
812
|
}
|
|
848
813
|
|
|
849
|
-
protected function pStmt_ClassConst(Stmt\ClassConst $node)
|
|
814
|
+
protected function pStmt_ClassConst(Stmt\ClassConst $node) {
|
|
850
815
|
return $this->pAttrGroups($node->attrGroups)
|
|
851
816
|
. $this->pModifiers($node->flags)
|
|
852
817
|
. 'const '
|
|
@@ -854,50 +819,46 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
854
819
|
. $this->pCommaSeparated($node->consts) . ';';
|
|
855
820
|
}
|
|
856
821
|
|
|
857
|
-
protected function pStmt_Function(Stmt\Function_ $node)
|
|
822
|
+
protected function pStmt_Function(Stmt\Function_ $node) {
|
|
858
823
|
return $this->pAttrGroups($node->attrGroups)
|
|
859
824
|
. 'function ' . ($node->byRef ? '&' : '') . $node->name
|
|
860
|
-
. '(' . $this->
|
|
861
|
-
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
|
825
|
+
. '(' . $this->pCommaSeparated($node->params) . ')'
|
|
826
|
+
. (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '')
|
|
862
827
|
. $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
|
|
863
828
|
}
|
|
864
829
|
|
|
865
|
-
protected function pStmt_Const(Stmt\Const_ $node)
|
|
830
|
+
protected function pStmt_Const(Stmt\Const_ $node) {
|
|
866
831
|
return 'const ' . $this->pCommaSeparated($node->consts) . ';';
|
|
867
832
|
}
|
|
868
833
|
|
|
869
|
-
protected function pStmt_Declare(Stmt\Declare_ $node)
|
|
834
|
+
protected function pStmt_Declare(Stmt\Declare_ $node) {
|
|
870
835
|
return 'declare (' . $this->pCommaSeparated($node->declares) . ')'
|
|
871
836
|
. (null !== $node->stmts ? ' {' . $this->pStmts($node->stmts) . $this->nl . '}' : ';');
|
|
872
837
|
}
|
|
873
838
|
|
|
874
|
-
protected function
|
|
839
|
+
protected function pStmt_DeclareDeclare(Stmt\DeclareDeclare $node) {
|
|
875
840
|
return $node->key . '=' . $this->p($node->value);
|
|
876
841
|
}
|
|
877
842
|
|
|
878
843
|
// Control flow
|
|
879
844
|
|
|
880
|
-
protected function pStmt_If(Stmt\If_ $node)
|
|
845
|
+
protected function pStmt_If(Stmt\If_ $node) {
|
|
881
846
|
return 'if (' . $this->p($node->cond) . ') {'
|
|
882
847
|
. $this->pStmts($node->stmts) . $this->nl . '}'
|
|
883
848
|
. ($node->elseifs ? ' ' . $this->pImplode($node->elseifs, ' ') : '')
|
|
884
849
|
. (null !== $node->else ? ' ' . $this->p($node->else) : '');
|
|
885
850
|
}
|
|
886
851
|
|
|
887
|
-
protected function pStmt_ElseIf(Stmt\ElseIf_ $node)
|
|
852
|
+
protected function pStmt_ElseIf(Stmt\ElseIf_ $node) {
|
|
888
853
|
return 'elseif (' . $this->p($node->cond) . ') {'
|
|
889
854
|
. $this->pStmts($node->stmts) . $this->nl . '}';
|
|
890
855
|
}
|
|
891
856
|
|
|
892
|
-
protected function pStmt_Else(Stmt\Else_ $node)
|
|
893
|
-
if (\count($node->stmts) === 1 && $node->stmts[0] instanceof Stmt\If_) {
|
|
894
|
-
// Print as "else if" rather than "else { if }"
|
|
895
|
-
return 'else ' . $this->p($node->stmts[0]);
|
|
896
|
-
}
|
|
857
|
+
protected function pStmt_Else(Stmt\Else_ $node) {
|
|
897
858
|
return 'else {' . $this->pStmts($node->stmts) . $this->nl . '}';
|
|
898
859
|
}
|
|
899
860
|
|
|
900
|
-
protected function pStmt_For(Stmt\For_ $node)
|
|
861
|
+
protected function pStmt_For(Stmt\For_ $node) {
|
|
901
862
|
return 'for ('
|
|
902
863
|
. $this->pCommaSeparated($node->init) . ';' . (!empty($node->cond) ? ' ' : '')
|
|
903
864
|
. $this->pCommaSeparated($node->cond) . ';' . (!empty($node->loop) ? ' ' : '')
|
|
@@ -905,116 +866,116 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
905
866
|
. ') {' . $this->pStmts($node->stmts) . $this->nl . '}';
|
|
906
867
|
}
|
|
907
868
|
|
|
908
|
-
protected function pStmt_Foreach(Stmt\Foreach_ $node)
|
|
869
|
+
protected function pStmt_Foreach(Stmt\Foreach_ $node) {
|
|
909
870
|
return 'foreach (' . $this->p($node->expr) . ' as '
|
|
910
871
|
. (null !== $node->keyVar ? $this->p($node->keyVar) . ' => ' : '')
|
|
911
872
|
. ($node->byRef ? '&' : '') . $this->p($node->valueVar) . ') {'
|
|
912
873
|
. $this->pStmts($node->stmts) . $this->nl . '}';
|
|
913
874
|
}
|
|
914
875
|
|
|
915
|
-
protected function pStmt_While(Stmt\While_ $node)
|
|
876
|
+
protected function pStmt_While(Stmt\While_ $node) {
|
|
916
877
|
return 'while (' . $this->p($node->cond) . ') {'
|
|
917
878
|
. $this->pStmts($node->stmts) . $this->nl . '}';
|
|
918
879
|
}
|
|
919
880
|
|
|
920
|
-
protected function pStmt_Do(Stmt\Do_ $node)
|
|
881
|
+
protected function pStmt_Do(Stmt\Do_ $node) {
|
|
921
882
|
return 'do {' . $this->pStmts($node->stmts) . $this->nl
|
|
922
883
|
. '} while (' . $this->p($node->cond) . ');';
|
|
923
884
|
}
|
|
924
885
|
|
|
925
|
-
protected function pStmt_Switch(Stmt\Switch_ $node)
|
|
886
|
+
protected function pStmt_Switch(Stmt\Switch_ $node) {
|
|
926
887
|
return 'switch (' . $this->p($node->cond) . ') {'
|
|
927
888
|
. $this->pStmts($node->cases) . $this->nl . '}';
|
|
928
889
|
}
|
|
929
890
|
|
|
930
|
-
protected function pStmt_Case(Stmt\Case_ $node)
|
|
891
|
+
protected function pStmt_Case(Stmt\Case_ $node) {
|
|
931
892
|
return (null !== $node->cond ? 'case ' . $this->p($node->cond) : 'default') . ':'
|
|
932
893
|
. $this->pStmts($node->stmts);
|
|
933
894
|
}
|
|
934
895
|
|
|
935
|
-
protected function pStmt_TryCatch(Stmt\TryCatch $node)
|
|
896
|
+
protected function pStmt_TryCatch(Stmt\TryCatch $node) {
|
|
936
897
|
return 'try {' . $this->pStmts($node->stmts) . $this->nl . '}'
|
|
937
898
|
. ($node->catches ? ' ' . $this->pImplode($node->catches, ' ') : '')
|
|
938
899
|
. ($node->finally !== null ? ' ' . $this->p($node->finally) : '');
|
|
939
900
|
}
|
|
940
901
|
|
|
941
|
-
protected function pStmt_Catch(Stmt\Catch_ $node)
|
|
902
|
+
protected function pStmt_Catch(Stmt\Catch_ $node) {
|
|
942
903
|
return 'catch (' . $this->pImplode($node->types, '|')
|
|
943
904
|
. ($node->var !== null ? ' ' . $this->p($node->var) : '')
|
|
944
905
|
. ') {' . $this->pStmts($node->stmts) . $this->nl . '}';
|
|
945
906
|
}
|
|
946
907
|
|
|
947
|
-
protected function pStmt_Finally(Stmt\Finally_ $node)
|
|
908
|
+
protected function pStmt_Finally(Stmt\Finally_ $node) {
|
|
948
909
|
return 'finally {' . $this->pStmts($node->stmts) . $this->nl . '}';
|
|
949
910
|
}
|
|
950
911
|
|
|
951
|
-
protected function pStmt_Break(Stmt\Break_ $node)
|
|
912
|
+
protected function pStmt_Break(Stmt\Break_ $node) {
|
|
952
913
|
return 'break' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';';
|
|
953
914
|
}
|
|
954
915
|
|
|
955
|
-
protected function pStmt_Continue(Stmt\Continue_ $node)
|
|
916
|
+
protected function pStmt_Continue(Stmt\Continue_ $node) {
|
|
956
917
|
return 'continue' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';';
|
|
957
918
|
}
|
|
958
919
|
|
|
959
|
-
protected function pStmt_Return(Stmt\Return_ $node)
|
|
920
|
+
protected function pStmt_Return(Stmt\Return_ $node) {
|
|
960
921
|
return 'return' . (null !== $node->expr ? ' ' . $this->p($node->expr) : '') . ';';
|
|
961
922
|
}
|
|
962
923
|
|
|
963
|
-
protected function
|
|
924
|
+
protected function pStmt_Throw(Stmt\Throw_ $node) {
|
|
925
|
+
return 'throw ' . $this->p($node->expr) . ';';
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
protected function pStmt_Label(Stmt\Label $node) {
|
|
964
929
|
return $node->name . ':';
|
|
965
930
|
}
|
|
966
931
|
|
|
967
|
-
protected function pStmt_Goto(Stmt\Goto_ $node)
|
|
932
|
+
protected function pStmt_Goto(Stmt\Goto_ $node) {
|
|
968
933
|
return 'goto ' . $node->name . ';';
|
|
969
934
|
}
|
|
970
935
|
|
|
971
936
|
// Other
|
|
972
937
|
|
|
973
|
-
protected function pStmt_Expression(Stmt\Expression $node)
|
|
938
|
+
protected function pStmt_Expression(Stmt\Expression $node) {
|
|
974
939
|
return $this->p($node->expr) . ';';
|
|
975
940
|
}
|
|
976
941
|
|
|
977
|
-
protected function pStmt_Echo(Stmt\Echo_ $node)
|
|
942
|
+
protected function pStmt_Echo(Stmt\Echo_ $node) {
|
|
978
943
|
return 'echo ' . $this->pCommaSeparated($node->exprs) . ';';
|
|
979
944
|
}
|
|
980
945
|
|
|
981
|
-
protected function pStmt_Static(Stmt\Static_ $node)
|
|
946
|
+
protected function pStmt_Static(Stmt\Static_ $node) {
|
|
982
947
|
return 'static ' . $this->pCommaSeparated($node->vars) . ';';
|
|
983
948
|
}
|
|
984
949
|
|
|
985
|
-
protected function pStmt_Global(Stmt\Global_ $node)
|
|
950
|
+
protected function pStmt_Global(Stmt\Global_ $node) {
|
|
986
951
|
return 'global ' . $this->pCommaSeparated($node->vars) . ';';
|
|
987
952
|
}
|
|
988
953
|
|
|
989
|
-
protected function
|
|
954
|
+
protected function pStmt_StaticVar(Stmt\StaticVar $node) {
|
|
990
955
|
return $this->p($node->var)
|
|
991
956
|
. (null !== $node->default ? ' = ' . $this->p($node->default) : '');
|
|
992
957
|
}
|
|
993
958
|
|
|
994
|
-
protected function pStmt_Unset(Stmt\Unset_ $node)
|
|
959
|
+
protected function pStmt_Unset(Stmt\Unset_ $node) {
|
|
995
960
|
return 'unset(' . $this->pCommaSeparated($node->vars) . ');';
|
|
996
961
|
}
|
|
997
962
|
|
|
998
|
-
protected function pStmt_InlineHTML(Stmt\InlineHTML $node)
|
|
999
|
-
$newline = $node->getAttribute('hasLeadingNewline', true) ?
|
|
963
|
+
protected function pStmt_InlineHTML(Stmt\InlineHTML $node) {
|
|
964
|
+
$newline = $node->getAttribute('hasLeadingNewline', true) ? "\n" : '';
|
|
1000
965
|
return '?>' . $newline . $node->value . '<?php ';
|
|
1001
966
|
}
|
|
1002
967
|
|
|
1003
|
-
protected function pStmt_HaltCompiler(Stmt\HaltCompiler $node)
|
|
968
|
+
protected function pStmt_HaltCompiler(Stmt\HaltCompiler $node) {
|
|
1004
969
|
return '__halt_compiler();' . $node->remaining;
|
|
1005
970
|
}
|
|
1006
971
|
|
|
1007
|
-
protected function pStmt_Nop(Stmt\Nop $node)
|
|
972
|
+
protected function pStmt_Nop(Stmt\Nop $node) {
|
|
1008
973
|
return '';
|
|
1009
974
|
}
|
|
1010
975
|
|
|
1011
|
-
protected function pStmt_Block(Stmt\Block $node): string {
|
|
1012
|
-
return '{' . $this->pStmts($node->stmts) . $this->nl . '}';
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
976
|
// Helpers
|
|
1016
977
|
|
|
1017
|
-
protected function pClassCommon(Stmt\Class_ $node,
|
|
978
|
+
protected function pClassCommon(Stmt\Class_ $node, $afterClassToken) {
|
|
1018
979
|
return $this->pAttrGroups($node->attrGroups, $node->name === null)
|
|
1019
980
|
. $this->pModifiers($node->flags)
|
|
1020
981
|
. 'class' . $afterClassToken
|
|
@@ -1023,20 +984,18 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
1023
984
|
. $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
|
|
1024
985
|
}
|
|
1025
986
|
|
|
1026
|
-
protected function pObjectProperty(
|
|
987
|
+
protected function pObjectProperty($node) {
|
|
1027
988
|
if ($node instanceof Expr) {
|
|
1028
989
|
return '{' . $this->p($node) . '}';
|
|
1029
990
|
} else {
|
|
1030
|
-
|
|
1031
|
-
return $node->name;
|
|
991
|
+
return $node;
|
|
1032
992
|
}
|
|
1033
993
|
}
|
|
1034
994
|
|
|
1035
|
-
|
|
1036
|
-
protected function pEncapsList(array $encapsList, ?string $quote): string {
|
|
995
|
+
protected function pEncapsList(array $encapsList, $quote) {
|
|
1037
996
|
$return = '';
|
|
1038
997
|
foreach ($encapsList as $element) {
|
|
1039
|
-
if ($element instanceof
|
|
998
|
+
if ($element instanceof Scalar\EncapsedStringPart) {
|
|
1040
999
|
$return .= $this->escapeString($element->value, $quote);
|
|
1041
1000
|
} else {
|
|
1042
1001
|
$return .= '{' . $this->p($element) . '}';
|
|
@@ -1046,25 +1005,14 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
1046
1005
|
return $return;
|
|
1047
1006
|
}
|
|
1048
1007
|
|
|
1049
|
-
protected function pSingleQuotedString(string $string)
|
|
1050
|
-
|
|
1051
|
-
// the end of the string ('Foo\Bar' instead of 'Foo\\Bar'). However, we also don't want to
|
|
1052
|
-
// produce an odd number of backslashes, so '\\\\a' should not get rendered as '\\\a', even
|
|
1053
|
-
// though that would be legal.
|
|
1054
|
-
$regex = '/\'|\\\\(?=[\'\\\\]|$)|(?<=\\\\)\\\\/';
|
|
1055
|
-
return '\'' . preg_replace($regex, '\\\\$0', $string) . '\'';
|
|
1008
|
+
protected function pSingleQuotedString(string $string) {
|
|
1009
|
+
return '\'' . addcslashes($string, '\'\\') . '\'';
|
|
1056
1010
|
}
|
|
1057
1011
|
|
|
1058
|
-
protected function escapeString(
|
|
1012
|
+
protected function escapeString($string, $quote) {
|
|
1059
1013
|
if (null === $quote) {
|
|
1060
1014
|
// For doc strings, don't escape newlines
|
|
1061
1015
|
$escaped = addcslashes($string, "\t\f\v$\\");
|
|
1062
|
-
// But do escape isolated \r. Combined with the terminating newline, it might get
|
|
1063
|
-
// interpreted as \r\n and dropped from the string contents.
|
|
1064
|
-
$escaped = preg_replace('/\r(?!\n)/', '\\r', $escaped);
|
|
1065
|
-
if ($this->phpVersion->supportsFlexibleHeredoc()) {
|
|
1066
|
-
$escaped = $this->indentString($escaped);
|
|
1067
|
-
}
|
|
1068
1016
|
} else {
|
|
1069
1017
|
$escaped = addcslashes($string, "\n\r\t\f\v$" . $quote . "\\");
|
|
1070
1018
|
}
|
|
@@ -1086,24 +1034,26 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
1086
1034
|
| (?<=[\xF0-\xF4])[\x80-\xBF](?![\x80-\xBF]{2}) # Short 4 byte sequence
|
|
1087
1035
|
| (?<=[\xF0-\xF4][\x80-\xBF])[\x80-\xBF](?![\x80-\xBF]) # Short 4 byte sequence (2)
|
|
1088
1036
|
)/x';
|
|
1089
|
-
return preg_replace_callback($regex, function ($matches)
|
|
1037
|
+
return preg_replace_callback($regex, function ($matches) {
|
|
1090
1038
|
assert(strlen($matches[0]) === 1);
|
|
1091
|
-
$hex = dechex(ord($matches[0]))
|
|
1039
|
+
$hex = dechex(ord($matches[0]));;
|
|
1092
1040
|
return '\\x' . str_pad($hex, 2, '0', \STR_PAD_LEFT);
|
|
1093
1041
|
}, $escaped);
|
|
1094
1042
|
}
|
|
1095
1043
|
|
|
1096
|
-
protected function containsEndLabel(
|
|
1097
|
-
$start = $atStart ? '(?:^|[\r\n])
|
|
1044
|
+
protected function containsEndLabel($string, $label, $atStart = true, $atEnd = true) {
|
|
1045
|
+
$start = $atStart ? '(?:^|[\r\n])' : '[\r\n]';
|
|
1046
|
+
$end = $atEnd ? '(?:$|[;\r\n])' : '[;\r\n]';
|
|
1098
1047
|
return false !== strpos($string, $label)
|
|
1099
|
-
&& preg_match('/' . $start . $label . '
|
|
1048
|
+
&& preg_match('/' . $start . $label . $end . '/', $string);
|
|
1100
1049
|
}
|
|
1101
1050
|
|
|
1102
|
-
|
|
1103
|
-
protected function encapsedContainsEndLabel(array $parts, string $label): bool {
|
|
1051
|
+
protected function encapsedContainsEndLabel(array $parts, $label) {
|
|
1104
1052
|
foreach ($parts as $i => $part) {
|
|
1105
|
-
|
|
1106
|
-
|
|
1053
|
+
$atStart = $i === 0;
|
|
1054
|
+
$atEnd = $i === count($parts) - 1;
|
|
1055
|
+
if ($part instanceof Scalar\EncapsedStringPart
|
|
1056
|
+
&& $this->containsEndLabel($part->value, $label, $atStart, $atEnd)
|
|
1107
1057
|
) {
|
|
1108
1058
|
return true;
|
|
1109
1059
|
}
|
|
@@ -1111,15 +1061,15 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
1111
1061
|
return false;
|
|
1112
1062
|
}
|
|
1113
1063
|
|
|
1114
|
-
protected function pDereferenceLhs(Node $node)
|
|
1064
|
+
protected function pDereferenceLhs(Node $node) {
|
|
1115
1065
|
if (!$this->dereferenceLhsRequiresParens($node)) {
|
|
1116
1066
|
return $this->p($node);
|
|
1117
|
-
} else
|
|
1067
|
+
} else {
|
|
1118
1068
|
return '(' . $this->p($node) . ')';
|
|
1119
1069
|
}
|
|
1120
1070
|
}
|
|
1121
1071
|
|
|
1122
|
-
protected function pStaticDereferenceLhs(Node $node)
|
|
1072
|
+
protected function pStaticDereferenceLhs(Node $node) {
|
|
1123
1073
|
if (!$this->staticDereferenceLhsRequiresParens($node)) {
|
|
1124
1074
|
return $this->p($node);
|
|
1125
1075
|
} else {
|
|
@@ -1127,15 +1077,15 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
1127
1077
|
}
|
|
1128
1078
|
}
|
|
1129
1079
|
|
|
1130
|
-
protected function pCallLhs(Node $node)
|
|
1080
|
+
protected function pCallLhs(Node $node) {
|
|
1131
1081
|
if (!$this->callLhsRequiresParens($node)) {
|
|
1132
1082
|
return $this->p($node);
|
|
1133
|
-
} else
|
|
1083
|
+
} else {
|
|
1134
1084
|
return '(' . $this->p($node) . ')';
|
|
1135
1085
|
}
|
|
1136
1086
|
}
|
|
1137
1087
|
|
|
1138
|
-
protected function
|
|
1088
|
+
protected function pNewVariable(Node $node): string {
|
|
1139
1089
|
if (!$this->newOperandRequiresParens($node)) {
|
|
1140
1090
|
return $this->p($node);
|
|
1141
1091
|
} else {
|
|
@@ -1145,8 +1095,9 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
1145
1095
|
|
|
1146
1096
|
/**
|
|
1147
1097
|
* @param Node[] $nodes
|
|
1098
|
+
* @return bool
|
|
1148
1099
|
*/
|
|
1149
|
-
protected function hasNodeWithComments(array $nodes)
|
|
1100
|
+
protected function hasNodeWithComments(array $nodes) {
|
|
1150
1101
|
foreach ($nodes as $node) {
|
|
1151
1102
|
if ($node && $node->getComments()) {
|
|
1152
1103
|
return true;
|
|
@@ -1155,8 +1106,7 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
1155
1106
|
return false;
|
|
1156
1107
|
}
|
|
1157
1108
|
|
|
1158
|
-
|
|
1159
|
-
protected function pMaybeMultiline(array $nodes, bool $trailingComma = false): string {
|
|
1109
|
+
protected function pMaybeMultiline(array $nodes, bool $trailingComma = false) {
|
|
1160
1110
|
if (!$this->hasNodeWithComments($nodes)) {
|
|
1161
1111
|
return $this->pCommaSeparated($nodes);
|
|
1162
1112
|
} else {
|
|
@@ -1164,7 +1114,6 @@ class Standard extends PrettyPrinterAbstract {
|
|
|
1164
1114
|
}
|
|
1165
1115
|
}
|
|
1166
1116
|
|
|
1167
|
-
/** @param Node\AttributeGroup[] $nodes */
|
|
1168
1117
|
protected function pAttrGroups(array $nodes, bool $inline = false): string {
|
|
1169
1118
|
$result = '';
|
|
1170
1119
|
$sep = $inline ? ' ' : $this->nl;
|