@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,32 +1,35 @@
|
|
|
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;
|
|
14
|
+
use function count, in_array, strtolower;
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Binary operation: arithmetic, logical, bitwise, comparison, null-coalescing, or pipe.
|
|
19
|
+
*/
|
|
20
|
+
class BinaryOpNode extends ExpressionNode implements OperatorNode
|
|
18
21
|
{
|
|
19
|
-
private const Ops = ['||', '&&', 'or', 'and', 'xor', '&', '^', '.', '+', '-', '*', '/', '%', '<<', '>>', '**',
|
|
20
|
-
'==', '!=', '===', '!==', '<=>', '<', '<=', '>', '>=', '??', ];
|
|
22
|
+
private const Ops = ['||', '&&', 'or', 'and', 'xor', '|', '&', '^', '.', '+', '-', '*', '/', '%', '<<', '>>', '**',
|
|
23
|
+
'==', '!=', '===', '!==', '<=>', '<', '<=', '>', '>=', '??', '|>'];
|
|
21
24
|
|
|
22
25
|
|
|
23
26
|
public function __construct(
|
|
24
27
|
public ExpressionNode $left,
|
|
25
|
-
public
|
|
28
|
+
public string $operator,
|
|
26
29
|
public ExpressionNode $right,
|
|
27
30
|
public ?Position $position = null,
|
|
28
31
|
) {
|
|
29
|
-
if (!in_array(strtolower($this->operator), self::Ops, true)) {
|
|
32
|
+
if (!in_array(strtolower($this->operator), self::Ops, strict: true)) {
|
|
30
33
|
throw new \InvalidArgumentException("Unexpected operator '$this->operator'");
|
|
31
34
|
}
|
|
32
35
|
}
|
|
@@ -53,7 +56,33 @@ class BinaryOpNode extends ExpressionNode
|
|
|
53
56
|
|
|
54
57
|
public function print(PrintContext $context): string
|
|
55
58
|
{
|
|
56
|
-
return $context->
|
|
59
|
+
return $context->parenthesize($this, $this->left, self::AssocLeft)
|
|
60
|
+
. ' ' . $this->operator . ' '
|
|
61
|
+
. $context->parenthesize($this, $this->right, self::AssocRight);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
public function getOperatorPrecedence(): array
|
|
66
|
+
{
|
|
67
|
+
return match (strtolower($this->operator)) {
|
|
68
|
+
'**' => [250, self::AssocRight],
|
|
69
|
+
'*', '/', '%' => [210, self::AssocLeft],
|
|
70
|
+
'+', '-' => [200, self::AssocLeft],
|
|
71
|
+
'<<', '>>' => [190, self::AssocLeft],
|
|
72
|
+
'.' => [185, self::AssocLeft],
|
|
73
|
+
'|>' => [183, self::AssocLeft],
|
|
74
|
+
'<', '<=', '>', '>=', '<=>' => [180, self::AssocNone],
|
|
75
|
+
'==', '!=', '===', '!==' => [170, self::AssocNone],
|
|
76
|
+
'&' => [160, self::AssocLeft],
|
|
77
|
+
'^' => [150, self::AssocLeft],
|
|
78
|
+
'|' => [140, self::AssocLeft],
|
|
79
|
+
'&&' => [130, self::AssocLeft],
|
|
80
|
+
'||' => [120, self::AssocLeft],
|
|
81
|
+
'??' => [110, self::AssocRight],
|
|
82
|
+
'and' => [50, self::AssocLeft],
|
|
83
|
+
'xor' => [40, self::AssocLeft],
|
|
84
|
+
'or' => [30, self::AssocLeft],
|
|
85
|
+
};
|
|
57
86
|
}
|
|
58
87
|
|
|
59
88
|
|
|
@@ -1,26 +1,28 @@
|
|
|
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
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Type cast (int), (string), (array), etc.
|
|
18
|
+
*/
|
|
19
|
+
class CastNode extends ExpressionNode implements OperatorNode
|
|
18
20
|
{
|
|
19
21
|
private const Types = ['int' => 1, 'float' => 1, 'string' => 1, 'array' => 1, 'object' => 1, 'bool' => 1];
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
public function __construct(
|
|
23
|
-
public
|
|
25
|
+
public string $type,
|
|
24
26
|
public ExpressionNode $expr,
|
|
25
27
|
public ?Position $position = null,
|
|
26
28
|
) {
|
|
@@ -32,7 +34,13 @@ class CastNode extends ExpressionNode
|
|
|
32
34
|
|
|
33
35
|
public function print(PrintContext $context): string
|
|
34
36
|
{
|
|
35
|
-
return
|
|
37
|
+
return '(' . $this->type . ') ' . $context->parenthesize($this, $this->expr, self::AssocRight);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
public function getOperatorPrecedence(): array
|
|
42
|
+
{
|
|
43
|
+
return [240, self::AssocRight];
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
|
package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClassConstantFetchNode.php
CHANGED
|
@@ -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
|
+
* Class constant access (Foo::CONST or Foo::class).
|
|
19
|
+
*/
|
|
19
20
|
class ClassConstantFetchNode extends ExpressionNode
|
|
20
21
|
{
|
|
21
22
|
public function __construct(
|
|
@@ -1,20 +1,22 @@
|
|
|
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
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Object cloning (clone $obj).
|
|
18
|
+
*/
|
|
19
|
+
class CloneNode extends ExpressionNode implements OperatorNode
|
|
18
20
|
{
|
|
19
21
|
public function __construct(
|
|
20
22
|
public ExpressionNode $expr,
|
|
@@ -29,6 +31,12 @@ class CloneNode extends ExpressionNode
|
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
|
|
34
|
+
public function getOperatorPrecedence(): array
|
|
35
|
+
{
|
|
36
|
+
return [270, self::AssocNone];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
32
40
|
public function &getIterator(): \Generator
|
|
33
41
|
{
|
|
34
42
|
yield $this->expr;
|
|
@@ -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;
|
|
@@ -14,8 +12,12 @@ use Latte\Compiler\Nodes\Php\ClosureUseNode;
|
|
|
14
12
|
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
15
13
|
use Latte\Compiler\Position;
|
|
16
14
|
use Latte\Compiler\PrintContext;
|
|
15
|
+
use Latte\Helpers;
|
|
17
16
|
|
|
18
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Closure or arrow function (fn($x) => $x or function($x) use ($y) {}).
|
|
20
|
+
*/
|
|
19
21
|
class ClosureNode extends ExpressionNode
|
|
20
22
|
{
|
|
21
23
|
public function __construct(
|
|
@@ -35,12 +37,12 @@ class ClosureNode extends ExpressionNode
|
|
|
35
37
|
|
|
36
38
|
public function print(PrintContext $context): string
|
|
37
39
|
{
|
|
38
|
-
$
|
|
40
|
+
$usesByRef = false;
|
|
39
41
|
foreach ($this->uses as $use) {
|
|
40
|
-
$
|
|
42
|
+
$usesByRef = $usesByRef || $use->byRef;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
return $
|
|
45
|
+
return $this->expr && !$usesByRef
|
|
44
46
|
? 'fn' . ($this->byRef ? '&' : '')
|
|
45
47
|
. '(' . $context->implode($this->params) . ')'
|
|
46
48
|
. ($this->returnType !== null ? ': ' . $this->returnType->print($context) : '')
|
|
@@ -59,10 +61,12 @@ class ClosureNode extends ExpressionNode
|
|
|
59
61
|
foreach ($this->params as &$item) {
|
|
60
62
|
yield $item;
|
|
61
63
|
}
|
|
64
|
+
Helpers::removeNulls($this->params);
|
|
62
65
|
|
|
63
66
|
foreach ($this->uses as &$item) {
|
|
64
67
|
yield $item;
|
|
65
68
|
}
|
|
69
|
+
Helpers::removeNulls($this->uses);
|
|
66
70
|
|
|
67
71
|
if ($this->returnType) {
|
|
68
72
|
yield $this->returnType;
|
|
@@ -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
|
+
* Global constant access (CONST or \CONST).
|
|
18
|
+
*/
|
|
18
19
|
class ConstantFetchNode extends ExpressionNode
|
|
19
20
|
{
|
|
20
21
|
public function __construct(
|
|
@@ -28,9 +29,9 @@ class ConstantFetchNode extends ExpressionNode
|
|
|
28
29
|
{
|
|
29
30
|
if ($this->name->kind === NameNode::KindNormal) {
|
|
30
31
|
return match ((string) $this->name) {
|
|
31
|
-
'__LINE__' => (string) $this->position->line,
|
|
32
|
-
'__FILE__' => '(is_file(
|
|
33
|
-
'__DIR__' => '(is_file(
|
|
32
|
+
'__LINE__' => (string) ($this->position->line ?? 0),
|
|
33
|
+
'__FILE__' => '(is_file($this->getName()) ? $this->getName() : null)',
|
|
34
|
+
'__DIR__' => '(is_file($this->getName()) ? dirname($this->getName()) : null)',
|
|
34
35
|
default => $this->name->print($context),
|
|
35
36
|
};
|
|
36
37
|
}
|
|
@@ -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
|
+
* empty() language construct.
|
|
17
|
+
*/
|
|
17
18
|
class EmptyNode extends ExpressionNode
|
|
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\Expression;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\Php;
|
|
@@ -15,6 +13,9 @@ use Latte\Compiler\Position;
|
|
|
15
13
|
use Latte\Compiler\PrintContext;
|
|
16
14
|
|
|
17
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Expression with filter applied ($expr|filter).
|
|
18
|
+
*/
|
|
18
19
|
class FilterCallNode extends ExpressionNode
|
|
19
20
|
{
|
|
20
21
|
public function __construct(
|
|
@@ -27,7 +28,12 @@ class FilterCallNode extends ExpressionNode
|
|
|
27
28
|
|
|
28
29
|
public function print(PrintContext $context): string
|
|
29
30
|
{
|
|
30
|
-
|
|
31
|
+
$filters = [];
|
|
32
|
+
for ($node = $this; $node instanceof self; $node = $node->expr) {
|
|
33
|
+
array_unshift($filters, $node->filter);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return Php\FilterNode::printSimple($context, $filters, $node->print($context));
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
|
|
@@ -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;
|
|
@@ -14,17 +12,27 @@ use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
|
14
12
|
use Latte\Compiler\Nodes\Php\NameNode;
|
|
15
13
|
use Latte\Compiler\Position;
|
|
16
14
|
use Latte\Compiler\PrintContext;
|
|
15
|
+
use Latte\Helpers;
|
|
17
16
|
|
|
18
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Function call with partial application or first-class callable support.
|
|
20
|
+
*/
|
|
19
21
|
class FunctionCallNode extends ExpressionNode
|
|
20
22
|
{
|
|
21
23
|
public function __construct(
|
|
22
24
|
public NameNode|ExpressionNode $name,
|
|
23
|
-
/** @var array<Php\ArgumentNode> */
|
|
25
|
+
/** @var array<Php\ArgumentNode|Php\VariadicPlaceholderNode> */
|
|
24
26
|
public array $args = [],
|
|
25
27
|
public ?Position $position = null,
|
|
26
28
|
) {
|
|
27
|
-
(function (Php\ArgumentNode ...$args) {})(...$args);
|
|
29
|
+
(function (Php\ArgumentNode|Php\VariadicPlaceholderNode ...$args) {})(...$args);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
public function isPartialFunction(): bool
|
|
34
|
+
{
|
|
35
|
+
return ($this->args[0] ?? null) instanceof Php\VariadicPlaceholderNode;
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
|
|
@@ -41,5 +49,6 @@ class FunctionCallNode extends ExpressionNode
|
|
|
41
49
|
foreach ($this->args as &$item) {
|
|
42
50
|
yield $item;
|
|
43
51
|
}
|
|
52
|
+
Helpers::removeNulls($this->args);
|
|
44
53
|
}
|
|
45
54
|
}
|
|
@@ -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
|
+
* Latte's `in` operator compiled to in_array() with strict mode.
|
|
17
|
+
*/
|
|
17
18
|
class InNode extends ExpressionNode
|
|
18
19
|
{
|
|
19
20
|
public function __construct(
|
|
@@ -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
11
|
use Latte\Compiler\Nodes\Php\NameNode;
|
|
12
|
+
use Latte\Compiler\Nodes\Php\OperatorNode;
|
|
14
13
|
use Latte\Compiler\Position;
|
|
15
14
|
use Latte\Compiler\PrintContext;
|
|
16
15
|
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* instanceof type check.
|
|
19
|
+
*/
|
|
20
|
+
class InstanceofNode extends ExpressionNode implements OperatorNode
|
|
19
21
|
{
|
|
20
22
|
public function __construct(
|
|
21
23
|
public ExpressionNode $expr,
|
|
@@ -27,11 +29,18 @@ class InstanceofNode extends ExpressionNode
|
|
|
27
29
|
|
|
28
30
|
public function print(PrintContext $context): string
|
|
29
31
|
{
|
|
30
|
-
return $context->
|
|
32
|
+
return $context->parenthesize($this, $this->expr, self::AssocLeft)
|
|
33
|
+
. ' instanceof '
|
|
31
34
|
. $context->dereferenceExpr($this->class);
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
|
|
38
|
+
public function getOperatorPrecedence(): array
|
|
39
|
+
{
|
|
40
|
+
return [230, self::AssocNone];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
35
44
|
public function &getIterator(): \Generator
|
|
36
45
|
{
|
|
37
46
|
yield $this->expr;
|
|
@@ -1,20 +1,22 @@
|
|
|
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;
|
|
14
12
|
use Latte\Compiler\Position;
|
|
15
13
|
use Latte\Compiler\PrintContext;
|
|
14
|
+
use Latte\Helpers;
|
|
16
15
|
|
|
17
16
|
|
|
17
|
+
/**
|
|
18
|
+
* isset() language construct.
|
|
19
|
+
*/
|
|
18
20
|
class IssetNode extends ExpressionNode
|
|
19
21
|
{
|
|
20
22
|
public function __construct(
|
|
@@ -50,5 +52,6 @@ class IssetNode extends ExpressionNode
|
|
|
50
52
|
foreach ($this->vars as &$item) {
|
|
51
53
|
yield $item;
|
|
52
54
|
}
|
|
55
|
+
Helpers::removeNulls($this->vars);
|
|
53
56
|
}
|
|
54
57
|
}
|
|
@@ -1,20 +1,22 @@
|
|
|
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;
|
|
13
11
|
use Latte\Compiler\Nodes\Php\MatchArmNode;
|
|
14
12
|
use Latte\Compiler\Position;
|
|
15
13
|
use Latte\Compiler\PrintContext;
|
|
14
|
+
use Latte\Helpers;
|
|
16
15
|
|
|
17
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Match expression.
|
|
19
|
+
*/
|
|
18
20
|
class MatchNode extends Php\ExpressionNode
|
|
19
21
|
{
|
|
20
22
|
public function __construct(
|
|
@@ -45,5 +47,6 @@ class MatchNode extends Php\ExpressionNode
|
|
|
45
47
|
foreach ($this->arms as &$item) {
|
|
46
48
|
yield $item;
|
|
47
49
|
}
|
|
50
|
+
Helpers::removeNulls($this->arms);
|
|
48
51
|
}
|
|
49
52
|
}
|
|
@@ -1,37 +1,49 @@
|
|
|
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
|
|
|
10
|
+
use Latte\CompileException;
|
|
12
11
|
use Latte\Compiler\Nodes\Php;
|
|
13
12
|
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
13
|
use Latte\Compiler\Nodes\Php\IdentifierNode;
|
|
15
14
|
use Latte\Compiler\Position;
|
|
16
15
|
use Latte\Compiler\PrintContext;
|
|
16
|
+
use Latte\Helpers;
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Method call with nullsafe support, partial application, or first-class callable.
|
|
21
|
+
*/
|
|
19
22
|
class MethodCallNode extends ExpressionNode
|
|
20
23
|
{
|
|
21
24
|
public function __construct(
|
|
22
25
|
public ExpressionNode $object,
|
|
23
26
|
public IdentifierNode|ExpressionNode $name,
|
|
24
|
-
/** @var array<Php\ArgumentNode> */
|
|
27
|
+
/** @var array<Php\ArgumentNode|Php\VariadicPlaceholderNode> */
|
|
25
28
|
public array $args = [],
|
|
26
29
|
public bool $nullsafe = false,
|
|
27
30
|
public ?Position $position = null,
|
|
28
31
|
) {
|
|
29
|
-
(function (Php\ArgumentNode ...$args) {})(...$args);
|
|
32
|
+
(function (Php\ArgumentNode|Php\VariadicPlaceholderNode ...$args) {})(...$args);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
public function isPartialFunction(): bool
|
|
37
|
+
{
|
|
38
|
+
return ($this->args[0] ?? null) instanceof Php\VariadicPlaceholderNode;
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
|
|
33
42
|
public function print(PrintContext $context): string
|
|
34
43
|
{
|
|
44
|
+
if ($this->nullsafe && $this->isPartialFunction()) {
|
|
45
|
+
throw new CompileException('Cannot combine nullsafe operator with Closure creation', $this->position);
|
|
46
|
+
}
|
|
35
47
|
return $context->dereferenceExpr($this->object)
|
|
36
48
|
. ($this->nullsafe ? '?->' : '->')
|
|
37
49
|
. $context->objectProperty($this->name)
|
|
@@ -46,5 +58,6 @@ class MethodCallNode extends ExpressionNode
|
|
|
46
58
|
foreach ($this->args as &$item) {
|
|
47
59
|
yield $item;
|
|
48
60
|
}
|
|
61
|
+
Helpers::removeNulls($this->args);
|
|
49
62
|
}
|
|
50
63
|
}
|
|
@@ -1,22 +1,25 @@
|
|
|
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;
|
|
13
11
|
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
12
|
use Latte\Compiler\Nodes\Php\NameNode;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\OperatorNode;
|
|
15
14
|
use Latte\Compiler\Position;
|
|
16
15
|
use Latte\Compiler\PrintContext;
|
|
16
|
+
use Latte\Helpers;
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Object instantiation (new ClassName or new $expr).
|
|
21
|
+
*/
|
|
22
|
+
class NewNode extends ExpressionNode implements OperatorNode
|
|
20
23
|
{
|
|
21
24
|
public function __construct(
|
|
22
25
|
public NameNode|ExpressionNode $class,
|
|
@@ -35,11 +38,18 @@ class NewNode extends ExpressionNode
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
|
|
41
|
+
public function getOperatorPrecedence(): array
|
|
42
|
+
{
|
|
43
|
+
return [270, self::AssocNone];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
38
47
|
public function &getIterator(): \Generator
|
|
39
48
|
{
|
|
40
49
|
yield $this->class;
|
|
41
50
|
foreach ($this->args as &$item) {
|
|
42
51
|
yield $item;
|
|
43
52
|
}
|
|
53
|
+
Helpers::removeNulls($this->args);
|
|
44
54
|
}
|
|
45
55
|
}
|