@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,15 +1,19 @@
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;
11
9
 
12
10
 
11
+ /**
12
+ * Base for Latte tags like {if}, {foreach}, {block}.
13
+ *
14
+ * Extend this class when creating custom tags. Implement static create(Tag)
15
+ * for parsing and print(PrintContext) for PHP code generation.
16
+ */
13
17
  abstract class StatementNode extends AreaNode
14
18
  {
15
19
  }
@@ -1,18 +1,19 @@
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;
11
9
 
12
10
  use Latte\Compiler\Node;
13
11
  use Latte\Compiler\PrintContext;
14
12
 
15
13
 
14
+ /**
15
+ * Root of template AST containing head declarations and main content fragment.
16
+ */
16
17
  final class TemplateNode extends Node
17
18
  {
18
19
  public FragmentNode $head;
@@ -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;
11
9
 
12
10
  use Latte\Compiler\Position;
13
11
  use Latte\Compiler\PrintContext;
12
+ use function trim, var_export;
14
13
 
15
14
 
15
+ /**
16
+ * Literal text content in template.
17
+ */
16
18
  class TextNode extends AreaNode
17
19
  {
18
20
  public function __construct(
@@ -26,7 +28,7 @@ class TextNode extends AreaNode
26
28
  {
27
29
  return $this->content === ''
28
30
  ? ''
29
- : 'echo ' . var_export($this->content, true) . ";\n";
31
+ : 'echo ' . var_export($this->content, return: true) . ";\n";
30
32
  }
31
33
 
32
34
 
@@ -1,15 +1,15 @@
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;
11
9
 
12
10
  use Latte\CompileException;
11
+ use function bindec, chr, count, explode, fclose, fwrite, hexdec, in_array, is_array, is_resource, max, octdec, preg_match, preg_replace, preg_replace_callback, proc_close, proc_open, str_repeat, str_replace, stream_get_contents, strip_tags, stripslashes, strlen, strpbrk, substr, substr_count, substr_replace, token_get_all, trim, var_export;
12
+ use const T_CATCH, T_CLOSE_TAG, T_COMMENT, T_CONSTANT_ENCAPSED_STRING, T_CURLY_OPEN, T_DOC_COMMENT, T_DOLLAR_OPEN_CURLY_BRACES, T_ECHO, T_ELSE, T_ELSEIF, T_FINALLY, T_OBJECT_OPERATOR, T_OPEN_TAG, T_WHITESPACE;
13
13
 
14
14
 
15
15
  /**
@@ -47,11 +47,11 @@ final class PhpHelpers
47
47
  } elseif ($name === T_WHITESPACE) {
48
48
  $prev = $tokens[$n - 1];
49
49
  $lines = substr_count($token, "\n");
50
- if ($prev === '}' && in_array($next[0], [T_ELSE, T_ELSEIF, T_CATCH, T_FINALLY], true)) {
50
+ if ($prev === '}' && in_array($next[0], [T_ELSE, T_ELSEIF, T_CATCH, T_FINALLY], strict: true)) {
51
51
  $token = ' ';
52
52
  } elseif ($prev === '{' || $prev === '}' || $prev === ';' || $lines) {
53
53
  $token = str_repeat("\n", max(1, $lines)) . str_repeat("\t", $level); // indent last line
54
- } elseif ($prev[0] === T_OPEN_TAG) {
54
+ } elseif (is_array($prev) && $prev[0] === T_OPEN_TAG) {
55
55
  $token = '';
56
56
  }
57
57
 
@@ -68,7 +68,7 @@ final class PhpHelpers
68
68
  throw new \LogicException('Unexpected token');
69
69
 
70
70
  } else {
71
- if (in_array($name, [T_CURLY_OPEN, T_DOLLAR_OPEN_CURLY_BRACES], true)) {
71
+ if (in_array($name, [T_CURLY_OPEN, T_DOLLAR_OPEN_CURLY_BRACES], strict: true)) {
72
72
  $level++;
73
73
  }
74
74
 
@@ -98,10 +98,13 @@ final class PhpHelpers
98
98
  }
99
99
 
100
100
 
101
+ /**
102
+ * Exports value to PHP code representation.
103
+ */
101
104
  public static function dump(mixed $value, bool $multiline = false): string
102
105
  {
103
106
  if (is_array($value)) {
104
- $indexed = $value && array_keys($value) === range(0, count($value) - 1);
107
+ $indexed = array_is_list($value);
105
108
  $s = '';
106
109
  foreach ($value as $k => $v) {
107
110
  $s .= $multiline
@@ -113,33 +116,37 @@ final class PhpHelpers
113
116
  } elseif ($value === null) {
114
117
  return 'null';
115
118
  } else {
116
- return var_export($value, true);
119
+ return var_export($value, return: true);
117
120
  }
118
121
  }
119
122
 
120
123
 
124
+ /**
125
+ * Optimizes consecutive echo statements into single call.
126
+ */
121
127
  public static function optimizeEcho(string $source): string
122
128
  {
123
129
  $res = '';
124
130
  $tokens = token_get_all($source);
125
131
  $start = null;
132
+ $str = '';
126
133
 
127
- for ($i = 0; $i < \count($tokens); $i++) {
134
+ for ($i = 0; $i < count($tokens); $i++) {
128
135
  $token = $tokens[$i];
129
136
  if ($token[0] === T_ECHO) {
130
- if (!$start) {
137
+ if ($start === null) {
131
138
  $str = '';
132
139
  $start = strlen($res);
133
140
  }
134
141
 
135
- } elseif ($start && $token[0] === T_CONSTANT_ENCAPSED_STRING && $token[1][0] === "'") {
142
+ } elseif ($start !== null && $token[0] === T_CONSTANT_ENCAPSED_STRING && $token[1][0] === "'") {
136
143
  $str .= stripslashes(substr($token[1], 1, -1));
137
144
 
138
- } elseif ($start && $token === ';') {
145
+ } elseif ($start !== null && $token === ';') {
139
146
  if ($str !== '') {
140
147
  $res = substr_replace(
141
148
  $res,
142
- 'echo ' . ($str === "\n" ? '"\n"' : var_export($str, true)),
149
+ 'echo ' . ($str === "\n" ? '"\n"' : var_export($str, return: true)),
143
150
  $start,
144
151
  strlen($res) - $start,
145
152
  );
@@ -156,7 +163,10 @@ final class PhpHelpers
156
163
  }
157
164
 
158
165
 
159
- public static function decodeNumber(string $str, &$base = null): int|float|null
166
+ /**
167
+ * Decodes number string to int or float value.
168
+ */
169
+ public static function decodeNumber(string $str, ?int &$base = null): int|float|null
160
170
  {
161
171
  $str = str_replace('_', '', $str);
162
172
 
@@ -185,7 +195,7 @@ final class PhpHelpers
185
195
  }
186
196
 
187
197
  return preg_replace_callback(
188
- '~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3}|u\{([0-9a-fA-F]+)\})~',
198
+ '~\\\([\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3}|u\{([0-9a-fA-F]+)\})~',
189
199
  function ($matches) {
190
200
  $ch = $matches[1];
191
201
  $replacements = [
@@ -201,11 +211,15 @@ final class PhpHelpers
201
211
  if (isset($replacements[$ch])) {
202
212
  return $replacements[$ch];
203
213
  } elseif ($ch[0] === 'x' || $ch[0] === 'X') {
204
- return chr(hexdec(substr($ch, 1)));
214
+ return chr((int) hexdec(substr($ch, 1)));
205
215
  } elseif ($ch[0] === 'u') {
206
- return self::codePointToUtf8(hexdec($matches[2]));
216
+ return self::codePointToUtf8((int) hexdec($matches[2]));
207
217
  } else {
208
- return chr(octdec($ch));
218
+ $num = (int) octdec($ch);
219
+ if ($num > 255) {
220
+ throw new CompileException("Octal escape sequence \\$ch is greater than \\377");
221
+ }
222
+ return chr($num);
209
223
  }
210
224
  },
211
225
  $str,
@@ -1,21 +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;
11
9
 
10
+ use function strlen, strrpos, substr_count;
11
+
12
12
 
13
- final class Position
13
+ final readonly class Position
14
14
  {
15
15
  public function __construct(
16
- public /*readonly*/ int $line = 1,
17
- public /*readonly*/ int $column = 1,
18
- public /*readonly*/ int $offset = 0,
16
+ public int $line = 1,
17
+ public int $column = 1,
18
+ public int $offset = 0,
19
19
  ) {
20
20
  }
21
21
 
@@ -1,82 +1,42 @@
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;
11
9
 
12
10
  use Latte\Compiler\Nodes\Php as Nodes;
13
11
  use Latte\Compiler\Nodes\Php\Expression;
12
+ use Latte\Compiler\Nodes\Php\OperatorNode;
14
13
  use Latte\Compiler\Nodes\Php\Scalar;
15
14
  use Latte\ContentType;
15
+ use Latte\Feature;
16
+ use function addcslashes, array_pop, count, end, implode, preg_replace, preg_replace_callback, strtolower, substr, trim, ucfirst;
16
17
 
17
18
 
18
19
  /**
19
- * PHP printing helpers and context.
20
- * The parts are based on great nikic/PHP-Parser project by Nikita Popov.
20
+ * Context for PHP code generation with escaping management.
21
21
  */
22
22
  final class PrintContext
23
23
  {
24
+ /** @var Nodes\ParameterNode[] */
24
25
  public array $paramsExtraction = [];
25
- public array $blocks = [];
26
26
 
27
- private array $exprPrecedenceMap = [
28
- // [precedence, associativity] (-1 is %left, 0 is %nonassoc and 1 is %right)
29
- Expression\PreOpNode::class => [10, 1],
30
- Expression\PostOpNode::class => [10, -1],
31
- Expression\UnaryOpNode::class => [10, 1],
32
- Expression\CastNode::class => [10, 1],
33
- Expression\ErrorSuppressNode::class => [10, 1],
34
- Expression\InstanceofNode::class => [20, 0],
35
- Expression\NotNode::class => [30, 1],
36
- Expression\TernaryNode::class => [150, 0],
37
- // parser uses %left for assignments, but they really behave as %right
38
- Expression\AssignNode::class => [160, 1],
39
- Expression\AssignOpNode::class => [160, 1],
40
- ];
41
-
42
- private array $binaryPrecedenceMap = [
43
- // [precedence, associativity] (-1 is %left, 0 is %nonassoc and 1 is %right)
44
- '**' => [0, 1],
45
- '*' => [40, -1],
46
- '/' => [40, -1],
47
- '%' => [40, -1],
48
- '+' => [50, -1],
49
- '-' => [50, -1],
50
- '.' => [50, -1],
51
- '<<' => [60, -1],
52
- '>>' => [60, -1],
53
- '<' => [70, 0],
54
- '<=' => [70, 0],
55
- '>' => [70, 0],
56
- '>=' => [70, 0],
57
- '==' => [80, 0],
58
- '!=' => [80, 0],
59
- '===' => [80, 0],
60
- '!==' => [80, 0],
61
- '<=>' => [80, 0],
62
- '&' => [90, -1],
63
- '^' => [100, -1],
64
- '|' => [110, -1],
65
- '&&' => [120, -1],
66
- '||' => [130, -1],
67
- '??' => [140, 1],
68
- 'and' => [170, -1],
69
- 'xor' => [180, -1],
70
- 'or' => [190, -1],
71
- ];
27
+ /** @var array<string, Block> */
28
+ public array $blocks = [];
72
29
  private int $counter = 0;
73
30
 
74
31
  /** @var Escaper[] */
75
32
  private array $escaperStack = [];
76
33
 
77
34
 
78
- public function __construct(string $contentType = ContentType::Html)
79
- {
35
+ public function __construct(
36
+ string $contentType = ContentType::Html,
37
+ /** @var array<string, bool> */
38
+ private array $features = [],
39
+ ) {
80
40
  $this->escaperStack[] = new Escaper($contentType);
81
41
  }
82
42
 
@@ -106,7 +66,7 @@ final class PrintContext
106
66
  return match ($fn) {
107
67
  'modify' => $args[$pos]->printSimple($this, $var),
108
68
  'modifyContent' => $args[$pos]->printContentAware($this, $var),
109
- 'escape' => end($this->escaperStack)->escape($var),
69
+ 'escape' => $this->getEscaper()->escape($var),
110
70
  };
111
71
  },
112
72
  $mask,
@@ -115,36 +75,46 @@ final class PrintContext
115
75
  return preg_replace_callback(
116
76
  '#([,+]?\s*)? % (\d+) \. ([a-z]{3,}) (\?)? (\s*\+\s*)? ()#xi',
117
77
  function ($m) use ($args) {
118
- [, $l, $pos, $format, $cond, $r] = $m;
78
+ [, $left, $pos, $format, $cond, $right] = $m;
119
79
  $arg = $args[$pos];
120
80
 
121
81
  $code = match ($format) {
122
82
  'dump' => PhpHelpers::dump($arg),
123
- 'node' => $arg ? $arg->print($this) : '',
83
+ 'node' => match (true) {
84
+ !$arg => '',
85
+ $arg instanceof OperatorNode && $arg->getOperatorPrecedence() < Expression\AssignNode::Precedence => '(' . $arg->print($this) . ')',
86
+ default => $arg->print($this),
87
+ },
124
88
  'raw' => (string) $arg,
125
89
  'args' => $this->implode($arg instanceof Expression\ArrayNode ? $arg->toArguments() : $arg),
126
- 'line' => $arg?->line ? "/* line $arg->line */" : '',
90
+ 'line' => $arg?->line ? "/* pos $arg->line" . ($arg->column ? ":$arg->column" : '') . ' */' : '',
127
91
  };
128
92
 
129
- if ($cond && ($code === '[]' || $code === '')) {
130
- return $r ? $l : $r;
93
+ if ($cond && ($code === '[]' || $code === '' || $code === 'null')) {
94
+ return $right ? $left : $right;
131
95
  }
132
96
 
133
97
  return $code === ''
134
- ? trim($l) . $r
135
- : $l . $code . $r;
98
+ ? trim($left) . $right
99
+ : $left . $code . $right;
136
100
  },
137
101
  $mask,
138
102
  );
139
103
  }
140
104
 
141
105
 
106
+ /**
107
+ * Pushes current escaper onto stack.
108
+ */
142
109
  public function beginEscape(): Escaper
143
110
  {
144
111
  return $this->escaperStack[] = $this->getEscaper();
145
112
  }
146
113
 
147
114
 
115
+ /**
116
+ * Restores previous escaper from stack.
117
+ */
148
118
  public function restoreEscape(): void
149
119
  {
150
120
  array_pop($this->escaperStack);
@@ -153,7 +123,9 @@ final class PrintContext
153
123
 
154
124
  public function getEscaper(): Escaper
155
125
  {
156
- return clone end($this->escaperStack);
126
+ $escaper = end($this->escaperStack);
127
+ assert($escaper instanceof Escaper);
128
+ return clone $escaper;
157
129
  }
158
130
 
159
131
 
@@ -173,12 +145,21 @@ final class PrintContext
173
145
  }
174
146
 
175
147
 
148
+ /**
149
+ * Generates unique ID for temporary variables.
150
+ */
176
151
  public function generateId(): int
177
152
  {
178
153
  return $this->counter++;
179
154
  }
180
155
 
181
156
 
157
+ public function hasFeature(Feature $feature): bool
158
+ {
159
+ return $this->features[$feature->name] ?? false;
160
+ }
161
+
162
+
182
163
  // PHP helpers
183
164
 
184
165
 
@@ -190,67 +171,45 @@ final class PrintContext
190
171
  }
191
172
 
192
173
 
193
- /**
194
- * Prints an infix operation while taking precedence into account.
195
- */
174
+ #[\Deprecated]
196
175
  public function infixOp(Node $node, Node $leftNode, string $operatorString, Node $rightNode): string
197
176
  {
198
- [$precedence, $associativity] = $this->getPrecedence($node);
199
- return $this->prec($leftNode, $precedence, $associativity, -1)
177
+ return $this->parenthesize($node, $leftNode, OperatorNode::AssocLeft)
200
178
  . $operatorString
201
- . $this->prec($rightNode, $precedence, $associativity, 1);
179
+ . $this->parenthesize($node, $rightNode, OperatorNode::AssocRight);
202
180
  }
203
181
 
204
182
 
205
- /**
206
- * Prints a prefix operation while taking precedence into account.
207
- */
183
+ #[\Deprecated]
208
184
  public function prefixOp(Node $node, string $operatorString, Node $expr): string
209
185
  {
210
- [$precedence, $associativity] = $this->getPrecedence($node);
211
- return $operatorString . $this->prec($expr, $precedence, $associativity, 1);
186
+ return $operatorString . $this->parenthesize($node, $expr, OperatorNode::AssocRight);
212
187
  }
213
188
 
214
189
 
215
- /**
216
- * Prints a postfix operation while taking precedence into account.
217
- */
190
+ #[\Deprecated]
218
191
  public function postfixOp(Node $node, Node $var, string $operatorString): string
219
192
  {
220
- [$precedence, $associativity] = $this->getPrecedence($node);
221
- return $this->prec($var, $precedence, $associativity, -1) . $operatorString;
193
+ return $this->parenthesize($node, $var, OperatorNode::AssocLeft) . $operatorString;
222
194
  }
223
195
 
224
196
 
225
197
  /**
226
198
  * Prints an expression node with the least amount of parentheses necessary to preserve the meaning.
227
199
  */
228
- private function prec(Node $node, int $parentPrecedence, int $parentAssociativity, int $childPosition): string
229
- {
230
- $precedence = $this->getPrecedence($node);
231
- if ($precedence) {
232
- $childPrecedence = $precedence[0];
233
- if ($childPrecedence > $parentPrecedence
234
- || ($parentPrecedence === $childPrecedence && $parentAssociativity !== $childPosition)
235
- ) {
236
- return '(' . $node->print($this) . ')';
237
- }
238
- }
239
-
240
- return $node->print($this);
241
- }
242
-
243
-
244
- private function getPrecedence(Node $node): ?array
200
+ public function parenthesize(OperatorNode $parentNode, Node $childNode, int $childPosition): string
245
201
  {
246
- return $node instanceof Expression\BinaryOpNode
247
- ? $this->binaryPrecedenceMap[$node->operator]
248
- : $this->exprPrecedenceMap[$node::class] ?? null;
202
+ [$parentPrec, $parentAssoc] = $parentNode->getOperatorPrecedence();
203
+ [$childPrec] = $childNode instanceof OperatorNode ? $childNode->getOperatorPrecedence() : [null];
204
+ return $childPrec && ($childPrec < $parentPrec || ($parentPrec === $childPrec && $parentAssoc !== $childPosition))
205
+ ? '(' . $childNode->print($this) . ')'
206
+ : $childNode->print($this);
249
207
  }
250
208
 
251
209
 
252
210
  /**
253
211
  * Prints an array of nodes and implodes the printed values with $glue
212
+ * @param (?Node)[] $nodes
254
213
  */
255
214
  public function implode(array $nodes, string $glue = ', '): string
256
215
  {
@@ -292,11 +251,8 @@ final class PrintContext
292
251
  || $expr instanceof Expression\VariableNode
293
252
  || $expr instanceof Expression\ArrayAccessNode
294
253
  || $expr instanceof Expression\FunctionCallNode
295
- || $expr instanceof Expression\FunctionCallableNode
296
254
  || $expr instanceof Expression\MethodCallNode
297
- || $expr instanceof Expression\MethodCallableNode
298
255
  || $expr instanceof Expression\StaticMethodCallNode
299
- || $expr instanceof Expression\StaticMethodCallableNode
300
256
  || $expr instanceof Expression\ArrayNode
301
257
  ? $expr->print($this)
302
258
  : '(' . $expr->print($this) . ')';
@@ -314,11 +270,8 @@ final class PrintContext
314
270
  || $expr instanceof Expression\PropertyFetchNode
315
271
  || $expr instanceof Expression\StaticPropertyFetchNode
316
272
  || $expr instanceof Expression\FunctionCallNode
317
- || $expr instanceof Expression\FunctionCallableNode
318
273
  || $expr instanceof Expression\MethodCallNode
319
- || $expr instanceof Expression\MethodCallableNode
320
274
  || $expr instanceof Expression\StaticMethodCallNode
321
- || $expr instanceof Expression\StaticMethodCallableNode
322
275
  || $expr instanceof Expression\ArrayNode
323
276
  || $expr instanceof Scalar\StringNode
324
277
  || $expr instanceof Scalar\BooleanNode
@@ -338,4 +291,19 @@ final class PrintContext
338
291
  $items = array_map(fn(Nodes\ArgumentNode $arg) => $arg->toArrayItem(), $args);
339
292
  return '[' . $this->implode($items) . ']';
340
293
  }
294
+
295
+
296
+ /**
297
+ * Ensures that expression evaluates to string or throws exception.
298
+ */
299
+ public function ensureString(Nodes\ExpressionNode $name, string $entity): string
300
+ {
301
+ return $name instanceof Scalar\StringNode
302
+ ? $name->print($this)
303
+ : $this->format(
304
+ '(LR\Helpers::stringOrNull($ʟ_tmp = %node) ?? throw new InvalidArgumentException(sprintf(%dump, get_debug_type($ʟ_tmp))))',
305
+ $name,
306
+ $entity . ' must be a string, %s given.',
307
+ );
308
+ }
341
309
  }
@@ -1,21 +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;
11
9
 
12
10
  use Latte\CompileException;
13
11
  use Latte\Compiler\Nodes\AreaNode;
14
12
  use Latte\Compiler\Nodes\Html\ElementNode;
13
+ use function array_search, in_array;
15
14
 
16
15
 
17
16
  /**
18
- * Latte tag or n:attribute.
17
+ * Represents a Latte tag or n:attribute during parsing.
19
18
  */
20
19
  final class Tag
21
20
  {
@@ -33,19 +32,20 @@ final class Tag
33
32
  public int $outputMode = self::OutputNone;
34
33
 
35
34
 
35
+ /** @param list<Token> $tokens */
36
36
  public function __construct(
37
- public /*readonly*/ string $name,
37
+ public readonly string $name,
38
38
  array $tokens,
39
- public /*readonly*/ Position $position,
40
- public /*readonly*/ bool $void = false,
41
- public /*readonly*/ bool $closing = false,
42
- public /*readonly*/ bool $inHead = false,
43
- public /*readonly*/ bool $inTag = false,
44
- public /*readonly*/ ?ElementNode $htmlElement = null,
39
+ public readonly Position $position,
40
+ public readonly bool $void = false,
41
+ public readonly bool $closing = false,
42
+ public readonly bool $inHead = false,
43
+ public readonly bool $inTag = false,
44
+ public readonly ?ElementNode $htmlElement = null,
45
45
  public ?self $parent = null,
46
- public /*readonly*/ ?string $prefix = null,
46
+ public readonly ?string $prefix = null,
47
47
  public ?AreaNode $node = null,
48
- public ?AreaNode $nAttributeNode = null,
48
+ public ?AreaNode $nAttribute = null,
49
49
  ) {
50
50
  $this->parser = new TagParser($tokens);
51
51
  }
@@ -90,7 +90,7 @@ final class Tag
90
90
  {
91
91
  $tag = $this->parent;
92
92
  while ($tag && (
93
- (!in_array($tag->node ? $tag->node::class : null, $classes, true) && !in_array($tag->name, $classes, true))
93
+ !in_array($tag->node ? $tag->node::class : null, $classes, strict: true)
94
94
  || ($condition && !$condition($tag))
95
95
  )) {
96
96
  $tag = $tag->parent;
@@ -110,7 +110,8 @@ final class Tag
110
110
 
111
111
  public function replaceNAttribute(AreaNode $node): void
112
112
  {
113
- $index = array_search($this->nAttributeNode, $this->htmlElement->attributes->children, true);
114
- $this->htmlElement->attributes->children[$index] = $this->nAttributeNode = $node;
113
+ assert($this->htmlElement !== null);
114
+ $index = array_search($this->nAttribute, $this->htmlElement->attributes->children, strict: true);
115
+ $this->htmlElement->attributes->children[$index] = $this->nAttribute = $node;
115
116
  }
116
117
  }