@vituum/vite-plugin-latte 2.0.0-next.4 → 2.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 (234) hide show
  1. package/README.md +1 -1
  2. package/index.js +4 -2
  3. package/package.json +11 -9
  4. package/types/index.d.ts +1 -1
  5. package/vendor/autoload.php +1 -4
  6. package/vendor/composer/InstalledVersions.php +36 -2
  7. package/vendor/composer/autoload_classmap.php +14 -15
  8. package/vendor/composer/autoload_psr4.php +2 -0
  9. package/vendor/composer/autoload_static.php +38 -15
  10. package/vendor/composer/installed.json +32 -22
  11. package/vendor/composer/installed.php +12 -12
  12. package/vendor/composer/platform_check.php +4 -5
  13. package/vendor/latte/latte/bin/latte-lint +10 -3
  14. package/vendor/latte/latte/composer.json +16 -6
  15. package/vendor/latte/latte/src/Bridges/Tracy/BlueScreenPanel.php +13 -38
  16. package/vendor/latte/latte/src/Bridges/Tracy/LattePanel.php +9 -7
  17. package/vendor/latte/latte/src/Bridges/Tracy/TracyExtension.php +2 -4
  18. package/vendor/latte/latte/src/Bridges/Tracy/dist/panel.phtml +94 -0
  19. package/vendor/latte/latte/src/Bridges/Tracy/dist/tab.phtml +10 -0
  20. package/vendor/latte/latte/src/Latte/Compiler/Block.php +4 -6
  21. package/vendor/latte/latte/src/Latte/Compiler/Escaper.php +67 -86
  22. package/vendor/latte/latte/src/Latte/Compiler/Node.php +6 -3
  23. package/vendor/latte/latte/src/Latte/Compiler/NodeHelpers.php +16 -6
  24. package/vendor/latte/latte/src/Latte/Compiler/NodeTraverser.php +25 -12
  25. package/vendor/latte/latte/src/Latte/Compiler/Nodes/AreaNode.php +7 -3
  26. package/vendor/latte/latte/src/Latte/Compiler/Nodes/AuxiliaryNode.php +5 -4
  27. package/vendor/latte/latte/src/Latte/Compiler/Nodes/FragmentNode.php +8 -4
  28. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/AttributeNode.php +7 -15
  29. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/BogusTagNode.php +4 -6
  30. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/CommentNode.php +4 -3
  31. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ElementNode.php +37 -67
  32. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ExpressionAttributeNode.php +60 -0
  33. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/TagNode.php +70 -0
  34. package/vendor/latte/latte/src/Latte/Compiler/Nodes/NopNode.php +4 -3
  35. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArgumentNode.php +4 -3
  36. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArrayItemNode.php +4 -15
  37. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ClosureUseNode.php +4 -3
  38. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ComplexTypeNode.php +4 -3
  39. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayAccessNode.php +4 -3
  40. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayNode.php +6 -22
  41. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignNode.php +18 -5
  42. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php +18 -7
  43. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AuxiliaryNode.php +5 -4
  44. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/BinaryOpNode.php +38 -9
  45. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CastNode.php +14 -6
  46. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClassConstantFetchNode.php +4 -3
  47. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CloneNode.php +12 -4
  48. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureNode.php +10 -6
  49. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ConstantFetchNode.php +7 -6
  50. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/EmptyNode.php +4 -3
  51. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FilterCallNode.php +10 -4
  52. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallNode.php +14 -5
  53. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InNode.php +4 -3
  54. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InstanceofNode.php +14 -5
  55. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/IssetNode.php +6 -3
  56. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MatchNode.php +6 -3
  57. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallNode.php +18 -5
  58. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NewNode.php +14 -4
  59. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PostOpNode.php +14 -6
  60. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PreOpNode.php +14 -6
  61. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PropertyFetchNode.php +4 -3
  62. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticMethodCallNode.php +14 -15
  63. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticPropertyFetchNode.php +4 -3
  64. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TemporaryNode.php +7 -6
  65. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TernaryNode.php +16 -11
  66. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/UnaryOpNode.php +19 -9
  67. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/VariableNode.php +4 -3
  68. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ExpressionNode.php +4 -3
  69. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/FilterNode.php +33 -8
  70. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IdentifierNode.php +4 -3
  71. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/InterpolatedStringPartNode.php +4 -3
  72. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IntersectionTypeNode.php +6 -3
  73. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListItemNode.php +4 -3
  74. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListNode.php +4 -3
  75. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/MatchArmNode.php +6 -3
  76. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ModifierNode.php +29 -41
  77. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NameNode.php +9 -4
  78. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NullableTypeNode.php +4 -3
  79. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/OperatorNode.php +27 -0
  80. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ParameterNode.php +4 -3
  81. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/BooleanNode.php +4 -3
  82. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/FloatNode.php +9 -6
  83. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/IntegerNode.php +8 -6
  84. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/InterpolatedStringNode.php +9 -5
  85. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/NullNode.php +4 -3
  86. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/StringNode.php +6 -4
  87. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ScalarNode.php +4 -3
  88. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/SuperiorTypeNode.php +4 -3
  89. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/UnionTypeNode.php +6 -3
  90. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/VarLikeIdentifierNode.php +4 -3
  91. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/{Expression/NotNode.php → VariadicPlaceholderNode.php} +9 -9
  92. package/vendor/latte/latte/src/Latte/{Essential → Compiler}/Nodes/PrintNode.php +9 -15
  93. package/vendor/latte/latte/src/Latte/Compiler/Nodes/StatementNode.php +7 -3
  94. package/vendor/latte/latte/src/Latte/Compiler/Nodes/TemplateNode.php +4 -3
  95. package/vendor/latte/latte/src/Latte/Compiler/Nodes/TextNode.php +6 -4
  96. package/vendor/latte/latte/src/Latte/Compiler/PhpHelpers.php +32 -18
  97. package/vendor/latte/latte/src/Latte/Compiler/Position.php +7 -7
  98. package/vendor/latte/latte/src/Latte/Compiler/PrintContext.php +72 -104
  99. package/vendor/latte/latte/src/Latte/Compiler/Tag.php +17 -16
  100. package/vendor/latte/latte/src/Latte/Compiler/TagLexer.php +11 -8
  101. package/vendor/latte/latte/src/Latte/Compiler/TagParser.php +28 -23
  102. package/vendor/latte/latte/src/Latte/Compiler/TagParserData.php +360 -336
  103. package/vendor/latte/latte/src/Latte/Compiler/TemplateGenerator.php +49 -38
  104. package/vendor/latte/latte/src/Latte/Compiler/TemplateLexer.php +37 -12
  105. package/vendor/latte/latte/src/Latte/Compiler/TemplateParser.php +35 -21
  106. package/vendor/latte/latte/src/Latte/Compiler/TemplateParserHtml.php +121 -71
  107. package/vendor/latte/latte/src/Latte/Compiler/Token.php +79 -70
  108. package/vendor/latte/latte/src/Latte/Compiler/TokenStream.php +21 -14
  109. package/vendor/latte/latte/src/Latte/ContentType.php +4 -3
  110. package/vendor/latte/latte/src/Latte/Engine.php +147 -188
  111. package/vendor/latte/latte/src/Latte/Essential/AuxiliaryIterator.php +5 -7
  112. package/vendor/latte/latte/src/Latte/Essential/Blueprint.php +5 -5
  113. package/vendor/latte/latte/src/Latte/Essential/CachingIterator.php +5 -4
  114. package/vendor/latte/latte/src/Latte/Essential/CoreExtension.php +155 -127
  115. package/vendor/latte/latte/src/Latte/Essential/Filters.php +99 -44
  116. package/vendor/latte/latte/src/Latte/Essential/Nodes/BlockNode.php +14 -13
  117. package/vendor/latte/latte/src/Latte/Essential/Nodes/CaptureNode.php +5 -6
  118. package/vendor/latte/latte/src/Latte/Essential/Nodes/ContentTypeNode.php +3 -4
  119. package/vendor/latte/latte/src/Latte/Essential/Nodes/CustomFunctionCallNode.php +46 -0
  120. package/vendor/latte/latte/src/Latte/Essential/Nodes/DebugbreakNode.php +2 -3
  121. package/vendor/latte/latte/src/Latte/Essential/Nodes/DefineNode.php +10 -7
  122. package/vendor/latte/latte/src/Latte/Essential/Nodes/DoNode.php +3 -4
  123. package/vendor/latte/latte/src/Latte/Essential/Nodes/DumpNode.php +2 -3
  124. package/vendor/latte/latte/src/Latte/Essential/Nodes/EmbedNode.php +8 -9
  125. package/vendor/latte/latte/src/Latte/Essential/Nodes/ExtendsNode.php +3 -5
  126. package/vendor/latte/latte/src/Latte/Essential/Nodes/FirstLastSepNode.php +4 -7
  127. package/vendor/latte/latte/src/Latte/Essential/Nodes/ForNode.php +6 -5
  128. package/vendor/latte/latte/src/Latte/Essential/Nodes/ForeachNode.php +7 -7
  129. package/vendor/latte/latte/src/Latte/Essential/Nodes/IfChangedNode.php +4 -5
  130. package/vendor/latte/latte/src/Latte/Essential/Nodes/IfContentNode.php +7 -6
  131. package/vendor/latte/latte/src/Latte/Essential/Nodes/IfNode.php +11 -11
  132. package/vendor/latte/latte/src/Latte/Essential/Nodes/ImportNode.php +5 -6
  133. package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeBlockNode.php +26 -27
  134. package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeFileNode.php +7 -10
  135. package/vendor/latte/latte/src/Latte/Essential/Nodes/IterateWhileNode.php +6 -6
  136. package/vendor/latte/latte/src/Latte/Essential/Nodes/JumpNode.php +4 -8
  137. package/vendor/latte/latte/src/Latte/Essential/Nodes/NAttrNode.php +35 -47
  138. package/vendor/latte/latte/src/Latte/Essential/Nodes/NClassNode.php +4 -5
  139. package/vendor/latte/latte/src/Latte/Essential/Nodes/NElseNode.php +69 -34
  140. package/vendor/latte/latte/src/Latte/Essential/Nodes/NTagNode.php +9 -33
  141. package/vendor/latte/latte/src/Latte/Essential/Nodes/ParametersNode.php +7 -4
  142. package/vendor/latte/latte/src/Latte/Essential/Nodes/RawPhpNode.php +3 -4
  143. package/vendor/latte/latte/src/Latte/Essential/Nodes/RollbackNode.php +2 -3
  144. package/vendor/latte/latte/src/Latte/Essential/Nodes/SpacelessNode.php +4 -5
  145. package/vendor/latte/latte/src/Latte/Essential/Nodes/SwitchNode.php +9 -7
  146. package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplatePrintNode.php +4 -4
  147. package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplateTypeNode.php +3 -4
  148. package/vendor/latte/latte/src/Latte/Essential/Nodes/TraceNode.php +2 -3
  149. package/vendor/latte/latte/src/Latte/Essential/Nodes/TranslateNode.php +5 -5
  150. package/vendor/latte/latte/src/Latte/Essential/Nodes/TryNode.php +4 -5
  151. package/vendor/latte/latte/src/Latte/Essential/Nodes/VarNode.php +10 -6
  152. package/vendor/latte/latte/src/Latte/Essential/Nodes/VarPrintNode.php +2 -3
  153. package/vendor/latte/latte/src/Latte/Essential/Nodes/VarTypeNode.php +3 -4
  154. package/vendor/latte/latte/src/Latte/Essential/Nodes/WhileNode.php +5 -5
  155. package/vendor/latte/latte/src/Latte/Essential/Passes.php +82 -21
  156. package/vendor/latte/latte/src/Latte/Essential/RawPhpExtension.php +2 -4
  157. package/vendor/latte/latte/src/Latte/Essential/RollbackException.php +1 -3
  158. package/vendor/latte/latte/src/Latte/Essential/Tracer.php +24 -28
  159. package/vendor/latte/latte/src/Latte/Essential/TranslatorExtension.php +14 -14
  160. package/vendor/latte/latte/src/Latte/Extension.php +12 -6
  161. package/vendor/latte/latte/src/Latte/Feature.php +24 -0
  162. package/vendor/latte/latte/src/Latte/Helpers.php +65 -15
  163. package/vendor/latte/latte/src/Latte/Loader.php +1 -9
  164. package/vendor/latte/latte/src/Latte/Loaders/FileLoader.php +11 -17
  165. package/vendor/latte/latte/src/Latte/Loaders/StringLoader.php +7 -21
  166. package/vendor/latte/latte/src/Latte/Policy.php +4 -3
  167. package/vendor/latte/latte/src/Latte/Runtime/Block.php +2 -4
  168. package/vendor/latte/latte/src/Latte/Runtime/Cache.php +143 -0
  169. package/vendor/latte/latte/src/Latte/Runtime/FilterExecutor.php +5 -6
  170. package/vendor/latte/latte/src/Latte/Runtime/FilterInfo.php +11 -11
  171. package/vendor/latte/latte/src/Latte/Runtime/FunctionExecutor.php +5 -6
  172. package/vendor/latte/latte/src/Latte/Runtime/Helpers.php +91 -0
  173. package/vendor/latte/latte/src/Latte/Runtime/Html.php +3 -5
  174. package/vendor/latte/latte/src/Latte/Runtime/HtmlHelpers.php +374 -0
  175. package/vendor/latte/latte/src/Latte/Runtime/HtmlStringable.php +1 -3
  176. package/vendor/latte/latte/src/Latte/Runtime/Template.php +162 -182
  177. package/vendor/latte/latte/src/Latte/Runtime/XmlHelpers.php +108 -0
  178. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallNode.php +12 -4
  179. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallNode.php +15 -5
  180. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/PropertyFetchNode.php +4 -3
  181. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/SandboxNode.php +5 -6
  182. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticMethodCallNode.php +14 -4
  183. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticPropertyFetchNode.php +4 -3
  184. package/vendor/latte/latte/src/Latte/Sandbox/RuntimeChecker.php +8 -6
  185. package/vendor/latte/latte/src/Latte/Sandbox/SandboxExtension.php +16 -12
  186. package/vendor/latte/latte/src/Latte/Sandbox/SecurityPolicy.php +18 -16
  187. package/vendor/latte/latte/src/Latte/attributes.php +7 -3
  188. package/vendor/latte/latte/src/Latte/exceptions.php +52 -6
  189. package/vendor/latte/latte/src/Tools/Linter.php +74 -28
  190. package/vendor/latte/latte/src/Tools/LinterExtension.php +176 -0
  191. package/vendor/nette/utils/composer.json +15 -5
  192. package/vendor/nette/utils/readme.md +1 -1
  193. package/vendor/nette/utils/src/HtmlStringable.php +4 -1
  194. package/vendor/nette/utils/src/Iterators/CachingIterator.php +10 -25
  195. package/vendor/nette/utils/src/Iterators/Mapper.php +2 -3
  196. package/vendor/nette/utils/src/SmartObject.php +3 -0
  197. package/vendor/nette/utils/src/StaticClass.php +1 -11
  198. package/vendor/nette/utils/src/Translator.php +1 -1
  199. package/vendor/nette/utils/src/Utils/ArrayHash.php +6 -10
  200. package/vendor/nette/utils/src/Utils/ArrayList.php +8 -12
  201. package/vendor/nette/utils/src/Utils/Arrays.php +38 -18
  202. package/vendor/nette/utils/src/Utils/Callback.php +13 -8
  203. package/vendor/nette/utils/src/Utils/DateTime.php +95 -26
  204. package/vendor/nette/utils/src/Utils/FileInfo.php +6 -7
  205. package/vendor/nette/utils/src/Utils/FileSystem.php +10 -5
  206. package/vendor/nette/utils/src/Utils/Finder.php +31 -12
  207. package/vendor/nette/utils/src/Utils/Floats.php +1 -0
  208. package/vendor/nette/utils/src/Utils/Helpers.php +22 -2
  209. package/vendor/nette/utils/src/Utils/Html.php +130 -127
  210. package/vendor/nette/utils/src/Utils/Image.php +80 -60
  211. package/vendor/nette/utils/src/Utils/ImageColor.php +5 -0
  212. package/vendor/nette/utils/src/Utils/ImageType.php +2 -0
  213. package/vendor/nette/utils/src/Utils/Iterables.php +41 -7
  214. package/vendor/nette/utils/src/Utils/Json.php +2 -0
  215. package/vendor/nette/utils/src/Utils/ObjectHelpers.php +2 -0
  216. package/vendor/nette/utils/src/Utils/Paginator.php +10 -43
  217. package/vendor/nette/utils/src/Utils/Random.php +2 -0
  218. package/vendor/nette/utils/src/Utils/Reflection.php +22 -15
  219. package/vendor/nette/utils/src/Utils/ReflectionMethod.php +6 -1
  220. package/vendor/nette/utils/src/Utils/Strings.php +62 -57
  221. package/vendor/nette/utils/src/Utils/Type.php +91 -42
  222. package/vendor/nette/utils/src/Utils/Validators.php +9 -7
  223. package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.panel.phtml +0 -101
  224. package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.tab.phtml +0 -15
  225. package/vendor/latte/latte/src/Latte/Compiler/ExpressionBuilder.php +0 -129
  226. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ErrorSuppressNode.php +0 -36
  227. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallableNode.php +0 -39
  228. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallableNode.php +0 -42
  229. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticMethodCallableNode.php +0 -57
  230. package/vendor/latte/latte/src/Latte/PositionAwareException.php +0 -47
  231. package/vendor/latte/latte/src/Latte/Runtime/Filters.php +0 -283
  232. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallableNode.php +0 -29
  233. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallableNode.php +0 -30
  234. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticMethodCallableNode.php +0 -30
@@ -1,28 +1,30 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php\Expression;
11
9
 
12
10
  use Latte\CompileException;
13
11
  use Latte\Compiler\Nodes\Php\ExpressionNode;
12
+ use Latte\Compiler\Nodes\Php\OperatorNode;
14
13
  use Latte\Compiler\Position;
15
14
  use Latte\Compiler\PrintContext;
16
15
 
17
16
 
18
- class PostOpNode extends ExpressionNode
17
+ /**
18
+ * Postfix increment/decrement ($var++, $var--).
19
+ */
20
+ class PostOpNode extends ExpressionNode implements OperatorNode
19
21
  {
20
22
  private const Ops = ['++' => 1, '--' => 1];
21
23
 
22
24
 
23
25
  public function __construct(
24
26
  public ExpressionNode $var,
25
- public /*readonly*/ string $operator,
27
+ public string $operator,
26
28
  public ?Position $position = null,
27
29
  ) {
28
30
  if (!isset(self::Ops[$this->operator])) {
@@ -35,7 +37,13 @@ class PostOpNode extends ExpressionNode
35
37
  public function print(PrintContext $context): string
36
38
  {
37
39
  $this->validate();
38
- return $context->postfixOp($this, $this->var, $this->operator);
40
+ return $context->parenthesize($this, $this->var, self::AssocLeft) . $this->operator;
41
+ }
42
+
43
+
44
+ public function getOperatorPrecedence(): array
45
+ {
46
+ return [240, self::AssocLeft];
39
47
  }
40
48
 
41
49
 
@@ -1,28 +1,30 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php\Expression;
11
9
 
12
10
  use Latte\CompileException;
13
11
  use Latte\Compiler\Nodes\Php\ExpressionNode;
12
+ use Latte\Compiler\Nodes\Php\OperatorNode;
14
13
  use Latte\Compiler\Position;
15
14
  use Latte\Compiler\PrintContext;
16
15
 
17
16
 
18
- class PreOpNode extends ExpressionNode
17
+ /**
18
+ * Prefix increment/decrement (++$var, --$var).
19
+ */
20
+ class PreOpNode extends ExpressionNode implements OperatorNode
19
21
  {
20
22
  private const Ops = ['++' => 1, '--' => 1];
21
23
 
22
24
 
23
25
  public function __construct(
24
26
  public ExpressionNode $var,
25
- public /*readonly*/ string $operator,
27
+ public string $operator,
26
28
  public ?Position $position = null,
27
29
  ) {
28
30
  if (!isset(self::Ops[$this->operator])) {
@@ -35,7 +37,13 @@ class PreOpNode extends ExpressionNode
35
37
  public function print(PrintContext $context): string
36
38
  {
37
39
  $this->validate();
38
- return $context->prefixOp($this, $this->operator, $this->var);
40
+ return $this->operator . $context->parenthesize($this, $this->var, self::AssocRight);
41
+ }
42
+
43
+
44
+ public function getOperatorPrecedence(): array
45
+ {
46
+ return [240, self::AssocRight];
39
47
  }
40
48
 
41
49
 
@@ -1,12 +1,10 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php\Expression;
11
9
 
12
10
  use Latte\Compiler\Nodes\Php\ExpressionNode;
@@ -15,6 +13,9 @@ use Latte\Compiler\Position;
15
13
  use Latte\Compiler\PrintContext;
16
14
 
17
15
 
16
+ /**
17
+ * Property access with nullsafe support ($obj->prop, $obj?->prop).
18
+ */
18
19
  class PropertyFetchNode extends ExpressionNode
19
20
  {
20
21
  public function __construct(
@@ -1,12 +1,10 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php\Expression;
11
9
 
12
10
  use Latte\Compiler\Nodes\Php;
@@ -15,18 +13,28 @@ use Latte\Compiler\Nodes\Php\IdentifierNode;
15
13
  use Latte\Compiler\Nodes\Php\NameNode;
16
14
  use Latte\Compiler\Position;
17
15
  use Latte\Compiler\PrintContext;
16
+ use Latte\Helpers;
18
17
 
19
18
 
19
+ /**
20
+ * Static method call with partial application or first-class callable support.
21
+ */
20
22
  class StaticMethodCallNode extends ExpressionNode
21
23
  {
22
24
  public function __construct(
23
25
  public NameNode|ExpressionNode $class,
24
26
  public IdentifierNode|ExpressionNode $name,
25
- /** @var array<Php\ArgumentNode> */
27
+ /** @var array<Php\ArgumentNode|Php\VariadicPlaceholderNode> */
26
28
  public array $args = [],
27
29
  public ?Position $position = null,
28
30
  ) {
29
- (function (Php\ArgumentNode ...$args) {})(...$args);
31
+ (function (Php\ArgumentNode|Php\VariadicPlaceholderNode ...$args) {})(...$args);
32
+ }
33
+
34
+
35
+ public function isPartialFunction(): bool
36
+ {
37
+ return ($this->args[0] ?? null) instanceof Php\VariadicPlaceholderNode;
30
38
  }
31
39
 
32
40
 
@@ -51,15 +59,6 @@ class StaticMethodCallNode extends ExpressionNode
51
59
  foreach ($this->args as &$item) {
52
60
  yield $item;
53
61
  }
54
- }
55
- }
56
-
57
-
58
- class_alias(StaticMethodCallNode::class, StaticCallNode::class);
59
-
60
- if (false) {
61
- /** @deprecated use Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode */
62
- class StaticCallNode
63
- {
62
+ Helpers::removeNulls($this->args);
64
63
  }
65
64
  }
@@ -1,12 +1,10 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php\Expression;
11
9
 
12
10
  use Latte\Compiler\Nodes\Php\ExpressionNode;
@@ -16,6 +14,9 @@ use Latte\Compiler\Position;
16
14
  use Latte\Compiler\PrintContext;
17
15
 
18
16
 
17
+ /**
18
+ * Static property access (Foo::$prop).
19
+ */
19
20
  class StaticPropertyFetchNode extends ExpressionNode
20
21
  {
21
22
  public function __construct(
@@ -1,38 +1,39 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php\Expression;
11
9
 
12
10
  use Latte\Compiler\Nodes\Php\ExpressionNode;
13
11
  use Latte\Compiler\Nodes\Php\ListNode;
12
+ use Latte\Compiler\Position;
14
13
  use Latte\Compiler\PrintContext;
15
14
 
16
15
 
17
16
  /**
18
- * Only for parser needs.
17
+ * Temporary container for partial parsing results (e.g., array destructuring).
19
18
  * @internal
20
19
  */
21
20
  class TemporaryNode extends ExpressionNode
22
21
  {
23
22
  public function __construct(
24
- public ListNode|null $value,
23
+ public ?ListNode $value,
24
+ public ?Position $position = null,
25
25
  ) {
26
26
  }
27
27
 
28
28
 
29
29
  public function print(PrintContext $context): string
30
30
  {
31
+ return '';
31
32
  }
32
33
 
33
34
 
34
35
  public function &getIterator(): \Generator
35
36
  {
36
- yield;
37
+ false && yield;
37
38
  }
38
39
  }
@@ -1,21 +1,23 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php\Expression;
11
9
 
12
10
  use Latte\Compiler\Nodes\Php\ExpressionNode;
13
- use Latte\Compiler\Nodes\Php\NameNode;
11
+ use Latte\Compiler\Nodes\Php\OperatorNode;
12
+ use Latte\Compiler\Nodes\Php\Scalar\NullNode;
14
13
  use Latte\Compiler\Position;
15
14
  use Latte\Compiler\PrintContext;
16
15
 
17
16
 
18
- class TernaryNode extends ExpressionNode
17
+ /**
18
+ * Ternary conditional ($cond ? $then : $else) or elvis operator ($a ?: $b).
19
+ */
20
+ class TernaryNode extends ExpressionNode implements OperatorNode
19
21
  {
20
22
  public function __construct(
21
23
  public ExpressionNode $cond,
@@ -28,12 +30,15 @@ class TernaryNode extends ExpressionNode
28
30
 
29
31
  public function print(PrintContext $context): string
30
32
  {
31
- return $context->infixOp(
32
- $this,
33
- $this->cond,
34
- ' ?' . ($this->if !== null ? ' ' . $this->if->print($context) . ' ' : '') . ': ',
35
- $this->else ?? new NameNode('null'),
36
- );
33
+ return $context->parenthesize($this, $this->cond, self::AssocLeft)
34
+ . ($this->if ? ' ? ' . $this->if->print($context) . ' : ' : ' ?: ')
35
+ . $context->parenthesize($this, $this->else ?? new NullNode, self::AssocRight);
36
+ }
37
+
38
+
39
+ public function getOperatorPrecedence(): array
40
+ {
41
+ return [100, self::AssocNone];
37
42
  }
38
43
 
39
44
 
@@ -1,27 +1,29 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php\Expression;
11
9
 
12
10
  use Latte\Compiler\Nodes\Php\ExpressionNode;
11
+ use Latte\Compiler\Nodes\Php\OperatorNode;
13
12
  use Latte\Compiler\Position;
14
13
  use Latte\Compiler\PrintContext;
15
14
 
16
15
 
17
- class UnaryOpNode extends ExpressionNode
16
+ /**
17
+ * Unary prefix operation (+, -, ~, @, !).
18
+ */
19
+ class UnaryOpNode extends ExpressionNode implements OperatorNode
18
20
  {
19
- private const Ops = ['+' => 1, '-' => 1, '~' => 1];
21
+ private const Ops = ['+' => 1, '-' => 1, '~' => 1, '@' => 1, '!' => 1];
20
22
 
21
23
 
22
24
  public function __construct(
23
25
  public ExpressionNode $expr,
24
- public /*readonly*/ string $operator,
26
+ public string $operator,
25
27
  public ?Position $position = null,
26
28
  ) {
27
29
  if (!isset(self::Ops[$this->operator])) {
@@ -32,9 +34,17 @@ class UnaryOpNode extends ExpressionNode
32
34
 
33
35
  public function print(PrintContext $context): string
34
36
  {
35
- return $this->expr instanceof self || $this->expr instanceof PreOpNode
36
- ? $this->operator . '(' . $this->expr->print($context) . ')' // Enforce -(-$expr) instead of --$expr
37
- : $context->prefixOp($this, $this->operator, $this->expr);
37
+ $pos = $this->expr instanceof self || $this->expr instanceof PreOpNode ? self::AssocLeft : self::AssocRight; // Enforce -(-$expr) instead of --$expr
38
+ return $this->operator . $context->parenthesize($this, $this->expr, $pos);
39
+ }
40
+
41
+
42
+ public function getOperatorPrecedence(): array
43
+ {
44
+ return match ($this->operator) {
45
+ '+', '-', '~', '@' => [240, self::AssocRight],
46
+ '!' => [220, self::AssocRight],
47
+ };
38
48
  }
39
49
 
40
50
 
@@ -1,12 +1,10 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php\Expression;
11
9
 
12
10
  use Latte\Compiler\Nodes\Php\ExpressionNode;
@@ -14,6 +12,9 @@ use Latte\Compiler\Position;
14
12
  use Latte\Compiler\PrintContext;
15
13
 
16
14
 
15
+ /**
16
+ * Variable access ($name or ${expr} for variable variables).
17
+ */
17
18
  class VariableNode extends ExpressionNode
18
19
  {
19
20
  public function __construct(
@@ -1,17 +1,18 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php;
11
9
 
12
10
  use Latte\Compiler\Node;
13
11
 
14
12
 
13
+ /**
14
+ * Base for PHP expression nodes (variables, operators, calls, literals).
15
+ */
15
16
  abstract class ExpressionNode extends Node
16
17
  {
17
18
  public function isWritable(): bool
@@ -1,27 +1,34 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php;
11
9
 
10
+ use Latte\CompileException;
12
11
  use Latte\Compiler\Node;
13
12
  use Latte\Compiler\Position;
14
13
  use Latte\Compiler\PrintContext;
14
+ use Latte\Helpers;
15
15
 
16
16
 
17
+ /**
18
+ * Single filter with name, arguments, and nullsafe flag (|name:arg).
19
+ */
17
20
  class FilterNode extends Node
18
21
  {
19
22
  public function __construct(
20
23
  public IdentifierNode $name,
21
24
  /** @var ArgumentNode[] */
22
25
  public array $args = [],
26
+ public bool $nullsafe = false,
23
27
  public ?Position $position = null,
24
28
  ) {
29
+ if ($name->name === 'escape') {
30
+ throw new CompileException("Filter 'escape' is not allowed.", $position);
31
+ }
25
32
  (function (ArgumentNode ...$args) {})(...$args);
26
33
  }
27
34
 
@@ -32,17 +39,34 @@ class FilterNode extends Node
32
39
  }
33
40
 
34
41
 
35
- public function printSimple(PrintContext $context, string $expr): string
42
+ /** @param self[] $filters */
43
+ public static function printSimple(PrintContext $context, array $filters, string $expr): string
36
44
  {
37
- return '($this->filters->' . $context->objectProperty($this->name) . ')('
38
- . $expr
39
- . ($this->args ? ', ' . $context->implode($this->args) : '')
40
- . ')';
45
+ $nullsafe = false;
46
+ $chain = $expr;
47
+ $tmp = '$ʟ_tmp';
48
+ foreach ($filters as $filter) {
49
+ if ($filter->nullsafe) {
50
+ $expr = $nullsafe ? "(($tmp = $expr) === null ? null : $chain)" : $chain;
51
+ $chain = $tmp;
52
+ $nullsafe = true;
53
+ }
54
+
55
+ $chain = '($this->filters->' . $context->objectProperty($filter->name) . ')('
56
+ . $chain
57
+ . ($filter->args ? ', ' . $context->implode($filter->args) : '')
58
+ . ')';
59
+ }
60
+
61
+ return $nullsafe ? "(($tmp = $expr) === null ? null : $chain)" : $chain;
41
62
  }
42
63
 
43
64
 
44
65
  public function printContentAware(PrintContext $context, string $expr): string
45
66
  {
67
+ if ($this->nullsafe) {
68
+ throw new CompileException('Content-aware filter cannot be nullsafe.', $this->position);
69
+ }
46
70
  return '$this->filters->filterContent('
47
71
  . $context->encodeString($this->name->name)
48
72
  . ', $ʟ_fi, '
@@ -58,5 +82,6 @@ class FilterNode extends Node
58
82
  foreach ($this->args as &$item) {
59
83
  yield $item;
60
84
  }
85
+ Helpers::removeNulls($this->args);
61
86
  }
62
87
  }
@@ -1,12 +1,10 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php;
11
9
 
12
10
  use Latte\Compiler\Node;
@@ -14,6 +12,9 @@ use Latte\Compiler\Position;
14
12
  use Latte\Compiler\PrintContext;
15
13
 
16
14
 
15
+ /**
16
+ * Simple identifier (unqualified name).
17
+ */
17
18
  class IdentifierNode extends Node
18
19
  {
19
20
  public function __construct(
@@ -1,12 +1,10 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php;
11
9
 
12
10
  use Latte\Compiler\Node;
@@ -14,6 +12,9 @@ use Latte\Compiler\Position;
14
12
  use Latte\Compiler\PrintContext;
15
13
 
16
14
 
15
+ /**
16
+ * Literal part of interpolated string.
17
+ */
17
18
  class InterpolatedStringPartNode extends Node
18
19
  {
19
20
  public function __construct(
@@ -1,18 +1,20 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php;
11
9
 
12
10
  use Latte\Compiler\Position;
13
11
  use Latte\Compiler\PrintContext;
12
+ use Latte\Helpers;
14
13
 
15
14
 
15
+ /**
16
+ * Intersection type (Type1&Type2).
17
+ */
16
18
  class IntersectionTypeNode extends ComplexTypeNode
17
19
  {
18
20
  public function __construct(
@@ -35,5 +37,6 @@ class IntersectionTypeNode extends ComplexTypeNode
35
37
  foreach ($this->types as &$item) {
36
38
  yield $item;
37
39
  }
40
+ Helpers::removeNulls($this->types);
38
41
  }
39
42
  }
@@ -1,12 +1,10 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php;
11
9
 
12
10
  use Latte\Compiler\Node;
@@ -14,6 +12,9 @@ use Latte\Compiler\Position;
14
12
  use Latte\Compiler\PrintContext;
15
13
 
16
14
 
15
+ /**
16
+ * Array destructuring item.
17
+ */
17
18
  class ListItemNode extends Node
18
19
  {
19
20
  public function __construct(
@@ -1,12 +1,10 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php;
11
9
 
12
10
  use Latte\CompileException;
@@ -15,6 +13,9 @@ use Latte\Compiler\Position;
15
13
  use Latte\Compiler\PrintContext;
16
14
 
17
15
 
16
+ /**
17
+ * Array destructuring ([$a, $b] = $arr).
18
+ */
18
19
  class ListNode extends Node
19
20
  {
20
21
  public function __construct(
@@ -1,19 +1,21 @@
1
- <?php
1
+ <?php declare(strict_types=1);
2
2
 
3
3
  /**
4
4
  * This file is part of the Latte (https://latte.nette.org)
5
5
  * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
6
  */
7
7
 
8
- declare(strict_types=1);
9
-
10
8
  namespace Latte\Compiler\Nodes\Php;
11
9
 
12
10
  use Latte\Compiler\Node;
13
11
  use Latte\Compiler\Position;
14
12
  use Latte\Compiler\PrintContext;
13
+ use Latte\Helpers;
15
14
 
16
15
 
16
+ /**
17
+ * Match expression arm with conditions and body.
18
+ */
17
19
  class MatchArmNode extends Node
18
20
  {
19
21
  public function __construct(
@@ -39,6 +41,7 @@ class MatchArmNode extends Node
39
41
  foreach ($this->conds as &$item) {
40
42
  yield $item;
41
43
  }
44
+ Helpers::removeNulls($this->conds);
42
45
  }
43
46
  yield $this->body;
44
47
  }