@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\Runtime;
|
|
11
9
|
|
|
12
10
|
use Latte;
|
|
@@ -16,7 +14,7 @@ use function array_keys, array_merge, array_pop, end, in_array, is_array, next,
|
|
|
16
14
|
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
|
-
*
|
|
17
|
+
* Base class for compiled templates.
|
|
20
18
|
*/
|
|
21
19
|
class Template
|
|
22
20
|
{
|
|
@@ -29,14 +27,6 @@ class Template
|
|
|
29
27
|
|
|
30
28
|
public const Blocks = [];
|
|
31
29
|
|
|
32
|
-
/** global accumulators for intermediate results */
|
|
33
|
-
public \stdClass $global;
|
|
34
|
-
|
|
35
|
-
/** @var mixed[] @internal */
|
|
36
|
-
protected array $params = [];
|
|
37
|
-
|
|
38
|
-
protected FilterExecutor $filters;
|
|
39
|
-
|
|
40
30
|
/** @internal */
|
|
41
31
|
protected string|false|null $parentName = null;
|
|
42
32
|
|
|
@@ -48,28 +38,18 @@ class Template
|
|
|
48
38
|
|
|
49
39
|
/** @var mixed[][] */
|
|
50
40
|
private array $blockStack = [];
|
|
51
|
-
|
|
52
|
-
private Engine $engine;
|
|
53
|
-
private string $name;
|
|
54
41
|
private ?Template $referringTemplate = null;
|
|
55
42
|
private ?string $referenceType = null;
|
|
56
43
|
|
|
57
44
|
|
|
58
|
-
/**
|
|
59
|
-
* @param mixed[] $params
|
|
60
|
-
*/
|
|
61
45
|
public function __construct(
|
|
62
|
-
Engine $engine,
|
|
63
|
-
array
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
private readonly Engine $engine,
|
|
47
|
+
/** @var array<string, mixed> */
|
|
48
|
+
protected array $params,
|
|
49
|
+
protected FilterExecutor $filters,
|
|
50
|
+
public \stdClass $global,
|
|
51
|
+
private readonly string $name,
|
|
67
52
|
) {
|
|
68
|
-
$this->engine = $engine;
|
|
69
|
-
$this->params = $params;
|
|
70
|
-
$this->filters = $filters;
|
|
71
|
-
$this->name = $name;
|
|
72
|
-
$this->global = $providers;
|
|
73
53
|
$this->initBlockLayer(self::LayerTop);
|
|
74
54
|
$this->initBlockLayer(self::LayerLocal);
|
|
75
55
|
$this->initBlockLayer(self::LayerSnippet);
|
|
@@ -135,10 +115,12 @@ class Template
|
|
|
135
115
|
throw new Latte\RuntimeException("Cannot include undefined block '$name'$hint");
|
|
136
116
|
}
|
|
137
117
|
|
|
118
|
+
$fn = reset($block->functions);
|
|
119
|
+
assert($fn !== false);
|
|
138
120
|
$this->filter(
|
|
139
|
-
fn() =>
|
|
121
|
+
fn() => $fn($params),
|
|
140
122
|
$mod,
|
|
141
|
-
$block->contentType,
|
|
123
|
+
$block->contentType ?? static::ContentType,
|
|
142
124
|
"block $name",
|
|
143
125
|
);
|
|
144
126
|
}
|
|
@@ -191,9 +173,9 @@ class Template
|
|
|
191
173
|
$child->referenceType = $relation;
|
|
192
174
|
$child->global = $this->global;
|
|
193
175
|
|
|
194
|
-
if (in_array($relation, ['extends', 'includeblock', 'import', 'embed'], true)) {
|
|
176
|
+
if (in_array($relation, ['extends', 'includeblock', 'import', 'embed'], strict: true)) {
|
|
195
177
|
foreach ($child->blocks[self::LayerTop] as $nm => $block) {
|
|
196
|
-
$this->addBlock($nm, $block->contentType, $block->functions);
|
|
178
|
+
$this->addBlock($nm, $block->contentType ?? static::ContentType, $block->functions);
|
|
197
179
|
}
|
|
198
180
|
|
|
199
181
|
$child->blocks[self::LayerTop] = &$this->blocks[self::LayerTop];
|
|
@@ -261,7 +243,7 @@ class Template
|
|
|
261
243
|
|
|
262
244
|
/**
|
|
263
245
|
* Returns array of all parameters.
|
|
264
|
-
* @return mixed
|
|
246
|
+
* @return array<string, mixed>
|
|
265
247
|
*/
|
|
266
248
|
public function getParameters(): array
|
|
267
249
|
{
|
|
@@ -287,14 +269,14 @@ class Template
|
|
|
287
269
|
}
|
|
288
270
|
|
|
289
271
|
|
|
290
|
-
/** @return mixed
|
|
272
|
+
/** @return array<string, mixed> */
|
|
291
273
|
public function prepare(): array
|
|
292
274
|
{
|
|
293
275
|
return $this->params;
|
|
294
276
|
}
|
|
295
277
|
|
|
296
278
|
|
|
297
|
-
/** @param mixed[]
|
|
279
|
+
/** @param mixed[] $params */
|
|
298
280
|
public function main(array $params): void
|
|
299
281
|
{
|
|
300
282
|
}
|
|
@@ -305,7 +287,7 @@ class Template
|
|
|
305
287
|
|
|
306
288
|
/**
|
|
307
289
|
* Creates block if doesn't exist and checks if content type is the same.
|
|
308
|
-
* @param
|
|
290
|
+
* @param \Closure[] $functions
|
|
309
291
|
* @internal
|
|
310
292
|
*/
|
|
311
293
|
protected function addBlock(
|
|
@@ -338,9 +320,7 @@ class Template
|
|
|
338
320
|
}
|
|
339
321
|
|
|
340
322
|
|
|
341
|
-
/**
|
|
342
|
-
* @return string[]
|
|
343
|
-
*/
|
|
323
|
+
/** @return list<string> */
|
|
344
324
|
public function getBlockNames(int|string $layer = self::LayerTop): array
|
|
345
325
|
{
|
|
346
326
|
return array_keys($this->blocks[$layer] ?? []);
|
|
@@ -358,6 +338,7 @@ class Template
|
|
|
358
338
|
}
|
|
359
339
|
|
|
360
340
|
|
|
341
|
+
/** @param array<string, mixed> $vars */
|
|
361
342
|
protected function enterBlockLayer(int $staticId, array $vars): void
|
|
362
343
|
{
|
|
363
344
|
$this->blockStack[] = $this->blocks[self::LayerTop];
|
|
@@ -368,15 +349,15 @@ class Template
|
|
|
368
349
|
|
|
369
350
|
protected function copyBlockLayer(): void
|
|
370
351
|
{
|
|
371
|
-
foreach (end($this->blockStack) as $nm => $block) {
|
|
372
|
-
$this->addBlock($nm, $block->contentType, $block->functions);
|
|
352
|
+
foreach (end($this->blockStack) ?: [] as $nm => $block) {
|
|
353
|
+
$this->addBlock($nm, $block->contentType ?? static::ContentType, $block->functions);
|
|
373
354
|
}
|
|
374
355
|
}
|
|
375
356
|
|
|
376
357
|
|
|
377
358
|
protected function leaveBlockLayer(): void
|
|
378
359
|
{
|
|
379
|
-
$this->blocks[self::LayerTop] = array_pop($this->blockStack);
|
|
360
|
+
$this->blocks[self::LayerTop] = array_pop($this->blockStack) ?? [];
|
|
380
361
|
array_pop($this->varStack);
|
|
381
362
|
}
|
|
382
363
|
}
|
|
@@ -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\Runtime;
|
|
11
9
|
|
|
12
10
|
use Latte;
|
|
@@ -29,7 +27,7 @@ final class XmlHelpers
|
|
|
29
27
|
/**
|
|
30
28
|
* Escapes string for use everywhere inside XML (except for comments and tags).
|
|
31
29
|
*/
|
|
32
|
-
public static function escapeText($s): string
|
|
30
|
+
public static function escapeText(mixed $s): string
|
|
33
31
|
{
|
|
34
32
|
if ($s instanceof HtmlStringable) {
|
|
35
33
|
return $s->__toString();
|
|
@@ -46,7 +44,7 @@ final class XmlHelpers
|
|
|
46
44
|
/**
|
|
47
45
|
* Escapes string for use inside XML attribute value.
|
|
48
46
|
*/
|
|
49
|
-
public static function escapeAttr($s): string
|
|
47
|
+
public static function escapeAttr(mixed $s): string
|
|
50
48
|
{
|
|
51
49
|
if ($s instanceof HtmlStringable) {
|
|
52
50
|
$s = HtmlHelpers::convertHtmlToText($s->__toString());
|
|
@@ -58,7 +56,7 @@ final class XmlHelpers
|
|
|
58
56
|
/**
|
|
59
57
|
* Escapes string for use inside XML tag.
|
|
60
58
|
*/
|
|
61
|
-
public static function escapeTag($s): string
|
|
59
|
+
public static function escapeTag(mixed $s): string
|
|
62
60
|
{
|
|
63
61
|
$s = self::escapeText((string) $s);
|
|
64
62
|
return preg_replace_callback(
|
|
@@ -77,7 +75,7 @@ final class XmlHelpers
|
|
|
77
75
|
return match (true) {
|
|
78
76
|
is_string($value), is_int($value), is_float($value), $value instanceof \Stringable => $namePart . '="' . self::escapeAttr($value) . '"',
|
|
79
77
|
$value === null => '',
|
|
80
|
-
default => HtmlHelpers::triggerInvalidValue(trim($namePart), $value)
|
|
78
|
+
default => HtmlHelpers::triggerInvalidValue(trim($namePart), $value),
|
|
81
79
|
};
|
|
82
80
|
}
|
|
83
81
|
|
|
@@ -1,18 +1,20 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
9
|
|
|
10
|
+
use Latte\Compiler\Nodes\Php\ArgumentNode;
|
|
12
11
|
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
12
|
use Latte\Compiler\PrintContext;
|
|
14
13
|
|
|
15
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Function call routed through sandbox security policy.
|
|
17
|
+
*/
|
|
16
18
|
class FunctionCallNode extends Expression\FunctionCallNode
|
|
17
19
|
{
|
|
18
20
|
public function __construct(Expression\FunctionCallNode $from)
|
|
@@ -23,10 +25,14 @@ class FunctionCallNode extends Expression\FunctionCallNode
|
|
|
23
25
|
|
|
24
26
|
public function print(PrintContext $context): string
|
|
25
27
|
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
if ($this->isPartialFunction()) {
|
|
29
|
+
return '$this->global->sandbox->closure(' . $context->memberAsString($this->name) . ')';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** @var array<ArgumentNode> $args */
|
|
33
|
+
$args = $this->args;
|
|
34
|
+
return '$this->global->sandbox->call('
|
|
35
|
+
. $context->memberAsString($this->name) . ', '
|
|
36
|
+
. $context->argumentsAsArray($args) . ')';
|
|
31
37
|
}
|
|
32
38
|
}
|
|
@@ -1,18 +1,20 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
9
|
|
|
10
|
+
use Latte\Compiler\Nodes\Php\ArgumentNode;
|
|
12
11
|
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
12
|
use Latte\Compiler\PrintContext;
|
|
14
13
|
|
|
15
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Method call routed through sandbox security policy.
|
|
17
|
+
*/
|
|
16
18
|
class MethodCallNode extends Expression\MethodCallNode
|
|
17
19
|
{
|
|
18
20
|
public function __construct(Expression\MethodCallNode $from)
|
|
@@ -23,14 +25,18 @@ class MethodCallNode extends Expression\MethodCallNode
|
|
|
23
25
|
|
|
24
26
|
public function print(PrintContext $context): string
|
|
25
27
|
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
. $this->object->print($context) . ', '
|
|
29
|
-
. $context->memberAsString($this->name) . '])'
|
|
30
|
-
: '$this->global->sandbox->callMethod('
|
|
28
|
+
if ($this->isPartialFunction()) {
|
|
29
|
+
return '$this->global->sandbox->closure(['
|
|
31
30
|
. $this->object->print($context) . ', '
|
|
32
|
-
. $context->memberAsString($this->name) . '
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
. $context->memberAsString($this->name) . '])';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @var array<ArgumentNode> $args */
|
|
35
|
+
$args = $this->args;
|
|
36
|
+
return '$this->global->sandbox->callMethod('
|
|
37
|
+
. $this->object->print($context) . ', '
|
|
38
|
+
. $context->memberAsString($this->name) . ', '
|
|
39
|
+
. $context->argumentsAsArray($args)
|
|
40
|
+
. ', ' . var_export($this->nullsafe, return: true) . ')';
|
|
35
41
|
}
|
|
36
42
|
}
|
|
@@ -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\Sandbox\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
11
|
use Latte\Compiler\PrintContext;
|
|
14
12
|
|
|
15
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Property access routed through sandbox security policy.
|
|
16
|
+
*/
|
|
16
17
|
class PropertyFetchNode extends Expression\PropertyFetchNode
|
|
17
18
|
{
|
|
18
19
|
public function __construct(Expression\PropertyFetchNode $from)
|
|
@@ -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\Sandbox\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\Php\Expression\ArrayNode;
|
|
@@ -17,7 +15,8 @@ use Latte\Compiler\Tag;
|
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
|
-
* {sandbox
|
|
18
|
+
* {sandbox 'file.latte'}
|
|
19
|
+
* Isolated template rendering with sandbox policy.
|
|
21
20
|
*/
|
|
22
21
|
class SandboxNode extends StatementNode
|
|
23
22
|
{
|
|
@@ -1,18 +1,20 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
9
|
|
|
10
|
+
use Latte\Compiler\Nodes\Php\ArgumentNode;
|
|
12
11
|
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
12
|
use Latte\Compiler\PrintContext;
|
|
14
13
|
|
|
15
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Static method call routed through sandbox security policy.
|
|
17
|
+
*/
|
|
16
18
|
class StaticMethodCallNode extends Expression\StaticMethodCallNode
|
|
17
19
|
{
|
|
18
20
|
public function __construct(Expression\StaticMethodCallNode $from)
|
|
@@ -23,13 +25,17 @@ class StaticMethodCallNode extends Expression\StaticMethodCallNode
|
|
|
23
25
|
|
|
24
26
|
public function print(PrintContext $context): string
|
|
25
27
|
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
. $context->memberAsString($this->class) . ', '
|
|
29
|
-
. $context->memberAsString($this->name) . '])'
|
|
30
|
-
: '$this->global->sandbox->call(['
|
|
28
|
+
if ($this->isPartialFunction()) {
|
|
29
|
+
return '$this->global->sandbox->closure(['
|
|
31
30
|
. $context->memberAsString($this->class) . ', '
|
|
32
|
-
. $context->memberAsString($this->name) . ']
|
|
33
|
-
|
|
31
|
+
. $context->memberAsString($this->name) . '])';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @var array<ArgumentNode> $args */
|
|
35
|
+
$args = $this->args;
|
|
36
|
+
return '$this->global->sandbox->call(['
|
|
37
|
+
. $context->memberAsString($this->class) . ', '
|
|
38
|
+
. $context->memberAsString($this->name) . '], '
|
|
39
|
+
. $context->argumentsAsArray($args) . ')';
|
|
34
40
|
}
|
|
35
41
|
}
|
|
@@ -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\Sandbox\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
11
|
use Latte\Compiler\PrintContext;
|
|
14
12
|
|
|
15
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Static property access routed through sandbox security policy.
|
|
16
|
+
*/
|
|
16
17
|
class StaticPropertyFetchNode extends Expression\StaticPropertyFetchNode
|
|
17
18
|
{
|
|
18
19
|
public function __construct(Expression\StaticPropertyFetchNode $from)
|
|
@@ -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\Sandbox;
|
|
11
9
|
|
|
12
10
|
use Latte;
|
|
@@ -22,6 +20,7 @@ final class RuntimeChecker
|
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
|
|
23
|
+
/** @param array<mixed> $args */
|
|
25
24
|
public function call(mixed $callable, array $args): mixed
|
|
26
25
|
{
|
|
27
26
|
self::checkCallable($callable);
|
|
@@ -30,6 +29,7 @@ final class RuntimeChecker
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
|
|
32
|
+
/** @param array<mixed> $args */
|
|
33
33
|
public function callMethod(mixed $object, mixed $method, array $args, bool $nullsafe = false): mixed
|
|
34
34
|
{
|
|
35
35
|
if ($object === null) {
|
|
@@ -53,11 +53,12 @@ final class RuntimeChecker
|
|
|
53
53
|
public function closure(mixed $callable): \Closure
|
|
54
54
|
{
|
|
55
55
|
self::checkCallable($callable);
|
|
56
|
-
return
|
|
56
|
+
return $callable(...);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
/** @return list<mixed> */
|
|
61
|
+
public function args(mixed ...$args): array
|
|
61
62
|
{
|
|
62
63
|
foreach ($args as $arg) {
|
|
63
64
|
if (
|
|
@@ -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\Sandbox;
|
|
11
9
|
|
|
12
10
|
use Latte;
|
|
@@ -75,6 +73,7 @@ final class SandboxExtension extends Latte\Extension
|
|
|
75
73
|
|
|
76
74
|
private function sandboxVisitor(Node $node): Node
|
|
77
75
|
{
|
|
76
|
+
assert($this->policy !== null);
|
|
78
77
|
if ($node instanceof Expression\VariableNode) {
|
|
79
78
|
if ($node->name === 'this') {
|
|
80
79
|
throw new SecurityViolationException("Forbidden variable \${$node->name}.", $node->position);
|
|
@@ -130,7 +129,9 @@ final class SandboxExtension extends Latte\Extension
|
|
|
130
129
|
|| $node instanceof Expression\StaticMethodCallNode
|
|
131
130
|
) {
|
|
132
131
|
$class = namespace\Nodes::class . strrchr($node::class, '\\');
|
|
133
|
-
|
|
132
|
+
$result = new $class($node);
|
|
133
|
+
assert($result instanceof Node);
|
|
134
|
+
return $result;
|
|
134
135
|
|
|
135
136
|
} else {
|
|
136
137
|
return $node;
|
|
@@ -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\Sandbox;
|
|
11
9
|
|
|
12
10
|
use Latte;
|
|
@@ -14,26 +12,26 @@ use function array_flip, array_map, assert, is_a, is_bool, strtolower;
|
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
|
-
* Default-deny policy.
|
|
15
|
+
* Default-deny security policy. Whitelist allowed tags, filters, functions, methods and properties.
|
|
18
16
|
*/
|
|
19
17
|
class SecurityPolicy implements Latte\Policy
|
|
20
18
|
{
|
|
21
19
|
public const All = ['*'];
|
|
22
20
|
public const ALL = self::All;
|
|
23
21
|
|
|
24
|
-
/** @var string
|
|
22
|
+
/** @var array<string, int> */
|
|
25
23
|
private array $tags = [];
|
|
26
24
|
|
|
27
|
-
/** @var string
|
|
25
|
+
/** @var array<string, int> */
|
|
28
26
|
private array $filters = [];
|
|
29
27
|
|
|
30
|
-
/** @var string
|
|
28
|
+
/** @var array<string, int> */
|
|
31
29
|
private array $functions = [];
|
|
32
30
|
|
|
33
|
-
/** @var string
|
|
31
|
+
/** @var array<string, array<string, int>> */
|
|
34
32
|
private array $methods = [];
|
|
35
33
|
|
|
36
|
-
/** @var string
|
|
34
|
+
/** @var array<string, array<string, int>> */
|
|
37
35
|
private array $properties = [];
|
|
38
36
|
|
|
39
37
|
/** @var array<string, array<string, bool>> */
|
|
@@ -43,6 +41,9 @@ class SecurityPolicy implements Latte\Policy
|
|
|
43
41
|
private array $propertyCache = [];
|
|
44
42
|
|
|
45
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Creates policy with safe defaults for user-generated templates.
|
|
46
|
+
*/
|
|
46
47
|
public static function createSafePolicy(): self
|
|
47
48
|
{
|
|
48
49
|
$policy = new self;
|
|
@@ -80,7 +81,7 @@ class SecurityPolicy implements Latte\Policy
|
|
|
80
81
|
*/
|
|
81
82
|
public function allowTags(array $tags): self
|
|
82
83
|
{
|
|
83
|
-
$this->tags += array_flip(array_map(
|
|
84
|
+
$this->tags += array_flip(array_map(strtolower(...), $tags));
|
|
84
85
|
return $this;
|
|
85
86
|
}
|
|
86
87
|
|
|
@@ -90,7 +91,7 @@ class SecurityPolicy implements Latte\Policy
|
|
|
90
91
|
*/
|
|
91
92
|
public function allowFilters(array $filters): self
|
|
92
93
|
{
|
|
93
|
-
$this->filters += array_flip(array_map(
|
|
94
|
+
$this->filters += array_flip(array_map(strtolower(...), $filters));
|
|
94
95
|
return $this;
|
|
95
96
|
}
|
|
96
97
|
|
|
@@ -100,7 +101,7 @@ class SecurityPolicy implements Latte\Policy
|
|
|
100
101
|
*/
|
|
101
102
|
public function allowFunctions(array $functions): self
|
|
102
103
|
{
|
|
103
|
-
$this->functions += array_flip(array_map(
|
|
104
|
+
$this->functions += array_flip(array_map(strtolower(...), $functions));
|
|
104
105
|
return $this;
|
|
105
106
|
}
|
|
106
107
|
|
|
@@ -111,7 +112,7 @@ class SecurityPolicy implements Latte\Policy
|
|
|
111
112
|
public function allowMethods(string $class, array $methods): self
|
|
112
113
|
{
|
|
113
114
|
$this->methodCache = [];
|
|
114
|
-
$this->methods[$class] = array_flip(array_map(
|
|
115
|
+
$this->methods[$class] = array_flip(array_map(strtolower(...), $methods));
|
|
115
116
|
return $this;
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -122,7 +123,7 @@ class SecurityPolicy implements Latte\Policy
|
|
|
122
123
|
public function allowProperties(string $class, array $properties): self
|
|
123
124
|
{
|
|
124
125
|
$this->propertyCache = [];
|
|
125
|
-
$this->properties[$class] = array_flip(array_map(
|
|
126
|
+
$this->properties[$class] = array_flip(array_map(strtolower(...), $properties));
|
|
126
127
|
return $this;
|
|
127
128
|
}
|
|
128
129
|
|
|
@@ -155,7 +156,7 @@ class SecurityPolicy implements Latte\Policy
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
foreach ($this->methods as $c => $methods) {
|
|
158
|
-
if (is_a($class, $c, true) && (isset($methods[$method]) || isset($methods['*']))) {
|
|
159
|
+
if (is_a($class, $c, allow_string: true) && (isset($methods[$method]) || isset($methods['*']))) {
|
|
159
160
|
return $res = true;
|
|
160
161
|
}
|
|
161
162
|
}
|
|
@@ -174,7 +175,7 @@ class SecurityPolicy implements Latte\Policy
|
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
foreach ($this->properties as $c => $properties) {
|
|
177
|
-
if (is_a($class, $c, true) && (isset($properties[$property]) || isset($properties['*']))) {
|
|
178
|
+
if (is_a($class, $c, allow_string: true) && (isset($properties[$property]) || isset($properties['*']))) {
|
|
178
179
|
return $res = true;
|
|
179
180
|
}
|
|
180
181
|
}
|
|
@@ -1,23 +1,27 @@
|
|
|
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\Attributes;
|
|
11
9
|
|
|
12
10
|
use Attribute;
|
|
13
11
|
|
|
14
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Marks method as a template function.
|
|
15
|
+
*/
|
|
15
16
|
#[Attribute(Attribute::TARGET_METHOD)]
|
|
16
17
|
class TemplateFunction
|
|
17
18
|
{
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Marks method as a template filter.
|
|
24
|
+
*/
|
|
21
25
|
#[Attribute(Attribute::TARGET_METHOD)]
|
|
22
26
|
class TemplateFilter
|
|
23
27
|
{
|