@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,226 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer;
|
|
4
|
+
|
|
5
|
+
use PhpParser\Error;
|
|
6
|
+
use PhpParser\ErrorHandler;
|
|
7
|
+
use PhpParser\Lexer;
|
|
8
|
+
use PhpParser\Lexer\TokenEmulator\AttributeEmulator;
|
|
9
|
+
use PhpParser\Lexer\TokenEmulator\EnumTokenEmulator;
|
|
10
|
+
use PhpParser\Lexer\TokenEmulator\CoaleseEqualTokenEmulator;
|
|
11
|
+
use PhpParser\Lexer\TokenEmulator\ExplicitOctalEmulator;
|
|
12
|
+
use PhpParser\Lexer\TokenEmulator\FlexibleDocStringEmulator;
|
|
13
|
+
use PhpParser\Lexer\TokenEmulator\FnTokenEmulator;
|
|
14
|
+
use PhpParser\Lexer\TokenEmulator\MatchTokenEmulator;
|
|
15
|
+
use PhpParser\Lexer\TokenEmulator\NullsafeTokenEmulator;
|
|
16
|
+
use PhpParser\Lexer\TokenEmulator\NumericLiteralSeparatorEmulator;
|
|
17
|
+
use PhpParser\Lexer\TokenEmulator\ReadonlyFunctionTokenEmulator;
|
|
18
|
+
use PhpParser\Lexer\TokenEmulator\ReadonlyTokenEmulator;
|
|
19
|
+
use PhpParser\Lexer\TokenEmulator\ReverseEmulator;
|
|
20
|
+
use PhpParser\Lexer\TokenEmulator\TokenEmulator;
|
|
21
|
+
use PhpParser\PhpVersion;
|
|
22
|
+
use PhpParser\Token;
|
|
23
|
+
|
|
24
|
+
class Emulative extends Lexer {
|
|
25
|
+
/** @var array{int, string, string}[] Patches used to reverse changes introduced in the code */
|
|
26
|
+
private array $patches = [];
|
|
27
|
+
|
|
28
|
+
/** @var list<TokenEmulator> */
|
|
29
|
+
private array $emulators = [];
|
|
30
|
+
|
|
31
|
+
private PhpVersion $targetPhpVersion;
|
|
32
|
+
|
|
33
|
+
private PhpVersion $hostPhpVersion;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param PhpVersion|null $phpVersion PHP version to emulate. Defaults to newest supported.
|
|
37
|
+
*/
|
|
38
|
+
public function __construct(?PhpVersion $phpVersion = null) {
|
|
39
|
+
$this->targetPhpVersion = $phpVersion ?? PhpVersion::getNewestSupported();
|
|
40
|
+
$this->hostPhpVersion = PhpVersion::getHostVersion();
|
|
41
|
+
|
|
42
|
+
$emulators = [
|
|
43
|
+
new MatchTokenEmulator(),
|
|
44
|
+
new NullsafeTokenEmulator(),
|
|
45
|
+
new AttributeEmulator(),
|
|
46
|
+
new EnumTokenEmulator(),
|
|
47
|
+
new ReadonlyTokenEmulator(),
|
|
48
|
+
new ExplicitOctalEmulator(),
|
|
49
|
+
new ReadonlyFunctionTokenEmulator(),
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
// Collect emulators that are relevant for the PHP version we're running
|
|
53
|
+
// and the PHP version we're targeting for emulation.
|
|
54
|
+
foreach ($emulators as $emulator) {
|
|
55
|
+
$emulatorPhpVersion = $emulator->getPhpVersion();
|
|
56
|
+
if ($this->isForwardEmulationNeeded($emulatorPhpVersion)) {
|
|
57
|
+
$this->emulators[] = $emulator;
|
|
58
|
+
} elseif ($this->isReverseEmulationNeeded($emulatorPhpVersion)) {
|
|
59
|
+
$this->emulators[] = new ReverseEmulator($emulator);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public function tokenize(string $code, ?ErrorHandler $errorHandler = null): array {
|
|
65
|
+
$emulators = array_filter($this->emulators, function ($emulator) use ($code) {
|
|
66
|
+
return $emulator->isEmulationNeeded($code);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (empty($emulators)) {
|
|
70
|
+
// Nothing to emulate, yay
|
|
71
|
+
return parent::tokenize($code, $errorHandler);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if ($errorHandler === null) {
|
|
75
|
+
$errorHandler = new ErrorHandler\Throwing();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
$this->patches = [];
|
|
79
|
+
foreach ($emulators as $emulator) {
|
|
80
|
+
$code = $emulator->preprocessCode($code, $this->patches);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
$collector = new ErrorHandler\Collecting();
|
|
84
|
+
$tokens = parent::tokenize($code, $collector);
|
|
85
|
+
$this->sortPatches();
|
|
86
|
+
$tokens = $this->fixupTokens($tokens);
|
|
87
|
+
|
|
88
|
+
$errors = $collector->getErrors();
|
|
89
|
+
if (!empty($errors)) {
|
|
90
|
+
$this->fixupErrors($errors);
|
|
91
|
+
foreach ($errors as $error) {
|
|
92
|
+
$errorHandler->handleError($error);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
foreach ($emulators as $emulator) {
|
|
97
|
+
$tokens = $emulator->emulate($code, $tokens);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return $tokens;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private function isForwardEmulationNeeded(PhpVersion $emulatorPhpVersion): bool {
|
|
104
|
+
return $this->hostPhpVersion->older($emulatorPhpVersion)
|
|
105
|
+
&& $this->targetPhpVersion->newerOrEqual($emulatorPhpVersion);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private function isReverseEmulationNeeded(PhpVersion $emulatorPhpVersion): bool {
|
|
109
|
+
return $this->hostPhpVersion->newerOrEqual($emulatorPhpVersion)
|
|
110
|
+
&& $this->targetPhpVersion->older($emulatorPhpVersion);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private function sortPatches(): void {
|
|
114
|
+
// Patches may be contributed by different emulators.
|
|
115
|
+
// Make sure they are sorted by increasing patch position.
|
|
116
|
+
usort($this->patches, function ($p1, $p2) {
|
|
117
|
+
return $p1[0] <=> $p2[0];
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param list<Token> $tokens
|
|
123
|
+
* @return list<Token>
|
|
124
|
+
*/
|
|
125
|
+
private function fixupTokens(array $tokens): array {
|
|
126
|
+
if (\count($this->patches) === 0) {
|
|
127
|
+
return $tokens;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Load first patch
|
|
131
|
+
$patchIdx = 0;
|
|
132
|
+
list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
|
|
133
|
+
|
|
134
|
+
// We use a manual loop over the tokens, because we modify the array on the fly
|
|
135
|
+
$posDelta = 0;
|
|
136
|
+
$lineDelta = 0;
|
|
137
|
+
for ($i = 0, $c = \count($tokens); $i < $c; $i++) {
|
|
138
|
+
$token = $tokens[$i];
|
|
139
|
+
$pos = $token->pos;
|
|
140
|
+
$token->pos += $posDelta;
|
|
141
|
+
$token->line += $lineDelta;
|
|
142
|
+
$localPosDelta = 0;
|
|
143
|
+
$len = \strlen($token->text);
|
|
144
|
+
while ($patchPos >= $pos && $patchPos < $pos + $len) {
|
|
145
|
+
$patchTextLen = \strlen($patchText);
|
|
146
|
+
if ($patchType === 'remove') {
|
|
147
|
+
if ($patchPos === $pos && $patchTextLen === $len) {
|
|
148
|
+
// Remove token entirely
|
|
149
|
+
array_splice($tokens, $i, 1, []);
|
|
150
|
+
$i--;
|
|
151
|
+
$c--;
|
|
152
|
+
} else {
|
|
153
|
+
// Remove from token string
|
|
154
|
+
$token->text = substr_replace(
|
|
155
|
+
$token->text, '', $patchPos - $pos + $localPosDelta, $patchTextLen
|
|
156
|
+
);
|
|
157
|
+
$localPosDelta -= $patchTextLen;
|
|
158
|
+
}
|
|
159
|
+
$lineDelta -= \substr_count($patchText, "\n");
|
|
160
|
+
} elseif ($patchType === 'add') {
|
|
161
|
+
// Insert into the token string
|
|
162
|
+
$token->text = substr_replace(
|
|
163
|
+
$token->text, $patchText, $patchPos - $pos + $localPosDelta, 0
|
|
164
|
+
);
|
|
165
|
+
$localPosDelta += $patchTextLen;
|
|
166
|
+
$lineDelta += \substr_count($patchText, "\n");
|
|
167
|
+
} elseif ($patchType === 'replace') {
|
|
168
|
+
// Replace inside the token string
|
|
169
|
+
$token->text = substr_replace(
|
|
170
|
+
$token->text, $patchText, $patchPos - $pos + $localPosDelta, $patchTextLen
|
|
171
|
+
);
|
|
172
|
+
} else {
|
|
173
|
+
assert(false);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Fetch the next patch
|
|
177
|
+
$patchIdx++;
|
|
178
|
+
if ($patchIdx >= \count($this->patches)) {
|
|
179
|
+
// No more patches. However, we still need to adjust position.
|
|
180
|
+
$patchPos = \PHP_INT_MAX;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
$posDelta += $localPosDelta;
|
|
188
|
+
}
|
|
189
|
+
return $tokens;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Fixup line and position information in errors.
|
|
194
|
+
*
|
|
195
|
+
* @param Error[] $errors
|
|
196
|
+
*/
|
|
197
|
+
private function fixupErrors(array $errors): void {
|
|
198
|
+
foreach ($errors as $error) {
|
|
199
|
+
$attrs = $error->getAttributes();
|
|
200
|
+
|
|
201
|
+
$posDelta = 0;
|
|
202
|
+
$lineDelta = 0;
|
|
203
|
+
foreach ($this->patches as $patch) {
|
|
204
|
+
list($patchPos, $patchType, $patchText) = $patch;
|
|
205
|
+
if ($patchPos >= $attrs['startFilePos']) {
|
|
206
|
+
// No longer relevant
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if ($patchType === 'add') {
|
|
211
|
+
$posDelta += strlen($patchText);
|
|
212
|
+
$lineDelta += substr_count($patchText, "\n");
|
|
213
|
+
} elseif ($patchType === 'remove') {
|
|
214
|
+
$posDelta -= strlen($patchText);
|
|
215
|
+
$lineDelta -= substr_count($patchText, "\n");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
$attrs['startFilePos'] += $posDelta;
|
|
220
|
+
$attrs['endFilePos'] += $posDelta;
|
|
221
|
+
$attrs['startLine'] += $lineDelta;
|
|
222
|
+
$attrs['endLine'] += $lineDelta;
|
|
223
|
+
$error->setAttributes($attrs);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer\TokenEmulator;
|
|
4
|
+
|
|
5
|
+
use PhpParser\PhpVersion;
|
|
6
|
+
use PhpParser\Token;
|
|
7
|
+
|
|
8
|
+
final class AttributeEmulator extends TokenEmulator {
|
|
9
|
+
public function getPhpVersion(): PhpVersion {
|
|
10
|
+
return PhpVersion::fromComponents(8, 0);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public function isEmulationNeeded(string $code): bool {
|
|
14
|
+
return strpos($code, '#[') !== false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public function emulate(string $code, array $tokens): array {
|
|
18
|
+
// We need to manually iterate and manage a count because we'll change
|
|
19
|
+
// the tokens array on the way.
|
|
20
|
+
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
|
|
21
|
+
$token = $tokens[$i];
|
|
22
|
+
if ($token->text === '#' && isset($tokens[$i + 1]) && $tokens[$i + 1]->text === '[') {
|
|
23
|
+
array_splice($tokens, $i, 2, [
|
|
24
|
+
new Token(\T_ATTRIBUTE, '#[', $token->line, $token->pos),
|
|
25
|
+
]);
|
|
26
|
+
$c--;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return $tokens;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public function reverseEmulate(string $code, array $tokens): array {
|
|
35
|
+
// TODO
|
|
36
|
+
return $tokens;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public function preprocessCode(string $code, array &$patches): string {
|
|
40
|
+
$pos = 0;
|
|
41
|
+
while (false !== $pos = strpos($code, '#[', $pos)) {
|
|
42
|
+
// Replace #[ with %[
|
|
43
|
+
$code[$pos] = '%';
|
|
44
|
+
$patches[] = [$pos, 'replace', '#'];
|
|
45
|
+
$pos += 2;
|
|
46
|
+
}
|
|
47
|
+
return $code;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer\TokenEmulator;
|
|
4
|
+
|
|
5
|
+
use PhpParser\PhpVersion;
|
|
6
|
+
|
|
7
|
+
final class EnumTokenEmulator extends KeywordEmulator {
|
|
8
|
+
public function getPhpVersion(): PhpVersion {
|
|
9
|
+
return PhpVersion::fromComponents(8, 1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public function getKeywordString(): string {
|
|
13
|
+
return 'enum';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public function getKeywordToken(): int {
|
|
17
|
+
return \T_ENUM;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected function isKeywordContext(array $tokens, int $pos): bool {
|
|
21
|
+
return parent::isKeywordContext($tokens, $pos)
|
|
22
|
+
&& isset($tokens[$pos + 2])
|
|
23
|
+
&& $tokens[$pos + 1]->id === \T_WHITESPACE
|
|
24
|
+
&& $tokens[$pos + 2]->id === \T_STRING;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer\TokenEmulator;
|
|
4
|
+
|
|
5
|
+
use PhpParser\PhpVersion;
|
|
6
|
+
use PhpParser\Token;
|
|
7
|
+
|
|
8
|
+
class ExplicitOctalEmulator extends TokenEmulator {
|
|
9
|
+
public function getPhpVersion(): PhpVersion {
|
|
10
|
+
return PhpVersion::fromComponents(8, 1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public function isEmulationNeeded(string $code): bool {
|
|
14
|
+
return strpos($code, '0o') !== false || strpos($code, '0O') !== false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public function emulate(string $code, array $tokens): array {
|
|
18
|
+
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
|
|
19
|
+
$token = $tokens[$i];
|
|
20
|
+
if ($token->id == \T_LNUMBER && $token->text === '0' &&
|
|
21
|
+
isset($tokens[$i + 1]) && $tokens[$i + 1]->id == \T_STRING &&
|
|
22
|
+
preg_match('/[oO][0-7]+(?:_[0-7]+)*/', $tokens[$i + 1]->text)
|
|
23
|
+
) {
|
|
24
|
+
$tokenKind = $this->resolveIntegerOrFloatToken($tokens[$i + 1]->text);
|
|
25
|
+
array_splice($tokens, $i, 2, [
|
|
26
|
+
new Token($tokenKind, '0' . $tokens[$i + 1]->text, $token->line, $token->pos),
|
|
27
|
+
]);
|
|
28
|
+
$c--;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return $tokens;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private function resolveIntegerOrFloatToken(string $str): int {
|
|
35
|
+
$str = substr($str, 1);
|
|
36
|
+
$str = str_replace('_', '', $str);
|
|
37
|
+
$num = octdec($str);
|
|
38
|
+
return is_float($num) ? \T_DNUMBER : \T_LNUMBER;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public function reverseEmulate(string $code, array $tokens): array {
|
|
42
|
+
// Explicit octals were not legal code previously, don't bother.
|
|
43
|
+
return $tokens;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer\TokenEmulator;
|
|
4
|
+
|
|
5
|
+
use PhpParser\Token;
|
|
6
|
+
|
|
7
|
+
abstract class KeywordEmulator extends TokenEmulator {
|
|
8
|
+
abstract public function getKeywordString(): string;
|
|
9
|
+
abstract public function getKeywordToken(): int;
|
|
10
|
+
|
|
11
|
+
public function isEmulationNeeded(string $code): bool {
|
|
12
|
+
return strpos(strtolower($code), $this->getKeywordString()) !== false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** @param Token[] $tokens */
|
|
16
|
+
protected function isKeywordContext(array $tokens, int $pos): bool {
|
|
17
|
+
$previousNonSpaceToken = $this->getPreviousNonSpaceToken($tokens, $pos);
|
|
18
|
+
return $previousNonSpaceToken === null || $previousNonSpaceToken->id !== \T_OBJECT_OPERATOR;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public function emulate(string $code, array $tokens): array {
|
|
22
|
+
$keywordString = $this->getKeywordString();
|
|
23
|
+
foreach ($tokens as $i => $token) {
|
|
24
|
+
if ($token->id === T_STRING && strtolower($token->text) === $keywordString
|
|
25
|
+
&& $this->isKeywordContext($tokens, $i)) {
|
|
26
|
+
$token->id = $this->getKeywordToken();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return $tokens;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** @param Token[] $tokens */
|
|
34
|
+
private function getPreviousNonSpaceToken(array $tokens, int $start): ?Token {
|
|
35
|
+
for ($i = $start - 1; $i >= 0; --$i) {
|
|
36
|
+
if ($tokens[$i]->id === T_WHITESPACE) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return $tokens[$i];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public function reverseEmulate(string $code, array $tokens): array {
|
|
47
|
+
$keywordToken = $this->getKeywordToken();
|
|
48
|
+
foreach ($tokens as $token) {
|
|
49
|
+
if ($token->id === $keywordToken) {
|
|
50
|
+
$token->id = \T_STRING;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return $tokens;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer\TokenEmulator;
|
|
4
|
+
|
|
5
|
+
use PhpParser\PhpVersion;
|
|
6
|
+
|
|
7
|
+
final class MatchTokenEmulator extends KeywordEmulator {
|
|
8
|
+
public function getPhpVersion(): PhpVersion {
|
|
9
|
+
return PhpVersion::fromComponents(8, 0);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public function getKeywordString(): string {
|
|
13
|
+
return 'match';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public function getKeywordToken(): int {
|
|
17
|
+
return \T_MATCH;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer\TokenEmulator;
|
|
4
|
+
|
|
5
|
+
use PhpParser\PhpVersion;
|
|
6
|
+
use PhpParser\Token;
|
|
7
|
+
|
|
8
|
+
final class NullsafeTokenEmulator extends TokenEmulator {
|
|
9
|
+
public function getPhpVersion(): PhpVersion {
|
|
10
|
+
return PhpVersion::fromComponents(8, 0);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public function isEmulationNeeded(string $code): bool {
|
|
14
|
+
return strpos($code, '?->') !== false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public function emulate(string $code, array $tokens): array {
|
|
18
|
+
// We need to manually iterate and manage a count because we'll change
|
|
19
|
+
// the tokens array on the way
|
|
20
|
+
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
|
|
21
|
+
$token = $tokens[$i];
|
|
22
|
+
if ($token->text === '?' && isset($tokens[$i + 1]) && $tokens[$i + 1]->id === \T_OBJECT_OPERATOR) {
|
|
23
|
+
array_splice($tokens, $i, 2, [
|
|
24
|
+
new Token(\T_NULLSAFE_OBJECT_OPERATOR, '?->', $token->line, $token->pos),
|
|
25
|
+
]);
|
|
26
|
+
$c--;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Handle ?-> inside encapsed string.
|
|
31
|
+
if ($token->id === \T_ENCAPSED_AND_WHITESPACE && isset($tokens[$i - 1])
|
|
32
|
+
&& $tokens[$i - 1]->id === \T_VARIABLE
|
|
33
|
+
&& preg_match('/^\?->([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/', $token->text, $matches)
|
|
34
|
+
) {
|
|
35
|
+
$replacement = [
|
|
36
|
+
new Token(\T_NULLSAFE_OBJECT_OPERATOR, '?->', $token->line, $token->pos),
|
|
37
|
+
new Token(\T_STRING, $matches[1], $token->line, $token->pos + 3),
|
|
38
|
+
];
|
|
39
|
+
$matchLen = \strlen($matches[0]);
|
|
40
|
+
if ($matchLen !== \strlen($token->text)) {
|
|
41
|
+
$replacement[] = new Token(
|
|
42
|
+
\T_ENCAPSED_AND_WHITESPACE,
|
|
43
|
+
\substr($token->text, $matchLen),
|
|
44
|
+
$token->line, $token->pos + $matchLen
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
array_splice($tokens, $i, 1, $replacement);
|
|
48
|
+
$c += \count($replacement) - 1;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return $tokens;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public function reverseEmulate(string $code, array $tokens): array {
|
|
57
|
+
// ?-> was not valid code previously, don't bother.
|
|
58
|
+
return $tokens;
|
|
59
|
+
}
|
|
60
|
+
}
|
package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyFunctionTokenEmulator.php
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer\TokenEmulator;
|
|
4
|
+
|
|
5
|
+
use PhpParser\PhpVersion;
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* In PHP 8.1, "readonly(" was special cased in the lexer in order to support functions with
|
|
9
|
+
* name readonly. In PHP 8.2, this may conflict with readonly properties having a DNF type. For
|
|
10
|
+
* this reason, PHP 8.2 instead treats this as T_READONLY and then handles it specially in the
|
|
11
|
+
* parser. This emulator only exists to handle this special case, which is skipped by the
|
|
12
|
+
* PHP 8.1 ReadonlyTokenEmulator.
|
|
13
|
+
*/
|
|
14
|
+
class ReadonlyFunctionTokenEmulator extends KeywordEmulator {
|
|
15
|
+
public function getKeywordString(): string {
|
|
16
|
+
return 'readonly';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public function getKeywordToken(): int {
|
|
20
|
+
return \T_READONLY;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public function getPhpVersion(): PhpVersion {
|
|
24
|
+
return PhpVersion::fromComponents(8, 2);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public function reverseEmulate(string $code, array $tokens): array {
|
|
28
|
+
// Don't bother
|
|
29
|
+
return $tokens;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer\TokenEmulator;
|
|
4
|
+
|
|
5
|
+
use PhpParser\PhpVersion;
|
|
6
|
+
|
|
7
|
+
final class ReadonlyTokenEmulator extends KeywordEmulator {
|
|
8
|
+
public function getPhpVersion(): PhpVersion {
|
|
9
|
+
return PhpVersion::fromComponents(8, 1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public function getKeywordString(): string {
|
|
13
|
+
return 'readonly';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public function getKeywordToken(): int {
|
|
17
|
+
return \T_READONLY;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected function isKeywordContext(array $tokens, int $pos): bool {
|
|
21
|
+
if (!parent::isKeywordContext($tokens, $pos)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
// Support "function readonly("
|
|
25
|
+
return !(isset($tokens[$pos + 1]) &&
|
|
26
|
+
($tokens[$pos + 1]->text === '(' ||
|
|
27
|
+
($tokens[$pos + 1]->id === \T_WHITESPACE &&
|
|
28
|
+
isset($tokens[$pos + 2]) &&
|
|
29
|
+
$tokens[$pos + 2]->text === '(')));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer\TokenEmulator;
|
|
4
|
+
|
|
5
|
+
use PhpParser\PhpVersion;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Reverses emulation direction of the inner emulator.
|
|
9
|
+
*/
|
|
10
|
+
final class ReverseEmulator extends TokenEmulator {
|
|
11
|
+
/** @var TokenEmulator Inner emulator */
|
|
12
|
+
private TokenEmulator $emulator;
|
|
13
|
+
|
|
14
|
+
public function __construct(TokenEmulator $emulator) {
|
|
15
|
+
$this->emulator = $emulator;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public function getPhpVersion(): PhpVersion {
|
|
19
|
+
return $this->emulator->getPhpVersion();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public function isEmulationNeeded(string $code): bool {
|
|
23
|
+
return $this->emulator->isEmulationNeeded($code);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public function emulate(string $code, array $tokens): array {
|
|
27
|
+
return $this->emulator->reverseEmulate($code, $tokens);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public function reverseEmulate(string $code, array $tokens): array {
|
|
31
|
+
return $this->emulator->emulate($code, $tokens);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public function preprocessCode(string $code, array &$patches): string {
|
|
35
|
+
return $code;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer\TokenEmulator;
|
|
4
|
+
|
|
5
|
+
use PhpParser\PhpVersion;
|
|
6
|
+
use PhpParser\Token;
|
|
7
|
+
|
|
8
|
+
/** @internal */
|
|
9
|
+
abstract class TokenEmulator {
|
|
10
|
+
abstract public function getPhpVersion(): PhpVersion;
|
|
11
|
+
|
|
12
|
+
abstract public function isEmulationNeeded(string $code): bool;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param Token[] $tokens Original tokens
|
|
16
|
+
* @return Token[] Modified Tokens
|
|
17
|
+
*/
|
|
18
|
+
abstract public function emulate(string $code, array $tokens): array;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param Token[] $tokens Original tokens
|
|
22
|
+
* @return Token[] Modified Tokens
|
|
23
|
+
*/
|
|
24
|
+
abstract public function reverseEmulate(string $code, array $tokens): array;
|
|
25
|
+
|
|
26
|
+
/** @param array{int, string, string}[] $patches */
|
|
27
|
+
public function preprocessCode(string $code, array &$patches): string {
|
|
28
|
+
return $code;
|
|
29
|
+
}
|
|
30
|
+
}
|