@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;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\TemplateNode;
|
|
@@ -19,8 +17,8 @@ use const PHP_VERSION_ID;
|
|
|
19
17
|
*/
|
|
20
18
|
class Engine
|
|
21
19
|
{
|
|
22
|
-
public const Version = '3.1.
|
|
23
|
-
public const VersionId =
|
|
20
|
+
public const Version = '3.1.2';
|
|
21
|
+
public const VersionId = 30102;
|
|
24
22
|
|
|
25
23
|
/** @deprecated use Engine::Version */
|
|
26
24
|
public const
|
|
@@ -53,21 +51,24 @@ class Engine
|
|
|
53
51
|
/** @var Extension[] */
|
|
54
52
|
private array $extensions = [];
|
|
55
53
|
private string $contentType = ContentType::Html;
|
|
56
|
-
private Cache $cache;
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
private Runtime\Cache $cache;
|
|
55
|
+
|
|
56
|
+
/** @var array<string, bool> */
|
|
57
|
+
private array $features = [
|
|
58
|
+
Feature::StrictTypes->name => true,
|
|
59
|
+
];
|
|
60
|
+
|
|
59
61
|
private ?Policy $policy = null;
|
|
60
62
|
private bool $sandboxed = false;
|
|
61
63
|
private ?string $phpBinary = null;
|
|
62
64
|
private ?string $configurationHash;
|
|
63
65
|
private ?string $locale = null;
|
|
64
66
|
private ?string $syntax = null;
|
|
65
|
-
private bool $migrationWarnings = false;
|
|
66
67
|
|
|
67
68
|
|
|
68
69
|
public function __construct()
|
|
69
70
|
{
|
|
70
|
-
$this->cache = new Cache;
|
|
71
|
+
$this->cache = new Runtime\Cache;
|
|
71
72
|
$this->filters = new Runtime\FilterExecutor;
|
|
72
73
|
$this->functions = new Runtime\FunctionExecutor;
|
|
73
74
|
$this->providers = new \stdClass;
|
|
@@ -158,7 +159,7 @@ class Engine
|
|
|
158
159
|
{
|
|
159
160
|
$parser = new Compiler\TemplateParser;
|
|
160
161
|
$parser->getLexer()->setSyntax($this->syntax);
|
|
161
|
-
$parser->strict = $this->
|
|
162
|
+
$parser->strict = $this->hasFeature(Feature::StrictParsing);
|
|
162
163
|
|
|
163
164
|
foreach ($this->extensions as $extension) {
|
|
164
165
|
$extension->beforeCompile($this);
|
|
@@ -196,8 +197,8 @@ class Engine
|
|
|
196
197
|
public function generate(TemplateNode $node, string $name): string
|
|
197
198
|
{
|
|
198
199
|
$generator = new Compiler\TemplateGenerator;
|
|
199
|
-
$generator->buildClass($node, $this->
|
|
200
|
-
return $generator->generateCode($this->getTemplateClass($name), $name, $this->
|
|
200
|
+
$generator->buildClass($node, $this->features);
|
|
201
|
+
return $generator->generateCode($this->getTemplateClass($name), $name, $this->hasFeature(Feature::StrictTypes));
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
|
|
@@ -215,17 +216,18 @@ class Engine
|
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
|
|
219
|
+
/** @return class-string<Runtime\Template> */
|
|
218
220
|
private function loadTemplate(string $name): string
|
|
219
221
|
{
|
|
220
222
|
$class = $this->getTemplateClass($name);
|
|
221
|
-
if (class_exists($class, false)) {
|
|
223
|
+
if (class_exists($class, autoload: false)) {
|
|
222
224
|
// nothing
|
|
223
225
|
} elseif ($this->cache->directory) {
|
|
224
226
|
$this->cache->loadOrCreate($this, $name);
|
|
225
227
|
} else {
|
|
226
228
|
$compiled = $this->compile($name);
|
|
227
229
|
if (@eval(substr($compiled, 5)) === false) { // @ is escalated to exception, substr removes <?php
|
|
228
|
-
throw (new CompileException('Error in template: ' . error_get_last()['message']))
|
|
230
|
+
throw (new CompileException('Error in template: ' . (error_get_last()['message'] ?? '')))
|
|
229
231
|
->setSource($compiled, "$name (compiled)");
|
|
230
232
|
}
|
|
231
233
|
}
|
|
@@ -267,13 +269,13 @@ class Engine
|
|
|
267
269
|
/**
|
|
268
270
|
* Returns values that determine isolation for different configurations.
|
|
269
271
|
* When any of these values change, a new compiled template is created to avoid conflicts.
|
|
272
|
+
* @return list<mixed>
|
|
270
273
|
*/
|
|
271
274
|
protected function generateConfigurationSignature(): array
|
|
272
275
|
{
|
|
273
276
|
return [
|
|
274
277
|
$this->contentType,
|
|
275
|
-
$this->
|
|
276
|
-
$this->strictParsing,
|
|
278
|
+
$this->features,
|
|
277
279
|
$this->syntax,
|
|
278
280
|
array_map(
|
|
279
281
|
fn($extension) => [get_debug_type($extension), $extension->getCacheKey($this)],
|
|
@@ -308,7 +310,7 @@ class Engine
|
|
|
308
310
|
|
|
309
311
|
/**
|
|
310
312
|
* Returns all run-time filters.
|
|
311
|
-
* @return callable
|
|
313
|
+
* @return array<string, callable>
|
|
312
314
|
*/
|
|
313
315
|
public function getFilters(): array
|
|
314
316
|
{
|
|
@@ -347,10 +349,10 @@ class Engine
|
|
|
347
349
|
}
|
|
348
350
|
|
|
349
351
|
|
|
350
|
-
/** @return Extension
|
|
352
|
+
/** @return list<Extension> */
|
|
351
353
|
public function getExtensions(): array
|
|
352
354
|
{
|
|
353
|
-
return $this->extensions;
|
|
355
|
+
return array_values($this->extensions);
|
|
354
356
|
}
|
|
355
357
|
|
|
356
358
|
|
|
@@ -379,7 +381,7 @@ class Engine
|
|
|
379
381
|
|
|
380
382
|
|
|
381
383
|
/**
|
|
382
|
-
* @return callable
|
|
384
|
+
* @return array<string, callable>
|
|
383
385
|
*/
|
|
384
386
|
public function getFunctions(): array
|
|
385
387
|
{
|
|
@@ -403,7 +405,7 @@ class Engine
|
|
|
403
405
|
|
|
404
406
|
/**
|
|
405
407
|
* Returns all providers.
|
|
406
|
-
* @return mixed
|
|
408
|
+
* @return array<string, mixed>
|
|
407
409
|
*/
|
|
408
410
|
public function getProviders(): array
|
|
409
411
|
{
|
|
@@ -428,7 +430,7 @@ class Engine
|
|
|
428
430
|
|
|
429
431
|
public function setExceptionHandler(callable $handler): static
|
|
430
432
|
{
|
|
431
|
-
$this->providers->coreExceptionHandler = $handler;
|
|
433
|
+
$this->providers->coreExceptionHandler = $handler(...);
|
|
432
434
|
return $this;
|
|
433
435
|
}
|
|
434
436
|
|
|
@@ -448,15 +450,22 @@ class Engine
|
|
|
448
450
|
|
|
449
451
|
|
|
450
452
|
/**
|
|
451
|
-
* Sets path to
|
|
453
|
+
* Sets path to cache directory.
|
|
452
454
|
*/
|
|
453
|
-
public function
|
|
455
|
+
public function setCacheDirectory(?string $path): static
|
|
454
456
|
{
|
|
455
457
|
$this->cache->directory = $path;
|
|
456
458
|
return $this;
|
|
457
459
|
}
|
|
458
460
|
|
|
459
461
|
|
|
462
|
+
/** @deprecated use setCacheDirectory() instead */
|
|
463
|
+
public function setTempDirectory(?string $path): static
|
|
464
|
+
{
|
|
465
|
+
return $this->setCacheDirectory($path);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
|
|
460
469
|
/**
|
|
461
470
|
* Sets auto-refresh mode.
|
|
462
471
|
*/
|
|
@@ -467,26 +476,46 @@ class Engine
|
|
|
467
476
|
}
|
|
468
477
|
|
|
469
478
|
|
|
479
|
+
/**
|
|
480
|
+
* Enables or disables an engine feature.
|
|
481
|
+
*/
|
|
482
|
+
public function setFeature(Feature $feature, bool $state = true): static
|
|
483
|
+
{
|
|
484
|
+
$this->features[$feature->name] = $state;
|
|
485
|
+
return $this;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Checks if a feature is enabled.
|
|
491
|
+
*/
|
|
492
|
+
public function hasFeature(Feature $feature): bool
|
|
493
|
+
{
|
|
494
|
+
return $this->features[$feature->name] ?? false;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
|
|
470
498
|
/**
|
|
471
499
|
* Enables declare(strict_types=1) in templates.
|
|
500
|
+
* @deprecated use setFeature(Feature::StrictTypes, ...) instead
|
|
472
501
|
*/
|
|
473
502
|
public function setStrictTypes(bool $state = true): static
|
|
474
503
|
{
|
|
475
|
-
$this->
|
|
476
|
-
return $this;
|
|
504
|
+
return $this->setFeature(Feature::StrictTypes, $state);
|
|
477
505
|
}
|
|
478
506
|
|
|
479
507
|
|
|
508
|
+
/** @deprecated use setFeature(Feature::StrictParsing, ...) instead */
|
|
480
509
|
public function setStrictParsing(bool $state = true): static
|
|
481
510
|
{
|
|
482
|
-
$this->
|
|
483
|
-
return $this;
|
|
511
|
+
return $this->setFeature(Feature::StrictParsing, $state);
|
|
484
512
|
}
|
|
485
513
|
|
|
486
514
|
|
|
515
|
+
/** @deprecated use hasFeature(Feature::StrictParsing) instead */
|
|
487
516
|
public function isStrictParsing(): bool
|
|
488
517
|
{
|
|
489
|
-
return $this->
|
|
518
|
+
return $this->hasFeature(Feature::StrictParsing);
|
|
490
519
|
}
|
|
491
520
|
|
|
492
521
|
|
|
@@ -539,16 +568,16 @@ class Engine
|
|
|
539
568
|
}
|
|
540
569
|
|
|
541
570
|
|
|
571
|
+
/** @deprecated use setFeature(Feature::MigrationWarnings, ...) instead */
|
|
542
572
|
public function setMigrationWarnings(bool $state = true): static
|
|
543
573
|
{
|
|
544
|
-
$this->
|
|
545
|
-
return $this;
|
|
574
|
+
return $this->setFeature(Feature::MigrationWarnings, $state);
|
|
546
575
|
}
|
|
547
576
|
|
|
548
577
|
|
|
549
578
|
/**
|
|
550
579
|
* @param object|mixed[] $params
|
|
551
|
-
* @return mixed
|
|
580
|
+
* @return array<string, mixed>
|
|
552
581
|
*/
|
|
553
582
|
private function processParams(object|array $params): array
|
|
554
583
|
{
|
|
@@ -560,11 +589,11 @@ class Engine
|
|
|
560
589
|
$methods = $rc->getMethods(\ReflectionMethod::IS_PUBLIC);
|
|
561
590
|
foreach ($methods as $method) {
|
|
562
591
|
if ($method->getAttributes(Attributes\TemplateFilter::class)) {
|
|
563
|
-
$this->addFilter($method->name,
|
|
592
|
+
$this->addFilter($method->name, $method->getClosure($params));
|
|
564
593
|
}
|
|
565
594
|
|
|
566
595
|
if ($method->getAttributes(Attributes\TemplateFunction::class)) {
|
|
567
|
-
$this->addFunction($method->name,
|
|
596
|
+
$this->addFunction($method->name, $method->getClosure($params));
|
|
568
597
|
}
|
|
569
598
|
}
|
|
570
599
|
|
|
@@ -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\Essential;
|
|
11
9
|
|
|
12
10
|
use function count;
|
|
@@ -21,11 +19,9 @@ use function count;
|
|
|
21
19
|
*/
|
|
22
20
|
class AuxiliaryIterator implements \IteratorAggregate, \Countable
|
|
23
21
|
{
|
|
24
|
-
/**
|
|
25
|
-
* @param array<array{K, V}> $pairs
|
|
26
|
-
*/
|
|
27
22
|
public function __construct(
|
|
28
|
-
|
|
23
|
+
/** @var array<array{K, V}> */
|
|
24
|
+
private readonly array $pairs,
|
|
29
25
|
) {
|
|
30
26
|
}
|
|
31
27
|
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Nette Framework (https://nette.org)
|
|
5
5
|
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential;
|
|
11
9
|
|
|
12
10
|
use Nette\PhpGenerator as Php;
|
|
@@ -19,6 +17,7 @@ use const DIRECTORY_SEPARATOR;
|
|
|
19
17
|
*/
|
|
20
18
|
final class Blueprint
|
|
21
19
|
{
|
|
20
|
+
/** @param array<string, mixed> $params */
|
|
22
21
|
public function generateTemplateClass(
|
|
23
22
|
array $params,
|
|
24
23
|
?string $name = 'Template',
|
|
@@ -140,7 +139,7 @@ final class Blueprint
|
|
|
140
139
|
. ($param->isReference() ? '&' : '')
|
|
141
140
|
. ($variadic ? '...' : '')
|
|
142
141
|
. '$' . $param->getName()
|
|
143
|
-
. ($param->hasDefaultValue() && !$variadic ? ' = ' . var_export($param->getDefaultValue(), true) : '');
|
|
142
|
+
. ($param->hasDefaultValue() && !$variadic ? ' = ' . var_export($param->getDefaultValue(), return: true) : '');
|
|
144
143
|
}
|
|
145
144
|
|
|
146
145
|
return '(' . implode(', ', $params) . ')';
|
|
@@ -177,7 +176,7 @@ final class Blueprint
|
|
|
177
176
|
}
|
|
178
177
|
|
|
179
178
|
|
|
180
|
-
private function getType($value): string
|
|
179
|
+
private function getType(mixed $value): string
|
|
181
180
|
{
|
|
182
181
|
return $value === null ? 'mixed' : get_debug_type($value);
|
|
183
182
|
}
|
|
@@ -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\Essential;
|
|
11
9
|
|
|
12
10
|
use function get_debug_type, is_array, max, method_exists, sprintf;
|
|
@@ -25,6 +23,7 @@ use function get_debug_type, is_array, max, method_exists, sprintf;
|
|
|
25
23
|
* @property-read mixed $nextKey
|
|
26
24
|
* @property-read mixed $nextValue
|
|
27
25
|
* @property-read ?self $parent
|
|
26
|
+
* @extends \CachingIterator<mixed, mixed, \Iterator<mixed, mixed>>
|
|
28
27
|
* @internal
|
|
29
28
|
*/
|
|
30
29
|
class CachingIterator extends \CachingIterator implements \Countable
|