@appthreat/atom-parsetools 1.0.0

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 (441) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +78 -0
  3. package/astgen.js +421 -0
  4. package/index.js +1 -0
  5. package/package.json +53 -0
  6. package/phpastgen.js +33 -0
  7. package/plugins/.gitkeep +0 -0
  8. package/plugins/autoload.php +22 -0
  9. package/plugins/bin/bundler +14 -0
  10. package/plugins/bin/php-parse +119 -0
  11. package/plugins/bin/ruby_ast_gen +14 -0
  12. package/plugins/composer/ClassLoader.php +579 -0
  13. package/plugins/composer/InstalledVersions.php +396 -0
  14. package/plugins/composer/LICENSE +21 -0
  15. package/plugins/composer/autoload_classmap.php +260 -0
  16. package/plugins/composer/autoload_namespaces.php +9 -0
  17. package/plugins/composer/autoload_psr4.php +10 -0
  18. package/plugins/composer/autoload_real.php +36 -0
  19. package/plugins/composer/autoload_static.php +286 -0
  20. package/plugins/composer/installed.json +65 -0
  21. package/plugins/composer/installed.php +32 -0
  22. package/plugins/log4j2.xml +13 -0
  23. package/plugins/nikic/php-parser/LICENSE +29 -0
  24. package/plugins/nikic/php-parser/README.md +225 -0
  25. package/plugins/nikic/php-parser/bin/php-parse +205 -0
  26. package/plugins/nikic/php-parser/composer.json +41 -0
  27. package/plugins/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php +148 -0
  28. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Class_.php +146 -0
  29. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Declaration.php +43 -0
  30. package/plugins/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php +85 -0
  31. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Enum_.php +117 -0
  32. package/plugins/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php +73 -0
  33. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Function_.php +67 -0
  34. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Interface_.php +93 -0
  35. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Method.php +146 -0
  36. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php +45 -0
  37. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Param.php +168 -0
  38. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Property.php +161 -0
  39. package/plugins/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php +64 -0
  40. package/plugins/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php +148 -0
  41. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Trait_.php +78 -0
  42. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Use_.php +49 -0
  43. package/plugins/nikic/php-parser/lib/PhpParser/Builder.php +13 -0
  44. package/plugins/nikic/php-parser/lib/PhpParser/BuilderFactory.php +399 -0
  45. package/plugins/nikic/php-parser/lib/PhpParser/BuilderHelpers.php +335 -0
  46. package/plugins/nikic/php-parser/lib/PhpParser/Comment/Doc.php +7 -0
  47. package/plugins/nikic/php-parser/lib/PhpParser/Comment.php +239 -0
  48. package/plugins/nikic/php-parser/lib/PhpParser/ConstExprEvaluationException.php +6 -0
  49. package/plugins/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php +229 -0
  50. package/plugins/nikic/php-parser/lib/PhpParser/Error.php +180 -0
  51. package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php +46 -0
  52. package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php +18 -0
  53. package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler.php +13 -0
  54. package/plugins/nikic/php-parser/lib/PhpParser/Internal/DiffElem.php +27 -0
  55. package/plugins/nikic/php-parser/lib/PhpParser/Internal/Differ.php +164 -0
  56. package/plugins/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php +64 -0
  57. package/plugins/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php +286 -0
  58. package/plugins/nikic/php-parser/lib/PhpParser/JsonDecoder.php +103 -0
  59. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php +251 -0
  60. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php +56 -0
  61. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php +47 -0
  62. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php +31 -0
  63. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php +44 -0
  64. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php +76 -0
  65. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php +23 -0
  66. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php +62 -0
  67. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php +23 -0
  68. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php +67 -0
  69. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php +105 -0
  70. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyFunctionTokenEmulator.php +31 -0
  71. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php +36 -0
  72. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php +36 -0
  73. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php +25 -0
  74. package/plugins/nikic/php-parser/lib/PhpParser/Lexer.php +560 -0
  75. package/plugins/nikic/php-parser/lib/PhpParser/NameContext.php +285 -0
  76. package/plugins/nikic/php-parser/lib/PhpParser/Node/Arg.php +46 -0
  77. package/plugins/nikic/php-parser/lib/PhpParser/Node/Attribute.php +34 -0
  78. package/plugins/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php +29 -0
  79. package/plugins/nikic/php-parser/lib/PhpParser/Node/ComplexType.php +14 -0
  80. package/plugins/nikic/php-parser/lib/PhpParser/Node/Const_.php +37 -0
  81. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php +34 -0
  82. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php +41 -0
  83. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php +34 -0
  84. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php +79 -0
  85. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php +34 -0
  86. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php +12 -0
  87. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php +12 -0
  88. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php +12 -0
  89. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php +12 -0
  90. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php +12 -0
  91. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php +12 -0
  92. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php +12 -0
  93. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php +12 -0
  94. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php +12 -0
  95. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php +12 -0
  96. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php +12 -0
  97. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php +12 -0
  98. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php +12 -0
  99. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php +30 -0
  100. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php +34 -0
  101. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php +16 -0
  102. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php +16 -0
  103. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php +16 -0
  104. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php +16 -0
  105. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php +16 -0
  106. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php +16 -0
  107. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php +16 -0
  108. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php +16 -0
  109. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php +16 -0
  110. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php +16 -0
  111. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php +16 -0
  112. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php +16 -0
  113. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php +16 -0
  114. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php +16 -0
  115. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php +16 -0
  116. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php +16 -0
  117. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php +16 -0
  118. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php +16 -0
  119. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php +16 -0
  120. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php +16 -0
  121. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php +16 -0
  122. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php +16 -0
  123. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php +16 -0
  124. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php +16 -0
  125. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php +16 -0
  126. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php +16 -0
  127. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php +16 -0
  128. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php +40 -0
  129. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php +30 -0
  130. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php +30 -0
  131. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php +39 -0
  132. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php +12 -0
  133. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php +12 -0
  134. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php +17 -0
  135. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php +12 -0
  136. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php +12 -0
  137. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php +12 -0
  138. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php +12 -0
  139. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php +26 -0
  140. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php +36 -0
  141. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php +30 -0
  142. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php +79 -0
  143. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php +34 -0
  144. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php +31 -0
  145. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php +30 -0
  146. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php +31 -0
  147. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php +30 -0
  148. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php +30 -0
  149. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php +34 -0
  150. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php +39 -0
  151. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php +39 -0
  152. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php +35 -0
  153. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php +30 -0
  154. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php +30 -0
  155. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php +31 -0
  156. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php +45 -0
  157. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php +41 -0
  158. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php +45 -0
  159. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php +35 -0
  160. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php +30 -0
  161. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php +30 -0
  162. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php +30 -0
  163. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php +30 -0
  164. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php +30 -0
  165. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php +35 -0
  166. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php +30 -0
  167. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php +46 -0
  168. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +36 -0
  169. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php +38 -0
  170. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php +30 -0
  171. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php +30 -0
  172. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php +30 -0
  173. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php +30 -0
  174. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php +30 -0
  175. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php +34 -0
  176. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr.php +9 -0
  177. package/plugins/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php +43 -0
  178. package/plugins/nikic/php-parser/lib/PhpParser/Node/Identifier.php +75 -0
  179. package/plugins/nikic/php-parser/lib/PhpParser/Node/IntersectionType.php +30 -0
  180. package/plugins/nikic/php-parser/lib/PhpParser/Node/MatchArm.php +31 -0
  181. package/plugins/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php +50 -0
  182. package/plugins/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php +50 -0
  183. package/plugins/nikic/php-parser/lib/PhpParser/Node/Name.php +254 -0
  184. package/plugins/nikic/php-parser/lib/PhpParser/Node/NullableType.php +28 -0
  185. package/plugins/nikic/php-parser/lib/PhpParser/Node/Param.php +60 -0
  186. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php +77 -0
  187. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php +31 -0
  188. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +30 -0
  189. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php +80 -0
  190. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php +16 -0
  191. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php +16 -0
  192. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php +16 -0
  193. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php +16 -0
  194. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php +16 -0
  195. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php +16 -0
  196. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php +16 -0
  197. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php +16 -0
  198. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php +28 -0
  199. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php +157 -0
  200. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar.php +7 -0
  201. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php +30 -0
  202. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php +34 -0
  203. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php +41 -0
  204. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php +85 -0
  205. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php +109 -0
  206. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php +161 -0
  207. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php +137 -0
  208. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php +30 -0
  209. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php +30 -0
  210. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php +34 -0
  211. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php +34 -0
  212. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php +34 -0
  213. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php +30 -0
  214. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php +34 -0
  215. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php +30 -0
  216. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php +37 -0
  217. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php +40 -0
  218. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php +33 -0
  219. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php +30 -0
  220. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php +43 -0
  221. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php +47 -0
  222. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php +77 -0
  223. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php +30 -0
  224. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php +31 -0
  225. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php +39 -0
  226. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php +30 -0
  227. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php +43 -0
  228. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php +30 -0
  229. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php +37 -0
  230. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php +31 -0
  231. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php +38 -0
  232. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php +17 -0
  233. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php +91 -0
  234. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php +34 -0
  235. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php +30 -0
  236. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php +37 -0
  237. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php +30 -0
  238. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php +34 -0
  239. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php +30 -0
  240. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php +34 -0
  241. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +38 -0
  242. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +34 -0
  243. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php +13 -0
  244. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php +32 -0
  245. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php +38 -0
  246. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php +30 -0
  247. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php +52 -0
  248. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php +47 -0
  249. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php +34 -0
  250. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt.php +9 -0
  251. package/plugins/nikic/php-parser/lib/PhpParser/Node/UnionType.php +28 -0
  252. package/plugins/nikic/php-parser/lib/PhpParser/Node/VarLikeIdentifier.php +17 -0
  253. package/plugins/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php +27 -0
  254. package/plugins/nikic/php-parser/lib/PhpParser/Node.php +151 -0
  255. package/plugins/nikic/php-parser/lib/PhpParser/NodeAbstract.php +178 -0
  256. package/plugins/nikic/php-parser/lib/PhpParser/NodeDumper.php +206 -0
  257. package/plugins/nikic/php-parser/lib/PhpParser/NodeFinder.php +81 -0
  258. package/plugins/nikic/php-parser/lib/PhpParser/NodeTraverser.php +291 -0
  259. package/plugins/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php +29 -0
  260. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php +20 -0
  261. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php +48 -0
  262. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php +50 -0
  263. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php +260 -0
  264. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php +52 -0
  265. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php +41 -0
  266. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor.php +72 -0
  267. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php +25 -0
  268. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Multiple.php +55 -0
  269. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php5.php +2682 -0
  270. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php7.php +2898 -0
  271. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Tokens.php +148 -0
  272. package/plugins/nikic/php-parser/lib/PhpParser/Parser.php +18 -0
  273. package/plugins/nikic/php-parser/lib/PhpParser/ParserAbstract.php +1060 -0
  274. package/plugins/nikic/php-parser/lib/PhpParser/ParserFactory.php +76 -0
  275. package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php +1126 -0
  276. package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +1576 -0
  277. package/plugins/rubyastgen/.bundle/config +5 -0
  278. package/plugins/rubyastgen/Gemfile +12 -0
  279. package/plugins/rubyastgen/Gemfile.lock +34 -0
  280. package/plugins/rubyastgen/bundle/bundler/setup.rb +42 -0
  281. package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/racc +29 -0
  282. package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/ruby-parse +29 -0
  283. package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/ruby-rewrite +29 -0
  284. package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/ruby_ast_gen +29 -0
  285. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/.rspec +3 -0
  286. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/Gemfile +10 -0
  287. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/LICENSE.txt +213 -0
  288. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/README.md +46 -0
  289. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/Rakefile +8 -0
  290. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/bin/console +11 -0
  291. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/bin/setup +6 -0
  292. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/exe/ruby_ast_gen +59 -0
  293. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/lib/ruby_ast_gen/node_handling.rb +232 -0
  294. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/lib/ruby_ast_gen/version.rb +5 -0
  295. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/lib/ruby_ast_gen.rb +140 -0
  296. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/ruby_ast_gen.gemspec +25 -0
  297. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/spec/ruby_ast_gen_spec.rb +175 -0
  298. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/spec/spec_helper.rb +15 -0
  299. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/update_version.rb +36 -0
  300. package/plugins/rubyastgen/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/racc-1.8.1/gem.build_complete +0 -0
  301. package/plugins/rubyastgen/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/racc-1.8.1/gem_make.out +18 -0
  302. package/plugins/rubyastgen/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/racc-1.8.1/racc/cparse.so +0 -0
  303. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/LICENSE.MIT +20 -0
  304. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/README.YARD.md +12 -0
  305. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/lib/ast/node.rb +268 -0
  306. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/lib/ast/processor/mixin.rb +288 -0
  307. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/lib/ast/processor.rb +12 -0
  308. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/lib/ast/sexp.rb +30 -0
  309. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/lib/ast.rb +17 -0
  310. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/BSDL +22 -0
  311. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/COPYING +56 -0
  312. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/Gemfile +10 -0
  313. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/README.md +69 -0
  314. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/Rakefile +18 -0
  315. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/bin/console +14 -0
  316. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/bin/setup +8 -0
  317. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/lib/ostruct.rb +489 -0
  318. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/ostruct.gemspec +24 -0
  319. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/LICENSE.txt +26 -0
  320. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/bin/ruby-parse +7 -0
  321. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/bin/ruby-rewrite +7 -0
  322. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/gauntlet_parser.rb +123 -0
  323. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/all.rb +17 -0
  324. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ast/node.rb +40 -0
  325. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ast/processor.rb +293 -0
  326. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/base.rb +294 -0
  327. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/builders/default.rb +2351 -0
  328. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/clobbering_error.rb +13 -0
  329. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/color.rb +32 -0
  330. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/context.rb +51 -0
  331. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/current.rb +146 -0
  332. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/current_arg_stack.rb +46 -0
  333. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/deprecation.rb +13 -0
  334. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/diagnostic/engine.rb +104 -0
  335. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/diagnostic.rb +163 -0
  336. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer/dedenter.rb +88 -0
  337. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer/explanation.rb +55 -0
  338. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer/literal.rb +284 -0
  339. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer/stack_state.rb +49 -0
  340. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer-F0.rb +12931 -0
  341. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer-F1.rb +14884 -0
  342. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer-strings.rb +5433 -0
  343. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/macruby.rb +9634 -0
  344. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/max_numparam_stack.rb +56 -0
  345. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/messages.rb +125 -0
  346. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/meta.rb +48 -0
  347. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/rewriter.rb +105 -0
  348. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby18.rb +9272 -0
  349. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby19.rb +9558 -0
  350. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby20.rb +10229 -0
  351. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby21.rb +10203 -0
  352. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby22.rb +10302 -0
  353. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby23.rb +10322 -0
  354. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby24.rb +10454 -0
  355. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby25.rb +10374 -0
  356. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby26.rb +10352 -0
  357. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby27.rb +11948 -0
  358. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby30.rb +12244 -0
  359. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby31.rb +12717 -0
  360. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby32.rb +12705 -0
  361. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby33.rb +12590 -0
  362. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby34.rb +12597 -0
  363. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/rubymotion.rb +9515 -0
  364. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/runner/ruby_parse.rb +157 -0
  365. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/runner/ruby_rewrite.rb +101 -0
  366. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/runner.rb +299 -0
  367. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/buffer.rb +369 -0
  368. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/comment/associator.rb +233 -0
  369. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/comment.rb +134 -0
  370. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/collection.rb +18 -0
  371. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/condition.rb +21 -0
  372. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/constant.rb +32 -0
  373. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/definition.rb +23 -0
  374. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/for.rb +19 -0
  375. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/heredoc.rb +19 -0
  376. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/index.rb +33 -0
  377. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/keyword.rb +20 -0
  378. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/method_definition.rb +25 -0
  379. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/objc_kwarg.rb +19 -0
  380. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/operator.rb +17 -0
  381. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/rescue_body.rb +21 -0
  382. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/send.rb +36 -0
  383. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/ternary.rb +18 -0
  384. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/variable.rb +31 -0
  385. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map.rb +186 -0
  386. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/range.rb +326 -0
  387. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/rewriter/action.rb +44 -0
  388. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/rewriter.rb +513 -0
  389. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/tree_rewriter/action.rb +243 -0
  390. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/tree_rewriter.rb +431 -0
  391. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/static_environment.rb +134 -0
  392. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/syntax_error.rb +21 -0
  393. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/tree_rewriter.rb +133 -0
  394. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/unknown_encoding_in_magic_comment_error.rb +15 -0
  395. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/variables_stack.rb +36 -0
  396. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/version.rb +5 -0
  397. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser.rb +91 -0
  398. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/parser.gemspec +43 -0
  399. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/BSDL +22 -0
  400. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/COPYING +56 -0
  401. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ChangeLog +846 -0
  402. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/README.ja.rdoc +58 -0
  403. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/README.rdoc +60 -0
  404. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/TODO +5 -0
  405. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/bin/racc +320 -0
  406. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/en/grammar.en.rdoc +218 -0
  407. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/en/grammar2.en.rdoc +219 -0
  408. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/command.ja.html +99 -0
  409. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/debug.ja.rdoc +36 -0
  410. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/grammar.ja.rdoc +348 -0
  411. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/index.ja.html +10 -0
  412. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/parser.ja.rdoc +125 -0
  413. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/usage.ja.html +414 -0
  414. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse/Makefile +273 -0
  415. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse/cparse.c +840 -0
  416. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse/extconf.rb +8 -0
  417. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/compat.rb +33 -0
  418. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/cparse.so +0 -0
  419. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/debugflags.rb +60 -0
  420. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/exception.rb +16 -0
  421. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/grammar.rb +1191 -0
  422. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/grammarfileparser.rb +667 -0
  423. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/info.rb +18 -0
  424. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/iset.rb +92 -0
  425. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/logfilegenerator.rb +212 -0
  426. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/parser-text.rb +644 -0
  427. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/parser.rb +630 -0
  428. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/parserfilegenerator.rb +473 -0
  429. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/sourcetext.rb +35 -0
  430. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/state.rb +976 -0
  431. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/statetransitiontable.rb +311 -0
  432. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/static.rb +5 -0
  433. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc.rb +6 -0
  434. package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/ast-2.4.3.gemspec +29 -0
  435. package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/ostruct-0.6.1.gemspec +21 -0
  436. package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/parser-3.3.8.0.gemspec +37 -0
  437. package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/racc-1.8.1.gemspec +28 -0
  438. package/plugins/rubyastgen/setup.ps1 +4 -0
  439. package/plugins/rubyastgen/setup.sh +6 -0
  440. package/rbastgen.js +53 -0
  441. package/scalasem.js +365 -0
@@ -0,0 +1,1576 @@
1
+ <?php declare(strict_types=1);
2
+
3
+ namespace PhpParser;
4
+
5
+ use PhpParser\Internal\DiffElem;
6
+ use PhpParser\Internal\PrintableNewAnonClassNode;
7
+ use PhpParser\Internal\TokenStream;
8
+ use PhpParser\Node\Expr;
9
+ use PhpParser\Node\Expr\AssignOp;
10
+ use PhpParser\Node\Expr\BinaryOp;
11
+ use PhpParser\Node\Expr\Cast;
12
+ use PhpParser\Node\Scalar;
13
+ use PhpParser\Node\Stmt;
14
+
15
+ abstract class PrettyPrinterAbstract
16
+ {
17
+ const FIXUP_PREC_LEFT = 0; // LHS operand affected by precedence
18
+ const FIXUP_PREC_RIGHT = 1; // RHS operand affected by precedence
19
+ const FIXUP_CALL_LHS = 2; // LHS of call
20
+ const FIXUP_DEREF_LHS = 3; // LHS of dereferencing operation
21
+ const FIXUP_BRACED_NAME = 4; // Name operand that may require bracing
22
+ const FIXUP_VAR_BRACED_NAME = 5; // Name operand that may require ${} bracing
23
+ const FIXUP_ENCAPSED = 6; // Encapsed string part
24
+ const FIXUP_NEW = 7; // New/instanceof operand
25
+ const FIXUP_STATIC_DEREF_LHS = 8; // LHS of static dereferencing operation
26
+
27
+ protected $precedenceMap = [
28
+ // [precedence, associativity]
29
+ // where for precedence -1 is %left, 0 is %nonassoc and 1 is %right
30
+ BinaryOp\Pow::class => [ 0, 1],
31
+ Expr\BitwiseNot::class => [ 10, 1],
32
+ Expr\PreInc::class => [ 10, 1],
33
+ Expr\PreDec::class => [ 10, 1],
34
+ Expr\PostInc::class => [ 10, -1],
35
+ Expr\PostDec::class => [ 10, -1],
36
+ Expr\UnaryPlus::class => [ 10, 1],
37
+ Expr\UnaryMinus::class => [ 10, 1],
38
+ Cast\Int_::class => [ 10, 1],
39
+ Cast\Double::class => [ 10, 1],
40
+ Cast\String_::class => [ 10, 1],
41
+ Cast\Array_::class => [ 10, 1],
42
+ Cast\Object_::class => [ 10, 1],
43
+ Cast\Bool_::class => [ 10, 1],
44
+ Cast\Unset_::class => [ 10, 1],
45
+ Expr\ErrorSuppress::class => [ 10, 1],
46
+ Expr\Instanceof_::class => [ 20, 0],
47
+ Expr\BooleanNot::class => [ 30, 1],
48
+ BinaryOp\Mul::class => [ 40, -1],
49
+ BinaryOp\Div::class => [ 40, -1],
50
+ BinaryOp\Mod::class => [ 40, -1],
51
+ BinaryOp\Plus::class => [ 50, -1],
52
+ BinaryOp\Minus::class => [ 50, -1],
53
+ BinaryOp\Concat::class => [ 50, -1],
54
+ BinaryOp\ShiftLeft::class => [ 60, -1],
55
+ BinaryOp\ShiftRight::class => [ 60, -1],
56
+ BinaryOp\Smaller::class => [ 70, 0],
57
+ BinaryOp\SmallerOrEqual::class => [ 70, 0],
58
+ BinaryOp\Greater::class => [ 70, 0],
59
+ BinaryOp\GreaterOrEqual::class => [ 70, 0],
60
+ BinaryOp\Equal::class => [ 80, 0],
61
+ BinaryOp\NotEqual::class => [ 80, 0],
62
+ BinaryOp\Identical::class => [ 80, 0],
63
+ BinaryOp\NotIdentical::class => [ 80, 0],
64
+ BinaryOp\Spaceship::class => [ 80, 0],
65
+ BinaryOp\BitwiseAnd::class => [ 90, -1],
66
+ BinaryOp\BitwiseXor::class => [100, -1],
67
+ BinaryOp\BitwiseOr::class => [110, -1],
68
+ BinaryOp\BooleanAnd::class => [120, -1],
69
+ BinaryOp\BooleanOr::class => [130, -1],
70
+ BinaryOp\Coalesce::class => [140, 1],
71
+ Expr\Ternary::class => [150, 0],
72
+ // parser uses %left for assignments, but they really behave as %right
73
+ Expr\Assign::class => [160, 1],
74
+ Expr\AssignRef::class => [160, 1],
75
+ AssignOp\Plus::class => [160, 1],
76
+ AssignOp\Minus::class => [160, 1],
77
+ AssignOp\Mul::class => [160, 1],
78
+ AssignOp\Div::class => [160, 1],
79
+ AssignOp\Concat::class => [160, 1],
80
+ AssignOp\Mod::class => [160, 1],
81
+ AssignOp\BitwiseAnd::class => [160, 1],
82
+ AssignOp\BitwiseOr::class => [160, 1],
83
+ AssignOp\BitwiseXor::class => [160, 1],
84
+ AssignOp\ShiftLeft::class => [160, 1],
85
+ AssignOp\ShiftRight::class => [160, 1],
86
+ AssignOp\Pow::class => [160, 1],
87
+ AssignOp\Coalesce::class => [160, 1],
88
+ Expr\YieldFrom::class => [165, 1],
89
+ Expr\Print_::class => [168, 1],
90
+ BinaryOp\LogicalAnd::class => [170, -1],
91
+ BinaryOp\LogicalXor::class => [180, -1],
92
+ BinaryOp\LogicalOr::class => [190, -1],
93
+ Expr\Include_::class => [200, -1],
94
+ ];
95
+
96
+ /** @var int Current indentation level. */
97
+ protected $indentLevel;
98
+ /** @var string Newline including current indentation. */
99
+ protected $nl;
100
+ /** @var string Token placed at end of doc string to ensure it is followed by a newline. */
101
+ protected $docStringEndToken;
102
+ /** @var bool Whether semicolon namespaces can be used (i.e. no global namespace is used) */
103
+ protected $canUseSemicolonNamespaces;
104
+ /** @var array Pretty printer options */
105
+ protected $options;
106
+
107
+ /** @var TokenStream Original tokens for use in format-preserving pretty print */
108
+ protected $origTokens;
109
+ /** @var Internal\Differ Differ for node lists */
110
+ protected $nodeListDiffer;
111
+ /** @var bool[] Map determining whether a certain character is a label character */
112
+ protected $labelCharMap;
113
+ /**
114
+ * @var int[][] Map from token classes and subnode names to FIXUP_* constants. This is used
115
+ * during format-preserving prints to place additional parens/braces if necessary.
116
+ */
117
+ protected $fixupMap;
118
+ /**
119
+ * @var int[][] Map from "{$node->getType()}->{$subNode}" to ['left' => $l, 'right' => $r],
120
+ * where $l and $r specify the token type that needs to be stripped when removing
121
+ * this node.
122
+ */
123
+ protected $removalMap;
124
+ /**
125
+ * @var mixed[] Map from "{$node->getType()}->{$subNode}" to [$find, $beforeToken, $extraLeft, $extraRight].
126
+ * $find is an optional token after which the insertion occurs. $extraLeft/Right
127
+ * are optionally added before/after the main insertions.
128
+ */
129
+ protected $insertionMap;
130
+ /**
131
+ * @var string[] Map From "{$node->getType()}->{$subNode}" to string that should be inserted
132
+ * between elements of this list subnode.
133
+ */
134
+ protected $listInsertionMap;
135
+ protected $emptyListInsertionMap;
136
+ /** @var int[] Map from "{$node->getType()}->{$subNode}" to token before which the modifiers
137
+ * should be reprinted. */
138
+ protected $modifierChangeMap;
139
+
140
+ /**
141
+ * Creates a pretty printer instance using the given options.
142
+ *
143
+ * Supported options:
144
+ * * bool $shortArraySyntax = false: Whether to use [] instead of array() as the default array
145
+ * syntax, if the node does not specify a format.
146
+ *
147
+ * @param array $options Dictionary of formatting options
148
+ */
149
+ public function __construct(array $options = []) {
150
+ $this->docStringEndToken = '_DOC_STRING_END_' . mt_rand();
151
+
152
+ $defaultOptions = ['shortArraySyntax' => false];
153
+ $this->options = $options + $defaultOptions;
154
+ }
155
+
156
+ /**
157
+ * Reset pretty printing state.
158
+ */
159
+ protected function resetState() {
160
+ $this->indentLevel = 0;
161
+ $this->nl = "\n";
162
+ $this->origTokens = null;
163
+ }
164
+
165
+ /**
166
+ * Set indentation level
167
+ *
168
+ * @param int $level Level in number of spaces
169
+ */
170
+ protected function setIndentLevel(int $level) {
171
+ $this->indentLevel = $level;
172
+ $this->nl = "\n" . \str_repeat(' ', $level);
173
+ }
174
+
175
+ /**
176
+ * Increase indentation level.
177
+ */
178
+ protected function indent() {
179
+ $this->indentLevel += 4;
180
+ $this->nl .= ' ';
181
+ }
182
+
183
+ /**
184
+ * Decrease indentation level.
185
+ */
186
+ protected function outdent() {
187
+ assert($this->indentLevel >= 4);
188
+ $this->indentLevel -= 4;
189
+ $this->nl = "\n" . str_repeat(' ', $this->indentLevel);
190
+ }
191
+
192
+ /**
193
+ * Pretty prints an array of statements.
194
+ *
195
+ * @param Node[] $stmts Array of statements
196
+ *
197
+ * @return string Pretty printed statements
198
+ */
199
+ public function prettyPrint(array $stmts) : string {
200
+ $this->resetState();
201
+ $this->preprocessNodes($stmts);
202
+
203
+ return ltrim($this->handleMagicTokens($this->pStmts($stmts, false)));
204
+ }
205
+
206
+ /**
207
+ * Pretty prints an expression.
208
+ *
209
+ * @param Expr $node Expression node
210
+ *
211
+ * @return string Pretty printed node
212
+ */
213
+ public function prettyPrintExpr(Expr $node) : string {
214
+ $this->resetState();
215
+ return $this->handleMagicTokens($this->p($node));
216
+ }
217
+
218
+ /**
219
+ * Pretty prints a file of statements (includes the opening <?php tag if it is required).
220
+ *
221
+ * @param Node[] $stmts Array of statements
222
+ *
223
+ * @return string Pretty printed statements
224
+ */
225
+ public function prettyPrintFile(array $stmts) : string {
226
+ if (!$stmts) {
227
+ return "<?php\n\n";
228
+ }
229
+
230
+ $p = "<?php\n\n" . $this->prettyPrint($stmts);
231
+
232
+ if ($stmts[0] instanceof Stmt\InlineHTML) {
233
+ $p = preg_replace('/^<\?php\s+\?>\n?/', '', $p);
234
+ }
235
+ if ($stmts[count($stmts) - 1] instanceof Stmt\InlineHTML) {
236
+ $p = preg_replace('/<\?php$/', '', rtrim($p));
237
+ }
238
+
239
+ return $p;
240
+ }
241
+
242
+ /**
243
+ * Preprocesses the top-level nodes to initialize pretty printer state.
244
+ *
245
+ * @param Node[] $nodes Array of nodes
246
+ */
247
+ protected function preprocessNodes(array $nodes) {
248
+ /* We can use semicolon-namespaces unless there is a global namespace declaration */
249
+ $this->canUseSemicolonNamespaces = true;
250
+ foreach ($nodes as $node) {
251
+ if ($node instanceof Stmt\Namespace_ && null === $node->name) {
252
+ $this->canUseSemicolonNamespaces = false;
253
+ break;
254
+ }
255
+ }
256
+ }
257
+
258
+ /**
259
+ * Handles (and removes) no-indent and doc-string-end tokens.
260
+ *
261
+ * @param string $str
262
+ * @return string
263
+ */
264
+ protected function handleMagicTokens(string $str) : string {
265
+ // Replace doc-string-end tokens with nothing or a newline
266
+ $str = str_replace($this->docStringEndToken . ";\n", ";\n", $str);
267
+ $str = str_replace($this->docStringEndToken, "\n", $str);
268
+
269
+ return $str;
270
+ }
271
+
272
+ /**
273
+ * Pretty prints an array of nodes (statements) and indents them optionally.
274
+ *
275
+ * @param Node[] $nodes Array of nodes
276
+ * @param bool $indent Whether to indent the printed nodes
277
+ *
278
+ * @return string Pretty printed statements
279
+ */
280
+ protected function pStmts(array $nodes, bool $indent = true) : string {
281
+ if ($indent) {
282
+ $this->indent();
283
+ }
284
+
285
+ $result = '';
286
+ foreach ($nodes as $node) {
287
+ $comments = $node->getComments();
288
+ if ($comments) {
289
+ $result .= $this->nl . $this->pComments($comments);
290
+ if ($node instanceof Stmt\Nop) {
291
+ continue;
292
+ }
293
+ }
294
+
295
+ $result .= $this->nl . $this->p($node);
296
+ }
297
+
298
+ if ($indent) {
299
+ $this->outdent();
300
+ }
301
+
302
+ return $result;
303
+ }
304
+
305
+ /**
306
+ * Pretty-print an infix operation while taking precedence into account.
307
+ *
308
+ * @param string $class Node class of operator
309
+ * @param Node $leftNode Left-hand side node
310
+ * @param string $operatorString String representation of the operator
311
+ * @param Node $rightNode Right-hand side node
312
+ *
313
+ * @return string Pretty printed infix operation
314
+ */
315
+ protected function pInfixOp(string $class, Node $leftNode, string $operatorString, Node $rightNode) : string {
316
+ list($precedence, $associativity) = $this->precedenceMap[$class];
317
+
318
+ return $this->pPrec($leftNode, $precedence, $associativity, -1)
319
+ . $operatorString
320
+ . $this->pPrec($rightNode, $precedence, $associativity, 1);
321
+ }
322
+
323
+ /**
324
+ * Pretty-print a prefix operation while taking precedence into account.
325
+ *
326
+ * @param string $class Node class of operator
327
+ * @param string $operatorString String representation of the operator
328
+ * @param Node $node Node
329
+ *
330
+ * @return string Pretty printed prefix operation
331
+ */
332
+ protected function pPrefixOp(string $class, string $operatorString, Node $node) : string {
333
+ list($precedence, $associativity) = $this->precedenceMap[$class];
334
+ return $operatorString . $this->pPrec($node, $precedence, $associativity, 1);
335
+ }
336
+
337
+ /**
338
+ * Pretty-print a postfix operation while taking precedence into account.
339
+ *
340
+ * @param string $class Node class of operator
341
+ * @param string $operatorString String representation of the operator
342
+ * @param Node $node Node
343
+ *
344
+ * @return string Pretty printed postfix operation
345
+ */
346
+ protected function pPostfixOp(string $class, Node $node, string $operatorString) : string {
347
+ list($precedence, $associativity) = $this->precedenceMap[$class];
348
+ return $this->pPrec($node, $precedence, $associativity, -1) . $operatorString;
349
+ }
350
+
351
+ /**
352
+ * Prints an expression node with the least amount of parentheses necessary to preserve the meaning.
353
+ *
354
+ * @param Node $node Node to pretty print
355
+ * @param int $parentPrecedence Precedence of the parent operator
356
+ * @param int $parentAssociativity Associativity of parent operator
357
+ * (-1 is left, 0 is nonassoc, 1 is right)
358
+ * @param int $childPosition Position of the node relative to the operator
359
+ * (-1 is left, 1 is right)
360
+ *
361
+ * @return string The pretty printed node
362
+ */
363
+ protected function pPrec(Node $node, int $parentPrecedence, int $parentAssociativity, int $childPosition) : string {
364
+ $class = \get_class($node);
365
+ if (isset($this->precedenceMap[$class])) {
366
+ $childPrecedence = $this->precedenceMap[$class][0];
367
+ if ($childPrecedence > $parentPrecedence
368
+ || ($parentPrecedence === $childPrecedence && $parentAssociativity !== $childPosition)
369
+ ) {
370
+ return '(' . $this->p($node) . ')';
371
+ }
372
+ }
373
+
374
+ return $this->p($node);
375
+ }
376
+
377
+ /**
378
+ * Pretty prints an array of nodes and implodes the printed values.
379
+ *
380
+ * @param Node[] $nodes Array of Nodes to be printed
381
+ * @param string $glue Character to implode with
382
+ *
383
+ * @return string Imploded pretty printed nodes
384
+ */
385
+ protected function pImplode(array $nodes, string $glue = '') : string {
386
+ $pNodes = [];
387
+ foreach ($nodes as $node) {
388
+ if (null === $node) {
389
+ $pNodes[] = '';
390
+ } else {
391
+ $pNodes[] = $this->p($node);
392
+ }
393
+ }
394
+
395
+ return implode($glue, $pNodes);
396
+ }
397
+
398
+ /**
399
+ * Pretty prints an array of nodes and implodes the printed values with commas.
400
+ *
401
+ * @param Node[] $nodes Array of Nodes to be printed
402
+ *
403
+ * @return string Comma separated pretty printed nodes
404
+ */
405
+ protected function pCommaSeparated(array $nodes) : string {
406
+ return $this->pImplode($nodes, ', ');
407
+ }
408
+
409
+ /**
410
+ * Pretty prints a comma-separated list of nodes in multiline style, including comments.
411
+ *
412
+ * The result includes a leading newline and one level of indentation (same as pStmts).
413
+ *
414
+ * @param Node[] $nodes Array of Nodes to be printed
415
+ * @param bool $trailingComma Whether to use a trailing comma
416
+ *
417
+ * @return string Comma separated pretty printed nodes in multiline style
418
+ */
419
+ protected function pCommaSeparatedMultiline(array $nodes, bool $trailingComma) : string {
420
+ $this->indent();
421
+
422
+ $result = '';
423
+ $lastIdx = count($nodes) - 1;
424
+ foreach ($nodes as $idx => $node) {
425
+ if ($node !== null) {
426
+ $comments = $node->getComments();
427
+ if ($comments) {
428
+ $result .= $this->nl . $this->pComments($comments);
429
+ }
430
+
431
+ $result .= $this->nl . $this->p($node);
432
+ } else {
433
+ $result .= $this->nl;
434
+ }
435
+ if ($trailingComma || $idx !== $lastIdx) {
436
+ $result .= ',';
437
+ }
438
+ }
439
+
440
+ $this->outdent();
441
+ return $result;
442
+ }
443
+
444
+ /**
445
+ * Prints reformatted text of the passed comments.
446
+ *
447
+ * @param Comment[] $comments List of comments
448
+ *
449
+ * @return string Reformatted text of comments
450
+ */
451
+ protected function pComments(array $comments) : string {
452
+ $formattedComments = [];
453
+
454
+ foreach ($comments as $comment) {
455
+ $formattedComments[] = str_replace("\n", $this->nl, $comment->getReformattedText());
456
+ }
457
+
458
+ return implode($this->nl, $formattedComments);
459
+ }
460
+
461
+ /**
462
+ * Perform a format-preserving pretty print of an AST.
463
+ *
464
+ * The format preservation is best effort. For some changes to the AST the formatting will not
465
+ * be preserved (at least not locally).
466
+ *
467
+ * In order to use this method a number of prerequisites must be satisfied:
468
+ * * The startTokenPos and endTokenPos attributes in the lexer must be enabled.
469
+ * * The CloningVisitor must be run on the AST prior to modification.
470
+ * * The original tokens must be provided, using the getTokens() method on the lexer.
471
+ *
472
+ * @param Node[] $stmts Modified AST with links to original AST
473
+ * @param Node[] $origStmts Original AST with token offset information
474
+ * @param array $origTokens Tokens of the original code
475
+ *
476
+ * @return string
477
+ */
478
+ public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens) : string {
479
+ $this->initializeNodeListDiffer();
480
+ $this->initializeLabelCharMap();
481
+ $this->initializeFixupMap();
482
+ $this->initializeRemovalMap();
483
+ $this->initializeInsertionMap();
484
+ $this->initializeListInsertionMap();
485
+ $this->initializeEmptyListInsertionMap();
486
+ $this->initializeModifierChangeMap();
487
+
488
+ $this->resetState();
489
+ $this->origTokens = new TokenStream($origTokens);
490
+
491
+ $this->preprocessNodes($stmts);
492
+
493
+ $pos = 0;
494
+ $result = $this->pArray($stmts, $origStmts, $pos, 0, 'File', 'stmts', null);
495
+ if (null !== $result) {
496
+ $result .= $this->origTokens->getTokenCode($pos, count($origTokens), 0);
497
+ } else {
498
+ // Fallback
499
+ // TODO Add <?php properly
500
+ $result = "<?php\n" . $this->pStmts($stmts, false);
501
+ }
502
+
503
+ return ltrim($this->handleMagicTokens($result));
504
+ }
505
+
506
+ protected function pFallback(Node $node) {
507
+ return $this->{'p' . $node->getType()}($node);
508
+ }
509
+
510
+ /**
511
+ * Pretty prints a node.
512
+ *
513
+ * This method also handles formatting preservation for nodes.
514
+ *
515
+ * @param Node $node Node to be pretty printed
516
+ * @param bool $parentFormatPreserved Whether parent node has preserved formatting
517
+ *
518
+ * @return string Pretty printed node
519
+ */
520
+ protected function p(Node $node, $parentFormatPreserved = false) : string {
521
+ // No orig tokens means this is a normal pretty print without preservation of formatting
522
+ if (!$this->origTokens) {
523
+ return $this->{'p' . $node->getType()}($node);
524
+ }
525
+
526
+ /** @var Node $origNode */
527
+ $origNode = $node->getAttribute('origNode');
528
+ if (null === $origNode) {
529
+ return $this->pFallback($node);
530
+ }
531
+
532
+ $class = \get_class($node);
533
+ \assert($class === \get_class($origNode));
534
+
535
+ $startPos = $origNode->getStartTokenPos();
536
+ $endPos = $origNode->getEndTokenPos();
537
+ \assert($startPos >= 0 && $endPos >= 0);
538
+
539
+ $fallbackNode = $node;
540
+ if ($node instanceof Expr\New_ && $node->class instanceof Stmt\Class_) {
541
+ // Normalize node structure of anonymous classes
542
+ $node = PrintableNewAnonClassNode::fromNewNode($node);
543
+ $origNode = PrintableNewAnonClassNode::fromNewNode($origNode);
544
+ }
545
+
546
+ // InlineHTML node does not contain closing and opening PHP tags. If the parent formatting
547
+ // is not preserved, then we need to use the fallback code to make sure the tags are
548
+ // printed.
549
+ if ($node instanceof Stmt\InlineHTML && !$parentFormatPreserved) {
550
+ return $this->pFallback($fallbackNode);
551
+ }
552
+
553
+ $indentAdjustment = $this->indentLevel - $this->origTokens->getIndentationBefore($startPos);
554
+
555
+ $type = $node->getType();
556
+ $fixupInfo = $this->fixupMap[$class] ?? null;
557
+
558
+ $result = '';
559
+ $pos = $startPos;
560
+ foreach ($node->getSubNodeNames() as $subNodeName) {
561
+ $subNode = $node->$subNodeName;
562
+ $origSubNode = $origNode->$subNodeName;
563
+
564
+ if ((!$subNode instanceof Node && $subNode !== null)
565
+ || (!$origSubNode instanceof Node && $origSubNode !== null)
566
+ ) {
567
+ if ($subNode === $origSubNode) {
568
+ // Unchanged, can reuse old code
569
+ continue;
570
+ }
571
+
572
+ if (is_array($subNode) && is_array($origSubNode)) {
573
+ // Array subnode changed, we might be able to reconstruct it
574
+ $listResult = $this->pArray(
575
+ $subNode, $origSubNode, $pos, $indentAdjustment, $type, $subNodeName,
576
+ $fixupInfo[$subNodeName] ?? null
577
+ );
578
+ if (null === $listResult) {
579
+ return $this->pFallback($fallbackNode);
580
+ }
581
+
582
+ $result .= $listResult;
583
+ continue;
584
+ }
585
+
586
+ if (is_int($subNode) && is_int($origSubNode)) {
587
+ // Check if this is a modifier change
588
+ $key = $type . '->' . $subNodeName;
589
+ if (!isset($this->modifierChangeMap[$key])) {
590
+ return $this->pFallback($fallbackNode);
591
+ }
592
+
593
+ $findToken = $this->modifierChangeMap[$key];
594
+ $result .= $this->pModifiers($subNode);
595
+ $pos = $this->origTokens->findRight($pos, $findToken);
596
+ continue;
597
+ }
598
+
599
+ // If a non-node, non-array subnode changed, we don't be able to do a partial
600
+ // reconstructions, as we don't have enough offset information. Pretty print the
601
+ // whole node instead.
602
+ return $this->pFallback($fallbackNode);
603
+ }
604
+
605
+ $extraLeft = '';
606
+ $extraRight = '';
607
+ if ($origSubNode !== null) {
608
+ $subStartPos = $origSubNode->getStartTokenPos();
609
+ $subEndPos = $origSubNode->getEndTokenPos();
610
+ \assert($subStartPos >= 0 && $subEndPos >= 0);
611
+ } else {
612
+ if ($subNode === null) {
613
+ // Both null, nothing to do
614
+ continue;
615
+ }
616
+
617
+ // A node has been inserted, check if we have insertion information for it
618
+ $key = $type . '->' . $subNodeName;
619
+ if (!isset($this->insertionMap[$key])) {
620
+ return $this->pFallback($fallbackNode);
621
+ }
622
+
623
+ list($findToken, $beforeToken, $extraLeft, $extraRight) = $this->insertionMap[$key];
624
+ if (null !== $findToken) {
625
+ $subStartPos = $this->origTokens->findRight($pos, $findToken)
626
+ + (int) !$beforeToken;
627
+ } else {
628
+ $subStartPos = $pos;
629
+ }
630
+
631
+ if (null === $extraLeft && null !== $extraRight) {
632
+ // If inserting on the right only, skipping whitespace looks better
633
+ $subStartPos = $this->origTokens->skipRightWhitespace($subStartPos);
634
+ }
635
+ $subEndPos = $subStartPos - 1;
636
+ }
637
+
638
+ if (null === $subNode) {
639
+ // A node has been removed, check if we have removal information for it
640
+ $key = $type . '->' . $subNodeName;
641
+ if (!isset($this->removalMap[$key])) {
642
+ return $this->pFallback($fallbackNode);
643
+ }
644
+
645
+ // Adjust positions to account for additional tokens that must be skipped
646
+ $removalInfo = $this->removalMap[$key];
647
+ if (isset($removalInfo['left'])) {
648
+ $subStartPos = $this->origTokens->skipLeft($subStartPos - 1, $removalInfo['left']) + 1;
649
+ }
650
+ if (isset($removalInfo['right'])) {
651
+ $subEndPos = $this->origTokens->skipRight($subEndPos + 1, $removalInfo['right']) - 1;
652
+ }
653
+ }
654
+
655
+ $result .= $this->origTokens->getTokenCode($pos, $subStartPos, $indentAdjustment);
656
+
657
+ if (null !== $subNode) {
658
+ $result .= $extraLeft;
659
+
660
+ $origIndentLevel = $this->indentLevel;
661
+ $this->setIndentLevel($this->origTokens->getIndentationBefore($subStartPos) + $indentAdjustment);
662
+
663
+ // If it's the same node that was previously in this position, it certainly doesn't
664
+ // need fixup. It's important to check this here, because our fixup checks are more
665
+ // conservative than strictly necessary.
666
+ if (isset($fixupInfo[$subNodeName])
667
+ && $subNode->getAttribute('origNode') !== $origSubNode
668
+ ) {
669
+ $fixup = $fixupInfo[$subNodeName];
670
+ $res = $this->pFixup($fixup, $subNode, $class, $subStartPos, $subEndPos);
671
+ } else {
672
+ $res = $this->p($subNode, true);
673
+ }
674
+
675
+ $this->safeAppend($result, $res);
676
+ $this->setIndentLevel($origIndentLevel);
677
+
678
+ $result .= $extraRight;
679
+ }
680
+
681
+ $pos = $subEndPos + 1;
682
+ }
683
+
684
+ $result .= $this->origTokens->getTokenCode($pos, $endPos + 1, $indentAdjustment);
685
+ return $result;
686
+ }
687
+
688
+ /**
689
+ * Perform a format-preserving pretty print of an array.
690
+ *
691
+ * @param array $nodes New nodes
692
+ * @param array $origNodes Original nodes
693
+ * @param int $pos Current token position (updated by reference)
694
+ * @param int $indentAdjustment Adjustment for indentation
695
+ * @param string $parentNodeType Type of the containing node.
696
+ * @param string $subNodeName Name of array subnode.
697
+ * @param null|int $fixup Fixup information for array item nodes
698
+ *
699
+ * @return null|string Result of pretty print or null if cannot preserve formatting
700
+ */
701
+ protected function pArray(
702
+ array $nodes, array $origNodes, int &$pos, int $indentAdjustment,
703
+ string $parentNodeType, string $subNodeName, $fixup
704
+ ) {
705
+ $diff = $this->nodeListDiffer->diffWithReplacements($origNodes, $nodes);
706
+
707
+ $mapKey = $parentNodeType . '->' . $subNodeName;
708
+ $insertStr = $this->listInsertionMap[$mapKey] ?? null;
709
+ $isStmtList = $subNodeName === 'stmts';
710
+
711
+ $beforeFirstKeepOrReplace = true;
712
+ $skipRemovedNode = false;
713
+ $delayedAdd = [];
714
+ $lastElemIndentLevel = $this->indentLevel;
715
+
716
+ $insertNewline = false;
717
+ if ($insertStr === "\n") {
718
+ $insertStr = '';
719
+ $insertNewline = true;
720
+ }
721
+
722
+ if ($isStmtList && \count($origNodes) === 1 && \count($nodes) !== 1) {
723
+ $startPos = $origNodes[0]->getStartTokenPos();
724
+ $endPos = $origNodes[0]->getEndTokenPos();
725
+ \assert($startPos >= 0 && $endPos >= 0);
726
+ if (!$this->origTokens->haveBraces($startPos, $endPos)) {
727
+ // This was a single statement without braces, but either additional statements
728
+ // have been added, or the single statement has been removed. This requires the
729
+ // addition of braces. For now fall back.
730
+ // TODO: Try to preserve formatting
731
+ return null;
732
+ }
733
+ }
734
+
735
+ $result = '';
736
+ foreach ($diff as $i => $diffElem) {
737
+ $diffType = $diffElem->type;
738
+ /** @var Node|null $arrItem */
739
+ $arrItem = $diffElem->new;
740
+ /** @var Node|null $origArrItem */
741
+ $origArrItem = $diffElem->old;
742
+
743
+ if ($diffType === DiffElem::TYPE_KEEP || $diffType === DiffElem::TYPE_REPLACE) {
744
+ $beforeFirstKeepOrReplace = false;
745
+
746
+ if ($origArrItem === null || $arrItem === null) {
747
+ // We can only handle the case where both are null
748
+ if ($origArrItem === $arrItem) {
749
+ continue;
750
+ }
751
+ return null;
752
+ }
753
+
754
+ if (!$arrItem instanceof Node || !$origArrItem instanceof Node) {
755
+ // We can only deal with nodes. This can occur for Names, which use string arrays.
756
+ return null;
757
+ }
758
+
759
+ $itemStartPos = $origArrItem->getStartTokenPos();
760
+ $itemEndPos = $origArrItem->getEndTokenPos();
761
+ \assert($itemStartPos >= 0 && $itemEndPos >= 0 && $itemStartPos >= $pos);
762
+
763
+ $origIndentLevel = $this->indentLevel;
764
+ $lastElemIndentLevel = $this->origTokens->getIndentationBefore($itemStartPos) + $indentAdjustment;
765
+ $this->setIndentLevel($lastElemIndentLevel);
766
+
767
+ $comments = $arrItem->getComments();
768
+ $origComments = $origArrItem->getComments();
769
+ $commentStartPos = $origComments ? $origComments[0]->getStartTokenPos() : $itemStartPos;
770
+ \assert($commentStartPos >= 0);
771
+
772
+ if ($commentStartPos < $pos) {
773
+ // Comments may be assigned to multiple nodes if they start at the same position.
774
+ // Make sure we don't try to print them multiple times.
775
+ $commentStartPos = $itemStartPos;
776
+ }
777
+
778
+ if ($skipRemovedNode) {
779
+ if ($isStmtList && ($this->origTokens->haveBracesInRange($pos, $itemStartPos) ||
780
+ $this->origTokens->haveTagInRange($pos, $itemStartPos))) {
781
+ // We'd remove the brace of a code block.
782
+ // TODO: Preserve formatting.
783
+ $this->setIndentLevel($origIndentLevel);
784
+ return null;
785
+ }
786
+ } else {
787
+ $result .= $this->origTokens->getTokenCode(
788
+ $pos, $commentStartPos, $indentAdjustment);
789
+ }
790
+
791
+ if (!empty($delayedAdd)) {
792
+ /** @var Node $delayedAddNode */
793
+ foreach ($delayedAdd as $delayedAddNode) {
794
+ if ($insertNewline) {
795
+ $delayedAddComments = $delayedAddNode->getComments();
796
+ if ($delayedAddComments) {
797
+ $result .= $this->pComments($delayedAddComments) . $this->nl;
798
+ }
799
+ }
800
+
801
+ $this->safeAppend($result, $this->p($delayedAddNode, true));
802
+
803
+ if ($insertNewline) {
804
+ $result .= $insertStr . $this->nl;
805
+ } else {
806
+ $result .= $insertStr;
807
+ }
808
+ }
809
+
810
+ $delayedAdd = [];
811
+ }
812
+
813
+ if ($comments !== $origComments) {
814
+ if ($comments) {
815
+ $result .= $this->pComments($comments) . $this->nl;
816
+ }
817
+ } else {
818
+ $result .= $this->origTokens->getTokenCode(
819
+ $commentStartPos, $itemStartPos, $indentAdjustment);
820
+ }
821
+
822
+ // If we had to remove anything, we have done so now.
823
+ $skipRemovedNode = false;
824
+ } elseif ($diffType === DiffElem::TYPE_ADD) {
825
+ if (null === $insertStr) {
826
+ // We don't have insertion information for this list type
827
+ return null;
828
+ }
829
+
830
+ // We go multiline if the original code was multiline,
831
+ // or if it's an array item with a comment above it.
832
+ if ($insertStr === ', ' &&
833
+ ($this->isMultiline($origNodes) || $arrItem->getComments())
834
+ ) {
835
+ $insertStr = ',';
836
+ $insertNewline = true;
837
+ }
838
+
839
+ if ($beforeFirstKeepOrReplace) {
840
+ // Will be inserted at the next "replace" or "keep" element
841
+ $delayedAdd[] = $arrItem;
842
+ continue;
843
+ }
844
+
845
+ $itemStartPos = $pos;
846
+ $itemEndPos = $pos - 1;
847
+
848
+ $origIndentLevel = $this->indentLevel;
849
+ $this->setIndentLevel($lastElemIndentLevel);
850
+
851
+ if ($insertNewline) {
852
+ $result .= $insertStr . $this->nl;
853
+ $comments = $arrItem->getComments();
854
+ if ($comments) {
855
+ $result .= $this->pComments($comments) . $this->nl;
856
+ }
857
+ } else {
858
+ $result .= $insertStr;
859
+ }
860
+ } elseif ($diffType === DiffElem::TYPE_REMOVE) {
861
+ if (!$origArrItem instanceof Node) {
862
+ // We only support removal for nodes
863
+ return null;
864
+ }
865
+
866
+ $itemStartPos = $origArrItem->getStartTokenPos();
867
+ $itemEndPos = $origArrItem->getEndTokenPos();
868
+ \assert($itemStartPos >= 0 && $itemEndPos >= 0);
869
+
870
+ // Consider comments part of the node.
871
+ $origComments = $origArrItem->getComments();
872
+ if ($origComments) {
873
+ $itemStartPos = $origComments[0]->getStartTokenPos();
874
+ }
875
+
876
+ if ($i === 0) {
877
+ // If we're removing from the start, keep the tokens before the node and drop those after it,
878
+ // instead of the other way around.
879
+ $result .= $this->origTokens->getTokenCode(
880
+ $pos, $itemStartPos, $indentAdjustment);
881
+ $skipRemovedNode = true;
882
+ } else {
883
+ if ($isStmtList && ($this->origTokens->haveBracesInRange($pos, $itemStartPos) ||
884
+ $this->origTokens->haveTagInRange($pos, $itemStartPos))) {
885
+ // We'd remove the brace of a code block.
886
+ // TODO: Preserve formatting.
887
+ return null;
888
+ }
889
+ }
890
+
891
+ $pos = $itemEndPos + 1;
892
+ continue;
893
+ } else {
894
+ throw new \Exception("Shouldn't happen");
895
+ }
896
+
897
+ if (null !== $fixup && $arrItem->getAttribute('origNode') !== $origArrItem) {
898
+ $res = $this->pFixup($fixup, $arrItem, null, $itemStartPos, $itemEndPos);
899
+ } else {
900
+ $res = $this->p($arrItem, true);
901
+ }
902
+ $this->safeAppend($result, $res);
903
+
904
+ $this->setIndentLevel($origIndentLevel);
905
+ $pos = $itemEndPos + 1;
906
+ }
907
+
908
+ if ($skipRemovedNode) {
909
+ // TODO: Support removing single node.
910
+ return null;
911
+ }
912
+
913
+ if (!empty($delayedAdd)) {
914
+ if (!isset($this->emptyListInsertionMap[$mapKey])) {
915
+ return null;
916
+ }
917
+
918
+ list($findToken, $extraLeft, $extraRight) = $this->emptyListInsertionMap[$mapKey];
919
+ if (null !== $findToken) {
920
+ $insertPos = $this->origTokens->findRight($pos, $findToken) + 1;
921
+ $result .= $this->origTokens->getTokenCode($pos, $insertPos, $indentAdjustment);
922
+ $pos = $insertPos;
923
+ }
924
+
925
+ $first = true;
926
+ $result .= $extraLeft;
927
+ foreach ($delayedAdd as $delayedAddNode) {
928
+ if (!$first) {
929
+ $result .= $insertStr;
930
+ if ($insertNewline) {
931
+ $result .= $this->nl;
932
+ }
933
+ }
934
+ $result .= $this->p($delayedAddNode, true);
935
+ $first = false;
936
+ }
937
+ $result .= $extraRight === "\n" ? $this->nl : $extraRight;
938
+ }
939
+
940
+ return $result;
941
+ }
942
+
943
+ /**
944
+ * Print node with fixups.
945
+ *
946
+ * Fixups here refer to the addition of extra parentheses, braces or other characters, that
947
+ * are required to preserve program semantics in a certain context (e.g. to maintain precedence
948
+ * or because only certain expressions are allowed in certain places).
949
+ *
950
+ * @param int $fixup Fixup type
951
+ * @param Node $subNode Subnode to print
952
+ * @param string|null $parentClass Class of parent node
953
+ * @param int $subStartPos Original start pos of subnode
954
+ * @param int $subEndPos Original end pos of subnode
955
+ *
956
+ * @return string Result of fixed-up print of subnode
957
+ */
958
+ protected function pFixup(int $fixup, Node $subNode, $parentClass, int $subStartPos, int $subEndPos) : string {
959
+ switch ($fixup) {
960
+ case self::FIXUP_PREC_LEFT:
961
+ case self::FIXUP_PREC_RIGHT:
962
+ if (!$this->origTokens->haveParens($subStartPos, $subEndPos)) {
963
+ list($precedence, $associativity) = $this->precedenceMap[$parentClass];
964
+ return $this->pPrec($subNode, $precedence, $associativity,
965
+ $fixup === self::FIXUP_PREC_LEFT ? -1 : 1);
966
+ }
967
+ break;
968
+ case self::FIXUP_CALL_LHS:
969
+ if ($this->callLhsRequiresParens($subNode)
970
+ && !$this->origTokens->haveParens($subStartPos, $subEndPos)
971
+ ) {
972
+ return '(' . $this->p($subNode) . ')';
973
+ }
974
+ break;
975
+ case self::FIXUP_DEREF_LHS:
976
+ if ($this->dereferenceLhsRequiresParens($subNode)
977
+ && !$this->origTokens->haveParens($subStartPos, $subEndPos)
978
+ ) {
979
+ return '(' . $this->p($subNode) . ')';
980
+ }
981
+ break;
982
+ case self::FIXUP_STATIC_DEREF_LHS:
983
+ if ($this->staticDereferenceLhsRequiresParens($subNode)
984
+ && !$this->origTokens->haveParens($subStartPos, $subEndPos)
985
+ ) {
986
+ return '(' . $this->p($subNode) . ')';
987
+ }
988
+ break;
989
+ case self::FIXUP_NEW:
990
+ if ($this->newOperandRequiresParens($subNode)
991
+ && !$this->origTokens->haveParens($subStartPos, $subEndPos)) {
992
+ return '(' . $this->p($subNode) . ')';
993
+ }
994
+ break;
995
+ case self::FIXUP_BRACED_NAME:
996
+ case self::FIXUP_VAR_BRACED_NAME:
997
+ if ($subNode instanceof Expr
998
+ && !$this->origTokens->haveBraces($subStartPos, $subEndPos)
999
+ ) {
1000
+ return ($fixup === self::FIXUP_VAR_BRACED_NAME ? '$' : '')
1001
+ . '{' . $this->p($subNode) . '}';
1002
+ }
1003
+ break;
1004
+ case self::FIXUP_ENCAPSED:
1005
+ if (!$subNode instanceof Scalar\EncapsedStringPart
1006
+ && !$this->origTokens->haveBraces($subStartPos, $subEndPos)
1007
+ ) {
1008
+ return '{' . $this->p($subNode) . '}';
1009
+ }
1010
+ break;
1011
+ default:
1012
+ throw new \Exception('Cannot happen');
1013
+ }
1014
+
1015
+ // Nothing special to do
1016
+ return $this->p($subNode);
1017
+ }
1018
+
1019
+ /**
1020
+ * Appends to a string, ensuring whitespace between label characters.
1021
+ *
1022
+ * Example: "echo" and "$x" result in "echo$x", but "echo" and "x" result in "echo x".
1023
+ * Without safeAppend the result would be "echox", which does not preserve semantics.
1024
+ *
1025
+ * @param string $str
1026
+ * @param string $append
1027
+ */
1028
+ protected function safeAppend(string &$str, string $append) {
1029
+ if ($str === "") {
1030
+ $str = $append;
1031
+ return;
1032
+ }
1033
+
1034
+ if ($append === "") {
1035
+ return;
1036
+ }
1037
+
1038
+ if (!$this->labelCharMap[$append[0]]
1039
+ || !$this->labelCharMap[$str[\strlen($str) - 1]]) {
1040
+ $str .= $append;
1041
+ } else {
1042
+ $str .= " " . $append;
1043
+ }
1044
+ }
1045
+
1046
+ /**
1047
+ * Determines whether the LHS of a call must be wrapped in parenthesis.
1048
+ *
1049
+ * @param Node $node LHS of a call
1050
+ *
1051
+ * @return bool Whether parentheses are required
1052
+ */
1053
+ protected function callLhsRequiresParens(Node $node) : bool {
1054
+ return !($node instanceof Node\Name
1055
+ || $node instanceof Expr\Variable
1056
+ || $node instanceof Expr\ArrayDimFetch
1057
+ || $node instanceof Expr\FuncCall
1058
+ || $node instanceof Expr\MethodCall
1059
+ || $node instanceof Expr\NullsafeMethodCall
1060
+ || $node instanceof Expr\StaticCall
1061
+ || $node instanceof Expr\Array_);
1062
+ }
1063
+
1064
+ /**
1065
+ * Determines whether the LHS of an array/object operation must be wrapped in parentheses.
1066
+ *
1067
+ * @param Node $node LHS of dereferencing operation
1068
+ *
1069
+ * @return bool Whether parentheses are required
1070
+ */
1071
+ protected function dereferenceLhsRequiresParens(Node $node) : bool {
1072
+ // A constant can occur on the LHS of an array/object deref, but not a static deref.
1073
+ return $this->staticDereferenceLhsRequiresParens($node)
1074
+ && !$node instanceof Expr\ConstFetch;
1075
+ }
1076
+
1077
+ /**
1078
+ * Determines whether the LHS of a static operation must be wrapped in parentheses.
1079
+ *
1080
+ * @param Node $node LHS of dereferencing operation
1081
+ *
1082
+ * @return bool Whether parentheses are required
1083
+ */
1084
+ protected function staticDereferenceLhsRequiresParens(Node $node): bool {
1085
+ return !($node instanceof Expr\Variable
1086
+ || $node instanceof Node\Name
1087
+ || $node instanceof Expr\ArrayDimFetch
1088
+ || $node instanceof Expr\PropertyFetch
1089
+ || $node instanceof Expr\NullsafePropertyFetch
1090
+ || $node instanceof Expr\StaticPropertyFetch
1091
+ || $node instanceof Expr\FuncCall
1092
+ || $node instanceof Expr\MethodCall
1093
+ || $node instanceof Expr\NullsafeMethodCall
1094
+ || $node instanceof Expr\StaticCall
1095
+ || $node instanceof Expr\Array_
1096
+ || $node instanceof Scalar\String_
1097
+ || $node instanceof Expr\ClassConstFetch);
1098
+ }
1099
+
1100
+ /**
1101
+ * Determines whether an expression used in "new" or "instanceof" requires parentheses.
1102
+ *
1103
+ * @param Node $node New or instanceof operand
1104
+ *
1105
+ * @return bool Whether parentheses are required
1106
+ */
1107
+ protected function newOperandRequiresParens(Node $node): bool {
1108
+ if ($node instanceof Node\Name || $node instanceof Expr\Variable) {
1109
+ return false;
1110
+ }
1111
+ if ($node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch ||
1112
+ $node instanceof Expr\NullsafePropertyFetch
1113
+ ) {
1114
+ return $this->newOperandRequiresParens($node->var);
1115
+ }
1116
+ if ($node instanceof Expr\StaticPropertyFetch) {
1117
+ return $this->newOperandRequiresParens($node->class);
1118
+ }
1119
+ return true;
1120
+ }
1121
+
1122
+ /**
1123
+ * Print modifiers, including trailing whitespace.
1124
+ *
1125
+ * @param int $modifiers Modifier mask to print
1126
+ *
1127
+ * @return string Printed modifiers
1128
+ */
1129
+ protected function pModifiers(int $modifiers) {
1130
+ return ($modifiers & Stmt\Class_::MODIFIER_PUBLIC ? 'public ' : '')
1131
+ . ($modifiers & Stmt\Class_::MODIFIER_PROTECTED ? 'protected ' : '')
1132
+ . ($modifiers & Stmt\Class_::MODIFIER_PRIVATE ? 'private ' : '')
1133
+ . ($modifiers & Stmt\Class_::MODIFIER_STATIC ? 'static ' : '')
1134
+ . ($modifiers & Stmt\Class_::MODIFIER_ABSTRACT ? 'abstract ' : '')
1135
+ . ($modifiers & Stmt\Class_::MODIFIER_FINAL ? 'final ' : '')
1136
+ . ($modifiers & Stmt\Class_::MODIFIER_READONLY ? 'readonly ' : '');
1137
+ }
1138
+
1139
+ /**
1140
+ * Determine whether a list of nodes uses multiline formatting.
1141
+ *
1142
+ * @param (Node|null)[] $nodes Node list
1143
+ *
1144
+ * @return bool Whether multiline formatting is used
1145
+ */
1146
+ protected function isMultiline(array $nodes) : bool {
1147
+ if (\count($nodes) < 2) {
1148
+ return false;
1149
+ }
1150
+
1151
+ $pos = -1;
1152
+ foreach ($nodes as $node) {
1153
+ if (null === $node) {
1154
+ continue;
1155
+ }
1156
+
1157
+ $endPos = $node->getEndTokenPos() + 1;
1158
+ if ($pos >= 0) {
1159
+ $text = $this->origTokens->getTokenCode($pos, $endPos, 0);
1160
+ if (false === strpos($text, "\n")) {
1161
+ // We require that a newline is present between *every* item. If the formatting
1162
+ // is inconsistent, with only some items having newlines, we don't consider it
1163
+ // as multiline
1164
+ return false;
1165
+ }
1166
+ }
1167
+ $pos = $endPos;
1168
+ }
1169
+
1170
+ return true;
1171
+ }
1172
+
1173
+ /**
1174
+ * Lazily initializes label char map.
1175
+ *
1176
+ * The label char map determines whether a certain character may occur in a label.
1177
+ */
1178
+ protected function initializeLabelCharMap() {
1179
+ if ($this->labelCharMap) return;
1180
+
1181
+ $this->labelCharMap = [];
1182
+ for ($i = 0; $i < 256; $i++) {
1183
+ // Since PHP 7.1 The lower range is 0x80. However, we also want to support code for
1184
+ // older versions.
1185
+ $chr = chr($i);
1186
+ $this->labelCharMap[$chr] = $i >= 0x7f || ctype_alnum($chr);
1187
+ }
1188
+ }
1189
+
1190
+ /**
1191
+ * Lazily initializes node list differ.
1192
+ *
1193
+ * The node list differ is used to determine differences between two array subnodes.
1194
+ */
1195
+ protected function initializeNodeListDiffer() {
1196
+ if ($this->nodeListDiffer) return;
1197
+
1198
+ $this->nodeListDiffer = new Internal\Differ(function ($a, $b) {
1199
+ if ($a instanceof Node && $b instanceof Node) {
1200
+ return $a === $b->getAttribute('origNode');
1201
+ }
1202
+ // Can happen for array destructuring
1203
+ return $a === null && $b === null;
1204
+ });
1205
+ }
1206
+
1207
+ /**
1208
+ * Lazily initializes fixup map.
1209
+ *
1210
+ * The fixup map is used to determine whether a certain subnode of a certain node may require
1211
+ * some kind of "fixup" operation, e.g. the addition of parenthesis or braces.
1212
+ */
1213
+ protected function initializeFixupMap() {
1214
+ if ($this->fixupMap) return;
1215
+
1216
+ $this->fixupMap = [
1217
+ Expr\PreInc::class => ['var' => self::FIXUP_PREC_RIGHT],
1218
+ Expr\PreDec::class => ['var' => self::FIXUP_PREC_RIGHT],
1219
+ Expr\PostInc::class => ['var' => self::FIXUP_PREC_LEFT],
1220
+ Expr\PostDec::class => ['var' => self::FIXUP_PREC_LEFT],
1221
+ Expr\Instanceof_::class => [
1222
+ 'expr' => self::FIXUP_PREC_LEFT,
1223
+ 'class' => self::FIXUP_NEW,
1224
+ ],
1225
+ Expr\Ternary::class => [
1226
+ 'cond' => self::FIXUP_PREC_LEFT,
1227
+ 'else' => self::FIXUP_PREC_RIGHT,
1228
+ ],
1229
+
1230
+ Expr\FuncCall::class => ['name' => self::FIXUP_CALL_LHS],
1231
+ Expr\StaticCall::class => ['class' => self::FIXUP_STATIC_DEREF_LHS],
1232
+ Expr\ArrayDimFetch::class => ['var' => self::FIXUP_DEREF_LHS],
1233
+ Expr\ClassConstFetch::class => [
1234
+ 'class' => self::FIXUP_STATIC_DEREF_LHS,
1235
+ 'name' => self::FIXUP_BRACED_NAME,
1236
+ ],
1237
+ Expr\New_::class => ['class' => self::FIXUP_NEW],
1238
+ Expr\MethodCall::class => [
1239
+ 'var' => self::FIXUP_DEREF_LHS,
1240
+ 'name' => self::FIXUP_BRACED_NAME,
1241
+ ],
1242
+ Expr\NullsafeMethodCall::class => [
1243
+ 'var' => self::FIXUP_DEREF_LHS,
1244
+ 'name' => self::FIXUP_BRACED_NAME,
1245
+ ],
1246
+ Expr\StaticPropertyFetch::class => [
1247
+ 'class' => self::FIXUP_STATIC_DEREF_LHS,
1248
+ 'name' => self::FIXUP_VAR_BRACED_NAME,
1249
+ ],
1250
+ Expr\PropertyFetch::class => [
1251
+ 'var' => self::FIXUP_DEREF_LHS,
1252
+ 'name' => self::FIXUP_BRACED_NAME,
1253
+ ],
1254
+ Expr\NullsafePropertyFetch::class => [
1255
+ 'var' => self::FIXUP_DEREF_LHS,
1256
+ 'name' => self::FIXUP_BRACED_NAME,
1257
+ ],
1258
+ Scalar\Encapsed::class => [
1259
+ 'parts' => self::FIXUP_ENCAPSED,
1260
+ ],
1261
+ ];
1262
+
1263
+ $binaryOps = [
1264
+ BinaryOp\Pow::class, BinaryOp\Mul::class, BinaryOp\Div::class, BinaryOp\Mod::class,
1265
+ BinaryOp\Plus::class, BinaryOp\Minus::class, BinaryOp\Concat::class,
1266
+ BinaryOp\ShiftLeft::class, BinaryOp\ShiftRight::class, BinaryOp\Smaller::class,
1267
+ BinaryOp\SmallerOrEqual::class, BinaryOp\Greater::class, BinaryOp\GreaterOrEqual::class,
1268
+ BinaryOp\Equal::class, BinaryOp\NotEqual::class, BinaryOp\Identical::class,
1269
+ BinaryOp\NotIdentical::class, BinaryOp\Spaceship::class, BinaryOp\BitwiseAnd::class,
1270
+ BinaryOp\BitwiseXor::class, BinaryOp\BitwiseOr::class, BinaryOp\BooleanAnd::class,
1271
+ BinaryOp\BooleanOr::class, BinaryOp\Coalesce::class, BinaryOp\LogicalAnd::class,
1272
+ BinaryOp\LogicalXor::class, BinaryOp\LogicalOr::class,
1273
+ ];
1274
+ foreach ($binaryOps as $binaryOp) {
1275
+ $this->fixupMap[$binaryOp] = [
1276
+ 'left' => self::FIXUP_PREC_LEFT,
1277
+ 'right' => self::FIXUP_PREC_RIGHT
1278
+ ];
1279
+ }
1280
+
1281
+ $assignOps = [
1282
+ Expr\Assign::class, Expr\AssignRef::class, AssignOp\Plus::class, AssignOp\Minus::class,
1283
+ AssignOp\Mul::class, AssignOp\Div::class, AssignOp\Concat::class, AssignOp\Mod::class,
1284
+ AssignOp\BitwiseAnd::class, AssignOp\BitwiseOr::class, AssignOp\BitwiseXor::class,
1285
+ AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class, AssignOp\Coalesce::class
1286
+ ];
1287
+ foreach ($assignOps as $assignOp) {
1288
+ $this->fixupMap[$assignOp] = [
1289
+ 'var' => self::FIXUP_PREC_LEFT,
1290
+ 'expr' => self::FIXUP_PREC_RIGHT,
1291
+ ];
1292
+ }
1293
+
1294
+ $prefixOps = [
1295
+ Expr\BitwiseNot::class, Expr\BooleanNot::class, Expr\UnaryPlus::class, Expr\UnaryMinus::class,
1296
+ Cast\Int_::class, Cast\Double::class, Cast\String_::class, Cast\Array_::class,
1297
+ Cast\Object_::class, Cast\Bool_::class, Cast\Unset_::class, Expr\ErrorSuppress::class,
1298
+ Expr\YieldFrom::class, Expr\Print_::class, Expr\Include_::class,
1299
+ ];
1300
+ foreach ($prefixOps as $prefixOp) {
1301
+ $this->fixupMap[$prefixOp] = ['expr' => self::FIXUP_PREC_RIGHT];
1302
+ }
1303
+ }
1304
+
1305
+ /**
1306
+ * Lazily initializes the removal map.
1307
+ *
1308
+ * The removal map is used to determine which additional tokens should be removed when a
1309
+ * certain node is replaced by null.
1310
+ */
1311
+ protected function initializeRemovalMap() {
1312
+ if ($this->removalMap) return;
1313
+
1314
+ $stripBoth = ['left' => \T_WHITESPACE, 'right' => \T_WHITESPACE];
1315
+ $stripLeft = ['left' => \T_WHITESPACE];
1316
+ $stripRight = ['right' => \T_WHITESPACE];
1317
+ $stripDoubleArrow = ['right' => \T_DOUBLE_ARROW];
1318
+ $stripColon = ['left' => ':'];
1319
+ $stripEquals = ['left' => '='];
1320
+ $this->removalMap = [
1321
+ 'Expr_ArrayDimFetch->dim' => $stripBoth,
1322
+ 'Expr_ArrayItem->key' => $stripDoubleArrow,
1323
+ 'Expr_ArrowFunction->returnType' => $stripColon,
1324
+ 'Expr_Closure->returnType' => $stripColon,
1325
+ 'Expr_Exit->expr' => $stripBoth,
1326
+ 'Expr_Ternary->if' => $stripBoth,
1327
+ 'Expr_Yield->key' => $stripDoubleArrow,
1328
+ 'Expr_Yield->value' => $stripBoth,
1329
+ 'Param->type' => $stripRight,
1330
+ 'Param->default' => $stripEquals,
1331
+ 'Stmt_Break->num' => $stripBoth,
1332
+ 'Stmt_Catch->var' => $stripLeft,
1333
+ 'Stmt_ClassConst->type' => $stripRight,
1334
+ 'Stmt_ClassMethod->returnType' => $stripColon,
1335
+ 'Stmt_Class->extends' => ['left' => \T_EXTENDS],
1336
+ 'Stmt_Enum->scalarType' => $stripColon,
1337
+ 'Stmt_EnumCase->expr' => $stripEquals,
1338
+ 'Expr_PrintableNewAnonClass->extends' => ['left' => \T_EXTENDS],
1339
+ 'Stmt_Continue->num' => $stripBoth,
1340
+ 'Stmt_Foreach->keyVar' => $stripDoubleArrow,
1341
+ 'Stmt_Function->returnType' => $stripColon,
1342
+ 'Stmt_If->else' => $stripLeft,
1343
+ 'Stmt_Namespace->name' => $stripLeft,
1344
+ 'Stmt_Property->type' => $stripRight,
1345
+ 'Stmt_PropertyProperty->default' => $stripEquals,
1346
+ 'Stmt_Return->expr' => $stripBoth,
1347
+ 'Stmt_StaticVar->default' => $stripEquals,
1348
+ 'Stmt_TraitUseAdaptation_Alias->newName' => $stripLeft,
1349
+ 'Stmt_TryCatch->finally' => $stripLeft,
1350
+ // 'Stmt_Case->cond': Replace with "default"
1351
+ // 'Stmt_Class->name': Unclear what to do
1352
+ // 'Stmt_Declare->stmts': Not a plain node
1353
+ // 'Stmt_TraitUseAdaptation_Alias->newModifier': Not a plain node
1354
+ ];
1355
+ }
1356
+
1357
+ protected function initializeInsertionMap() {
1358
+ if ($this->insertionMap) return;
1359
+
1360
+ // TODO: "yield" where both key and value are inserted doesn't work
1361
+ // [$find, $beforeToken, $extraLeft, $extraRight]
1362
+ $this->insertionMap = [
1363
+ 'Expr_ArrayDimFetch->dim' => ['[', false, null, null],
1364
+ 'Expr_ArrayItem->key' => [null, false, null, ' => '],
1365
+ 'Expr_ArrowFunction->returnType' => [')', false, ' : ', null],
1366
+ 'Expr_Closure->returnType' => [')', false, ' : ', null],
1367
+ 'Expr_Ternary->if' => ['?', false, ' ', ' '],
1368
+ 'Expr_Yield->key' => [\T_YIELD, false, null, ' => '],
1369
+ 'Expr_Yield->value' => [\T_YIELD, false, ' ', null],
1370
+ 'Param->type' => [null, false, null, ' '],
1371
+ 'Param->default' => [null, false, ' = ', null],
1372
+ 'Stmt_Break->num' => [\T_BREAK, false, ' ', null],
1373
+ 'Stmt_Catch->var' => [null, false, ' ', null],
1374
+ 'Stmt_ClassMethod->returnType' => [')', false, ' : ', null],
1375
+ 'Stmt_ClassConst->type' => [\T_CONST, false, ' ', null],
1376
+ 'Stmt_Class->extends' => [null, false, ' extends ', null],
1377
+ 'Stmt_Enum->scalarType' => [null, false, ' : ', null],
1378
+ 'Stmt_EnumCase->expr' => [null, false, ' = ', null],
1379
+ 'Expr_PrintableNewAnonClass->extends' => [null, ' extends ', null],
1380
+ 'Stmt_Continue->num' => [\T_CONTINUE, false, ' ', null],
1381
+ 'Stmt_Foreach->keyVar' => [\T_AS, false, null, ' => '],
1382
+ 'Stmt_Function->returnType' => [')', false, ' : ', null],
1383
+ 'Stmt_If->else' => [null, false, ' ', null],
1384
+ 'Stmt_Namespace->name' => [\T_NAMESPACE, false, ' ', null],
1385
+ 'Stmt_Property->type' => [\T_VARIABLE, true, null, ' '],
1386
+ 'Stmt_PropertyProperty->default' => [null, false, ' = ', null],
1387
+ 'Stmt_Return->expr' => [\T_RETURN, false, ' ', null],
1388
+ 'Stmt_StaticVar->default' => [null, false, ' = ', null],
1389
+ //'Stmt_TraitUseAdaptation_Alias->newName' => [T_AS, false, ' ', null], // TODO
1390
+ 'Stmt_TryCatch->finally' => [null, false, ' ', null],
1391
+
1392
+ // 'Expr_Exit->expr': Complicated due to optional ()
1393
+ // 'Stmt_Case->cond': Conversion from default to case
1394
+ // 'Stmt_Class->name': Unclear
1395
+ // 'Stmt_Declare->stmts': Not a proper node
1396
+ // 'Stmt_TraitUseAdaptation_Alias->newModifier': Not a proper node
1397
+ ];
1398
+ }
1399
+
1400
+ protected function initializeListInsertionMap() {
1401
+ if ($this->listInsertionMap) return;
1402
+
1403
+ $this->listInsertionMap = [
1404
+ // special
1405
+ //'Expr_ShellExec->parts' => '', // TODO These need to be treated more carefully
1406
+ //'Scalar_Encapsed->parts' => '',
1407
+ 'Stmt_Catch->types' => '|',
1408
+ 'UnionType->types' => '|',
1409
+ 'IntersectionType->types' => '&',
1410
+ 'Stmt_If->elseifs' => ' ',
1411
+ 'Stmt_TryCatch->catches' => ' ',
1412
+
1413
+ // comma-separated lists
1414
+ 'Expr_Array->items' => ', ',
1415
+ 'Expr_ArrowFunction->params' => ', ',
1416
+ 'Expr_Closure->params' => ', ',
1417
+ 'Expr_Closure->uses' => ', ',
1418
+ 'Expr_FuncCall->args' => ', ',
1419
+ 'Expr_Isset->vars' => ', ',
1420
+ 'Expr_List->items' => ', ',
1421
+ 'Expr_MethodCall->args' => ', ',
1422
+ 'Expr_NullsafeMethodCall->args' => ', ',
1423
+ 'Expr_New->args' => ', ',
1424
+ 'Expr_PrintableNewAnonClass->args' => ', ',
1425
+ 'Expr_StaticCall->args' => ', ',
1426
+ 'Stmt_ClassConst->consts' => ', ',
1427
+ 'Stmt_ClassMethod->params' => ', ',
1428
+ 'Stmt_Class->implements' => ', ',
1429
+ 'Stmt_Enum->implements' => ', ',
1430
+ 'Expr_PrintableNewAnonClass->implements' => ', ',
1431
+ 'Stmt_Const->consts' => ', ',
1432
+ 'Stmt_Declare->declares' => ', ',
1433
+ 'Stmt_Echo->exprs' => ', ',
1434
+ 'Stmt_For->init' => ', ',
1435
+ 'Stmt_For->cond' => ', ',
1436
+ 'Stmt_For->loop' => ', ',
1437
+ 'Stmt_Function->params' => ', ',
1438
+ 'Stmt_Global->vars' => ', ',
1439
+ 'Stmt_GroupUse->uses' => ', ',
1440
+ 'Stmt_Interface->extends' => ', ',
1441
+ 'Stmt_Match->arms' => ', ',
1442
+ 'Stmt_Property->props' => ', ',
1443
+ 'Stmt_StaticVar->vars' => ', ',
1444
+ 'Stmt_TraitUse->traits' => ', ',
1445
+ 'Stmt_TraitUseAdaptation_Precedence->insteadof' => ', ',
1446
+ 'Stmt_Unset->vars' => ', ',
1447
+ 'Stmt_Use->uses' => ', ',
1448
+ 'MatchArm->conds' => ', ',
1449
+ 'AttributeGroup->attrs' => ', ',
1450
+
1451
+ // statement lists
1452
+ 'Expr_Closure->stmts' => "\n",
1453
+ 'Stmt_Case->stmts' => "\n",
1454
+ 'Stmt_Catch->stmts' => "\n",
1455
+ 'Stmt_Class->stmts' => "\n",
1456
+ 'Stmt_Enum->stmts' => "\n",
1457
+ 'Expr_PrintableNewAnonClass->stmts' => "\n",
1458
+ 'Stmt_Interface->stmts' => "\n",
1459
+ 'Stmt_Trait->stmts' => "\n",
1460
+ 'Stmt_ClassMethod->stmts' => "\n",
1461
+ 'Stmt_Declare->stmts' => "\n",
1462
+ 'Stmt_Do->stmts' => "\n",
1463
+ 'Stmt_ElseIf->stmts' => "\n",
1464
+ 'Stmt_Else->stmts' => "\n",
1465
+ 'Stmt_Finally->stmts' => "\n",
1466
+ 'Stmt_Foreach->stmts' => "\n",
1467
+ 'Stmt_For->stmts' => "\n",
1468
+ 'Stmt_Function->stmts' => "\n",
1469
+ 'Stmt_If->stmts' => "\n",
1470
+ 'Stmt_Namespace->stmts' => "\n",
1471
+ 'Stmt_Class->attrGroups' => "\n",
1472
+ 'Stmt_Enum->attrGroups' => "\n",
1473
+ 'Stmt_EnumCase->attrGroups' => "\n",
1474
+ 'Stmt_Interface->attrGroups' => "\n",
1475
+ 'Stmt_Trait->attrGroups' => "\n",
1476
+ 'Stmt_Function->attrGroups' => "\n",
1477
+ 'Stmt_ClassMethod->attrGroups' => "\n",
1478
+ 'Stmt_ClassConst->attrGroups' => "\n",
1479
+ 'Stmt_Property->attrGroups' => "\n",
1480
+ 'Expr_PrintableNewAnonClass->attrGroups' => ' ',
1481
+ 'Expr_Closure->attrGroups' => ' ',
1482
+ 'Expr_ArrowFunction->attrGroups' => ' ',
1483
+ 'Param->attrGroups' => ' ',
1484
+ 'Stmt_Switch->cases' => "\n",
1485
+ 'Stmt_TraitUse->adaptations' => "\n",
1486
+ 'Stmt_TryCatch->stmts' => "\n",
1487
+ 'Stmt_While->stmts' => "\n",
1488
+
1489
+ // dummy for top-level context
1490
+ 'File->stmts' => "\n",
1491
+ ];
1492
+ }
1493
+
1494
+ protected function initializeEmptyListInsertionMap() {
1495
+ if ($this->emptyListInsertionMap) return;
1496
+
1497
+ // TODO Insertion into empty statement lists.
1498
+
1499
+ // [$find, $extraLeft, $extraRight]
1500
+ $this->emptyListInsertionMap = [
1501
+ 'Expr_ArrowFunction->params' => ['(', '', ''],
1502
+ 'Expr_Closure->uses' => [')', ' use(', ')'],
1503
+ 'Expr_Closure->params' => ['(', '', ''],
1504
+ 'Expr_FuncCall->args' => ['(', '', ''],
1505
+ 'Expr_MethodCall->args' => ['(', '', ''],
1506
+ 'Expr_NullsafeMethodCall->args' => ['(', '', ''],
1507
+ 'Expr_New->args' => ['(', '', ''],
1508
+ 'Expr_PrintableNewAnonClass->args' => ['(', '', ''],
1509
+ 'Expr_PrintableNewAnonClass->implements' => [null, ' implements ', ''],
1510
+ 'Expr_StaticCall->args' => ['(', '', ''],
1511
+ 'Stmt_Class->implements' => [null, ' implements ', ''],
1512
+ 'Stmt_Enum->implements' => [null, ' implements ', ''],
1513
+ 'Stmt_ClassMethod->params' => ['(', '', ''],
1514
+ 'Stmt_Interface->extends' => [null, ' extends ', ''],
1515
+ 'Stmt_Function->params' => ['(', '', ''],
1516
+ 'Stmt_Interface->attrGroups' => [null, '', "\n"],
1517
+ 'Stmt_Class->attrGroups' => [null, '', "\n"],
1518
+ 'Stmt_ClassConst->attrGroups' => [null, '', "\n"],
1519
+ 'Stmt_ClassMethod->attrGroups' => [null, '', "\n"],
1520
+ 'Stmt_Function->attrGroups' => [null, '', "\n"],
1521
+ 'Stmt_Property->attrGroups' => [null, '', "\n"],
1522
+ 'Stmt_Trait->attrGroups' => [null, '', "\n"],
1523
+ 'Expr_ArrowFunction->attrGroups' => [null, '', ' '],
1524
+ 'Expr_Closure->attrGroups' => [null, '', ' '],
1525
+ 'Expr_PrintableNewAnonClass->attrGroups' => [\T_NEW, ' ', ''],
1526
+
1527
+ /* These cannot be empty to start with:
1528
+ * Expr_Isset->vars
1529
+ * Stmt_Catch->types
1530
+ * Stmt_Const->consts
1531
+ * Stmt_ClassConst->consts
1532
+ * Stmt_Declare->declares
1533
+ * Stmt_Echo->exprs
1534
+ * Stmt_Global->vars
1535
+ * Stmt_GroupUse->uses
1536
+ * Stmt_Property->props
1537
+ * Stmt_StaticVar->vars
1538
+ * Stmt_TraitUse->traits
1539
+ * Stmt_TraitUseAdaptation_Precedence->insteadof
1540
+ * Stmt_Unset->vars
1541
+ * Stmt_Use->uses
1542
+ * UnionType->types
1543
+ */
1544
+
1545
+ /* TODO
1546
+ * Stmt_If->elseifs
1547
+ * Stmt_TryCatch->catches
1548
+ * Expr_Array->items
1549
+ * Expr_List->items
1550
+ * Stmt_For->init
1551
+ * Stmt_For->cond
1552
+ * Stmt_For->loop
1553
+ */
1554
+ ];
1555
+ }
1556
+
1557
+ protected function initializeModifierChangeMap() {
1558
+ if ($this->modifierChangeMap) return;
1559
+
1560
+ $this->modifierChangeMap = [
1561
+ 'Stmt_ClassConst->flags' => \T_CONST,
1562
+ 'Stmt_ClassMethod->flags' => \T_FUNCTION,
1563
+ 'Stmt_Class->flags' => \T_CLASS,
1564
+ 'Stmt_Property->flags' => \T_VARIABLE,
1565
+ 'Expr_PrintableNewAnonClass->flags' => \T_CLASS,
1566
+ 'Param->flags' => \T_VARIABLE,
1567
+ //'Stmt_TraitUseAdaptation_Alias->newModifier' => 0, // TODO
1568
+ ];
1569
+
1570
+ // List of integer subnodes that are not modifiers:
1571
+ // Expr_Include->type
1572
+ // Stmt_GroupUse->type
1573
+ // Stmt_Use->type
1574
+ // Stmt_UseUse->type
1575
+ }
1576
+ }