@vituum/vite-plugin-latte 2.0.0-next.5 → 2.0.1
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 +2 -1
- package/package.json +20 -10
- package/vendor/composer/autoload_classmap.php +3 -2
- package/vendor/composer/autoload_static.php +3 -2
- package/vendor/composer/installed.json +21 -17
- package/vendor/composer/installed.php +8 -8
- package/vendor/latte/latte/composer.json +9 -2
- package/vendor/latte/latte/src/Bridges/Tracy/BlueScreenPanel.php +7 -7
- package/vendor/latte/latte/src/Bridges/Tracy/LattePanel.php +5 -4
- package/vendor/latte/latte/src/Bridges/Tracy/TracyExtension.php +2 -4
- package/vendor/latte/latte/src/Bridges/Tracy/dist/panel.phtml +2 -4
- package/vendor/latte/latte/src/Bridges/Tracy/dist/tab.phtml +2 -4
- package/vendor/latte/latte/src/Latte/Compiler/Block.php +1 -3
- package/vendor/latte/latte/src/Latte/Compiler/Escaper.php +4 -8
- package/vendor/latte/latte/src/Latte/Compiler/Node.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/NodeHelpers.php +15 -6
- package/vendor/latte/latte/src/Latte/Compiler/NodeTraverser.php +14 -9
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AreaNode.php +7 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AuxiliaryNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/FragmentNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/AttributeNode.php +6 -5
- 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 +5 -7
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ExpressionAttributeNode.php +6 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/TagNode.php +1 -3
- 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 -3
- 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 +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AuxiliaryNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/BinaryOpNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CastNode.php +4 -3
- 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 +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureNode.php +7 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ConstantFetchNode.php +5 -4
- 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 +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallNode.php +4 -3
- 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 +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/IssetNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MatchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NewNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PostOpNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PreOpNode.php +4 -3
- 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 +4 -3
- 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 +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/UnaryOpNode.php +4 -3
- 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 +4 -3
- 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 +4 -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 +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ModifierNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NameNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NullableTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/OperatorNode.php +1 -3
- 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 +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/IntegerNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/InterpolatedStringNode.php +6 -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 +5 -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 +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/VarLikeIdentifierNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/VariadicPlaceholderNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/PrintNode.php +3 -4
- 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 +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/PhpHelpers.php +23 -15
- package/vendor/latte/latte/src/Latte/Compiler/Position.php +5 -7
- package/vendor/latte/latte/src/Latte/Compiler/PrintContext.php +30 -9
- package/vendor/latte/latte/src/Latte/Compiler/Tag.php +6 -6
- package/vendor/latte/latte/src/Latte/Compiler/TagLexer.php +4 -6
- package/vendor/latte/latte/src/Latte/Compiler/TagParser.php +14 -11
- package/vendor/latte/latte/src/Latte/Compiler/TagParserData.php +2 -4
- package/vendor/latte/latte/src/Latte/Compiler/TemplateGenerator.php +13 -11
- package/vendor/latte/latte/src/Latte/Compiler/TemplateLexer.php +21 -7
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParser.php +32 -19
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParserHtml.php +28 -21
- package/vendor/latte/latte/src/Latte/Compiler/Token.php +10 -9
- package/vendor/latte/latte/src/Latte/Compiler/TokenStream.php +20 -14
- package/vendor/latte/latte/src/Latte/ContentType.php +4 -3
- package/vendor/latte/latte/src/Latte/Engine.php +64 -35
- package/vendor/latte/latte/src/Latte/Essential/AuxiliaryIterator.php +3 -7
- package/vendor/latte/latte/src/Latte/Essential/Blueprint.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/CachingIterator.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/CoreExtension.php +1 -3
- package/vendor/latte/latte/src/Latte/Essential/Filters.php +65 -32
- package/vendor/latte/latte/src/Latte/Essential/Nodes/BlockNode.php +8 -6
- 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 +2 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DebugbreakNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DefineNode.php +6 -6
- 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 +3 -5
- 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 +3 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForeachNode.php +7 -8
- 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 +6 -9
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ImportNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeBlockNode.php +8 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeFileNode.php +2 -4
- 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 +3 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NClassNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NElseNode.php +8 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NTagNode.php +4 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ParametersNode.php +4 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RawPhpNode.php +2 -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 +3 -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 +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TryNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarNode.php +8 -7
- 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 +26 -15
- package/vendor/latte/latte/src/Latte/Essential/RawPhpExtension.php +1 -3
- package/vendor/latte/latte/src/Latte/Essential/RollbackException.php +1 -3
- package/vendor/latte/latte/src/Latte/Essential/Tracer.php +20 -13
- package/vendor/latte/latte/src/Latte/Essential/TranslatorExtension.php +9 -10
- package/vendor/latte/latte/src/Latte/Extension.php +10 -6
- package/vendor/latte/latte/src/Latte/Feature.php +24 -0
- package/vendor/latte/latte/src/Latte/Helpers.php +18 -10
- package/vendor/latte/latte/src/Latte/Loader.php +1 -3
- package/vendor/latte/latte/src/Latte/Loaders/FileLoader.php +8 -5
- package/vendor/latte/latte/src/Latte/Loaders/StringLoader.php +5 -13
- 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/{Cache.php → Runtime/Cache.php} +12 -11
- package/vendor/latte/latte/src/Latte/Runtime/FilterExecutor.php +3 -5
- package/vendor/latte/latte/src/Latte/Runtime/FilterInfo.php +10 -11
- package/vendor/latte/latte/src/Latte/Runtime/FunctionExecutor.php +4 -6
- package/vendor/latte/latte/src/Latte/Runtime/Helpers.php +5 -7
- package/vendor/latte/latte/src/Latte/Runtime/Html.php +3 -5
- package/vendor/latte/latte/src/Latte/Runtime/HtmlHelpers.php +18 -18
- package/vendor/latte/latte/src/Latte/Runtime/HtmlStringable.php +1 -3
- package/vendor/latte/latte/src/Latte/Runtime/Template.php +23 -42
- package/vendor/latte/latte/src/Latte/Runtime/XmlHelpers.php +5 -7
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallNode.php +14 -8
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallNode.php +17 -11
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/PropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/SandboxNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticMethodCallNode.php +16 -10
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticPropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Sandbox/RuntimeChecker.php +6 -5
- package/vendor/latte/latte/src/Latte/Sandbox/SandboxExtension.php +5 -4
- package/vendor/latte/latte/src/Latte/Sandbox/SecurityPolicy.php +17 -16
- package/vendor/latte/latte/src/Latte/attributes.php +7 -3
- package/vendor/latte/latte/src/Latte/exceptions.php +38 -3
- package/vendor/latte/latte/src/Tools/Linter.php +20 -14
- package/vendor/latte/latte/src/Tools/LinterExtension.php +26 -7
- package/vendor/nette/utils/composer.json +8 -1
- package/vendor/nette/utils/src/HtmlStringable.php +4 -1
- package/vendor/nette/utils/src/Iterators/CachingIterator.php +9 -24
- 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 -1
- package/vendor/nette/utils/src/Translator.php +1 -1
- package/vendor/nette/utils/src/Utils/ArrayHash.php +1 -5
- package/vendor/nette/utils/src/Utils/ArrayList.php +3 -6
- package/vendor/nette/utils/src/Utils/Arrays.php +33 -10
- package/vendor/nette/utils/src/Utils/Callback.php +12 -7
- package/vendor/nette/utils/src/Utils/DateTime.php +1 -1
- package/vendor/nette/utils/src/Utils/FileInfo.php +5 -7
- package/vendor/nette/utils/src/Utils/FileSystem.php +5 -2
- package/vendor/nette/utils/src/Utils/Finder.php +27 -8
- package/vendor/nette/utils/src/Utils/Helpers.php +7 -1
- package/vendor/nette/utils/src/Utils/Html.php +123 -118
- package/vendor/nette/utils/src/Utils/Image.php +72 -54
- package/vendor/nette/utils/src/Utils/ImageColor.php +4 -0
- package/vendor/nette/utils/src/Utils/Iterables.php +16 -8
- package/vendor/nette/utils/src/Utils/Paginator.php +10 -43
- package/vendor/nette/utils/src/Utils/Reflection.php +17 -7
- package/vendor/nette/utils/src/Utils/ReflectionMethod.php +4 -1
- package/vendor/nette/utils/src/Utils/Strings.php +48 -15
- package/vendor/nette/utils/src/Utils/Type.php +41 -27
- package/vendor/nette/utils/src/Utils/Validators.php +8 -7
- package/vendor/latte/latte/src/Bridges/Tracy/panel.latte +0 -94
- package/vendor/latte/latte/src/Bridges/Tracy/tab.latte +0 -8
- package/vendor/latte/latte/src/Latte/PositionAwareException.php +0 -47
|
@@ -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;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -15,6 +13,9 @@ use Latte\Compiler\Position;
|
|
|
15
13
|
use Latte\Compiler\PrintContext;
|
|
16
14
|
|
|
17
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Array destructuring ([$a, $b] = $arr).
|
|
18
|
+
*/
|
|
18
19
|
class ListNode extends Node
|
|
19
20
|
{
|
|
20
21
|
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;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Node;
|
|
@@ -15,6 +13,9 @@ use Latte\Compiler\PrintContext;
|
|
|
15
13
|
use Latte\Helpers;
|
|
16
14
|
|
|
17
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Match expression arm with conditions and body.
|
|
18
|
+
*/
|
|
18
19
|
class MatchArmNode extends Node
|
|
19
20
|
{
|
|
20
21
|
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;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Node;
|
|
@@ -15,6 +13,9 @@ use Latte\Compiler\PrintContext;
|
|
|
15
13
|
use Latte\Helpers;
|
|
16
14
|
|
|
17
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Chain of filters with auto-escape flag.
|
|
18
|
+
*/
|
|
18
19
|
class ModifierNode extends Node
|
|
19
20
|
{
|
|
20
21
|
/** @deprecated */
|
|
@@ -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;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Node;
|
|
@@ -15,6 +13,9 @@ use Latte\Compiler\PrintContext;
|
|
|
15
13
|
use function array_flip, str_starts_with, strtolower, substr;
|
|
16
14
|
|
|
17
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Qualified name for functions, classes, or constants (\Foo\Bar).
|
|
18
|
+
*/
|
|
18
19
|
class NameNode extends Node
|
|
19
20
|
{
|
|
20
21
|
public const
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Compiler\Nodes\Php;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Position;
|
|
13
11
|
use Latte\Compiler\PrintContext;
|
|
14
12
|
|
|
15
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Nullable type (?Type).
|
|
16
|
+
*/
|
|
16
17
|
class NullableTypeNode extends ComplexTypeNode
|
|
17
18
|
{
|
|
18
19
|
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;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -15,6 +13,9 @@ use Latte\Compiler\Position;
|
|
|
15
13
|
use Latte\Compiler\PrintContext;
|
|
16
14
|
|
|
17
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Function parameter with type, default value, and variadic support.
|
|
18
|
+
*/
|
|
18
19
|
class ParameterNode extends Node
|
|
19
20
|
{
|
|
20
21
|
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\Scalar;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\Php\ScalarNode;
|
|
@@ -14,6 +12,9 @@ use Latte\Compiler\Position;
|
|
|
14
12
|
use Latte\Compiler\PrintContext;
|
|
15
13
|
|
|
16
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Boolean literal (true/false).
|
|
17
|
+
*/
|
|
17
18
|
class BooleanNode extends ScalarNode
|
|
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\Scalar;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\Php\ScalarNode;
|
|
@@ -17,6 +15,9 @@ use function is_finite, preg_match, sprintf, str_replace, strpbrk;
|
|
|
17
15
|
use const INF;
|
|
18
16
|
|
|
19
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Floating-point literal including infinity and NaN.
|
|
20
|
+
*/
|
|
20
21
|
class FloatNode extends ScalarNode
|
|
21
22
|
{
|
|
22
23
|
public function __construct(
|
|
@@ -26,7 +27,7 @@ class FloatNode extends ScalarNode
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
|
|
29
|
-
public static function parse(string $str, Position $position): static
|
|
30
|
+
public static function parse(string $str, ?Position $position): static
|
|
30
31
|
{
|
|
31
32
|
return strpbrk($str, '.eE') === false
|
|
32
33
|
? new static((float) PhpHelpers::decodeNumber($str), $position)
|
|
@@ -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\Scalar;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -17,6 +15,9 @@ use Latte\Compiler\PrintContext;
|
|
|
17
15
|
use const PHP_INT_MAX;
|
|
18
16
|
|
|
19
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Integer literal in decimal, hex, octal, or binary notation.
|
|
20
|
+
*/
|
|
20
21
|
class IntegerNode extends ScalarNode
|
|
21
22
|
{
|
|
22
23
|
public const KindBinary = 2;
|
|
@@ -33,7 +34,7 @@ class IntegerNode extends ScalarNode
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
public static function parse(string $str, Position $position): static
|
|
37
|
+
public static function parse(string $str, ?Position $position): static
|
|
37
38
|
{
|
|
38
39
|
$num = PhpHelpers::decodeNumber($str, $base);
|
|
39
40
|
if ($num === null) {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Compiler\Nodes\Php\Scalar;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
@@ -19,6 +17,9 @@ use Latte\Helpers;
|
|
|
19
17
|
use function substr;
|
|
20
18
|
|
|
21
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Double-quoted string with embedded expressions ("Hello $name").
|
|
22
|
+
*/
|
|
22
23
|
class InterpolatedStringNode extends ScalarNode
|
|
23
24
|
{
|
|
24
25
|
public function __construct(
|
|
@@ -29,8 +30,8 @@ class InterpolatedStringNode extends ScalarNode
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
|
|
32
|
-
/** @param array<ExpressionNode|InterpolatedStringPartNode>
|
|
33
|
-
public static function parse(array $parts, Position $position): static
|
|
33
|
+
/** @param array<ExpressionNode|InterpolatedStringPartNode> $parts */
|
|
34
|
+
public static function parse(array $parts, ?Position $position): static
|
|
34
35
|
{
|
|
35
36
|
foreach ($parts as $part) {
|
|
36
37
|
if ($part instanceof InterpolatedStringPartNode) {
|
|
@@ -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\Scalar;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\Php\ScalarNode;
|
|
@@ -14,6 +12,9 @@ use Latte\Compiler\Position;
|
|
|
14
12
|
use Latte\Compiler\PrintContext;
|
|
15
13
|
|
|
16
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Null literal.
|
|
17
|
+
*/
|
|
17
18
|
class NullNode extends ScalarNode
|
|
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\Scalar;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\Php\ScalarNode;
|
|
@@ -16,6 +14,9 @@ use Latte\Compiler\PrintContext;
|
|
|
16
14
|
use function strtr, substr;
|
|
17
15
|
|
|
18
16
|
|
|
17
|
+
/**
|
|
18
|
+
* String literal, single or double quoted.
|
|
19
|
+
*/
|
|
19
20
|
class StringNode extends ScalarNode
|
|
20
21
|
{
|
|
21
22
|
public function __construct(
|
|
@@ -25,7 +26,7 @@ class StringNode extends ScalarNode
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
|
|
28
|
-
public static function parse(string $str, Position $position): static
|
|
29
|
+
public static function parse(string $str, ?Position $position): static
|
|
29
30
|
{
|
|
30
31
|
$str = $str[0] === "'"
|
|
31
32
|
? strtr(substr($str, 1, -1), ['\\\\' => '\\', "\\'" => "'"])
|
|
@@ -1,15 +1,16 @@
|
|
|
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;
|
|
11
9
|
|
|
12
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Base for literal value nodes (strings, numbers, booleans, null).
|
|
13
|
+
*/
|
|
13
14
|
abstract class ScalarNode extends ExpressionNode
|
|
14
15
|
{
|
|
15
16
|
public function &getIterator(): \Generator
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Compiler\Nodes\Php;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Position;
|
|
13
11
|
use Latte\Compiler\PrintContext;
|
|
14
12
|
|
|
15
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Type not expressible in native PHP syntax (e.g., int[], array<K,V>).
|
|
16
|
+
*/
|
|
16
17
|
class SuperiorTypeNode extends ComplexTypeNode
|
|
17
18
|
{
|
|
18
19
|
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;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Position;
|
|
@@ -14,6 +12,9 @@ use Latte\Compiler\PrintContext;
|
|
|
14
12
|
use Latte\Helpers;
|
|
15
13
|
|
|
16
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Union type (Type1|Type2).
|
|
17
|
+
*/
|
|
17
18
|
class UnionTypeNode extends ComplexTypeNode
|
|
18
19
|
{
|
|
19
20
|
public function __construct(
|
|
@@ -1,17 +1,18 @@
|
|
|
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;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\PrintContext;
|
|
13
11
|
|
|
14
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Identifier for static property name in Foo::$bar syntax.
|
|
15
|
+
*/
|
|
15
16
|
class VarLikeIdentifierNode extends IdentifierNode
|
|
16
17
|
{
|
|
17
18
|
public function print(PrintContext $context): string
|
|
@@ -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;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Node;
|
|
@@ -14,6 +12,9 @@ use Latte\Compiler\Position;
|
|
|
14
12
|
use Latte\Compiler\PrintContext;
|
|
15
13
|
|
|
16
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Placeholder ... for partial function application or first-class callable creation.
|
|
17
|
+
*/
|
|
17
18
|
class VariadicPlaceholderNode extends Node
|
|
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;
|
|
11
9
|
|
|
12
10
|
use Latte;
|
|
@@ -18,7 +16,8 @@ use Latte\Compiler\TemplateParser;
|
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
|
-
* {=
|
|
19
|
+
* {= $expr|filter}
|
|
20
|
+
* Outputs escaped expression.
|
|
22
21
|
*/
|
|
23
22
|
class PrintNode extends StatementNode
|
|
24
23
|
{
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Compiler\Nodes;
|
|
11
9
|
|
|
12
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Base for Latte tags like {if}, {foreach}, {block}.
|
|
13
|
+
*
|
|
14
|
+
* Extend this class when creating custom tags. Implement static create(Tag)
|
|
15
|
+
* for parsing and print(PrintContext) for PHP code generation.
|
|
16
|
+
*/
|
|
13
17
|
abstract class StatementNode extends AreaNode
|
|
14
18
|
{
|
|
15
19
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Compiler\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Node;
|
|
13
11
|
use Latte\Compiler\PrintContext;
|
|
14
12
|
|
|
15
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Root of template AST containing head declarations and main content fragment.
|
|
16
|
+
*/
|
|
16
17
|
final class TemplateNode extends Node
|
|
17
18
|
{
|
|
18
19
|
public FragmentNode $head;
|
|
@@ -1,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;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Position;
|
|
@@ -14,6 +12,9 @@ use Latte\Compiler\PrintContext;
|
|
|
14
12
|
use function trim, var_export;
|
|
15
13
|
|
|
16
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Literal text content in template.
|
|
17
|
+
*/
|
|
17
18
|
class TextNode extends AreaNode
|
|
18
19
|
{
|
|
19
20
|
public function __construct(
|
|
@@ -27,7 +28,7 @@ class TextNode extends AreaNode
|
|
|
27
28
|
{
|
|
28
29
|
return $this->content === ''
|
|
29
30
|
? ''
|
|
30
|
-
: 'echo ' . var_export($this->content, true) . ";\n";
|
|
31
|
+
: 'echo ' . var_export($this->content, return: true) . ";\n";
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Compiler;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -49,11 +47,11 @@ final class PhpHelpers
|
|
|
49
47
|
} elseif ($name === T_WHITESPACE) {
|
|
50
48
|
$prev = $tokens[$n - 1];
|
|
51
49
|
$lines = substr_count($token, "\n");
|
|
52
|
-
if ($prev === '}' && in_array($next[0], [T_ELSE, T_ELSEIF, T_CATCH, T_FINALLY], true)) {
|
|
50
|
+
if ($prev === '}' && in_array($next[0], [T_ELSE, T_ELSEIF, T_CATCH, T_FINALLY], strict: true)) {
|
|
53
51
|
$token = ' ';
|
|
54
52
|
} elseif ($prev === '{' || $prev === '}' || $prev === ';' || $lines) {
|
|
55
53
|
$token = str_repeat("\n", max(1, $lines)) . str_repeat("\t", $level); // indent last line
|
|
56
|
-
} elseif ($prev[0] === T_OPEN_TAG) {
|
|
54
|
+
} elseif (is_array($prev) && $prev[0] === T_OPEN_TAG) {
|
|
57
55
|
$token = '';
|
|
58
56
|
}
|
|
59
57
|
|
|
@@ -70,7 +68,7 @@ final class PhpHelpers
|
|
|
70
68
|
throw new \LogicException('Unexpected token');
|
|
71
69
|
|
|
72
70
|
} else {
|
|
73
|
-
if (in_array($name, [T_CURLY_OPEN, T_DOLLAR_OPEN_CURLY_BRACES], true)) {
|
|
71
|
+
if (in_array($name, [T_CURLY_OPEN, T_DOLLAR_OPEN_CURLY_BRACES], strict: true)) {
|
|
74
72
|
$level++;
|
|
75
73
|
}
|
|
76
74
|
|
|
@@ -100,6 +98,9 @@ final class PhpHelpers
|
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Exports value to PHP code representation.
|
|
103
|
+
*/
|
|
103
104
|
public static function dump(mixed $value, bool $multiline = false): string
|
|
104
105
|
{
|
|
105
106
|
if (is_array($value)) {
|
|
@@ -115,33 +116,37 @@ final class PhpHelpers
|
|
|
115
116
|
} elseif ($value === null) {
|
|
116
117
|
return 'null';
|
|
117
118
|
} else {
|
|
118
|
-
return var_export($value, true);
|
|
119
|
+
return var_export($value, return: true);
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Optimizes consecutive echo statements into single call.
|
|
126
|
+
*/
|
|
123
127
|
public static function optimizeEcho(string $source): string
|
|
124
128
|
{
|
|
125
129
|
$res = '';
|
|
126
130
|
$tokens = token_get_all($source);
|
|
127
131
|
$start = null;
|
|
132
|
+
$str = '';
|
|
128
133
|
|
|
129
134
|
for ($i = 0; $i < count($tokens); $i++) {
|
|
130
135
|
$token = $tokens[$i];
|
|
131
136
|
if ($token[0] === T_ECHO) {
|
|
132
|
-
if (
|
|
137
|
+
if ($start === null) {
|
|
133
138
|
$str = '';
|
|
134
139
|
$start = strlen($res);
|
|
135
140
|
}
|
|
136
141
|
|
|
137
|
-
} elseif ($start && $token[0] === T_CONSTANT_ENCAPSED_STRING && $token[1][0] === "'") {
|
|
142
|
+
} elseif ($start !== null && $token[0] === T_CONSTANT_ENCAPSED_STRING && $token[1][0] === "'") {
|
|
138
143
|
$str .= stripslashes(substr($token[1], 1, -1));
|
|
139
144
|
|
|
140
|
-
} elseif ($start && $token === ';') {
|
|
145
|
+
} elseif ($start !== null && $token === ';') {
|
|
141
146
|
if ($str !== '') {
|
|
142
147
|
$res = substr_replace(
|
|
143
148
|
$res,
|
|
144
|
-
'echo ' . ($str === "\n" ? '"\n"' : var_export($str, true)),
|
|
149
|
+
'echo ' . ($str === "\n" ? '"\n"' : var_export($str, return: true)),
|
|
145
150
|
$start,
|
|
146
151
|
strlen($res) - $start,
|
|
147
152
|
);
|
|
@@ -158,7 +163,10 @@ final class PhpHelpers
|
|
|
158
163
|
}
|
|
159
164
|
|
|
160
165
|
|
|
161
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Decodes number string to int or float value.
|
|
168
|
+
*/
|
|
169
|
+
public static function decodeNumber(string $str, ?int &$base = null): int|float|null
|
|
162
170
|
{
|
|
163
171
|
$str = str_replace('_', '', $str);
|
|
164
172
|
|
|
@@ -203,11 +211,11 @@ final class PhpHelpers
|
|
|
203
211
|
if (isset($replacements[$ch])) {
|
|
204
212
|
return $replacements[$ch];
|
|
205
213
|
} elseif ($ch[0] === 'x' || $ch[0] === 'X') {
|
|
206
|
-
return chr(hexdec(substr($ch, 1)));
|
|
214
|
+
return chr((int) hexdec(substr($ch, 1)));
|
|
207
215
|
} elseif ($ch[0] === 'u') {
|
|
208
|
-
return self::codePointToUtf8(hexdec($matches[2]));
|
|
216
|
+
return self::codePointToUtf8((int) hexdec($matches[2]));
|
|
209
217
|
} else {
|
|
210
|
-
$num = octdec($ch);
|
|
218
|
+
$num = (int) octdec($ch);
|
|
211
219
|
if ($num > 255) {
|
|
212
220
|
throw new CompileException("Octal escape sequence \\$ch is greater than \\377");
|
|
213
221
|
}
|