@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.
- package/README.md +1 -1
- package/index.js +4 -2
- package/package.json +11 -9
- package/types/index.d.ts +1 -1
- package/vendor/autoload.php +1 -4
- package/vendor/composer/InstalledVersions.php +36 -2
- package/vendor/composer/autoload_classmap.php +14 -15
- package/vendor/composer/autoload_psr4.php +2 -0
- package/vendor/composer/autoload_static.php +38 -15
- package/vendor/composer/installed.json +32 -22
- package/vendor/composer/installed.php +12 -12
- package/vendor/composer/platform_check.php +4 -5
- package/vendor/latte/latte/bin/latte-lint +10 -3
- package/vendor/latte/latte/composer.json +16 -6
- package/vendor/latte/latte/src/Bridges/Tracy/BlueScreenPanel.php +13 -38
- package/vendor/latte/latte/src/Bridges/Tracy/LattePanel.php +9 -7
- package/vendor/latte/latte/src/Bridges/Tracy/TracyExtension.php +2 -4
- package/vendor/latte/latte/src/Bridges/Tracy/dist/panel.phtml +94 -0
- package/vendor/latte/latte/src/Bridges/Tracy/dist/tab.phtml +10 -0
- package/vendor/latte/latte/src/Latte/Compiler/Block.php +4 -6
- package/vendor/latte/latte/src/Latte/Compiler/Escaper.php +67 -86
- package/vendor/latte/latte/src/Latte/Compiler/Node.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/NodeHelpers.php +16 -6
- package/vendor/latte/latte/src/Latte/Compiler/NodeTraverser.php +25 -12
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AreaNode.php +7 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AuxiliaryNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/FragmentNode.php +8 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/AttributeNode.php +7 -15
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/BogusTagNode.php +4 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/CommentNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ElementNode.php +37 -67
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ExpressionAttributeNode.php +60 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/TagNode.php +70 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/NopNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArgumentNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArrayItemNode.php +4 -15
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ClosureUseNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ComplexTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayAccessNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayNode.php +6 -22
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignNode.php +18 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php +18 -7
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AuxiliaryNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/BinaryOpNode.php +38 -9
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CastNode.php +14 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClassConstantFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CloneNode.php +12 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureNode.php +10 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ConstantFetchNode.php +7 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/EmptyNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FilterCallNode.php +10 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallNode.php +14 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InstanceofNode.php +14 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/IssetNode.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MatchNode.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallNode.php +18 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NewNode.php +14 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PostOpNode.php +14 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PreOpNode.php +14 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticMethodCallNode.php +14 -15
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticPropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TemporaryNode.php +7 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TernaryNode.php +16 -11
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/UnaryOpNode.php +19 -9
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/VariableNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ExpressionNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/FilterNode.php +33 -8
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IdentifierNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/InterpolatedStringPartNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IntersectionTypeNode.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListItemNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/MatchArmNode.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ModifierNode.php +29 -41
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NameNode.php +9 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NullableTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/OperatorNode.php +27 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ParameterNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/BooleanNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/FloatNode.php +9 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/IntegerNode.php +8 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/InterpolatedStringNode.php +9 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/NullNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/StringNode.php +6 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ScalarNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/SuperiorTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/UnionTypeNode.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/VarLikeIdentifierNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/{Expression/NotNode.php → VariadicPlaceholderNode.php} +9 -9
- package/vendor/latte/latte/src/Latte/{Essential → Compiler}/Nodes/PrintNode.php +9 -15
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/StatementNode.php +7 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TemplateNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TextNode.php +6 -4
- package/vendor/latte/latte/src/Latte/Compiler/PhpHelpers.php +32 -18
- package/vendor/latte/latte/src/Latte/Compiler/Position.php +7 -7
- package/vendor/latte/latte/src/Latte/Compiler/PrintContext.php +72 -104
- package/vendor/latte/latte/src/Latte/Compiler/Tag.php +17 -16
- package/vendor/latte/latte/src/Latte/Compiler/TagLexer.php +11 -8
- package/vendor/latte/latte/src/Latte/Compiler/TagParser.php +28 -23
- package/vendor/latte/latte/src/Latte/Compiler/TagParserData.php +360 -336
- package/vendor/latte/latte/src/Latte/Compiler/TemplateGenerator.php +49 -38
- package/vendor/latte/latte/src/Latte/Compiler/TemplateLexer.php +37 -12
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParser.php +35 -21
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParserHtml.php +121 -71
- package/vendor/latte/latte/src/Latte/Compiler/Token.php +79 -70
- package/vendor/latte/latte/src/Latte/Compiler/TokenStream.php +21 -14
- package/vendor/latte/latte/src/Latte/ContentType.php +4 -3
- package/vendor/latte/latte/src/Latte/Engine.php +147 -188
- package/vendor/latte/latte/src/Latte/Essential/AuxiliaryIterator.php +5 -7
- package/vendor/latte/latte/src/Latte/Essential/Blueprint.php +5 -5
- package/vendor/latte/latte/src/Latte/Essential/CachingIterator.php +5 -4
- package/vendor/latte/latte/src/Latte/Essential/CoreExtension.php +155 -127
- package/vendor/latte/latte/src/Latte/Essential/Filters.php +99 -44
- package/vendor/latte/latte/src/Latte/Essential/Nodes/BlockNode.php +14 -13
- package/vendor/latte/latte/src/Latte/Essential/Nodes/CaptureNode.php +5 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ContentTypeNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/CustomFunctionCallNode.php +46 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DebugbreakNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DefineNode.php +10 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DoNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DumpNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/EmbedNode.php +8 -9
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ExtendsNode.php +3 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/FirstLastSepNode.php +4 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForNode.php +6 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForeachNode.php +7 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfChangedNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfContentNode.php +7 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfNode.php +11 -11
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ImportNode.php +5 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeBlockNode.php +26 -27
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeFileNode.php +7 -10
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IterateWhileNode.php +6 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/JumpNode.php +4 -8
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NAttrNode.php +35 -47
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NClassNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NElseNode.php +69 -34
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NTagNode.php +9 -33
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ParametersNode.php +7 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RawPhpNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RollbackNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SpacelessNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SwitchNode.php +9 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplatePrintNode.php +4 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplateTypeNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TraceNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TranslateNode.php +5 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TryNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarNode.php +10 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarPrintNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarTypeNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/WhileNode.php +5 -5
- package/vendor/latte/latte/src/Latte/Essential/Passes.php +82 -21
- package/vendor/latte/latte/src/Latte/Essential/RawPhpExtension.php +2 -4
- package/vendor/latte/latte/src/Latte/Essential/RollbackException.php +1 -3
- package/vendor/latte/latte/src/Latte/Essential/Tracer.php +24 -28
- package/vendor/latte/latte/src/Latte/Essential/TranslatorExtension.php +14 -14
- package/vendor/latte/latte/src/Latte/Extension.php +12 -6
- package/vendor/latte/latte/src/Latte/Feature.php +24 -0
- package/vendor/latte/latte/src/Latte/Helpers.php +65 -15
- package/vendor/latte/latte/src/Latte/Loader.php +1 -9
- package/vendor/latte/latte/src/Latte/Loaders/FileLoader.php +11 -17
- package/vendor/latte/latte/src/Latte/Loaders/StringLoader.php +7 -21
- package/vendor/latte/latte/src/Latte/Policy.php +4 -3
- package/vendor/latte/latte/src/Latte/Runtime/Block.php +2 -4
- package/vendor/latte/latte/src/Latte/Runtime/Cache.php +143 -0
- package/vendor/latte/latte/src/Latte/Runtime/FilterExecutor.php +5 -6
- package/vendor/latte/latte/src/Latte/Runtime/FilterInfo.php +11 -11
- package/vendor/latte/latte/src/Latte/Runtime/FunctionExecutor.php +5 -6
- package/vendor/latte/latte/src/Latte/Runtime/Helpers.php +91 -0
- package/vendor/latte/latte/src/Latte/Runtime/Html.php +3 -5
- package/vendor/latte/latte/src/Latte/Runtime/HtmlHelpers.php +374 -0
- package/vendor/latte/latte/src/Latte/Runtime/HtmlStringable.php +1 -3
- package/vendor/latte/latte/src/Latte/Runtime/Template.php +162 -182
- package/vendor/latte/latte/src/Latte/Runtime/XmlHelpers.php +108 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallNode.php +12 -4
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallNode.php +15 -5
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/PropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/SandboxNode.php +5 -6
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticMethodCallNode.php +14 -4
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticPropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Sandbox/RuntimeChecker.php +8 -6
- package/vendor/latte/latte/src/Latte/Sandbox/SandboxExtension.php +16 -12
- package/vendor/latte/latte/src/Latte/Sandbox/SecurityPolicy.php +18 -16
- package/vendor/latte/latte/src/Latte/attributes.php +7 -3
- package/vendor/latte/latte/src/Latte/exceptions.php +52 -6
- package/vendor/latte/latte/src/Tools/Linter.php +74 -28
- package/vendor/latte/latte/src/Tools/LinterExtension.php +176 -0
- package/vendor/nette/utils/composer.json +15 -5
- package/vendor/nette/utils/readme.md +1 -1
- package/vendor/nette/utils/src/HtmlStringable.php +4 -1
- package/vendor/nette/utils/src/Iterators/CachingIterator.php +10 -25
- package/vendor/nette/utils/src/Iterators/Mapper.php +2 -3
- package/vendor/nette/utils/src/SmartObject.php +3 -0
- package/vendor/nette/utils/src/StaticClass.php +1 -11
- package/vendor/nette/utils/src/Translator.php +1 -1
- package/vendor/nette/utils/src/Utils/ArrayHash.php +6 -10
- package/vendor/nette/utils/src/Utils/ArrayList.php +8 -12
- package/vendor/nette/utils/src/Utils/Arrays.php +38 -18
- package/vendor/nette/utils/src/Utils/Callback.php +13 -8
- package/vendor/nette/utils/src/Utils/DateTime.php +95 -26
- package/vendor/nette/utils/src/Utils/FileInfo.php +6 -7
- package/vendor/nette/utils/src/Utils/FileSystem.php +10 -5
- package/vendor/nette/utils/src/Utils/Finder.php +31 -12
- package/vendor/nette/utils/src/Utils/Floats.php +1 -0
- package/vendor/nette/utils/src/Utils/Helpers.php +22 -2
- package/vendor/nette/utils/src/Utils/Html.php +130 -127
- package/vendor/nette/utils/src/Utils/Image.php +80 -60
- package/vendor/nette/utils/src/Utils/ImageColor.php +5 -0
- package/vendor/nette/utils/src/Utils/ImageType.php +2 -0
- package/vendor/nette/utils/src/Utils/Iterables.php +41 -7
- package/vendor/nette/utils/src/Utils/Json.php +2 -0
- package/vendor/nette/utils/src/Utils/ObjectHelpers.php +2 -0
- package/vendor/nette/utils/src/Utils/Paginator.php +10 -43
- package/vendor/nette/utils/src/Utils/Random.php +2 -0
- package/vendor/nette/utils/src/Utils/Reflection.php +22 -15
- package/vendor/nette/utils/src/Utils/ReflectionMethod.php +6 -1
- package/vendor/nette/utils/src/Utils/Strings.php +62 -57
- package/vendor/nette/utils/src/Utils/Type.php +91 -42
- package/vendor/nette/utils/src/Utils/Validators.php +9 -7
- package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.panel.phtml +0 -101
- package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.tab.phtml +0 -15
- package/vendor/latte/latte/src/Latte/Compiler/ExpressionBuilder.php +0 -129
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ErrorSuppressNode.php +0 -36
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallableNode.php +0 -39
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallableNode.php +0 -42
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticMethodCallableNode.php +0 -57
- package/vendor/latte/latte/src/Latte/PositionAwareException.php +0 -47
- package/vendor/latte/latte/src/Latte/Runtime/Filters.php +0 -283
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallableNode.php +0 -29
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallableNode.php +0 -30
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticMethodCallableNode.php +0 -30
|
@@ -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 array_splice, constant, count, is_float, is_int, is_numeric, ord, preg_last_error, preg_last_error_msg, preg_match, preg_match_all, str_contains, str_replace, str_split, strlen, strtolower, substr, trim;
|
|
12
|
+
use const PREG_SET_ORDER, PREG_UNMATCHED_AS_NULL;
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -82,8 +82,8 @@ final class TagLexer
|
|
|
82
82
|
{
|
|
83
83
|
preg_match(
|
|
84
84
|
$colon
|
|
85
|
-
? '~ ( [./@_a-z0-9#!-] | :(?!:) | \{\$ [_a-z0-9\[\]()>-]+ })++ (?=\s+[!"\'$(\[{
|
|
86
|
-
: '~ ( [./@_a-z0-9#!-] | \{\$ [_a-z0-9\[\]()>-]+ })++ (?=\s+[!"\'$(\[{
|
|
85
|
+
? '~ ( [./@_a-z0-9#!-] | :(?!:) | \{\$ [_a-z0-9\[\]()>-]+ } )++ (?=\s+[!"\'$(\[{,\\\|\~\w-] | [,|] | \s*$) ~xAi'
|
|
86
|
+
: '~ ( [./@_a-z0-9#!-] | \{\$ [_a-z0-9\[\]()>-]+ } )++ (?=\s+[!"\'$(\[{,\\\|\~\w-] | [,:|] | \s*$) ~xAi',
|
|
87
87
|
$input,
|
|
88
88
|
$match,
|
|
89
89
|
offset: $position->offset - $offsetDelta,
|
|
@@ -145,8 +145,11 @@ final class TagLexer
|
|
|
145
145
|
(?<Php_PowEqual> \*\*= )|
|
|
146
146
|
(?<Php_CoalesceEqual> \?\?= )|
|
|
147
147
|
(?<Php_Coalesce> \?\? )|
|
|
148
|
+
(?<Php_NullsafePipe> \?\| )|
|
|
148
149
|
(?<Php_BooleanOr> \|\| )|
|
|
149
150
|
(?<Php_BooleanAnd> && )|
|
|
151
|
+
(?<Php_Pipe> \|> )|
|
|
152
|
+
(?<Php_FilterPipe> \| (?= [ \t]* [a-z] ) )|
|
|
150
153
|
(?<Php_AmpersandFollowed> & (?= [ \t\r\n]* (\$|\.\.\.) ) )|
|
|
151
154
|
(?<Php_AmpersandNotFollowed> & )|
|
|
152
155
|
(?<Php_IsIdentical> === )|
|
|
@@ -206,7 +209,7 @@ final class TagLexer
|
|
|
206
209
|
|| isset($m[$type = 'Php_NullsafeObjectOperator'])
|
|
207
210
|
|| isset($m[$type = 'Php_UndefinedsafeObjectOperator'])
|
|
208
211
|
) {
|
|
209
|
-
$this->addToken(constant(Token::class . '::' . $type), $m[$type]);
|
|
212
|
+
$this->addToken(constant(Token::class . '::' . $type), $m[$type] ?? '');
|
|
210
213
|
if (isset($m['Php_Whitespace'])) {
|
|
211
214
|
$this->addToken(Token::Php_Whitespace, $m['Php_Whitespace']);
|
|
212
215
|
}
|
|
@@ -356,8 +359,8 @@ final class TagLexer
|
|
|
356
359
|
|| isset($m[$type = 'Php_NullsafeObjectOperator'])
|
|
357
360
|
|| isset($m[$type = 'Php_UndefinedsafeObjectOperator'])
|
|
358
361
|
) {
|
|
359
|
-
$this->addToken(constant(Token::class . '::' . $type), $m[$type]);
|
|
360
|
-
$this->addToken(Token::Php_Identifier, $m['Php_Identifier']);
|
|
362
|
+
$this->addToken(constant(Token::class . '::' . $type), $m[$type] ?? '');
|
|
363
|
+
$this->addToken(Token::Php_Identifier, $m['Php_Identifier'] ?? '');
|
|
361
364
|
|
|
362
365
|
} elseif (isset($m['offset'])) {
|
|
363
366
|
$this->addToken(null, '[');
|
|
@@ -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;
|
|
11
9
|
|
|
12
10
|
use Latte;
|
|
@@ -16,14 +14,17 @@ use Latte\Compiler\Nodes\Php\Expression;
|
|
|
16
14
|
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
17
15
|
use Latte\Compiler\Nodes\Php\NameNode;
|
|
18
16
|
use Latte\Compiler\Nodes\Php\Scalar;
|
|
17
|
+
use function count, is_int, ord, preg_match, preg_replace, preg_replace_callback, str_contains, strlen, strtolower, substr;
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Parser for PHP-like expression language used in tags.
|
|
23
22
|
* Based on works by Nikita Popov, Moriyoshi Koizumi and Masato Bito.
|
|
24
23
|
*/
|
|
25
|
-
final class TagParser
|
|
24
|
+
final class TagParser
|
|
26
25
|
{
|
|
26
|
+
use TagParserData;
|
|
27
|
+
|
|
27
28
|
private const
|
|
28
29
|
SchemaExpression = 'e',
|
|
29
30
|
SchemaArguments = 'a',
|
|
@@ -32,17 +33,18 @@ final class TagParser extends TagParserData
|
|
|
32
33
|
|
|
33
34
|
private const SymbolNone = -1;
|
|
34
35
|
|
|
35
|
-
public TokenStream
|
|
36
|
+
public readonly TokenStream $stream;
|
|
36
37
|
public string $text;
|
|
37
38
|
|
|
38
|
-
/** @var \SplObjectStorage<Expression\ArrayNode> */
|
|
39
|
+
/** @var \SplObjectStorage<Expression\ArrayNode, null> */
|
|
39
40
|
protected \SplObjectStorage $shortArrays;
|
|
40
|
-
private int
|
|
41
|
+
private readonly int $offsetDelta;
|
|
41
42
|
|
|
42
43
|
|
|
44
|
+
/** @param array<int, mixed> $tokens */
|
|
43
45
|
public function __construct(array $tokens)
|
|
44
46
|
{
|
|
45
|
-
$this->offsetDelta = $tokens[0]->position->offset
|
|
47
|
+
$this->offsetDelta = $tokens[0]->position->offset;
|
|
46
48
|
$tokens = $this->filterTokens($tokens);
|
|
47
49
|
$this->stream = new TokenStream(new \ArrayIterator($tokens));
|
|
48
50
|
}
|
|
@@ -107,7 +109,7 @@ final class TagParser extends TagParserData
|
|
|
107
109
|
{
|
|
108
110
|
$kind = [
|
|
109
111
|
Token::Php_Identifier, Token::Php_Constant, Token::Php_Ellipsis, Token::Php_Array, Token::Php_Integer,
|
|
110
|
-
Token::Php_NameFullyQualified, Token::Php_NameQualified, Token::Php_Null, Token::Php_False,
|
|
112
|
+
Token::Php_NameFullyQualified, Token::Php_NameQualified, Token::Php_Null, Token::Php_False, Token::Php_FilterPipe,
|
|
111
113
|
'(', ')', '<', '>', '[', ']', '|', '&', '{', '}', ':', ',', '=', '?',
|
|
112
114
|
];
|
|
113
115
|
$res = null;
|
|
@@ -121,6 +123,7 @@ final class TagParser extends TagParserData
|
|
|
121
123
|
|
|
122
124
|
/**
|
|
123
125
|
* Parses variables used in foreach.
|
|
126
|
+
* @return array{?Nodes\Php\ExpressionNode, Nodes\Php\ExpressionNode|Nodes\Php\ListNode, bool}
|
|
124
127
|
* @internal
|
|
125
128
|
*/
|
|
126
129
|
public function parseForeach(): array
|
|
@@ -142,9 +145,10 @@ final class TagParser extends TagParserData
|
|
|
142
145
|
}
|
|
143
146
|
|
|
144
147
|
|
|
145
|
-
|
|
148
|
+
#[\Deprecated('use tryConsumeTokenBeforeUnquotedString()')]
|
|
146
149
|
public function tryConsumeModifier(string ...$kind): ?Token
|
|
147
150
|
{
|
|
151
|
+
trigger_error(__METHOD__ . '() was renamed to tryConsumeTokenBeforeUnquotedString()', E_USER_DEPRECATED);
|
|
148
152
|
return $this->tryConsumeTokenBeforeUnquotedString(...$kind);
|
|
149
153
|
}
|
|
150
154
|
|
|
@@ -287,15 +291,13 @@ final class TagParser extends TagParserData
|
|
|
287
291
|
}
|
|
288
292
|
|
|
289
293
|
|
|
290
|
-
public function throwReservedKeywordException(Token $token)
|
|
294
|
+
public function throwReservedKeywordException(Token $token): never
|
|
291
295
|
{
|
|
292
296
|
throw new Latte\CompileException("Keyword '$token->text' cannot be used in Latte.", $token->position);
|
|
293
297
|
}
|
|
294
298
|
|
|
295
299
|
|
|
296
|
-
|
|
297
|
-
Expression\FunctionCallNode|Expression\FunctionCallableNode $func,
|
|
298
|
-
): ExpressionNode
|
|
300
|
+
private function checkFunctionName(Expression\FunctionCallNode $func): Expression\FunctionCallNode
|
|
299
301
|
{
|
|
300
302
|
if ($func->name instanceof NameNode && $func->name->isKeyword()) {
|
|
301
303
|
$this->throwReservedKeywordException(new Token(0, (string) $func->name, $func->name->position));
|
|
@@ -304,7 +306,7 @@ final class TagParser extends TagParserData
|
|
|
304
306
|
}
|
|
305
307
|
|
|
306
308
|
|
|
307
|
-
|
|
309
|
+
private static function handleBuiltinTypes(NameNode $name): NameNode|Node\IdentifierNode
|
|
308
310
|
{
|
|
309
311
|
$builtinTypes = [
|
|
310
312
|
'bool' => true, 'int' => true, 'float' => true, 'string' => true, 'iterable' => true, 'void' => true,
|
|
@@ -318,7 +320,7 @@ final class TagParser extends TagParserData
|
|
|
318
320
|
}
|
|
319
321
|
|
|
320
322
|
|
|
321
|
-
|
|
323
|
+
private static function parseOffset(string $str, Position $position): Scalar\StringNode|Scalar\IntegerNode
|
|
322
324
|
{
|
|
323
325
|
if (!preg_match('/^(?:0|-?[1-9][0-9]*)$/', $str)) {
|
|
324
326
|
return new Scalar\StringNode($str, $position);
|
|
@@ -333,8 +335,8 @@ final class TagParser extends TagParserData
|
|
|
333
335
|
}
|
|
334
336
|
|
|
335
337
|
|
|
336
|
-
/** @param ExpressionNode[]
|
|
337
|
-
|
|
338
|
+
/** @param ExpressionNode[] $parts */
|
|
339
|
+
private function parseDocString(
|
|
338
340
|
string $startToken,
|
|
339
341
|
array $parts,
|
|
340
342
|
string $endToken,
|
|
@@ -359,7 +361,7 @@ final class TagParser extends TagParserData
|
|
|
359
361
|
$newParts = [];
|
|
360
362
|
foreach ($parts as $i => $part) {
|
|
361
363
|
if ($part instanceof Node\InterpolatedStringPartNode) {
|
|
362
|
-
$isLast = $i ===
|
|
364
|
+
$isLast = $i === count($parts) - 1;
|
|
363
365
|
$part->value = $this->stripIndentation(
|
|
364
366
|
$part->value,
|
|
365
367
|
$indentation,
|
|
@@ -404,7 +406,7 @@ final class TagParser extends TagParserData
|
|
|
404
406
|
return preg_replace_callback(
|
|
405
407
|
$regex,
|
|
406
408
|
function ($matches) use ($indentation, $position) {
|
|
407
|
-
$indentLen =
|
|
409
|
+
$indentLen = strlen($indentation);
|
|
408
410
|
$prefix = substr($matches[1], 0, $indentLen);
|
|
409
411
|
if (str_contains($prefix, $indentation[0] === ' ' ? "\t" : ' ')) {
|
|
410
412
|
throw new CompileException('Invalid indentation - tabs and spaces cannot be mixed', $position);
|
|
@@ -424,7 +426,7 @@ final class TagParser extends TagParserData
|
|
|
424
426
|
|
|
425
427
|
public function convertArrayToList(Expression\ArrayNode $array): Node\ListNode
|
|
426
428
|
{
|
|
427
|
-
$this->shortArrays
|
|
429
|
+
unset($this->shortArrays[$array]);
|
|
428
430
|
$items = [];
|
|
429
431
|
foreach ($array->items as $item) {
|
|
430
432
|
$value = $item->value;
|
|
@@ -433,7 +435,7 @@ final class TagParser extends TagParserData
|
|
|
433
435
|
}
|
|
434
436
|
$value = match (true) {
|
|
435
437
|
$value instanceof Expression\TemporaryNode => $value->value,
|
|
436
|
-
$value instanceof Expression\ArrayNode && $this->shortArrays
|
|
438
|
+
$value instanceof Expression\ArrayNode && isset($this->shortArrays[$value]) => $this->convertArrayToList($value),
|
|
437
439
|
default => $value,
|
|
438
440
|
};
|
|
439
441
|
$items[] = $value
|
|
@@ -456,7 +458,10 @@ final class TagParser extends TagParserData
|
|
|
456
458
|
}
|
|
457
459
|
|
|
458
460
|
|
|
459
|
-
/**
|
|
461
|
+
/**
|
|
462
|
+
* @param Token[] $tokens
|
|
463
|
+
* @return Token[]
|
|
464
|
+
*/
|
|
460
465
|
private function filterTokens(array $tokens): array
|
|
461
466
|
{
|
|
462
467
|
$this->text = '';
|