@appthreat/atom 1.8.1 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/package.json +1 -1
  2. package/phpastgen.js +7 -1
  3. package/plugins/autoload.php +1 -1
  4. package/plugins/bin/atom +1 -1
  5. package/plugins/bin/atom.bat +1 -1
  6. package/plugins/composer/autoload_classmap.php +18 -18
  7. package/plugins/composer/autoload_real.php +4 -4
  8. package/plugins/composer/autoload_static.php +22 -22
  9. package/plugins/composer/installed.json +10 -12
  10. package/plugins/composer/installed.php +9 -9
  11. package/plugins/lib/io.appthreat.atom-1.8.2-classpath.jar +0 -0
  12. package/plugins/lib/{io.appthreat.atom-1.8.1.jar → io.appthreat.atom-1.8.2.jar} +0 -0
  13. package/plugins/lib/{io.appthreat.c2cpg_3-1.1.3.jar → io.appthreat.c2cpg_3-1.1.4.jar} +0 -0
  14. package/plugins/lib/{io.appthreat.dataflowengineoss_3-1.1.3.jar → io.appthreat.dataflowengineoss_3-1.1.4.jar} +0 -0
  15. package/plugins/lib/{io.appthreat.javasrc2cpg_3-1.1.3.jar → io.appthreat.javasrc2cpg_3-1.1.4.jar} +0 -0
  16. package/plugins/lib/{io.appthreat.jimple2cpg_3-1.1.3.jar → io.appthreat.jimple2cpg_3-1.1.4.jar} +0 -0
  17. package/plugins/lib/{io.appthreat.jssrc2cpg_3-1.1.3.jar → io.appthreat.jssrc2cpg_3-1.1.4.jar} +0 -0
  18. package/plugins/lib/{io.appthreat.php2atom_3-1.1.3.jar → io.appthreat.php2atom_3-1.1.4.jar} +0 -0
  19. package/plugins/lib/{io.appthreat.pysrc2cpg_3-1.1.3.jar → io.appthreat.pysrc2cpg_3-1.1.4.jar} +0 -0
  20. package/plugins/lib/{io.appthreat.semanticcpg_3-1.1.3.jar → io.appthreat.semanticcpg_3-1.1.4.jar} +0 -0
  21. package/plugins/lib/{io.appthreat.x2cpg_3-1.1.3.jar → io.appthreat.x2cpg_3-1.1.4.jar} +0 -0
  22. package/plugins/nikic/php-parser/README.md +12 -20
  23. package/plugins/nikic/php-parser/bin/php-parse +10 -11
  24. package/plugins/nikic/php-parser/composer.json +4 -6
  25. package/plugins/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php +15 -17
  26. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Class_.php +30 -35
  27. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Declaration.php +4 -11
  28. package/plugins/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php +7 -9
  29. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Enum_.php +27 -26
  30. package/plugins/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php +7 -7
  31. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Function_.php +7 -7
  32. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Interface_.php +10 -11
  33. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Method.php +15 -16
  34. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php +5 -5
  35. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Param.php +35 -16
  36. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Property.php +19 -19
  37. package/plugins/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php +5 -6
  38. package/plugins/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php +28 -25
  39. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Trait_.php +11 -16
  40. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Use_.php +8 -8
  41. package/plugins/nikic/php-parser/lib/PhpParser/Builder.php +3 -2
  42. package/plugins/nikic/php-parser/lib/PhpParser/BuilderFactory.php +69 -45
  43. package/plugins/nikic/php-parser/lib/PhpParser/BuilderHelpers.php +19 -17
  44. package/plugins/nikic/php-parser/lib/PhpParser/Comment/Doc.php +2 -1
  45. package/plugins/nikic/php-parser/lib/PhpParser/Comment.php +67 -35
  46. package/plugins/nikic/php-parser/lib/PhpParser/ConstExprEvaluationException.php +3 -3
  47. package/plugins/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php +10 -15
  48. package/plugins/nikic/php-parser/lib/PhpParser/Error.php +33 -24
  49. package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php +9 -6
  50. package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php +3 -2
  51. package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler.php +3 -2
  52. package/plugins/nikic/php-parser/lib/PhpParser/Internal/DiffElem.php +7 -11
  53. package/plugins/nikic/php-parser/lib/PhpParser/Internal/Differ.php +22 -36
  54. package/plugins/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php +13 -20
  55. package/plugins/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php +70 -55
  56. package/plugins/nikic/php-parser/lib/PhpParser/JsonDecoder.php +10 -15
  57. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php +93 -68
  58. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php +18 -11
  59. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php +47 -0
  60. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php +15 -10
  61. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php +11 -12
  62. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php +76 -0
  63. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php +23 -0
  64. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php +25 -19
  65. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php +10 -6
  66. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php +29 -22
  67. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php +105 -0
  68. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyFunctionTokenEmulator.php +3 -3
  69. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php +15 -10
  70. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php +5 -6
  71. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php +5 -10
  72. package/plugins/nikic/php-parser/lib/PhpParser/Lexer.php +513 -69
  73. package/plugins/nikic/php-parser/lib/PhpParser/NameContext.php +24 -23
  74. package/plugins/nikic/php-parser/lib/PhpParser/Node/Arg.php +15 -13
  75. package/plugins/nikic/php-parser/lib/PhpParser/Node/Attribute.php +10 -9
  76. package/plugins/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php +7 -5
  77. package/plugins/nikic/php-parser/lib/PhpParser/Node/ComplexType.php +2 -1
  78. package/plugins/nikic/php-parser/lib/PhpParser/Node/Const_.php +10 -9
  79. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php +11 -10
  80. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php +39 -1
  81. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php +11 -11
  82. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php +28 -33
  83. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php +10 -9
  84. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php +3 -2
  85. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php +3 -2
  86. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php +3 -2
  87. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php +3 -2
  88. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php +3 -2
  89. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php +3 -2
  90. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php +3 -2
  91. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php +3 -2
  92. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php +3 -2
  93. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php +3 -2
  94. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php +3 -2
  95. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php +3 -2
  96. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php +3 -2
  97. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php +8 -7
  98. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php +10 -9
  99. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php +5 -4
  100. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php +5 -4
  101. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php +5 -4
  102. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php +5 -4
  103. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php +5 -4
  104. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php +5 -4
  105. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php +5 -4
  106. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php +5 -4
  107. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php +5 -4
  108. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php +5 -4
  109. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php +5 -4
  110. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php +5 -4
  111. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php +5 -4
  112. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php +5 -4
  113. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php +5 -4
  114. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php +5 -4
  115. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php +5 -4
  116. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php +5 -4
  117. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php +5 -4
  118. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php +5 -4
  119. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php +5 -4
  120. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php +5 -4
  121. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php +5 -4
  122. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php +5 -4
  123. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php +5 -4
  124. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php +5 -4
  125. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php +5 -4
  126. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php +11 -8
  127. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php +8 -7
  128. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php +8 -7
  129. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php +7 -3
  130. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php +3 -2
  131. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php +3 -2
  132. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php +6 -5
  133. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php +3 -2
  134. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php +3 -2
  135. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php +3 -2
  136. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php +3 -2
  137. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php +6 -5
  138. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php +10 -10
  139. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php +8 -7
  140. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php +26 -33
  141. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php +32 -1
  142. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php +8 -7
  143. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php +8 -7
  144. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php +6 -5
  145. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php +8 -7
  146. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php +8 -7
  147. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php +11 -10
  148. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php +11 -10
  149. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php +14 -13
  150. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php +11 -11
  151. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php +8 -7
  152. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php +8 -12
  153. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php +7 -8
  154. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php +12 -12
  155. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php +11 -10
  156. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php +12 -12
  157. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php +10 -10
  158. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php +8 -7
  159. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php +8 -7
  160. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php +7 -6
  161. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php +8 -7
  162. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php +8 -7
  163. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php +10 -10
  164. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php +9 -9
  165. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php +13 -12
  166. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +11 -11
  167. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php +13 -12
  168. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php +7 -6
  169. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php +8 -7
  170. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php +8 -7
  171. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php +7 -6
  172. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php +8 -7
  173. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php +11 -10
  174. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr.php +2 -1
  175. package/plugins/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php +8 -5
  176. package/plugins/nikic/php-parser/lib/PhpParser/Node/Identifier.php +13 -13
  177. package/plugins/nikic/php-parser/lib/PhpParser/Node/IntersectionType.php +9 -6
  178. package/plugins/nikic/php-parser/lib/PhpParser/Node/MatchArm.php +9 -8
  179. package/plugins/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php +9 -8
  180. package/plugins/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php +9 -8
  181. package/plugins/nikic/php-parser/lib/PhpParser/Node/Name.php +56 -71
  182. package/plugins/nikic/php-parser/lib/PhpParser/Node/NullableType.php +10 -11
  183. package/plugins/nikic/php-parser/lib/PhpParser/Node/Param.php +22 -46
  184. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php +75 -1
  185. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php +29 -1
  186. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +28 -1
  187. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php +78 -1
  188. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php +5 -4
  189. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php +5 -4
  190. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php +5 -4
  191. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php +5 -4
  192. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php +5 -4
  193. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php +5 -4
  194. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php +5 -4
  195. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php +5 -4
  196. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php +5 -4
  197. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php +26 -30
  198. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar.php +2 -1
  199. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php +9 -8
  200. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php +11 -10
  201. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php +12 -11
  202. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php +32 -24
  203. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php +13 -13
  204. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php +54 -47
  205. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php +89 -46
  206. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php +8 -7
  207. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php +9 -8
  208. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php +32 -1
  209. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php +12 -12
  210. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php +10 -9
  211. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php +8 -7
  212. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php +10 -9
  213. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php +8 -7
  214. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php +12 -11
  215. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php +13 -17
  216. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php +8 -7
  217. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php +8 -7
  218. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php +15 -19
  219. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php +17 -20
  220. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php +24 -28
  221. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php +8 -7
  222. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php +8 -7
  223. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php +14 -16
  224. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php +8 -7
  225. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php +15 -18
  226. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php +8 -7
  227. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php +10 -13
  228. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php +8 -7
  229. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php +12 -11
  230. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php +5 -4
  231. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php +37 -28
  232. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php +32 -1
  233. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php +9 -8
  234. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php +35 -1
  235. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php +8 -8
  236. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php +10 -9
  237. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php +30 -0
  238. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php +9 -8
  239. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +13 -12
  240. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +10 -9
  241. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php +4 -3
  242. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php +8 -10
  243. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php +12 -11
  244. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php +8 -7
  245. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php +50 -1
  246. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php +16 -16
  247. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php +10 -9
  248. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt.php +2 -1
  249. package/plugins/nikic/php-parser/lib/PhpParser/Node/UnionType.php +8 -7
  250. package/plugins/nikic/php-parser/lib/PhpParser/Node/VarLikeIdentifier.php +3 -2
  251. package/plugins/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php +2 -2
  252. package/plugins/nikic/php-parser/lib/PhpParser/Node.php +29 -24
  253. package/plugins/nikic/php-parser/lib/PhpParser/NodeAbstract.php +20 -20
  254. package/plugins/nikic/php-parser/lib/PhpParser/NodeDumper.php +84 -168
  255. package/plugins/nikic/php-parser/lib/PhpParser/NodeFinder.php +19 -28
  256. package/plugins/nikic/php-parser/lib/PhpParser/NodeTraverser.php +84 -71
  257. package/plugins/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php +7 -4
  258. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php +2 -1
  259. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php +5 -4
  260. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php +7 -6
  261. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php +28 -30
  262. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php +3 -2
  263. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php +11 -8
  264. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor.php +7 -59
  265. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php +2 -1
  266. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Multiple.php +55 -0
  267. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php5.php +2682 -0
  268. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php7.php +1522 -1323
  269. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Tokens.php +148 -0
  270. package/plugins/nikic/php-parser/lib/PhpParser/Parser.php +3 -9
  271. package/plugins/nikic/php-parser/lib/PhpParser/ParserAbstract.php +252 -433
  272. package/plugins/nikic/php-parser/lib/PhpParser/ParserFactory.php +49 -15
  273. package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php +335 -386
  274. package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +438 -517
  275. package/plugins/lib/io.appthreat.atom-1.8.1-classpath.jar +0 -0
  276. package/plugins/nikic/php-parser/.php-cs-fixer.dist.php +0 -31
  277. package/plugins/nikic/php-parser/Makefile +0 -10
  278. package/plugins/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php +0 -237
  279. package/plugins/nikic/php-parser/lib/PhpParser/Modifiers.php +0 -69
  280. package/plugins/nikic/php-parser/lib/PhpParser/Node/ArrayItem.php +0 -43
  281. package/plugins/nikic/php-parser/lib/PhpParser/Node/ClosureUse.php +0 -36
  282. package/plugins/nikic/php-parser/lib/PhpParser/Node/DeclareItem.php +0 -37
  283. package/plugins/nikic/php-parser/lib/PhpParser/Node/InterpolatedStringPart.php +0 -32
  284. package/plugins/nikic/php-parser/lib/PhpParser/Node/PropertyItem.php +0 -37
  285. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/Float_.php +0 -78
  286. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/Int_.php +0 -82
  287. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/InterpolatedString.php +0 -34
  288. package/plugins/nikic/php-parser/lib/PhpParser/Node/StaticVar.php +0 -39
  289. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Block.php +0 -29
  290. package/plugins/nikic/php-parser/lib/PhpParser/Node/UseItem.php +0 -55
  291. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php +0 -82
  292. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php8.php +0 -2717
  293. package/plugins/nikic/php-parser/lib/PhpParser/PhpVersion.php +0 -164
  294. package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinter.php +0 -51
  295. package/plugins/nikic/php-parser/lib/PhpParser/Token.php +0 -18
  296. package/plugins/nikic/php-parser/lib/PhpParser/compatibility_tokens.php +0 -56
  297. package/plugins/nikic/php-parser/phpstan-baseline.neon +0 -236
  298. package/plugins/nikic/php-parser/phpstan.neon.dist +0 -8
@@ -2,23 +2,22 @@
2
2
 
3
3
  namespace PhpParser\Internal;
4
4
 
5
- use PhpParser\Token;
6
-
7
5
  /**
8
6
  * Provides operations on token streams, for use by pretty printer.
9
7
  *
10
8
  * @internal
11
9
  */
12
- class TokenStream {
13
- /** @var Token[] Tokens (in PhpToken::tokenize() format) */
14
- private array $tokens;
10
+ class TokenStream
11
+ {
12
+ /** @var array Tokens (in token_get_all format) */
13
+ private $tokens;
15
14
  /** @var int[] Map from position to indentation */
16
- private array $indentMap;
15
+ private $indentMap;
17
16
 
18
17
  /**
19
18
  * Create token stream instance.
20
19
  *
21
- * @param Token[] $tokens Tokens in PhpToken::tokenize() format
20
+ * @param array $tokens Tokens in token_get_all() format
22
21
  */
23
22
  public function __construct(array $tokens) {
24
23
  $this->tokens = $tokens;
@@ -29,9 +28,11 @@ class TokenStream {
29
28
  * Whether the given position is immediately surrounded by parenthesis.
30
29
  *
31
30
  * @param int $startPos Start position
32
- * @param int $endPos End position
31
+ * @param int $endPos End position
32
+ *
33
+ * @return bool
33
34
  */
34
- public function haveParens(int $startPos, int $endPos): bool {
35
+ public function haveParens(int $startPos, int $endPos) : bool {
35
36
  return $this->haveTokenImmediatelyBefore($startPos, '(')
36
37
  && $this->haveTokenImmediatelyAfter($endPos, ')');
37
38
  }
@@ -40,9 +41,11 @@ class TokenStream {
40
41
  * Whether the given position is immediately surrounded by braces.
41
42
  *
42
43
  * @param int $startPos Start position
43
- * @param int $endPos End position
44
+ * @param int $endPos End position
45
+ *
46
+ * @return bool
44
47
  */
45
- public function haveBraces(int $startPos, int $endPos): bool {
48
+ public function haveBraces(int $startPos, int $endPos) : bool {
46
49
  return ($this->haveTokenImmediatelyBefore($startPos, '{')
47
50
  || $this->haveTokenImmediatelyBefore($startPos, T_CURLY_OPEN))
48
51
  && $this->haveTokenImmediatelyAfter($endPos, '}');
@@ -53,20 +56,21 @@ class TokenStream {
53
56
  *
54
57
  * During this check whitespace and comments are skipped.
55
58
  *
56
- * @param int $pos Position before which the token should occur
59
+ * @param int $pos Position before which the token should occur
57
60
  * @param int|string $expectedTokenType Token to check for
58
61
  *
59
62
  * @return bool Whether the expected token was found
60
63
  */
61
- public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType): bool {
64
+ public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType) : bool {
62
65
  $tokens = $this->tokens;
63
66
  $pos--;
64
67
  for (; $pos >= 0; $pos--) {
65
- $token = $tokens[$pos];
66
- if ($token->is($expectedTokenType)) {
68
+ $tokenType = $tokens[$pos][0];
69
+ if ($tokenType === $expectedTokenType) {
67
70
  return true;
68
71
  }
69
- if (!$token->isIgnorable()) {
72
+ if ($tokenType !== \T_WHITESPACE
73
+ && $tokenType !== \T_COMMENT && $tokenType !== \T_DOC_COMMENT) {
70
74
  break;
71
75
  }
72
76
  }
@@ -78,28 +82,28 @@ class TokenStream {
78
82
  *
79
83
  * During this check whitespace and comments are skipped.
80
84
  *
81
- * @param int $pos Position after which the token should occur
85
+ * @param int $pos Position after which the token should occur
82
86
  * @param int|string $expectedTokenType Token to check for
83
87
  *
84
88
  * @return bool Whether the expected token was found
85
89
  */
86
- public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType): bool {
90
+ public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType) : bool {
87
91
  $tokens = $this->tokens;
88
92
  $pos++;
89
- for ($c = \count($tokens); $pos < $c; $pos++) {
90
- $token = $tokens[$pos];
91
- if ($token->is($expectedTokenType)) {
93
+ for (; $pos < \count($tokens); $pos++) {
94
+ $tokenType = $tokens[$pos][0];
95
+ if ($tokenType === $expectedTokenType) {
92
96
  return true;
93
97
  }
94
- if (!$token->isIgnorable()) {
98
+ if ($tokenType !== \T_WHITESPACE
99
+ && $tokenType !== \T_COMMENT && $tokenType !== \T_DOC_COMMENT) {
95
100
  break;
96
101
  }
97
102
  }
98
103
  return false;
99
104
  }
100
105
 
101
- /** @param int|string|(int|string)[] $skipTokenType */
102
- public function skipLeft(int $pos, $skipTokenType): int {
106
+ public function skipLeft(int $pos, $skipTokenType) {
103
107
  $tokens = $this->tokens;
104
108
 
105
109
  $pos = $this->skipLeftWhitespace($pos);
@@ -107,7 +111,7 @@ class TokenStream {
107
111
  return $pos;
108
112
  }
109
113
 
110
- if (!$tokens[$pos]->is($skipTokenType)) {
114
+ if ($tokens[$pos][0] !== $skipTokenType) {
111
115
  // Shouldn't happen. The skip token MUST be there
112
116
  throw new \Exception('Encountered unexpected token');
113
117
  }
@@ -116,8 +120,7 @@ class TokenStream {
116
120
  return $this->skipLeftWhitespace($pos);
117
121
  }
118
122
 
119
- /** @param int|string|(int|string)[] $skipTokenType */
120
- public function skipRight(int $pos, $skipTokenType): int {
123
+ public function skipRight(int $pos, $skipTokenType) {
121
124
  $tokens = $this->tokens;
122
125
 
123
126
  $pos = $this->skipRightWhitespace($pos);
@@ -125,7 +128,7 @@ class TokenStream {
125
128
  return $pos;
126
129
  }
127
130
 
128
- if (!$tokens[$pos]->is($skipTokenType)) {
131
+ if ($tokens[$pos][0] !== $skipTokenType) {
129
132
  // Shouldn't happen. The skip token MUST be there
130
133
  throw new \Exception('Encountered unexpected token');
131
134
  }
@@ -140,10 +143,11 @@ class TokenStream {
140
143
  * @param int $pos Token position
141
144
  * @return int Non-whitespace token position
142
145
  */
143
- public function skipLeftWhitespace(int $pos): int {
146
+ public function skipLeftWhitespace(int $pos) {
144
147
  $tokens = $this->tokens;
145
148
  for (; $pos >= 0; $pos--) {
146
- if (!$tokens[$pos]->isIgnorable()) {
149
+ $type = $tokens[$pos][0];
150
+ if ($type !== \T_WHITESPACE && $type !== \T_COMMENT && $type !== \T_DOC_COMMENT) {
147
151
  break;
148
152
  }
149
153
  }
@@ -156,21 +160,22 @@ class TokenStream {
156
160
  * @param int $pos Token position
157
161
  * @return int Non-whitespace token position
158
162
  */
159
- public function skipRightWhitespace(int $pos): int {
163
+ public function skipRightWhitespace(int $pos) {
160
164
  $tokens = $this->tokens;
161
165
  for ($count = \count($tokens); $pos < $count; $pos++) {
162
- if (!$tokens[$pos]->isIgnorable()) {
166
+ $type = $tokens[$pos][0];
167
+ if ($type !== \T_WHITESPACE && $type !== \T_COMMENT && $type !== \T_DOC_COMMENT) {
163
168
  break;
164
169
  }
165
170
  }
166
171
  return $pos;
167
172
  }
168
173
 
169
- /** @param int|string|(int|string)[] $findTokenType */
170
- public function findRight(int $pos, $findTokenType): int {
174
+ public function findRight(int $pos, $findTokenType) {
171
175
  $tokens = $this->tokens;
172
176
  for ($count = \count($tokens); $pos < $count; $pos++) {
173
- if ($tokens[$pos]->is($findTokenType)) {
177
+ $type = $tokens[$pos][0];
178
+ if ($type === $findTokenType) {
174
179
  return $pos;
175
180
  }
176
181
  }
@@ -185,16 +190,22 @@ class TokenStream {
185
190
  * @param int|string $tokenType Token type to look for
186
191
  * @return bool Whether the token occurs in the given range
187
192
  */
188
- public function haveTokenInRange(int $startPos, int $endPos, $tokenType): bool {
193
+ public function haveTokenInRange(int $startPos, int $endPos, $tokenType) {
189
194
  $tokens = $this->tokens;
190
195
  for ($pos = $startPos; $pos < $endPos; $pos++) {
191
- if ($tokens[$pos]->is($tokenType)) {
196
+ if ($tokens[$pos][0] === $tokenType) {
192
197
  return true;
193
198
  }
194
199
  }
195
200
  return false;
196
201
  }
197
202
 
203
+ public function haveBracesInRange(int $startPos, int $endPos) {
204
+ return $this->haveTokenInRange($startPos, $endPos, '{')
205
+ || $this->haveTokenInRange($startPos, $endPos, T_CURLY_OPEN)
206
+ || $this->haveTokenInRange($startPos, $endPos, '}');
207
+ }
208
+
198
209
  public function haveTagInRange(int $startPos, int $endPos): bool {
199
210
  return $this->haveTokenInRange($startPos, $endPos, \T_OPEN_TAG)
200
211
  || $this->haveTokenInRange($startPos, $endPos, \T_CLOSE_TAG);
@@ -207,37 +218,41 @@ class TokenStream {
207
218
  *
208
219
  * @return int Indentation depth (in spaces)
209
220
  */
210
- public function getIndentationBefore(int $pos): int {
221
+ public function getIndentationBefore(int $pos) : int {
211
222
  return $this->indentMap[$pos];
212
223
  }
213
224
 
214
225
  /**
215
226
  * Get the code corresponding to a token offset range, optionally adjusted for indentation.
216
227
  *
217
- * @param int $from Token start position (inclusive)
218
- * @param int $to Token end position (exclusive)
228
+ * @param int $from Token start position (inclusive)
229
+ * @param int $to Token end position (exclusive)
219
230
  * @param int $indent By how much the code should be indented (can be negative as well)
220
231
  *
221
232
  * @return string Code corresponding to token range, adjusted for indentation
222
233
  */
223
- public function getTokenCode(int $from, int $to, int $indent): string {
234
+ public function getTokenCode(int $from, int $to, int $indent) : string {
224
235
  $tokens = $this->tokens;
225
236
  $result = '';
226
237
  for ($pos = $from; $pos < $to; $pos++) {
227
238
  $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);
239
+ if (\is_array($token)) {
240
+ $type = $token[0];
241
+ $content = $token[1];
242
+ if ($type === \T_CONSTANT_ENCAPSED_STRING || $type === \T_ENCAPSED_AND_WHITESPACE) {
243
+ $result .= $content;
238
244
  } else {
239
- $result .= $text;
245
+ // TODO Handle non-space indentation
246
+ if ($indent < 0) {
247
+ $result .= str_replace("\n" . str_repeat(" ", -$indent), "\n", $content);
248
+ } elseif ($indent > 0) {
249
+ $result .= str_replace("\n", "\n" . str_repeat(" ", $indent), $content);
250
+ } else {
251
+ $result .= $content;
252
+ }
240
253
  }
254
+ } else {
255
+ $result .= $token;
241
256
  }
242
257
  }
243
258
  return $result;
@@ -248,14 +263,14 @@ class TokenStream {
248
263
  *
249
264
  * @return int[] Token position to indentation map
250
265
  */
251
- private function calcIndentMap(): array {
266
+ private function calcIndentMap() {
252
267
  $indentMap = [];
253
268
  $indent = 0;
254
269
  foreach ($this->tokens as $token) {
255
270
  $indentMap[] = $indent;
256
271
 
257
- if ($token->id === \T_WHITESPACE) {
258
- $content = $token->text;
272
+ if ($token[0] === \T_WHITESPACE) {
273
+ $content = $token[1];
259
274
  $newlinePos = \strrpos($content, "\n");
260
275
  if (false !== $newlinePos) {
261
276
  $indent = \strlen($content) - $newlinePos - 1;
@@ -2,11 +2,11 @@
2
2
 
3
3
  namespace PhpParser;
4
4
 
5
- class JsonDecoder {
6
- /** @var \ReflectionClass<Node>[] Node type to reflection class map */
7
- private array $reflectionClassCache;
5
+ class JsonDecoder
6
+ {
7
+ /** @var \ReflectionClass[] Node type to reflection class map */
8
+ private $reflectionClassCache;
8
9
 
9
- /** @return mixed */
10
10
  public function decode(string $json) {
11
11
  $value = json_decode($json, true);
12
12
  if (json_last_error()) {
@@ -16,10 +16,6 @@ class JsonDecoder {
16
16
  return $this->decodeRecursive($value);
17
17
  }
18
18
 
19
- /**
20
- * @param mixed $value
21
- * @return mixed
22
- */
23
19
  private function decodeRecursive($value) {
24
20
  if (\is_array($value)) {
25
21
  if (isset($value['nodeType'])) {
@@ -33,7 +29,7 @@ class JsonDecoder {
33
29
  return $value;
34
30
  }
35
31
 
36
- private function decodeArray(array $array): array {
32
+ private function decodeArray(array $array) : array {
37
33
  $decodedArray = [];
38
34
  foreach ($array as $key => $value) {
39
35
  $decodedArray[$key] = $this->decodeRecursive($value);
@@ -41,13 +37,14 @@ class JsonDecoder {
41
37
  return $decodedArray;
42
38
  }
43
39
 
44
- private function decodeNode(array $value): Node {
40
+ private function decodeNode(array $value) : Node {
45
41
  $nodeType = $value['nodeType'];
46
42
  if (!\is_string($nodeType)) {
47
43
  throw new \RuntimeException('Node type must be a string');
48
44
  }
49
45
 
50
46
  $reflectionClass = $this->reflectionClassFromNodeType($nodeType);
47
+ /** @var Node $node */
51
48
  $node = $reflectionClass->newInstanceWithoutConstructor();
52
49
 
53
50
  if (isset($value['attributes'])) {
@@ -69,7 +66,7 @@ class JsonDecoder {
69
66
  return $node;
70
67
  }
71
68
 
72
- private function decodeComment(array $value): Comment {
69
+ private function decodeComment(array $value) : Comment {
73
70
  $className = $value['nodeType'] === 'Comment' ? Comment::class : Comment\Doc::class;
74
71
  if (!isset($value['text'])) {
75
72
  throw new \RuntimeException('Comment must have text');
@@ -82,8 +79,7 @@ class JsonDecoder {
82
79
  );
83
80
  }
84
81
 
85
- /** @return \ReflectionClass<Node> */
86
- private function reflectionClassFromNodeType(string $nodeType): \ReflectionClass {
82
+ private function reflectionClassFromNodeType(string $nodeType) : \ReflectionClass {
87
83
  if (!isset($this->reflectionClassCache[$nodeType])) {
88
84
  $className = $this->classNameFromNodeType($nodeType);
89
85
  $this->reflectionClassCache[$nodeType] = new \ReflectionClass($className);
@@ -91,8 +87,7 @@ class JsonDecoder {
91
87
  return $this->reflectionClassCache[$nodeType];
92
88
  }
93
89
 
94
- /** @return class-string<Node> */
95
- private function classNameFromNodeType(string $nodeType): string {
90
+ private function classNameFromNodeType(string $nodeType) : string {
96
91
  $className = 'PhpParser\\Node\\' . strtr($nodeType, '_', '\\');
97
92
  if (class_exists($className)) {
98
93
  return $className;
@@ -18,29 +18,42 @@ use PhpParser\Lexer\TokenEmulator\ReadonlyFunctionTokenEmulator;
18
18
  use PhpParser\Lexer\TokenEmulator\ReadonlyTokenEmulator;
19
19
  use PhpParser\Lexer\TokenEmulator\ReverseEmulator;
20
20
  use PhpParser\Lexer\TokenEmulator\TokenEmulator;
21
- use PhpParser\PhpVersion;
22
- use PhpParser\Token;
23
21
 
24
- class Emulative extends Lexer {
25
- /** @var array{int, string, string}[] Patches used to reverse changes introduced in the code */
26
- private array $patches = [];
22
+ class Emulative extends Lexer
23
+ {
24
+ const PHP_7_3 = '7.3dev';
25
+ const PHP_7_4 = '7.4dev';
26
+ const PHP_8_0 = '8.0dev';
27
+ const PHP_8_1 = '8.1dev';
28
+ const PHP_8_2 = '8.2dev';
27
29
 
28
- /** @var list<TokenEmulator> */
29
- private array $emulators = [];
30
+ /** @var mixed[] Patches used to reverse changes introduced in the code */
31
+ private $patches = [];
30
32
 
31
- private PhpVersion $targetPhpVersion;
33
+ /** @var TokenEmulator[] */
34
+ private $emulators = [];
32
35
 
33
- private PhpVersion $hostPhpVersion;
36
+ /** @var string */
37
+ private $targetPhpVersion;
34
38
 
35
39
  /**
36
- * @param PhpVersion|null $phpVersion PHP version to emulate. Defaults to newest supported.
40
+ * @param mixed[] $options Lexer options. In addition to the usual options,
41
+ * accepts a 'phpVersion' string that specifies the
42
+ * version to emulate. Defaults to newest supported.
37
43
  */
38
- public function __construct(?PhpVersion $phpVersion = null) {
39
- $this->targetPhpVersion = $phpVersion ?? PhpVersion::getNewestSupported();
40
- $this->hostPhpVersion = PhpVersion::getHostVersion();
44
+ public function __construct(array $options = [])
45
+ {
46
+ $this->targetPhpVersion = $options['phpVersion'] ?? Emulative::PHP_8_2;
47
+ unset($options['phpVersion']);
48
+
49
+ parent::__construct($options);
41
50
 
42
51
  $emulators = [
52
+ new FlexibleDocStringEmulator(),
53
+ new FnTokenEmulator(),
43
54
  new MatchTokenEmulator(),
55
+ new CoaleseEqualTokenEmulator(),
56
+ new NumericLiteralSeparatorEmulator(),
44
57
  new NullsafeTokenEmulator(),
45
58
  new AttributeEmulator(),
46
59
  new EnumTokenEmulator(),
@@ -55,24 +68,21 @@ class Emulative extends Lexer {
55
68
  $emulatorPhpVersion = $emulator->getPhpVersion();
56
69
  if ($this->isForwardEmulationNeeded($emulatorPhpVersion)) {
57
70
  $this->emulators[] = $emulator;
58
- } elseif ($this->isReverseEmulationNeeded($emulatorPhpVersion)) {
71
+ } else if ($this->isReverseEmulationNeeded($emulatorPhpVersion)) {
59
72
  $this->emulators[] = new ReverseEmulator($emulator);
60
73
  }
61
74
  }
62
75
  }
63
76
 
64
- public function tokenize(string $code, ?ErrorHandler $errorHandler = null): array {
65
- $emulators = array_filter($this->emulators, function ($emulator) use ($code) {
77
+ public function startLexing(string $code, ErrorHandler $errorHandler = null) {
78
+ $emulators = array_filter($this->emulators, function($emulator) use($code) {
66
79
  return $emulator->isEmulationNeeded($code);
67
80
  });
68
81
 
69
82
  if (empty($emulators)) {
70
83
  // Nothing to emulate, yay
71
- return parent::tokenize($code, $errorHandler);
72
- }
73
-
74
- if ($errorHandler === null) {
75
- $errorHandler = new ErrorHandler\Throwing();
84
+ parent::startLexing($code, $errorHandler);
85
+ return;
76
86
  }
77
87
 
78
88
  $this->patches = [];
@@ -81,9 +91,9 @@ class Emulative extends Lexer {
81
91
  }
82
92
 
83
93
  $collector = new ErrorHandler\Collecting();
84
- $tokens = parent::tokenize($code, $collector);
94
+ parent::startLexing($code, $collector);
85
95
  $this->sortPatches();
86
- $tokens = $this->fixupTokens($tokens);
96
+ $this->fixupTokens();
87
97
 
88
98
  $errors = $collector->getErrors();
89
99
  if (!empty($errors)) {
@@ -94,80 +104,90 @@ class Emulative extends Lexer {
94
104
  }
95
105
 
96
106
  foreach ($emulators as $emulator) {
97
- $tokens = $emulator->emulate($code, $tokens);
107
+ $this->tokens = $emulator->emulate($code, $this->tokens);
98
108
  }
99
-
100
- return $tokens;
101
109
  }
102
110
 
103
- private function isForwardEmulationNeeded(PhpVersion $emulatorPhpVersion): bool {
104
- return $this->hostPhpVersion->older($emulatorPhpVersion)
105
- && $this->targetPhpVersion->newerOrEqual($emulatorPhpVersion);
111
+ private function isForwardEmulationNeeded(string $emulatorPhpVersion): bool {
112
+ return version_compare(\PHP_VERSION, $emulatorPhpVersion, '<')
113
+ && version_compare($this->targetPhpVersion, $emulatorPhpVersion, '>=');
106
114
  }
107
115
 
108
- private function isReverseEmulationNeeded(PhpVersion $emulatorPhpVersion): bool {
109
- return $this->hostPhpVersion->newerOrEqual($emulatorPhpVersion)
110
- && $this->targetPhpVersion->older($emulatorPhpVersion);
116
+ private function isReverseEmulationNeeded(string $emulatorPhpVersion): bool {
117
+ return version_compare(\PHP_VERSION, $emulatorPhpVersion, '>=')
118
+ && version_compare($this->targetPhpVersion, $emulatorPhpVersion, '<');
111
119
  }
112
120
 
113
- private function sortPatches(): void {
121
+ private function sortPatches()
122
+ {
114
123
  // Patches may be contributed by different emulators.
115
124
  // Make sure they are sorted by increasing patch position.
116
- usort($this->patches, function ($p1, $p2) {
125
+ usort($this->patches, function($p1, $p2) {
117
126
  return $p1[0] <=> $p2[0];
118
127
  });
119
128
  }
120
129
 
121
- /**
122
- * @param list<Token> $tokens
123
- * @return list<Token>
124
- */
125
- private function fixupTokens(array $tokens): array {
130
+ private function fixupTokens()
131
+ {
126
132
  if (\count($this->patches) === 0) {
127
- return $tokens;
133
+ return;
128
134
  }
129
135
 
130
136
  // Load first patch
131
137
  $patchIdx = 0;
138
+
132
139
  list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
133
140
 
134
141
  // 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);
142
+ $pos = 0;
143
+ for ($i = 0, $c = \count($this->tokens); $i < $c; $i++) {
144
+ $token = $this->tokens[$i];
145
+ if (\is_string($token)) {
146
+ if ($patchPos === $pos) {
147
+ // Only support replacement for string tokens.
148
+ assert($patchType === 'replace');
149
+ $this->tokens[$i] = $patchText;
150
+
151
+ // Fetch the next patch
152
+ $patchIdx++;
153
+ if ($patchIdx >= \count($this->patches)) {
154
+ // No more patches, we're done
155
+ return;
156
+ }
157
+ list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
158
+ }
159
+
160
+ $pos += \strlen($token);
161
+ continue;
162
+ }
163
+
164
+ $len = \strlen($token[1]);
165
+ $posDelta = 0;
144
166
  while ($patchPos >= $pos && $patchPos < $pos + $len) {
145
167
  $patchTextLen = \strlen($patchText);
146
168
  if ($patchType === 'remove') {
147
169
  if ($patchPos === $pos && $patchTextLen === $len) {
148
170
  // Remove token entirely
149
- array_splice($tokens, $i, 1, []);
171
+ array_splice($this->tokens, $i, 1, []);
150
172
  $i--;
151
173
  $c--;
152
174
  } else {
153
175
  // Remove from token string
154
- $token->text = substr_replace(
155
- $token->text, '', $patchPos - $pos + $localPosDelta, $patchTextLen
176
+ $this->tokens[$i][1] = substr_replace(
177
+ $token[1], '', $patchPos - $pos + $posDelta, $patchTextLen
156
178
  );
157
- $localPosDelta -= $patchTextLen;
179
+ $posDelta -= $patchTextLen;
158
180
  }
159
- $lineDelta -= \substr_count($patchText, "\n");
160
181
  } elseif ($patchType === 'add') {
161
182
  // Insert into the token string
162
- $token->text = substr_replace(
163
- $token->text, $patchText, $patchPos - $pos + $localPosDelta, 0
183
+ $this->tokens[$i][1] = substr_replace(
184
+ $token[1], $patchText, $patchPos - $pos + $posDelta, 0
164
185
  );
165
- $localPosDelta += $patchTextLen;
166
- $lineDelta += \substr_count($patchText, "\n");
167
- } elseif ($patchType === 'replace') {
186
+ $posDelta += $patchTextLen;
187
+ } else if ($patchType === 'replace') {
168
188
  // Replace inside the token string
169
- $token->text = substr_replace(
170
- $token->text, $patchText, $patchPos - $pos + $localPosDelta, $patchTextLen
189
+ $this->tokens[$i][1] = substr_replace(
190
+ $token[1], $patchText, $patchPos - $pos + $posDelta, $patchTextLen
171
191
  );
172
192
  } else {
173
193
  assert(false);
@@ -176,17 +196,22 @@ class Emulative extends Lexer {
176
196
  // Fetch the next patch
177
197
  $patchIdx++;
178
198
  if ($patchIdx >= \count($this->patches)) {
179
- // No more patches. However, we still need to adjust position.
180
- $patchPos = \PHP_INT_MAX;
181
- break;
199
+ // No more patches, we're done
200
+ return;
182
201
  }
183
202
 
184
203
  list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
204
+
205
+ // Multiple patches may apply to the same token. Reload the current one to check
206
+ // If the new patch applies
207
+ $token = $this->tokens[$i];
185
208
  }
186
209
 
187
- $posDelta += $localPosDelta;
210
+ $pos += $len;
188
211
  }
189
- return $tokens;
212
+
213
+ // A patch did not apply
214
+ assert(false);
190
215
  }
191
216
 
192
217
  /**
@@ -194,7 +219,7 @@ class Emulative extends Lexer {
194
219
  *
195
220
  * @param Error[] $errors
196
221
  */
197
- private function fixupErrors(array $errors): void {
222
+ private function fixupErrors(array $errors) {
198
223
  foreach ($errors as $error) {
199
224
  $attrs = $error->getAttributes();
200
225
 
@@ -210,7 +235,7 @@ class Emulative extends Lexer {
210
235
  if ($patchType === 'add') {
211
236
  $posDelta += strlen($patchText);
212
237
  $lineDelta += substr_count($patchText, "\n");
213
- } elseif ($patchType === 'remove') {
238
+ } else if ($patchType === 'remove') {
214
239
  $posDelta -= strlen($patchText);
215
240
  $lineDelta -= substr_count($patchText, "\n");
216
241
  }