@vituum/vite-plugin-latte 0.1.8
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 +39 -0
- package/handler.js +9 -0
- package/index.js +138 -0
- package/index.php +173 -0
- package/latte/AssetFilter.php +11 -0
- package/latte/FetchFunction.php +28 -0
- package/latte/IconFilter.php +14 -0
- package/latte/JsonTag.php +64 -0
- package/latte/PlaceholderFunction.php +11 -0
- package/latte/RandomColorFunction.php +14 -0
- package/latte/TelFilter.php +22 -0
- package/package.json +35 -0
- package/vendor/autoload.php +7 -0
- package/vendor/bin/latte-lint +107 -0
- package/vendor/composer/ClassLoader.php +572 -0
- package/vendor/composer/InstalledVersions.php +350 -0
- package/vendor/composer/LICENSE +21 -0
- package/vendor/composer/autoload_classmap.php +183 -0
- package/vendor/composer/autoload_namespaces.php +9 -0
- package/vendor/composer/autoload_psr4.php +9 -0
- package/vendor/composer/autoload_real.php +57 -0
- package/vendor/composer/autoload_static.php +193 -0
- package/vendor/composer/installed.json +93 -0
- package/vendor/composer/installed.php +32 -0
- package/vendor/composer/platform_check.php +26 -0
- package/vendor/latte/latte/bin/latte-lint +29 -0
- package/vendor/latte/latte/composer.json +53 -0
- package/vendor/latte/latte/license.md +60 -0
- package/vendor/latte/latte/ncs.php +14 -0
- package/vendor/latte/latte/ncs.xml +9 -0
- package/vendor/latte/latte/readme.md +21 -0
- package/vendor/latte/latte/src/Bridges/Tracy/BlueScreenPanel.php +114 -0
- package/vendor/latte/latte/src/Bridges/Tracy/LattePanel.php +99 -0
- package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.panel.phtml +98 -0
- package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.tab.phtml +15 -0
- package/vendor/latte/latte/src/Latte/Compiler/Block.php +44 -0
- package/vendor/latte/latte/src/Latte/Compiler/Escaper.php +244 -0
- package/vendor/latte/latte/src/Latte/Compiler/ExpressionBuilder.php +128 -0
- package/vendor/latte/latte/src/Latte/Compiler/Node.php +28 -0
- package/vendor/latte/latte/src/Latte/Compiler/NodeHelpers.php +132 -0
- package/vendor/latte/latte/src/Latte/Compiler/NodeTraverser.php +77 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AreaNode.php +17 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AuxiliaryNode.php +27 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/FragmentNode.php +59 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/AttributeNode.php +48 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/BogusTagNode.php +46 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/CommentNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ElementNode.php +129 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/QuotedValue.php +53 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/NopNode.php +21 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArgumentNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ComplexTypeNode.php +17 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayAccessNode.php +41 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayItemNode.php +52 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayNode.php +94 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/BinaryOpNode.php +65 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CastNode.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClassConstantFetchNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CloneNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureNode.php +73 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureUseNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ConstantFetchNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/EmptyNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ErrorSuppressNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FilterCallNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallableNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InRangeNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InstanceofNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/IssetNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MatchNode.php +49 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallNode.php +50 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallableNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NewNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NotNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PostOpNode.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PreOpNode.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PropertyFetchNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticCallNode.php +55 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticCallableNode.php +47 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticPropertyFetchNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TernaryNode.php +50 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/UnaryOpNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/VariableNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ExpressionNode.php +17 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/FilterNode.php +67 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IdentifierNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IntersectionTypeNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/MatchArmNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ModifierNode.php +107 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NameNode.php +89 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NullableTypeNode.php +35 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ParameterNode.php +54 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/BooleanNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/EncapsedStringNode.php +80 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/EncapsedStringPartNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/FloatNode.php +63 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/IntegerNode.php +70 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/NullNode.php +29 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/StringNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ScalarNode.php +15 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/SuperiorTypeNode.php +29 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/UnionTypeNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/VarLikeIdentifierNode.php +21 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/StatementNode.php +15 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TemplateNode.php +34 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TextNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Compiler/PhpHelpers.php +227 -0
- package/vendor/latte/latte/src/Latte/Compiler/Position.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/PrintContext.php +334 -0
- package/vendor/latte/latte/src/Latte/Compiler/Tag.php +117 -0
- package/vendor/latte/latte/src/Latte/Compiler/TagLexer.php +399 -0
- package/vendor/latte/latte/src/Latte/Compiler/TagParser.php +388 -0
- package/vendor/latte/latte/src/Latte/Compiler/TagParserData.php +580 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateGenerator.php +206 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateLexer.php +391 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParser.php +448 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParserHtml.php +506 -0
- package/vendor/latte/latte/src/Latte/Compiler/Token.php +259 -0
- package/vendor/latte/latte/src/Latte/Compiler/TokenStream.php +151 -0
- package/vendor/latte/latte/src/Latte/ContentType.php +22 -0
- package/vendor/latte/latte/src/Latte/Engine.php +591 -0
- package/vendor/latte/latte/src/Latte/Essential/Blueprint.php +160 -0
- package/vendor/latte/latte/src/Latte/Essential/CachingIterator.php +232 -0
- package/vendor/latte/latte/src/Latte/Essential/CoreExtension.php +232 -0
- package/vendor/latte/latte/src/Latte/Essential/Filters.php +591 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/BlockNode.php +161 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/CaptureNode.php +98 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ContentTypeNode.php +74 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DebugbreakNode.php +53 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DefineNode.php +134 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DoNode.php +49 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DumpNode.php +58 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/EmbedNode.php +125 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ExtendsNode.php +60 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/FirstLastSepNode.php +81 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForNode.php +91 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForeachNode.php +155 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfChangedNode.php +141 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfContentNode.php +82 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfNode.php +180 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ImportNode.php +49 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeBlockNode.php +140 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeFileNode.php +81 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IterateWhileNode.php +94 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NAttrNode.php +105 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NClassNode.php +54 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NTagNode.php +79 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ParametersNode.php +84 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/PrintNode.php +70 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RawPhpNode.php +46 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RollbackNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SkipNode.php +71 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SpacelessNode.php +62 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SwitchNode.php +118 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplatePrintNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplateTypeNode.php +38 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TraceNode.php +35 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TranslateNode.php +104 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TryNode.php +75 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarNode.php +106 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarPrintNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarTypeNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/WhileNode.php +81 -0
- package/vendor/latte/latte/src/Latte/Essential/Passes.php +115 -0
- package/vendor/latte/latte/src/Latte/Essential/RawPhpExtension.php +28 -0
- package/vendor/latte/latte/src/Latte/Essential/RollbackException.php +16 -0
- package/vendor/latte/latte/src/Latte/Essential/Tracer.php +117 -0
- package/vendor/latte/latte/src/Latte/Essential/TranslatorExtension.php +101 -0
- package/vendor/latte/latte/src/Latte/Extension.php +97 -0
- package/vendor/latte/latte/src/Latte/Helpers.php +96 -0
- package/vendor/latte/latte/src/Latte/Loader.php +37 -0
- package/vendor/latte/latte/src/Latte/Loaders/FileLoader.php +95 -0
- package/vendor/latte/latte/src/Latte/Loaders/StringLoader.php +76 -0
- package/vendor/latte/latte/src/Latte/Policy.php +24 -0
- package/vendor/latte/latte/src/Latte/PositionAwareException.php +50 -0
- package/vendor/latte/latte/src/Latte/Runtime/Block.php +24 -0
- package/vendor/latte/latte/src/Latte/Runtime/FilterExecutor.php +151 -0
- package/vendor/latte/latte/src/Latte/Runtime/FilterInfo.php +39 -0
- package/vendor/latte/latte/src/Latte/Runtime/Filters.php +234 -0
- package/vendor/latte/latte/src/Latte/Runtime/Html.php +35 -0
- package/vendor/latte/latte/src/Latte/Runtime/HtmlStringable.php +17 -0
- package/vendor/latte/latte/src/Latte/Runtime/Template.php +381 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallableNode.php +29 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallNode.php +32 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallableNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/PropertyFetchNode.php +32 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/SandboxNode.php +73 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticCallNode.php +31 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticCallableNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticPropertyFetchNode.php +32 -0
- package/vendor/latte/latte/src/Latte/Sandbox/RuntimeChecker.php +116 -0
- package/vendor/latte/latte/src/Latte/Sandbox/SandboxExtension.php +132 -0
- package/vendor/latte/latte/src/Latte/Sandbox/SecurityPolicy.php +185 -0
- package/vendor/latte/latte/src/Latte/Strict.php +101 -0
- package/vendor/latte/latte/src/Latte/attributes.php +24 -0
- package/vendor/latte/latte/src/Latte/exceptions.php +69 -0
- package/vendor/latte/latte/src/Tools/Linter.php +175 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
13
|
+
use Latte\Compiler\Position;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CloneNode extends ExpressionNode
|
|
18
|
+
{
|
|
19
|
+
public function __construct(
|
|
20
|
+
public ExpressionNode $expr,
|
|
21
|
+
public ?Position $position = null,
|
|
22
|
+
) {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
public function print(PrintContext $context): string
|
|
27
|
+
{
|
|
28
|
+
return 'clone ' . $this->expr->print($context);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
public function &getIterator(): \Generator
|
|
33
|
+
{
|
|
34
|
+
yield $this->expr;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
|
+
use Latte\Compiler\Position;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ClosureNode extends ExpressionNode
|
|
19
|
+
{
|
|
20
|
+
public function __construct(
|
|
21
|
+
public bool $byRef,
|
|
22
|
+
/** @var Php\ParameterNode[] */
|
|
23
|
+
public array $params,
|
|
24
|
+
/** @var ClosureUseNode[] */
|
|
25
|
+
public array $uses,
|
|
26
|
+
public Php\IdentifierNode|Php\NameNode|Php\ComplexTypeNode|null $returnType = null,
|
|
27
|
+
public ?ExpressionNode $expr,
|
|
28
|
+
public ?Position $position = null,
|
|
29
|
+
) {
|
|
30
|
+
(function (Php\ParameterNode ...$args) {})(...$params);
|
|
31
|
+
(function (ClosureUseNode ...$args) {})(...$uses);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
public function print(PrintContext $context): string
|
|
36
|
+
{
|
|
37
|
+
$arrow = (bool) $this->expr;
|
|
38
|
+
foreach ($this->uses as $use) {
|
|
39
|
+
$arrow = $arrow && !$use->byRef;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return $arrow
|
|
43
|
+
? 'fn' . ($this->byRef ? '&' : '')
|
|
44
|
+
. '(' . $context->implode($this->params) . ')'
|
|
45
|
+
. ($this->returnType !== null ? ': ' . $this->returnType->print($context) : '')
|
|
46
|
+
. ' => '
|
|
47
|
+
. $this->expr->print($context)
|
|
48
|
+
: 'function ' . ($this->byRef ? '&' : '')
|
|
49
|
+
. '(' . $context->implode($this->params) . ')'
|
|
50
|
+
. (!empty($this->uses) ? ' use (' . $context->implode($this->uses) . ')' : '')
|
|
51
|
+
. ($this->returnType !== null ? ' : ' . $this->returnType->print($context) : '')
|
|
52
|
+
. ($this->expr ? ' { return ' . $this->expr->print($context) . '; }' : ' {}');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
public function &getIterator(): \Generator
|
|
57
|
+
{
|
|
58
|
+
foreach ($this->params as &$item) {
|
|
59
|
+
yield $item;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
foreach ($this->uses as &$item) {
|
|
63
|
+
yield $item;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if ($this->returnType) {
|
|
67
|
+
yield $this->returnType;
|
|
68
|
+
}
|
|
69
|
+
if ($this->expr) {
|
|
70
|
+
yield $this->expr;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Node;
|
|
13
|
+
use Latte\Compiler\Position;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ClosureUseNode extends Node
|
|
18
|
+
{
|
|
19
|
+
public function __construct(
|
|
20
|
+
public VariableNode $var,
|
|
21
|
+
public bool $byRef = false,
|
|
22
|
+
public ?Position $position = null,
|
|
23
|
+
) {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public function print(PrintContext $context): string
|
|
28
|
+
{
|
|
29
|
+
return ($this->byRef ? '&' : '') . $this->var->print($context);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
public function &getIterator(): \Generator
|
|
34
|
+
{
|
|
35
|
+
yield $this->var;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\NameNode;
|
|
14
|
+
use Latte\Compiler\Position;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ConstantFetchNode extends ExpressionNode
|
|
19
|
+
{
|
|
20
|
+
public function __construct(
|
|
21
|
+
public NameNode $name,
|
|
22
|
+
public ?Position $position = null,
|
|
23
|
+
) {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public function print(PrintContext $context): string
|
|
28
|
+
{
|
|
29
|
+
return $this->name->print($context);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
public function &getIterator(): \Generator
|
|
34
|
+
{
|
|
35
|
+
yield $this->name;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
13
|
+
use Latte\Compiler\Position;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class EmptyNode extends ExpressionNode
|
|
18
|
+
{
|
|
19
|
+
public function __construct(
|
|
20
|
+
public ExpressionNode $expr,
|
|
21
|
+
public ?Position $position = null,
|
|
22
|
+
) {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
public function print(PrintContext $context): string
|
|
27
|
+
{
|
|
28
|
+
return 'empty(' . $this->expr->print($context) . ')';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
public function &getIterator(): \Generator
|
|
33
|
+
{
|
|
34
|
+
yield $this->expr;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
13
|
+
use Latte\Compiler\Position;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ErrorSuppressNode extends ExpressionNode
|
|
18
|
+
{
|
|
19
|
+
public function __construct(
|
|
20
|
+
public ExpressionNode $expr,
|
|
21
|
+
public ?Position $position = null,
|
|
22
|
+
) {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
public function print(PrintContext $context): string
|
|
27
|
+
{
|
|
28
|
+
return $context->prefixOp($this, '@', $this->expr);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
public function &getIterator(): \Generator
|
|
33
|
+
{
|
|
34
|
+
yield $this->expr;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
|
+
use Latte\Compiler\Position;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class FilterCallNode extends ExpressionNode
|
|
19
|
+
{
|
|
20
|
+
public function __construct(
|
|
21
|
+
public ExpressionNode $expr,
|
|
22
|
+
public Php\FilterNode $filter,
|
|
23
|
+
public ?Position $position = null,
|
|
24
|
+
) {
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
public function print(PrintContext $context): string
|
|
29
|
+
{
|
|
30
|
+
return $this->filter->printSimple($context, $this->expr->print($context));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
public function &getIterator(): \Generator
|
|
35
|
+
{
|
|
36
|
+
yield $this->expr;
|
|
37
|
+
yield $this->filter;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
|
+
use Latte\Compiler\Nodes\Php\NameNode;
|
|
15
|
+
use Latte\Compiler\Position;
|
|
16
|
+
use Latte\Compiler\PrintContext;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class FunctionCallNode extends ExpressionNode
|
|
20
|
+
{
|
|
21
|
+
public function __construct(
|
|
22
|
+
public NameNode|ExpressionNode $name,
|
|
23
|
+
/** @var array<Php\ArgumentNode> */
|
|
24
|
+
public array $args = [],
|
|
25
|
+
public ?Position $position = null,
|
|
26
|
+
) {
|
|
27
|
+
(function (Php\ArgumentNode ...$args) {})(...$args);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
public function print(PrintContext $context): string
|
|
32
|
+
{
|
|
33
|
+
return $context->callExpr($this->name)
|
|
34
|
+
. '(' . $context->implode($this->args) . ')';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
public function &getIterator(): \Generator
|
|
39
|
+
{
|
|
40
|
+
yield $this->name;
|
|
41
|
+
foreach ($this->args as &$item) {
|
|
42
|
+
yield $item;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\NameNode;
|
|
14
|
+
use Latte\Compiler\Position;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class FunctionCallableNode extends ExpressionNode
|
|
19
|
+
{
|
|
20
|
+
public function __construct(
|
|
21
|
+
public NameNode|ExpressionNode $name,
|
|
22
|
+
public ?Position $position = null,
|
|
23
|
+
) {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public function print(PrintContext $context): string
|
|
28
|
+
{
|
|
29
|
+
return PHP_VERSION_ID < 80100
|
|
30
|
+
? $context->memberAsString($this->name)
|
|
31
|
+
: $context->callExpr($this->name) . '(...)';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
public function &getIterator(): \Generator
|
|
36
|
+
{
|
|
37
|
+
yield $this->name;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
13
|
+
use Latte\Compiler\Position;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class InRangeNode extends ExpressionNode
|
|
18
|
+
{
|
|
19
|
+
public function __construct(
|
|
20
|
+
public ExpressionNode $needle,
|
|
21
|
+
public ExpressionNode $haystack,
|
|
22
|
+
public ?Position $position = null,
|
|
23
|
+
) {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public function print(PrintContext $context): string
|
|
28
|
+
{
|
|
29
|
+
return 'in_array('
|
|
30
|
+
. $this->needle->print($context)
|
|
31
|
+
. ', '
|
|
32
|
+
. $this->haystack->print($context)
|
|
33
|
+
. ', true)';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
public function &getIterator(): \Generator
|
|
38
|
+
{
|
|
39
|
+
yield $this->needle;
|
|
40
|
+
yield $this->haystack;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\NameNode;
|
|
14
|
+
use Latte\Compiler\Position;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class InstanceofNode extends ExpressionNode
|
|
19
|
+
{
|
|
20
|
+
public function __construct(
|
|
21
|
+
public ExpressionNode $expr,
|
|
22
|
+
public NameNode|ExpressionNode $class,
|
|
23
|
+
public ?Position $position = null,
|
|
24
|
+
) {
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
public function print(PrintContext $context): string
|
|
29
|
+
{
|
|
30
|
+
return $context->postfixOp($this, $this->expr, ' instanceof ')
|
|
31
|
+
. $context->dereferenceExpr($this->class);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
public function &getIterator(): \Generator
|
|
36
|
+
{
|
|
37
|
+
yield $this->expr;
|
|
38
|
+
yield $this->class;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
13
|
+
use Latte\Compiler\Position;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class IssetNode extends ExpressionNode
|
|
18
|
+
{
|
|
19
|
+
public function __construct(
|
|
20
|
+
/** @var ExpressionNode[] */
|
|
21
|
+
public array $vars,
|
|
22
|
+
public ?Position $position = null,
|
|
23
|
+
) {
|
|
24
|
+
(function (ExpressionNode ...$args) {})(...$vars);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
public function print(PrintContext $context): string
|
|
29
|
+
{
|
|
30
|
+
return 'isset(' . $context->implode($this->vars) . ')';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
public function &getIterator(): \Generator
|
|
35
|
+
{
|
|
36
|
+
foreach ($this->vars as &$item) {
|
|
37
|
+
yield $item;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\MatchArmNode;
|
|
14
|
+
use Latte\Compiler\Position;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class MatchNode extends Php\ExpressionNode
|
|
19
|
+
{
|
|
20
|
+
public function __construct(
|
|
21
|
+
public Php\ExpressionNode $cond,
|
|
22
|
+
/** @var MatchArmNode[] */
|
|
23
|
+
public array $arms = [],
|
|
24
|
+
public ?Position $position = null,
|
|
25
|
+
) {
|
|
26
|
+
(function (MatchArmNode ...$args) {})(...$arms);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
public function print(PrintContext $context): string
|
|
31
|
+
{
|
|
32
|
+
$res = 'match (' . $this->cond->print($context) . ') {';
|
|
33
|
+
foreach ($this->arms as $node) {
|
|
34
|
+
$res .= "\n" . $node->print($context) . ',';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
$res .= "\n}";
|
|
38
|
+
return $res;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
public function &getIterator(): \Generator
|
|
43
|
+
{
|
|
44
|
+
yield $this->cond;
|
|
45
|
+
foreach ($this->arms as &$item) {
|
|
46
|
+
yield $item;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
|
+
use Latte\Compiler\Nodes\Php\IdentifierNode;
|
|
15
|
+
use Latte\Compiler\Position;
|
|
16
|
+
use Latte\Compiler\PrintContext;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class MethodCallNode extends ExpressionNode
|
|
20
|
+
{
|
|
21
|
+
public function __construct(
|
|
22
|
+
public ExpressionNode $object,
|
|
23
|
+
public IdentifierNode|ExpressionNode $name,
|
|
24
|
+
/** @var array<Php\ArgumentNode> */
|
|
25
|
+
public array $args = [],
|
|
26
|
+
public bool $nullsafe = false,
|
|
27
|
+
public ?Position $position = null,
|
|
28
|
+
) {
|
|
29
|
+
(function (Php\ArgumentNode ...$args) {})(...$args);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
public function print(PrintContext $context): string
|
|
34
|
+
{
|
|
35
|
+
return $context->dereferenceExpr($this->object)
|
|
36
|
+
. ($this->nullsafe ? '?->' : '->')
|
|
37
|
+
. $context->objectProperty($this->name)
|
|
38
|
+
. '(' . $context->implode($this->args) . ')';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
public function &getIterator(): \Generator
|
|
43
|
+
{
|
|
44
|
+
yield $this->object;
|
|
45
|
+
yield $this->name;
|
|
46
|
+
foreach ($this->args as &$item) {
|
|
47
|
+
yield $item;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\IdentifierNode;
|
|
14
|
+
use Latte\Compiler\Position;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class MethodCallableNode extends ExpressionNode
|
|
19
|
+
{
|
|
20
|
+
public function __construct(
|
|
21
|
+
public ExpressionNode $object,
|
|
22
|
+
public IdentifierNode|ExpressionNode $name,
|
|
23
|
+
public ?Position $position = null,
|
|
24
|
+
) {
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
public function print(PrintContext $context): string
|
|
29
|
+
{
|
|
30
|
+
return PHP_VERSION_ID < 80100
|
|
31
|
+
? '[' . $this->object->print($context) . ', ' . $context->memberAsString($this->name) . ']'
|
|
32
|
+
: $context->dereferenceExpr($this->object)
|
|
33
|
+
. '->' . $context->objectProperty($this->name) . '(...)';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
public function &getIterator(): \Generator
|
|
38
|
+
{
|
|
39
|
+
yield $this->object;
|
|
40
|
+
yield $this->name;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Compiler\Nodes\Php\Expression;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
|
+
use Latte\Compiler\Nodes\Php\NameNode;
|
|
15
|
+
use Latte\Compiler\Position;
|
|
16
|
+
use Latte\Compiler\PrintContext;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class NewNode extends ExpressionNode
|
|
20
|
+
{
|
|
21
|
+
public function __construct(
|
|
22
|
+
public NameNode|ExpressionNode $class,
|
|
23
|
+
/** @var Php\ArgumentNode[] */
|
|
24
|
+
public array $args = [],
|
|
25
|
+
public ?Position $position = null,
|
|
26
|
+
) {
|
|
27
|
+
(function (Php\ArgumentNode ...$args) {})(...$args);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
public function print(PrintContext $context): string
|
|
32
|
+
{
|
|
33
|
+
return 'new ' . $context->dereferenceExpr($this->class)
|
|
34
|
+
. ($this->args ? '(' . $context->implode($this->args) . ')' : '');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
public function &getIterator(): \Generator
|
|
39
|
+
{
|
|
40
|
+
yield $this->class;
|
|
41
|
+
foreach ($this->args as &$item) {
|
|
42
|
+
yield $item;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|