@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,107 @@
|
|
|
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;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Node;
|
|
13
|
+
use Latte\Compiler\Position;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ModifierNode extends Node
|
|
18
|
+
{
|
|
19
|
+
public function __construct(
|
|
20
|
+
/** @var FilterNode[] */
|
|
21
|
+
public array $filters,
|
|
22
|
+
public bool $escape = false,
|
|
23
|
+
public bool $check = true,
|
|
24
|
+
public ?Position $position = null,
|
|
25
|
+
) {
|
|
26
|
+
(function (FilterNode ...$args) {})(...$filters);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
public function hasFilter(string $name): bool
|
|
31
|
+
{
|
|
32
|
+
foreach ($this->filters as $filter) {
|
|
33
|
+
if ($filter->name->name === $name) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
public function print(PrintContext $context): string
|
|
43
|
+
{
|
|
44
|
+
throw new \LogicException('Cannot directly print ModifierNode');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
public function printSimple(PrintContext $context, string $expr): string
|
|
49
|
+
{
|
|
50
|
+
$escape = $this->escape;
|
|
51
|
+
$check = $this->check;
|
|
52
|
+
foreach ($this->filters as $filter) {
|
|
53
|
+
$name = $filter->name->name;
|
|
54
|
+
if (['nocheck' => 1, 'noCheck' => 1][$name] ?? null) {
|
|
55
|
+
$check = false;
|
|
56
|
+
} elseif ($name === 'noescape') {
|
|
57
|
+
$escape = false;
|
|
58
|
+
} else {
|
|
59
|
+
if (['datastream' => 1, 'dataStream' => 1][$name] ?? null) {
|
|
60
|
+
$check = false;
|
|
61
|
+
}
|
|
62
|
+
$expr = $filter->printSimple($context, $expr);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
$escaper = $context->getEscaper();
|
|
67
|
+
if ($check) {
|
|
68
|
+
$expr = $escaper->check($expr);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if ($escape) {
|
|
72
|
+
$expr = $escaper->escape($expr);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return $expr;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
public function printContentAware(PrintContext $context, string $expr): string
|
|
80
|
+
{
|
|
81
|
+
foreach ($this->filters as $filter) {
|
|
82
|
+
$name = $filter->name->name;
|
|
83
|
+
if ($name === 'noescape') {
|
|
84
|
+
$noescape = true;
|
|
85
|
+
} else {
|
|
86
|
+
$expr = $filter->printContentAware($context, $expr);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if ($this->escape && empty($noescape)) {
|
|
91
|
+
$expr = 'LR\Filters::convertTo($ʟ_fi, '
|
|
92
|
+
. var_export($context->getEscaper()->export(), true) . ', '
|
|
93
|
+
. $expr
|
|
94
|
+
. ')';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return $expr;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
public function &getIterator(): \Generator
|
|
102
|
+
{
|
|
103
|
+
foreach ($this->filters as &$filter) {
|
|
104
|
+
yield $filter;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Node;
|
|
13
|
+
use Latte\Compiler\Position;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class NameNode extends Node
|
|
18
|
+
{
|
|
19
|
+
public const
|
|
20
|
+
KindNormal = 1,
|
|
21
|
+
KindFullyQualified = 2;
|
|
22
|
+
|
|
23
|
+
/** @var string[] */
|
|
24
|
+
public array $parts;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public function __construct(
|
|
28
|
+
string|array $name,
|
|
29
|
+
public int $kind = self::KindNormal,
|
|
30
|
+
public ?Position $position = null,
|
|
31
|
+
) {
|
|
32
|
+
if ($name === '' || $name === []) {
|
|
33
|
+
throw new \InvalidArgumentException('Name cannot be empty');
|
|
34
|
+
|
|
35
|
+
} elseif (is_string($name)) {
|
|
36
|
+
if (str_starts_with($name, '\\')) {
|
|
37
|
+
$this->kind = self::KindFullyQualified;
|
|
38
|
+
$name = substr($name, 1);
|
|
39
|
+
} elseif (str_starts_with($name, 'namespace\\')) {
|
|
40
|
+
throw new \InvalidArgumentException('Relative name is not supported');
|
|
41
|
+
} else {
|
|
42
|
+
$this->kind = self::KindNormal;
|
|
43
|
+
}
|
|
44
|
+
$this->parts = explode('\\', $name);
|
|
45
|
+
|
|
46
|
+
} else {
|
|
47
|
+
$this->parts = $name;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
private function isKeyword(): bool
|
|
53
|
+
{
|
|
54
|
+
static $keywords;
|
|
55
|
+
$keywords ??= array_flip([
|
|
56
|
+
'include', 'include_once', 'eval', 'require', 'require_once', 'or', 'xor', 'and',
|
|
57
|
+
'instanceof', 'new', 'clone', 'exit', 'if', 'elseif', 'else', 'endif', 'echo', 'do', 'while',
|
|
58
|
+
'endwhile', 'for', 'endfor', 'foreach', 'endforeach', 'declare', 'enddeclare', 'as', 'try', 'catch',
|
|
59
|
+
'finally', 'throw', 'use', 'insteadof', 'global', 'var', 'unset', 'isset', 'empty', 'continue', 'goto',
|
|
60
|
+
'function', 'const', 'return', 'print', 'yield', 'list', 'switch', 'endswitch', 'case', 'default',
|
|
61
|
+
'break', 'array', 'callable', 'extends', 'implements', 'namespace', 'trait', 'interface', 'class',
|
|
62
|
+
'static', 'abstract', 'final', 'private', 'protected', 'public', 'fn', 'match', 'self', 'parent',
|
|
63
|
+
]);
|
|
64
|
+
return count($this->parts) === 1
|
|
65
|
+
&& (isset($keywords[strtolower($this->parts[0])]) || str_starts_with($this->parts[0], '__'));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
public function print(PrintContext $context): string
|
|
70
|
+
{
|
|
71
|
+
return $this->toCodeString();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
public function __toString(): string
|
|
76
|
+
{
|
|
77
|
+
return implode('\\', $this->parts);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
public function toCodeString(): string
|
|
82
|
+
{
|
|
83
|
+
$prefix = match ($this->kind) {
|
|
84
|
+
self::KindNormal => $this->isKeyword() ? 'namespace\\' : '',
|
|
85
|
+
self::KindFullyQualified => '\\',
|
|
86
|
+
};
|
|
87
|
+
return $prefix . implode('\\', $this->parts);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Position;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class NullableTypeNode extends ComplexTypeNode
|
|
17
|
+
{
|
|
18
|
+
public function __construct(
|
|
19
|
+
public IdentifierNode|NameNode $type,
|
|
20
|
+
public ?Position $position = null,
|
|
21
|
+
) {
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
public function print(PrintContext $context): string
|
|
26
|
+
{
|
|
27
|
+
return '?' . $this->type->print($context);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
public function &getIterator(): \Generator
|
|
32
|
+
{
|
|
33
|
+
yield $this->type;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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;
|
|
11
|
+
|
|
12
|
+
use Latte\CompileException;
|
|
13
|
+
use Latte\Compiler\Node;
|
|
14
|
+
use Latte\Compiler\Position;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ParameterNode extends Node
|
|
19
|
+
{
|
|
20
|
+
public function __construct(
|
|
21
|
+
public Expression\VariableNode $var,
|
|
22
|
+
public ?ExpressionNode $default = null,
|
|
23
|
+
public IdentifierNode|NameNode|ComplexTypeNode|null $type = null,
|
|
24
|
+
public bool $byRef = false,
|
|
25
|
+
public bool $variadic = false,
|
|
26
|
+
public ?Position $position = null,
|
|
27
|
+
) {
|
|
28
|
+
if ($variadic && $default !== null) {
|
|
29
|
+
throw new CompileException('Variadic parameter cannot have a default value', $position);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
public function print(PrintContext $context): string
|
|
35
|
+
{
|
|
36
|
+
return ($this->type ? $this->type->print($context) . ' ' : '')
|
|
37
|
+
. ($this->byRef ? '&' : '')
|
|
38
|
+
. ($this->variadic ? '...' : '')
|
|
39
|
+
. $this->var->print($context)
|
|
40
|
+
. ($this->default ? ' = ' . $this->default->print($context) : '');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
public function &getIterator(): \Generator
|
|
45
|
+
{
|
|
46
|
+
if ($this->type) {
|
|
47
|
+
yield $this->type;
|
|
48
|
+
}
|
|
49
|
+
yield $this->var;
|
|
50
|
+
if ($this->default) {
|
|
51
|
+
yield $this->default;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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\Scalar;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ScalarNode;
|
|
13
|
+
use Latte\Compiler\Position;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class BooleanNode extends ScalarNode
|
|
18
|
+
{
|
|
19
|
+
public function __construct(
|
|
20
|
+
public bool $value,
|
|
21
|
+
public ?Position $position = null,
|
|
22
|
+
) {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
public function print(PrintContext $context): string
|
|
27
|
+
{
|
|
28
|
+
return $this->value ? 'true' : 'false';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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\Scalar;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
|
+
use Latte\Compiler\Nodes\Php\ScalarNode;
|
|
15
|
+
use Latte\Compiler\PhpHelpers;
|
|
16
|
+
use Latte\Compiler\Position;
|
|
17
|
+
use Latte\Compiler\PrintContext;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class EncapsedStringNode extends ScalarNode
|
|
21
|
+
{
|
|
22
|
+
public function __construct(
|
|
23
|
+
/** @var ExpressionNode[] */
|
|
24
|
+
public array $parts,
|
|
25
|
+
public ?Position $position = null,
|
|
26
|
+
) {
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/** @param ExpressionNode[] $parts */
|
|
31
|
+
public static function parse(array $parts, Position $position): static
|
|
32
|
+
{
|
|
33
|
+
foreach ($parts as $part) {
|
|
34
|
+
if ($part instanceof EncapsedStringPartNode) {
|
|
35
|
+
$part->value = PhpHelpers::decodeEscapeSequences($part->value, '"');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return new static($parts, $position);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
public function print(PrintContext $context): string
|
|
44
|
+
{
|
|
45
|
+
$s = '';
|
|
46
|
+
$expr = false;
|
|
47
|
+
foreach ($this->parts as $part) {
|
|
48
|
+
if ($part instanceof EncapsedStringPartNode) {
|
|
49
|
+
$s .= substr($context->encodeString($part->value, '"'), 1, -1);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
$partStr = $part->print($context);
|
|
54
|
+
if ($partStr[0] === '$' &&
|
|
55
|
+
($part instanceof Expression\VariableNode
|
|
56
|
+
|| $part instanceof Expression\PropertyFetchNode
|
|
57
|
+
|| $part instanceof Expression\MethodCallNode
|
|
58
|
+
|| $part instanceof Expression\ArrayAccessNode
|
|
59
|
+
)) {
|
|
60
|
+
$s .= '{' . $partStr . '}';
|
|
61
|
+
|
|
62
|
+
} else {
|
|
63
|
+
$s .= '" . (' . $partStr . ') . "';
|
|
64
|
+
$expr = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return $expr
|
|
69
|
+
? '("' . $s . '")'
|
|
70
|
+
: '"' . $s . '"';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
public function &getIterator(): \Generator
|
|
75
|
+
{
|
|
76
|
+
foreach ($this->parts as &$item) {
|
|
77
|
+
yield $item;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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\Scalar;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ScalarNode;
|
|
13
|
+
use Latte\Compiler\Position;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class EncapsedStringPartNode extends ScalarNode
|
|
18
|
+
{
|
|
19
|
+
public function __construct(
|
|
20
|
+
public string $value,
|
|
21
|
+
public ?Position $position = null,
|
|
22
|
+
) {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
public function print(PrintContext $context): string
|
|
27
|
+
{
|
|
28
|
+
throw new \LogicException('Cannot directly print EncapsedStringPart');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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\Scalar;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ScalarNode;
|
|
13
|
+
use Latte\Compiler\PhpHelpers;
|
|
14
|
+
use Latte\Compiler\Position;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class FloatNode extends ScalarNode
|
|
19
|
+
{
|
|
20
|
+
public function __construct(
|
|
21
|
+
public float $value,
|
|
22
|
+
public ?Position $position = null,
|
|
23
|
+
) {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public static function parse(string $str, Position $position): static
|
|
28
|
+
{
|
|
29
|
+
return strpbrk($str, '.eE') === false
|
|
30
|
+
? new static((float) PhpHelpers::decodeNumber($str), $position)
|
|
31
|
+
: new static((float) str_replace('_', '', $str), $position);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
public function print(PrintContext $context): string
|
|
36
|
+
{
|
|
37
|
+
if (!is_finite($this->value)) {
|
|
38
|
+
if ($this->value === \INF) {
|
|
39
|
+
return '\INF';
|
|
40
|
+
} elseif ($this->value === -\INF) {
|
|
41
|
+
return '-\INF';
|
|
42
|
+
} else {
|
|
43
|
+
return '\NAN';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Try to find a short full-precision representation
|
|
48
|
+
$stringValue = sprintf('%.16G', $this->value);
|
|
49
|
+
if ($this->value !== (float) $stringValue) {
|
|
50
|
+
$stringValue = sprintf('%.17G', $this->value);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// %G is locale dependent and there exists no locale-independent alternative. We don't want
|
|
54
|
+
// mess with switching locales here, so let's assume that a comma is the only non-standard
|
|
55
|
+
// decimal separator we may encounter...
|
|
56
|
+
$stringValue = str_replace(',', '.', $stringValue);
|
|
57
|
+
|
|
58
|
+
// ensure that number is really printed as float
|
|
59
|
+
return preg_match('/^-?[0-9]+$/', $stringValue)
|
|
60
|
+
? $stringValue . '.0'
|
|
61
|
+
: $stringValue;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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\Scalar;
|
|
11
|
+
|
|
12
|
+
use Latte\CompileException;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\ScalarNode;
|
|
14
|
+
use Latte\Compiler\PhpHelpers;
|
|
15
|
+
use Latte\Compiler\Position;
|
|
16
|
+
use Latte\Compiler\PrintContext;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class IntegerNode extends ScalarNode
|
|
20
|
+
{
|
|
21
|
+
public const KindBinary = 2;
|
|
22
|
+
public const KindOctal = 8;
|
|
23
|
+
public const KindDecimal = 10;
|
|
24
|
+
public const KindHexa = 16;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public function __construct(
|
|
28
|
+
public int $value,
|
|
29
|
+
public int $kind = self::KindDecimal,
|
|
30
|
+
public ?Position $position = null,
|
|
31
|
+
) {
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
public static function parse(string $str, Position $position): static
|
|
36
|
+
{
|
|
37
|
+
$num = PhpHelpers::decodeNumber($str, $base);
|
|
38
|
+
if ($num === null) {
|
|
39
|
+
throw new CompileException('Invalid numeric literal', $position);
|
|
40
|
+
}
|
|
41
|
+
return new static($num, $base, $position);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
public function print(PrintContext $context): string
|
|
46
|
+
{
|
|
47
|
+
if ($this->value === -\PHP_INT_MAX - 1) {
|
|
48
|
+
// PHP_INT_MIN cannot be represented as a literal, because the sign is not part of the literal
|
|
49
|
+
return '(-' . \PHP_INT_MAX . '-1)';
|
|
50
|
+
|
|
51
|
+
} elseif ($this->kind === self::KindDecimal) {
|
|
52
|
+
return (string) $this->value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if ($this->value < 0) {
|
|
56
|
+
$sign = '-';
|
|
57
|
+
$str = (string) -$this->value;
|
|
58
|
+
} else {
|
|
59
|
+
$sign = '';
|
|
60
|
+
$str = (string) $this->value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return match ($this->kind) {
|
|
64
|
+
self::KindBinary => $sign . '0b' . base_convert($str, 10, 2),
|
|
65
|
+
self::KindOctal => $sign . '0' . base_convert($str, 10, 8),
|
|
66
|
+
self::KindHexa => $sign . '0x' . base_convert($str, 10, 16),
|
|
67
|
+
default => throw new \Exception('Invalid number kind'),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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\Scalar;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ScalarNode;
|
|
13
|
+
use Latte\Compiler\Position;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class NullNode extends ScalarNode
|
|
18
|
+
{
|
|
19
|
+
public function __construct(
|
|
20
|
+
public ?Position $position = null,
|
|
21
|
+
) {
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
public function print(PrintContext $context): string
|
|
26
|
+
{
|
|
27
|
+
return 'null';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -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\Scalar;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\ScalarNode;
|
|
13
|
+
use Latte\Compiler\PhpHelpers;
|
|
14
|
+
use Latte\Compiler\Position;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class StringNode extends ScalarNode
|
|
19
|
+
{
|
|
20
|
+
public function __construct(
|
|
21
|
+
public string $value,
|
|
22
|
+
public ?Position $position = null,
|
|
23
|
+
) {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public static function parse(string $str, Position $position): static
|
|
28
|
+
{
|
|
29
|
+
$str = $str[0] === "'"
|
|
30
|
+
? strtr(substr($str, 1, -1), ['\\\\' => '\\', "\\'" => "'"])
|
|
31
|
+
: PhpHelpers::decodeEscapeSequences(substr($str, 1, -1), '"');
|
|
32
|
+
return new static($str, $position);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
public function print(PrintContext $context): string
|
|
37
|
+
{
|
|
38
|
+
return $context->encodeString($this->value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
abstract class ScalarNode extends ExpressionNode
|
|
14
|
+
{
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Position;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class SuperiorTypeNode extends ComplexTypeNode
|
|
17
|
+
{
|
|
18
|
+
public function __construct(
|
|
19
|
+
public string $type,
|
|
20
|
+
public ?Position $position = null,
|
|
21
|
+
) {
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
public function print(PrintContext $context): string
|
|
26
|
+
{
|
|
27
|
+
throw new \LogicException('Cannot directly print SuperiorTypeNode');
|
|
28
|
+
}
|
|
29
|
+
}
|