@appthreat/atom 1.7.5 → 1.8.1
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/astgen.js +6 -2
- package/index.js +3 -1
- package/package.json +3 -2
- package/phpastgen.js +31 -0
- package/plugins/autoload.php +25 -0
- package/plugins/bin/atom +1 -1
- package/plugins/bin/atom.bat +1 -1
- package/plugins/bin/php-parse +119 -0
- package/plugins/composer/ClassLoader.php +579 -0
- package/plugins/composer/InstalledVersions.php +359 -0
- package/plugins/composer/LICENSE +21 -0
- package/plugins/composer/autoload_classmap.php +260 -0
- package/plugins/composer/autoload_namespaces.php +9 -0
- package/plugins/composer/autoload_psr4.php +10 -0
- package/plugins/composer/autoload_real.php +36 -0
- package/plugins/composer/autoload_static.php +286 -0
- package/plugins/composer/installed.json +67 -0
- package/plugins/composer/installed.php +32 -0
- package/plugins/lib/{com.fasterxml.jackson.core.jackson-annotations-2.15.2.jar → com.fasterxml.jackson.core.jackson-annotations-2.16.0.jar} +0 -0
- package/plugins/lib/com.fasterxml.jackson.core.jackson-core-2.16.0.jar +0 -0
- package/plugins/lib/{com.fasterxml.jackson.core.jackson-databind-2.15.2.jar → com.fasterxml.jackson.core.jackson-databind-2.16.0.jar} +0 -0
- package/plugins/lib/{com.github.javaparser.javaparser-core-3.25.6.jar → com.github.javaparser.javaparser-core-3.25.7.jar} +0 -0
- package/plugins/lib/{com.github.javaparser.javaparser-symbol-solver-core-3.25.6.jar → com.github.javaparser.javaparser-symbol-solver-core-3.25.7.jar} +0 -0
- package/plugins/lib/{com.typesafe.config-1.4.2.jar → com.typesafe.config-1.4.3.jar} +0 -0
- package/plugins/lib/io.appthreat.atom-1.8.1-classpath.jar +0 -0
- package/plugins/lib/{io.appthreat.atom-1.7.5.jar → io.appthreat.atom-1.8.1.jar} +0 -0
- package/plugins/lib/{io.appthreat.c2cpg_3-1.0.10.jar → io.appthreat.c2cpg_3-1.1.3.jar} +0 -0
- package/plugins/lib/{io.appthreat.dataflowengineoss_3-1.0.10.jar → io.appthreat.dataflowengineoss_3-1.1.3.jar} +0 -0
- package/plugins/lib/{io.appthreat.javasrc2cpg_3-1.0.10.jar → io.appthreat.javasrc2cpg_3-1.1.3.jar} +0 -0
- package/plugins/lib/{io.appthreat.jimple2cpg_3-1.0.10.jar → io.appthreat.jimple2cpg_3-1.1.3.jar} +0 -0
- package/plugins/lib/{io.appthreat.jssrc2cpg_3-1.0.10.jar → io.appthreat.jssrc2cpg_3-1.1.3.jar} +0 -0
- package/plugins/lib/io.appthreat.php2atom_3-1.1.3.jar +0 -0
- package/plugins/lib/{io.appthreat.pysrc2cpg_3-1.0.10.jar → io.appthreat.pysrc2cpg_3-1.1.3.jar} +0 -0
- package/plugins/lib/{io.appthreat.semanticcpg_3-1.0.10.jar → io.appthreat.semanticcpg_3-1.1.3.jar} +0 -0
- package/plugins/lib/{io.appthreat.x2cpg_3-1.0.10.jar → io.appthreat.x2cpg_3-1.1.3.jar} +0 -0
- package/plugins/lib/io.circe.circe-core_3-0.14.6.jar +0 -0
- package/plugins/lib/io.circe.circe-generic_3-0.14.6.jar +0 -0
- package/plugins/lib/io.circe.circe-jawn_3-0.14.6.jar +0 -0
- package/plugins/lib/io.circe.circe-numbers_3-0.14.6.jar +0 -0
- package/plugins/lib/io.circe.circe-parser_3-0.14.6.jar +0 -0
- package/plugins/lib/org.gradle.gradle-tooling-api-8.5.jar +0 -0
- package/plugins/lib/{org.json4s.json4s-ast_3-4.0.6.jar → org.json4s.json4s-ast_3-4.0.7.jar} +0 -0
- package/plugins/lib/{org.json4s.json4s-core_3-4.0.6.jar → org.json4s.json4s-core_3-4.0.7.jar} +0 -0
- package/plugins/lib/{org.json4s.json4s-native-core_3-4.0.6.jar → org.json4s.json4s-native-core_3-4.0.7.jar} +0 -0
- package/plugins/lib/{org.json4s.json4s-native_3-4.0.6.jar → org.json4s.json4s-native_3-4.0.7.jar} +0 -0
- package/plugins/lib/{org.json4s.json4s-scalap_3-4.0.6.jar → org.json4s.json4s-scalap_3-4.0.7.jar} +0 -0
- package/plugins/lib/org.scala-lang.modules.scala-parser-combinators_3-2.3.0.jar +0 -0
- package/plugins/nikic/php-parser/.php-cs-fixer.dist.php +31 -0
- package/plugins/nikic/php-parser/LICENSE +29 -0
- package/plugins/nikic/php-parser/Makefile +10 -0
- package/plugins/nikic/php-parser/README.md +233 -0
- package/plugins/nikic/php-parser/bin/php-parse +206 -0
- package/plugins/nikic/php-parser/composer.json +43 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php +150 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Class_.php +151 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Declaration.php +50 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php +87 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Enum_.php +116 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php +73 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Function_.php +67 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Interface_.php +94 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Method.php +147 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php +45 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Param.php +149 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Property.php +161 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php +65 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php +145 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Trait_.php +83 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder/Use_.php +49 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Builder.php +12 -0
- package/plugins/nikic/php-parser/lib/PhpParser/BuilderFactory.php +375 -0
- package/plugins/nikic/php-parser/lib/PhpParser/BuilderHelpers.php +333 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Comment/Doc.php +6 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Comment.php +207 -0
- package/plugins/nikic/php-parser/lib/PhpParser/ConstExprEvaluationException.php +6 -0
- package/plugins/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php +234 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Error.php +171 -0
- package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php +43 -0
- package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php +17 -0
- package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler.php +12 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Internal/DiffElem.php +31 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Internal/Differ.php +178 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php +71 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php +237 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php +271 -0
- package/plugins/nikic/php-parser/lib/PhpParser/JsonDecoder.php +108 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php +226 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php +49 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php +26 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php +45 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php +56 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php +19 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php +60 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyFunctionTokenEmulator.php +31 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php +31 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php +37 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php +30 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Lexer.php +116 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Modifiers.php +69 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NameContext.php +284 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Arg.php +44 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/ArrayItem.php +43 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Attribute.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php +27 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/ClosureUse.php +36 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/ComplexType.php +13 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Const_.php +36 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/DeclareItem.php +37 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php +3 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php +34 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php +84 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php +37 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php +35 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php +16 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php +11 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php +25 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php +36 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php +86 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php +3 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php +30 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php +30 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php +38 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php +38 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php +35 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php +34 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php +32 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php +45 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php +40 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php +45 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php +35 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php +35 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php +30 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php +45 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +36 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php +37 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr.php +8 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php +40 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Identifier.php +75 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/InterpolatedStringPart.php +32 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/IntersectionType.php +27 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/MatchArm.php +30 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php +49 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php +49 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Name.php +269 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/NullableType.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Param.php +84 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/PropertyItem.php +37 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php +3 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php +3 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +3 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/Float_.php +78 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/Int_.php +82 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/InterpolatedString.php +34 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php +3 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php +15 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php +27 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php +161 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar.php +6 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/StaticVar.php +39 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Block.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php +40 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php +77 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php +109 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php +154 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php +94 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php +3 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php +34 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php +36 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php +44 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php +32 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php +47 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php +50 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php +81 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php +30 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php +41 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php +46 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php +40 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php +30 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php +37 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php +16 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php +82 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php +3 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php +3 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php +30 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +37 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php +12 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php +34 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php +37 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php +29 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php +3 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php +47 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php +33 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt.php +8 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/UnionType.php +27 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/UseItem.php +55 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/VarLikeIdentifier.php +16 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php +27 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Node.php +146 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeAbstract.php +178 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeDumper.php +290 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeFinder.php +90 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeTraverser.php +278 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php +26 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php +19 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php +82 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php +47 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php +49 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php +262 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php +51 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php +38 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor.php +124 -0
- package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php +24 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php7.php +2699 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php8.php +2717 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Parser.php +24 -0
- package/plugins/nikic/php-parser/lib/PhpParser/ParserAbstract.php +1241 -0
- package/plugins/nikic/php-parser/lib/PhpParser/ParserFactory.php +42 -0
- package/plugins/nikic/php-parser/lib/PhpParser/PhpVersion.php +164 -0
- package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php +1177 -0
- package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinter.php +51 -0
- package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +1655 -0
- package/plugins/nikic/php-parser/lib/PhpParser/Token.php +18 -0
- package/plugins/nikic/php-parser/lib/PhpParser/compatibility_tokens.php +56 -0
- package/plugins/nikic/php-parser/phpstan-baseline.neon +236 -0
- package/plugins/nikic/php-parser/phpstan.neon.dist +8 -0
- package/utils.mjs +10 -0
- package/plugins/lib/com.fasterxml.jackson.core.jackson-core-2.15.2.jar +0 -0
- package/plugins/lib/io.appthreat.atom-1.7.5-classpath.jar +0 -0
- package/plugins/lib/io.circe.circe-core_3-0.14.5.jar +0 -0
- package/plugins/lib/io.circe.circe-generic_3-0.14.5.jar +0 -0
- package/plugins/lib/io.circe.circe-jawn_3-0.14.5.jar +0 -0
- package/plugins/lib/io.circe.circe-numbers_3-0.14.5.jar +0 -0
- package/plugins/lib/io.circe.circe-parser_3-0.14.5.jar +0 -0
- package/plugins/lib/org.gradle.gradle-tooling-api-8.3.jar +0 -0
- package/plugins/lib/org.scala-lang.modules.scala-parser-combinators_3-2.2.0.jar +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Internal;
|
|
4
|
+
|
|
5
|
+
use PhpParser\Node;
|
|
6
|
+
use PhpParser\Node\Expr;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This node is used internally by the format-preserving pretty printer to print anonymous classes.
|
|
10
|
+
*
|
|
11
|
+
* The normal anonymous class structure violates assumptions about the order of token offsets.
|
|
12
|
+
* Namely, the constructor arguments are part of the Expr\New_ node and follow the class node, even
|
|
13
|
+
* though they are actually interleaved with them. This special node type is used temporarily to
|
|
14
|
+
* restore a sane token offset order.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
class PrintableNewAnonClassNode extends Expr {
|
|
19
|
+
/** @var Node\AttributeGroup[] PHP attribute groups */
|
|
20
|
+
public array $attrGroups;
|
|
21
|
+
/** @var int Modifiers */
|
|
22
|
+
public int $flags;
|
|
23
|
+
/** @var (Node\Arg|Node\VariadicPlaceholder)[] Arguments */
|
|
24
|
+
public array $args;
|
|
25
|
+
/** @var null|Node\Name Name of extended class */
|
|
26
|
+
public ?Node\Name $extends;
|
|
27
|
+
/** @var Node\Name[] Names of implemented interfaces */
|
|
28
|
+
public array $implements;
|
|
29
|
+
/** @var Node\Stmt[] Statements */
|
|
30
|
+
public array $stmts;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param Node\AttributeGroup[] $attrGroups PHP attribute groups
|
|
34
|
+
* @param (Node\Arg|Node\VariadicPlaceholder)[] $args Arguments
|
|
35
|
+
* @param Node\Name|null $extends Name of extended class
|
|
36
|
+
* @param Node\Name[] $implements Names of implemented interfaces
|
|
37
|
+
* @param Node\Stmt[] $stmts Statements
|
|
38
|
+
* @param array<string, mixed> $attributes Attributes
|
|
39
|
+
*/
|
|
40
|
+
public function __construct(
|
|
41
|
+
array $attrGroups, int $flags, array $args, ?Node\Name $extends, array $implements,
|
|
42
|
+
array $stmts, array $attributes
|
|
43
|
+
) {
|
|
44
|
+
parent::__construct($attributes);
|
|
45
|
+
$this->attrGroups = $attrGroups;
|
|
46
|
+
$this->flags = $flags;
|
|
47
|
+
$this->args = $args;
|
|
48
|
+
$this->extends = $extends;
|
|
49
|
+
$this->implements = $implements;
|
|
50
|
+
$this->stmts = $stmts;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public static function fromNewNode(Expr\New_ $newNode): self {
|
|
54
|
+
$class = $newNode->class;
|
|
55
|
+
assert($class instanceof Node\Stmt\Class_);
|
|
56
|
+
// We don't assert that $class->name is null here, to allow consumers to assign unique names
|
|
57
|
+
// to anonymous classes for their own purposes. We simplify ignore the name here.
|
|
58
|
+
return new self(
|
|
59
|
+
$class->attrGroups, $class->flags, $newNode->args, $class->extends, $class->implements,
|
|
60
|
+
$class->stmts, $newNode->getAttributes()
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public function getType(): string {
|
|
65
|
+
return 'Expr_PrintableNewAnonClass';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public function getSubNodeNames(): array {
|
|
69
|
+
return ['attrGroups', 'flags', 'args', 'extends', 'implements', 'stmts'];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Internal;
|
|
4
|
+
|
|
5
|
+
if (\PHP_VERSION_ID >= 80000) {
|
|
6
|
+
class TokenPolyfill extends \PhpToken {
|
|
7
|
+
}
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This is a polyfill for the PhpToken class introduced in PHP 8.0. We do not actually polyfill
|
|
13
|
+
* PhpToken, because composer might end up picking a different polyfill implementation, which does
|
|
14
|
+
* not meet our requirements.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
class TokenPolyfill {
|
|
19
|
+
/** @var int The ID of the token. Either a T_* constant of a character code < 256. */
|
|
20
|
+
public int $id;
|
|
21
|
+
/** @var string The textual content of the token. */
|
|
22
|
+
public string $text;
|
|
23
|
+
/** @var int The 1-based starting line of the token (or -1 if unknown). */
|
|
24
|
+
public int $line;
|
|
25
|
+
/** @var int The 0-based starting position of the token (or -1 if unknown). */
|
|
26
|
+
public int $pos;
|
|
27
|
+
|
|
28
|
+
/** @var array<int, bool> Tokens ignored by the PHP parser. */
|
|
29
|
+
private const IGNORABLE_TOKENS = [
|
|
30
|
+
\T_WHITESPACE => true,
|
|
31
|
+
\T_COMMENT => true,
|
|
32
|
+
\T_DOC_COMMENT => true,
|
|
33
|
+
\T_OPEN_TAG => true,
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
/** @var array<int, bool> Tokens that may be part of a T_NAME_* identifier. */
|
|
37
|
+
private static array $identifierTokens;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Create a Token with the given ID and text, as well optional line and position information.
|
|
41
|
+
*/
|
|
42
|
+
final public function __construct(int $id, string $text, int $line = -1, int $pos = -1) {
|
|
43
|
+
$this->id = $id;
|
|
44
|
+
$this->text = $text;
|
|
45
|
+
$this->line = $line;
|
|
46
|
+
$this->pos = $pos;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get the name of the token. For single-char tokens this will be the token character.
|
|
51
|
+
* Otherwise it will be a T_* style name, or null if the token ID is unknown.
|
|
52
|
+
*/
|
|
53
|
+
public function getTokenName(): ?string {
|
|
54
|
+
if ($this->id < 256) {
|
|
55
|
+
return \chr($this->id);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
$name = token_name($this->id);
|
|
59
|
+
return $name === 'UNKNOWN' ? null : $name;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Check whether the token is of the given kind. The kind may be either an integer that matches
|
|
64
|
+
* the token ID, a string that matches the token text, or an array of integers/strings. In the
|
|
65
|
+
* latter case, the function returns true if any of the kinds in the array match.
|
|
66
|
+
*
|
|
67
|
+
* @param int|string|(int|string)[] $kind
|
|
68
|
+
*/
|
|
69
|
+
public function is($kind): bool {
|
|
70
|
+
if (\is_int($kind)) {
|
|
71
|
+
return $this->id === $kind;
|
|
72
|
+
}
|
|
73
|
+
if (\is_string($kind)) {
|
|
74
|
+
return $this->text === $kind;
|
|
75
|
+
}
|
|
76
|
+
if (\is_array($kind)) {
|
|
77
|
+
foreach ($kind as $entry) {
|
|
78
|
+
if (\is_int($entry)) {
|
|
79
|
+
if ($this->id === $entry) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
} elseif (\is_string($entry)) {
|
|
83
|
+
if ($this->text === $entry) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
throw new \TypeError(
|
|
88
|
+
'Argument #1 ($kind) must only have elements of type string|int, ' .
|
|
89
|
+
gettype($entry) . ' given');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
throw new \TypeError(
|
|
95
|
+
'Argument #1 ($kind) must be of type string|int|array, ' .gettype($kind) . ' given');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Check whether this token would be ignored by the PHP parser. Returns true for T_WHITESPACE,
|
|
100
|
+
* T_COMMENT, T_DOC_COMMENT and T_OPEN_TAG, and false for everything else.
|
|
101
|
+
*/
|
|
102
|
+
public function isIgnorable(): bool {
|
|
103
|
+
return isset(self::IGNORABLE_TOKENS[$this->id]);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Return the textual content of the token.
|
|
108
|
+
*/
|
|
109
|
+
public function __toString(): string {
|
|
110
|
+
return $this->text;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Tokenize the given source code and return an array of tokens.
|
|
115
|
+
*
|
|
116
|
+
* This performs certain canonicalizations to match the PHP 8.0 token format:
|
|
117
|
+
* * Bad characters are represented using T_BAD_CHARACTER rather than omitted.
|
|
118
|
+
* * T_COMMENT does not include trailing newlines, instead the newline is part of a following
|
|
119
|
+
* T_WHITESPACE token.
|
|
120
|
+
* * Namespaced names are represented using T_NAME_* tokens.
|
|
121
|
+
*
|
|
122
|
+
* @return static[]
|
|
123
|
+
*/
|
|
124
|
+
public static function tokenize(string $code, int $flags = 0): array {
|
|
125
|
+
self::init();
|
|
126
|
+
|
|
127
|
+
$tokens = [];
|
|
128
|
+
$line = 1;
|
|
129
|
+
$pos = 0;
|
|
130
|
+
$origTokens = \token_get_all($code, $flags);
|
|
131
|
+
|
|
132
|
+
$numTokens = \count($origTokens);
|
|
133
|
+
for ($i = 0; $i < $numTokens; $i++) {
|
|
134
|
+
$token = $origTokens[$i];
|
|
135
|
+
if (\is_string($token)) {
|
|
136
|
+
if (\strlen($token) === 2) {
|
|
137
|
+
// b" and B" are tokenized as single-char tokens, even though they aren't.
|
|
138
|
+
$tokens[] = new static(\ord('"'), $token, $line, $pos);
|
|
139
|
+
$pos += 2;
|
|
140
|
+
} else {
|
|
141
|
+
$tokens[] = new static(\ord($token), $token, $line, $pos);
|
|
142
|
+
$pos++;
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
$id = $token[0];
|
|
146
|
+
$text = $token[1];
|
|
147
|
+
|
|
148
|
+
// Emulate PHP 8.0 comment format, which does not include trailing whitespace anymore.
|
|
149
|
+
if ($id === \T_COMMENT && \substr($text, 0, 2) !== '/*' &&
|
|
150
|
+
\preg_match('/(\r\n|\n|\r)$/D', $text, $matches)
|
|
151
|
+
) {
|
|
152
|
+
$trailingNewline = $matches[0];
|
|
153
|
+
$text = \substr($text, 0, -\strlen($trailingNewline));
|
|
154
|
+
$tokens[] = new static($id, $text, $line, $pos);
|
|
155
|
+
$pos += \strlen($text);
|
|
156
|
+
|
|
157
|
+
if ($i + 1 < $numTokens && $origTokens[$i + 1][0] === \T_WHITESPACE) {
|
|
158
|
+
// Move trailing newline into following T_WHITESPACE token, if it already exists.
|
|
159
|
+
$origTokens[$i + 1][1] = $trailingNewline . $origTokens[$i + 1][1];
|
|
160
|
+
$origTokens[$i + 1][2]--;
|
|
161
|
+
} else {
|
|
162
|
+
// Otherwise, we need to create a new T_WHITESPACE token.
|
|
163
|
+
$tokens[] = new static(\T_WHITESPACE, $trailingNewline, $line, $pos);
|
|
164
|
+
$line++;
|
|
165
|
+
$pos += \strlen($trailingNewline);
|
|
166
|
+
}
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Emulate PHP 8.0 T_NAME_* tokens, by combining sequences of T_NS_SEPARATOR and
|
|
171
|
+
// T_STRING into a single token.
|
|
172
|
+
if (($id === \T_NS_SEPARATOR || isset(self::$identifierTokens[$id]))) {
|
|
173
|
+
$newText = $text;
|
|
174
|
+
$lastWasSeparator = $id === \T_NS_SEPARATOR;
|
|
175
|
+
for ($j = $i + 1; $j < $numTokens; $j++) {
|
|
176
|
+
if ($lastWasSeparator) {
|
|
177
|
+
if (!isset(self::$identifierTokens[$origTokens[$j][0]])) {
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
$lastWasSeparator = false;
|
|
181
|
+
} else {
|
|
182
|
+
if ($origTokens[$j][0] !== \T_NS_SEPARATOR) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
$lastWasSeparator = true;
|
|
186
|
+
}
|
|
187
|
+
$newText .= $origTokens[$j][1];
|
|
188
|
+
}
|
|
189
|
+
if ($lastWasSeparator) {
|
|
190
|
+
// Trailing separator is not part of the name.
|
|
191
|
+
$j--;
|
|
192
|
+
$newText = \substr($newText, 0, -1);
|
|
193
|
+
}
|
|
194
|
+
if ($j > $i + 1) {
|
|
195
|
+
if ($id === \T_NS_SEPARATOR) {
|
|
196
|
+
$id = \T_NAME_FULLY_QUALIFIED;
|
|
197
|
+
} elseif ($id === \T_NAMESPACE) {
|
|
198
|
+
$id = \T_NAME_RELATIVE;
|
|
199
|
+
} else {
|
|
200
|
+
$id = \T_NAME_QUALIFIED;
|
|
201
|
+
}
|
|
202
|
+
$tokens[] = new static($id, $newText, $line, $pos);
|
|
203
|
+
$pos += \strlen($newText);
|
|
204
|
+
$i = $j - 1;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
$tokens[] = new static($id, $text, $line, $pos);
|
|
210
|
+
$line += \substr_count($text, "\n");
|
|
211
|
+
$pos += \strlen($text);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return $tokens;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Initialize private static state needed by tokenize(). */
|
|
218
|
+
private static function init(): void {
|
|
219
|
+
if (isset(self::$identifierTokens)) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Based on semi_reserved production.
|
|
224
|
+
self::$identifierTokens = \array_fill_keys([
|
|
225
|
+
\T_STRING,
|
|
226
|
+
\T_STATIC, \T_ABSTRACT, \T_FINAL, \T_PRIVATE, \T_PROTECTED, \T_PUBLIC, \T_READONLY,
|
|
227
|
+
\T_INCLUDE, \T_INCLUDE_ONCE, \T_EVAL, \T_REQUIRE, \T_REQUIRE_ONCE, \T_LOGICAL_OR, \T_LOGICAL_XOR, \T_LOGICAL_AND,
|
|
228
|
+
\T_INSTANCEOF, \T_NEW, \T_CLONE, \T_EXIT, \T_IF, \T_ELSEIF, \T_ELSE, \T_ENDIF, \T_ECHO, \T_DO, \T_WHILE,
|
|
229
|
+
\T_ENDWHILE, \T_FOR, \T_ENDFOR, \T_FOREACH, \T_ENDFOREACH, \T_DECLARE, \T_ENDDECLARE, \T_AS, \T_TRY, \T_CATCH,
|
|
230
|
+
\T_FINALLY, \T_THROW, \T_USE, \T_INSTEADOF, \T_GLOBAL, \T_VAR, \T_UNSET, \T_ISSET, \T_EMPTY, \T_CONTINUE, \T_GOTO,
|
|
231
|
+
\T_FUNCTION, \T_CONST, \T_RETURN, \T_PRINT, \T_YIELD, \T_LIST, \T_SWITCH, \T_ENDSWITCH, \T_CASE, \T_DEFAULT,
|
|
232
|
+
\T_BREAK, \T_ARRAY, \T_CALLABLE, \T_EXTENDS, \T_IMPLEMENTS, \T_NAMESPACE, \T_TRAIT, \T_INTERFACE, \T_CLASS,
|
|
233
|
+
\T_CLASS_C, \T_TRAIT_C, \T_FUNC_C, \T_METHOD_C, \T_LINE, \T_FILE, \T_DIR, \T_NS_C, \T_HALT_COMPILER, \T_FN,
|
|
234
|
+
\T_MATCH,
|
|
235
|
+
], true);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Internal;
|
|
4
|
+
|
|
5
|
+
use PhpParser\Token;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Provides operations on token streams, for use by pretty printer.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
class TokenStream {
|
|
13
|
+
/** @var Token[] Tokens (in PhpToken::tokenize() format) */
|
|
14
|
+
private array $tokens;
|
|
15
|
+
/** @var int[] Map from position to indentation */
|
|
16
|
+
private array $indentMap;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create token stream instance.
|
|
20
|
+
*
|
|
21
|
+
* @param Token[] $tokens Tokens in PhpToken::tokenize() format
|
|
22
|
+
*/
|
|
23
|
+
public function __construct(array $tokens) {
|
|
24
|
+
$this->tokens = $tokens;
|
|
25
|
+
$this->indentMap = $this->calcIndentMap();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Whether the given position is immediately surrounded by parenthesis.
|
|
30
|
+
*
|
|
31
|
+
* @param int $startPos Start position
|
|
32
|
+
* @param int $endPos End position
|
|
33
|
+
*/
|
|
34
|
+
public function haveParens(int $startPos, int $endPos): bool {
|
|
35
|
+
return $this->haveTokenImmediatelyBefore($startPos, '(')
|
|
36
|
+
&& $this->haveTokenImmediatelyAfter($endPos, ')');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether the given position is immediately surrounded by braces.
|
|
41
|
+
*
|
|
42
|
+
* @param int $startPos Start position
|
|
43
|
+
* @param int $endPos End position
|
|
44
|
+
*/
|
|
45
|
+
public function haveBraces(int $startPos, int $endPos): bool {
|
|
46
|
+
return ($this->haveTokenImmediatelyBefore($startPos, '{')
|
|
47
|
+
|| $this->haveTokenImmediatelyBefore($startPos, T_CURLY_OPEN))
|
|
48
|
+
&& $this->haveTokenImmediatelyAfter($endPos, '}');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Check whether the position is directly preceded by a certain token type.
|
|
53
|
+
*
|
|
54
|
+
* During this check whitespace and comments are skipped.
|
|
55
|
+
*
|
|
56
|
+
* @param int $pos Position before which the token should occur
|
|
57
|
+
* @param int|string $expectedTokenType Token to check for
|
|
58
|
+
*
|
|
59
|
+
* @return bool Whether the expected token was found
|
|
60
|
+
*/
|
|
61
|
+
public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType): bool {
|
|
62
|
+
$tokens = $this->tokens;
|
|
63
|
+
$pos--;
|
|
64
|
+
for (; $pos >= 0; $pos--) {
|
|
65
|
+
$token = $tokens[$pos];
|
|
66
|
+
if ($token->is($expectedTokenType)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
if (!$token->isIgnorable()) {
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Check whether the position is directly followed by a certain token type.
|
|
78
|
+
*
|
|
79
|
+
* During this check whitespace and comments are skipped.
|
|
80
|
+
*
|
|
81
|
+
* @param int $pos Position after which the token should occur
|
|
82
|
+
* @param int|string $expectedTokenType Token to check for
|
|
83
|
+
*
|
|
84
|
+
* @return bool Whether the expected token was found
|
|
85
|
+
*/
|
|
86
|
+
public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType): bool {
|
|
87
|
+
$tokens = $this->tokens;
|
|
88
|
+
$pos++;
|
|
89
|
+
for ($c = \count($tokens); $pos < $c; $pos++) {
|
|
90
|
+
$token = $tokens[$pos];
|
|
91
|
+
if ($token->is($expectedTokenType)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
if (!$token->isIgnorable()) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** @param int|string|(int|string)[] $skipTokenType */
|
|
102
|
+
public function skipLeft(int $pos, $skipTokenType): int {
|
|
103
|
+
$tokens = $this->tokens;
|
|
104
|
+
|
|
105
|
+
$pos = $this->skipLeftWhitespace($pos);
|
|
106
|
+
if ($skipTokenType === \T_WHITESPACE) {
|
|
107
|
+
return $pos;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!$tokens[$pos]->is($skipTokenType)) {
|
|
111
|
+
// Shouldn't happen. The skip token MUST be there
|
|
112
|
+
throw new \Exception('Encountered unexpected token');
|
|
113
|
+
}
|
|
114
|
+
$pos--;
|
|
115
|
+
|
|
116
|
+
return $this->skipLeftWhitespace($pos);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** @param int|string|(int|string)[] $skipTokenType */
|
|
120
|
+
public function skipRight(int $pos, $skipTokenType): int {
|
|
121
|
+
$tokens = $this->tokens;
|
|
122
|
+
|
|
123
|
+
$pos = $this->skipRightWhitespace($pos);
|
|
124
|
+
if ($skipTokenType === \T_WHITESPACE) {
|
|
125
|
+
return $pos;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!$tokens[$pos]->is($skipTokenType)) {
|
|
129
|
+
// Shouldn't happen. The skip token MUST be there
|
|
130
|
+
throw new \Exception('Encountered unexpected token');
|
|
131
|
+
}
|
|
132
|
+
$pos++;
|
|
133
|
+
|
|
134
|
+
return $this->skipRightWhitespace($pos);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Return first non-whitespace token position smaller or equal to passed position.
|
|
139
|
+
*
|
|
140
|
+
* @param int $pos Token position
|
|
141
|
+
* @return int Non-whitespace token position
|
|
142
|
+
*/
|
|
143
|
+
public function skipLeftWhitespace(int $pos): int {
|
|
144
|
+
$tokens = $this->tokens;
|
|
145
|
+
for (; $pos >= 0; $pos--) {
|
|
146
|
+
if (!$tokens[$pos]->isIgnorable()) {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return $pos;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Return first non-whitespace position greater or equal to passed position.
|
|
155
|
+
*
|
|
156
|
+
* @param int $pos Token position
|
|
157
|
+
* @return int Non-whitespace token position
|
|
158
|
+
*/
|
|
159
|
+
public function skipRightWhitespace(int $pos): int {
|
|
160
|
+
$tokens = $this->tokens;
|
|
161
|
+
for ($count = \count($tokens); $pos < $count; $pos++) {
|
|
162
|
+
if (!$tokens[$pos]->isIgnorable()) {
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return $pos;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** @param int|string|(int|string)[] $findTokenType */
|
|
170
|
+
public function findRight(int $pos, $findTokenType): int {
|
|
171
|
+
$tokens = $this->tokens;
|
|
172
|
+
for ($count = \count($tokens); $pos < $count; $pos++) {
|
|
173
|
+
if ($tokens[$pos]->is($findTokenType)) {
|
|
174
|
+
return $pos;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return -1;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Whether the given position range contains a certain token type.
|
|
182
|
+
*
|
|
183
|
+
* @param int $startPos Starting position (inclusive)
|
|
184
|
+
* @param int $endPos Ending position (exclusive)
|
|
185
|
+
* @param int|string $tokenType Token type to look for
|
|
186
|
+
* @return bool Whether the token occurs in the given range
|
|
187
|
+
*/
|
|
188
|
+
public function haveTokenInRange(int $startPos, int $endPos, $tokenType): bool {
|
|
189
|
+
$tokens = $this->tokens;
|
|
190
|
+
for ($pos = $startPos; $pos < $endPos; $pos++) {
|
|
191
|
+
if ($tokens[$pos]->is($tokenType)) {
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public function haveTagInRange(int $startPos, int $endPos): bool {
|
|
199
|
+
return $this->haveTokenInRange($startPos, $endPos, \T_OPEN_TAG)
|
|
200
|
+
|| $this->haveTokenInRange($startPos, $endPos, \T_CLOSE_TAG);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Get indentation before token position.
|
|
205
|
+
*
|
|
206
|
+
* @param int $pos Token position
|
|
207
|
+
*
|
|
208
|
+
* @return int Indentation depth (in spaces)
|
|
209
|
+
*/
|
|
210
|
+
public function getIndentationBefore(int $pos): int {
|
|
211
|
+
return $this->indentMap[$pos];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Get the code corresponding to a token offset range, optionally adjusted for indentation.
|
|
216
|
+
*
|
|
217
|
+
* @param int $from Token start position (inclusive)
|
|
218
|
+
* @param int $to Token end position (exclusive)
|
|
219
|
+
* @param int $indent By how much the code should be indented (can be negative as well)
|
|
220
|
+
*
|
|
221
|
+
* @return string Code corresponding to token range, adjusted for indentation
|
|
222
|
+
*/
|
|
223
|
+
public function getTokenCode(int $from, int $to, int $indent): string {
|
|
224
|
+
$tokens = $this->tokens;
|
|
225
|
+
$result = '';
|
|
226
|
+
for ($pos = $from; $pos < $to; $pos++) {
|
|
227
|
+
$token = $tokens[$pos];
|
|
228
|
+
$id = $token->id;
|
|
229
|
+
$text = $token->text;
|
|
230
|
+
if ($id === \T_CONSTANT_ENCAPSED_STRING || $id === \T_ENCAPSED_AND_WHITESPACE) {
|
|
231
|
+
$result .= $text;
|
|
232
|
+
} else {
|
|
233
|
+
// TODO Handle non-space indentation
|
|
234
|
+
if ($indent < 0) {
|
|
235
|
+
$result .= str_replace("\n" . str_repeat(" ", -$indent), "\n", $text);
|
|
236
|
+
} elseif ($indent > 0) {
|
|
237
|
+
$result .= str_replace("\n", "\n" . str_repeat(" ", $indent), $text);
|
|
238
|
+
} else {
|
|
239
|
+
$result .= $text;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return $result;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Precalculate the indentation at every token position.
|
|
248
|
+
*
|
|
249
|
+
* @return int[] Token position to indentation map
|
|
250
|
+
*/
|
|
251
|
+
private function calcIndentMap(): array {
|
|
252
|
+
$indentMap = [];
|
|
253
|
+
$indent = 0;
|
|
254
|
+
foreach ($this->tokens as $token) {
|
|
255
|
+
$indentMap[] = $indent;
|
|
256
|
+
|
|
257
|
+
if ($token->id === \T_WHITESPACE) {
|
|
258
|
+
$content = $token->text;
|
|
259
|
+
$newlinePos = \strrpos($content, "\n");
|
|
260
|
+
if (false !== $newlinePos) {
|
|
261
|
+
$indent = \strlen($content) - $newlinePos - 1;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Add a sentinel for one past end of the file
|
|
267
|
+
$indentMap[] = $indent;
|
|
268
|
+
|
|
269
|
+
return $indentMap;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser;
|
|
4
|
+
|
|
5
|
+
class JsonDecoder {
|
|
6
|
+
/** @var \ReflectionClass<Node>[] Node type to reflection class map */
|
|
7
|
+
private array $reflectionClassCache;
|
|
8
|
+
|
|
9
|
+
/** @return mixed */
|
|
10
|
+
public function decode(string $json) {
|
|
11
|
+
$value = json_decode($json, true);
|
|
12
|
+
if (json_last_error()) {
|
|
13
|
+
throw new \RuntimeException('JSON decoding error: ' . json_last_error_msg());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return $this->decodeRecursive($value);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param mixed $value
|
|
21
|
+
* @return mixed
|
|
22
|
+
*/
|
|
23
|
+
private function decodeRecursive($value) {
|
|
24
|
+
if (\is_array($value)) {
|
|
25
|
+
if (isset($value['nodeType'])) {
|
|
26
|
+
if ($value['nodeType'] === 'Comment' || $value['nodeType'] === 'Comment_Doc') {
|
|
27
|
+
return $this->decodeComment($value);
|
|
28
|
+
}
|
|
29
|
+
return $this->decodeNode($value);
|
|
30
|
+
}
|
|
31
|
+
return $this->decodeArray($value);
|
|
32
|
+
}
|
|
33
|
+
return $value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private function decodeArray(array $array): array {
|
|
37
|
+
$decodedArray = [];
|
|
38
|
+
foreach ($array as $key => $value) {
|
|
39
|
+
$decodedArray[$key] = $this->decodeRecursive($value);
|
|
40
|
+
}
|
|
41
|
+
return $decodedArray;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private function decodeNode(array $value): Node {
|
|
45
|
+
$nodeType = $value['nodeType'];
|
|
46
|
+
if (!\is_string($nodeType)) {
|
|
47
|
+
throw new \RuntimeException('Node type must be a string');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
$reflectionClass = $this->reflectionClassFromNodeType($nodeType);
|
|
51
|
+
$node = $reflectionClass->newInstanceWithoutConstructor();
|
|
52
|
+
|
|
53
|
+
if (isset($value['attributes'])) {
|
|
54
|
+
if (!\is_array($value['attributes'])) {
|
|
55
|
+
throw new \RuntimeException('Attributes must be an array');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
$node->setAttributes($this->decodeArray($value['attributes']));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
foreach ($value as $name => $subNode) {
|
|
62
|
+
if ($name === 'nodeType' || $name === 'attributes') {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
$node->$name = $this->decodeRecursive($subNode);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return $node;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private function decodeComment(array $value): Comment {
|
|
73
|
+
$className = $value['nodeType'] === 'Comment' ? Comment::class : Comment\Doc::class;
|
|
74
|
+
if (!isset($value['text'])) {
|
|
75
|
+
throw new \RuntimeException('Comment must have text');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return new $className(
|
|
79
|
+
$value['text'],
|
|
80
|
+
$value['line'] ?? -1, $value['filePos'] ?? -1, $value['tokenPos'] ?? -1,
|
|
81
|
+
$value['endLine'] ?? -1, $value['endFilePos'] ?? -1, $value['endTokenPos'] ?? -1
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** @return \ReflectionClass<Node> */
|
|
86
|
+
private function reflectionClassFromNodeType(string $nodeType): \ReflectionClass {
|
|
87
|
+
if (!isset($this->reflectionClassCache[$nodeType])) {
|
|
88
|
+
$className = $this->classNameFromNodeType($nodeType);
|
|
89
|
+
$this->reflectionClassCache[$nodeType] = new \ReflectionClass($className);
|
|
90
|
+
}
|
|
91
|
+
return $this->reflectionClassCache[$nodeType];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** @return class-string<Node> */
|
|
95
|
+
private function classNameFromNodeType(string $nodeType): string {
|
|
96
|
+
$className = 'PhpParser\\Node\\' . strtr($nodeType, '_', '\\');
|
|
97
|
+
if (class_exists($className)) {
|
|
98
|
+
return $className;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
$className .= '_';
|
|
102
|
+
if (class_exists($className)) {
|
|
103
|
+
return $className;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
throw new \RuntimeException("Unknown node type \"$nodeType\"");
|
|
107
|
+
}
|
|
108
|
+
}
|