@vituum/vite-plugin-latte 2.0.0-next.5 → 2.0.0
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 +10 -9
- 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
|
@@ -18,9 +18,11 @@ use function explode, is_string, str_contains;
|
|
|
18
18
|
*/
|
|
19
19
|
final class ReflectionMethod extends \ReflectionMethod
|
|
20
20
|
{
|
|
21
|
-
|
|
21
|
+
/** @var \ReflectionClass<object> */
|
|
22
|
+
private readonly \ReflectionClass $originalClass;
|
|
22
23
|
|
|
23
24
|
|
|
25
|
+
/** @param class-string|object $objectOrMethod */
|
|
24
26
|
public function __construct(object|string $objectOrMethod, ?string $method = null)
|
|
25
27
|
{
|
|
26
28
|
if (is_string($objectOrMethod) && str_contains($objectOrMethod, '::')) {
|
|
@@ -31,6 +33,7 @@ final class ReflectionMethod extends \ReflectionMethod
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
|
|
36
|
+
/** @return \ReflectionClass<object> */
|
|
34
37
|
public function getOriginalClass(): \ReflectionClass
|
|
35
38
|
{
|
|
36
39
|
return $this->originalClass;
|
|
@@ -59,7 +59,8 @@ class Strings
|
|
|
59
59
|
throw new Nette\NotSupportedException(__METHOD__ . '() requires ICONV extension that is not loaded.');
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
$res = iconv('UTF-32BE', 'UTF-8//IGNORE', pack('N', $code));
|
|
63
|
+
return $res === false ? throw new Nette\ShouldNotHappenException : $res;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
|
|
@@ -73,11 +74,11 @@ class Strings
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
$tmp = iconv('UTF-8', 'UTF-32BE//IGNORE', $c);
|
|
76
|
-
if (
|
|
77
|
+
if ($tmp === false || $tmp === '') {
|
|
77
78
|
throw new Nette\InvalidArgumentException('Invalid UTF-8 character "' . ($c === '' ? '' : '\x' . strtoupper(bin2hex($c))) . '".');
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
return unpack('N', $tmp)[1];
|
|
81
|
+
return unpack('N', $tmp)[1] ?? throw new Nette\ShouldNotHappenException;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
|
|
@@ -124,7 +125,8 @@ class Strings
|
|
|
124
125
|
$start += self::length($s); // unifies iconv_substr behavior with mb_substr
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
$res = iconv_substr($s, $start, $length, 'UTF-8');
|
|
129
|
+
return $res === false ? throw new Nette\InvalidStateException('iconv_substr() failed.') : $res;
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
|
|
@@ -135,7 +137,7 @@ class Strings
|
|
|
135
137
|
public static function normalize(string $s): string
|
|
136
138
|
{
|
|
137
139
|
// convert to compressed normal form (NFC)
|
|
138
|
-
if (class_exists('Normalizer', false) && ($n = \Normalizer::normalize($s, \Normalizer::FORM_C)) !== false) {
|
|
140
|
+
if (class_exists('Normalizer', autoload: false) && ($n = \Normalizer::normalize($s, \Normalizer::FORM_C)) !== false) {
|
|
139
141
|
$s = $n;
|
|
140
142
|
}
|
|
141
143
|
|
|
@@ -201,14 +203,23 @@ class Strings
|
|
|
201
203
|
$s = strtr($s, ["\u{AE}" => '(R)', "\u{A9}" => '(c)', "\u{2026}" => '...', "\u{AB}" => '<<', "\u{BB}" => '>>', "\u{A3}" => 'lb', "\u{A5}" => 'yen', "\u{B2}" => '^2', "\u{B3}" => '^3', "\u{B5}" => 'u', "\u{B9}" => '^1', "\u{BA}" => 'o', "\u{BF}" => '?', "\u{2CA}" => "'", "\u{2CD}" => '_', "\u{2DD}" => '"', "\u{1FEF}" => '', "\u{20AC}" => 'EUR', "\u{2122}" => 'TM', "\u{212E}" => 'e', "\u{2190}" => '<-', "\u{2191}" => '^', "\u{2192}" => '->', "\u{2193}" => 'V', "\u{2194}" => '<->']); // ® © … « » £ ¥ ² ³ µ ¹ º ¿ ˊ ˍ ˝ ` € ™ ℮ ← ↑ → ↓ ↔
|
|
202
204
|
}
|
|
203
205
|
|
|
204
|
-
$s = \Transliterator::create('Any-Latin; Latin-ASCII')
|
|
206
|
+
$s = \Transliterator::create('Any-Latin; Latin-ASCII')?->transliterate($s)
|
|
207
|
+
?? throw new Nette\InvalidStateException('Transliterator::transliterate() failed.');
|
|
208
|
+
|
|
205
209
|
// use iconv because The transliterator leaves some characters out of ASCII, eg → ʾ
|
|
206
210
|
if ($iconv === 'glibc') {
|
|
207
211
|
$s = strtr($s, '?', "\x01"); // temporarily hide ? to distinguish them from the garbage that iconv creates
|
|
208
212
|
$s = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s);
|
|
213
|
+
if ($s === false) {
|
|
214
|
+
throw new Nette\InvalidStateException('iconv() failed.');
|
|
215
|
+
}
|
|
216
|
+
|
|
209
217
|
$s = str_replace(['?', "\x01"], ['', '?'], $s); // remove garbage and restore ? characters
|
|
210
218
|
} elseif ($iconv === 'libiconv') {
|
|
211
219
|
$s = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s);
|
|
220
|
+
if ($s === false) {
|
|
221
|
+
throw new Nette\InvalidStateException('iconv() failed.');
|
|
222
|
+
}
|
|
212
223
|
} else { // null or 'unknown' (#216)
|
|
213
224
|
$s = self::pcre('preg_replace', ['#[^\x00-\x7F]++#', '', $s]); // remove non-ascii chars
|
|
214
225
|
}
|
|
@@ -323,7 +334,7 @@ class Strings
|
|
|
323
334
|
*/
|
|
324
335
|
public static function compare(string $left, string $right, ?int $length = null): bool
|
|
325
336
|
{
|
|
326
|
-
if (class_exists('Normalizer', false)) {
|
|
337
|
+
if (class_exists('Normalizer', autoload: false)) {
|
|
327
338
|
$left = \Normalizer::normalize($left, \Normalizer::FORM_D); // form NFD is faster
|
|
328
339
|
$right = \Normalizer::normalize($right, \Normalizer::FORM_D); // form NFD is faster
|
|
329
340
|
}
|
|
@@ -347,6 +358,10 @@ class Strings
|
|
|
347
358
|
public static function findPrefix(array $strings): string
|
|
348
359
|
{
|
|
349
360
|
$first = array_shift($strings);
|
|
361
|
+
if ($first === null) {
|
|
362
|
+
return '';
|
|
363
|
+
}
|
|
364
|
+
|
|
350
365
|
for ($i = 0; $i < strlen($first); $i++) {
|
|
351
366
|
foreach ($strings as $s) {
|
|
352
367
|
if (!isset($s[$i]) || $first[$i] !== $s[$i]) {
|
|
@@ -370,8 +385,8 @@ class Strings
|
|
|
370
385
|
public static function length(string $s): int
|
|
371
386
|
{
|
|
372
387
|
return match (true) {
|
|
373
|
-
extension_loaded('mbstring') => mb_strlen($s, 'UTF-8'),
|
|
374
|
-
extension_loaded('iconv') => iconv_strlen($s, 'UTF-8'),
|
|
388
|
+
extension_loaded('mbstring') => (int) mb_strlen($s, 'UTF-8'),
|
|
389
|
+
extension_loaded('iconv') => (int) iconv_strlen($s, 'UTF-8'),
|
|
375
390
|
default => strlen(@utf8_decode($s)), // deprecated
|
|
376
391
|
};
|
|
377
392
|
}
|
|
@@ -420,7 +435,10 @@ class Strings
|
|
|
420
435
|
throw new Nette\NotSupportedException(__METHOD__ . '() requires ICONV extension that is not loaded.');
|
|
421
436
|
}
|
|
422
437
|
|
|
423
|
-
|
|
438
|
+
$tmp = iconv('UTF-8', 'UTF-32BE', $s);
|
|
439
|
+
return $tmp === false
|
|
440
|
+
? throw new Nette\InvalidStateException('iconv() failed.')
|
|
441
|
+
: (string) iconv('UTF-32LE', 'UTF-8', strrev($tmp));
|
|
424
442
|
}
|
|
425
443
|
|
|
426
444
|
|
|
@@ -499,6 +517,7 @@ class Strings
|
|
|
499
517
|
|
|
500
518
|
/**
|
|
501
519
|
* Divides the string into arrays according to the regular expression. Expressions in parentheses will be captured and returned as well.
|
|
520
|
+
* @return list<string>
|
|
502
521
|
*/
|
|
503
522
|
public static function split(
|
|
504
523
|
string $subject,
|
|
@@ -525,6 +544,7 @@ class Strings
|
|
|
525
544
|
/**
|
|
526
545
|
* Searches the string for the part matching the regular expression and returns
|
|
527
546
|
* an array with the found expression and individual subexpressions, or `null`.
|
|
547
|
+
* @return ?array<string>
|
|
528
548
|
*/
|
|
529
549
|
public static function match(
|
|
530
550
|
string $subject,
|
|
@@ -545,6 +565,7 @@ class Strings
|
|
|
545
565
|
$pattern .= 'u';
|
|
546
566
|
}
|
|
547
567
|
|
|
568
|
+
$m = [];
|
|
548
569
|
if ($offset > strlen($subject)) {
|
|
549
570
|
return null;
|
|
550
571
|
} elseif (!self::pcre('preg_match', [$pattern, $subject, &$m, $flags, $offset])) {
|
|
@@ -560,7 +581,7 @@ class Strings
|
|
|
560
581
|
/**
|
|
561
582
|
* Searches the string for all occurrences matching the regular expression and
|
|
562
583
|
* returns an array of arrays containing the found expression and each subexpression.
|
|
563
|
-
* @return ($lazy is true ? \Generator<int, array
|
|
584
|
+
* @return ($lazy is true ? \Generator<int, array<string>> : list<array<string>>)
|
|
564
585
|
*/
|
|
565
586
|
public static function matchAll(
|
|
566
587
|
string $subject,
|
|
@@ -583,10 +604,12 @@ class Strings
|
|
|
583
604
|
$flags = PREG_OFFSET_CAPTURE | ($unmatchedAsNull ? PREG_UNMATCHED_AS_NULL : 0);
|
|
584
605
|
return (function () use ($utf8, $captureOffset, $flags, $subject, $pattern, $offset) {
|
|
585
606
|
$counter = 0;
|
|
607
|
+
$m = [];
|
|
586
608
|
while (
|
|
587
609
|
$offset <= strlen($subject) - ($counter ? 1 : 0)
|
|
588
610
|
&& self::pcre('preg_match', [$pattern, $subject, &$m, $flags, $offset])
|
|
589
611
|
) {
|
|
612
|
+
/** @var list<array{string, int}> $m */
|
|
590
613
|
$offset = $m[0][1] + max(1, strlen($m[0][0]));
|
|
591
614
|
if (!$captureOffset) {
|
|
592
615
|
$m = array_map(fn($item) => $item[0], $m);
|
|
@@ -606,6 +629,7 @@ class Strings
|
|
|
606
629
|
? $captureOffset
|
|
607
630
|
: ($captureOffset ? PREG_OFFSET_CAPTURE : 0) | ($unmatchedAsNull ? PREG_UNMATCHED_AS_NULL : 0) | ($patternOrder ? PREG_PATTERN_ORDER : 0);
|
|
608
631
|
|
|
632
|
+
$m = [];
|
|
609
633
|
self::pcre('preg_match_all', [
|
|
610
634
|
$pattern, $subject, &$m,
|
|
611
635
|
($flags & PREG_PATTERN_ORDER) ? $flags : ($flags | PREG_SET_ORDER),
|
|
@@ -619,6 +643,7 @@ class Strings
|
|
|
619
643
|
|
|
620
644
|
/**
|
|
621
645
|
* Replaces all occurrences matching regular expression $pattern which can be string or array in the form `pattern => replacement`.
|
|
646
|
+
* @param string|array<string, string> $pattern
|
|
622
647
|
*/
|
|
623
648
|
public static function replace(
|
|
624
649
|
string $subject,
|
|
@@ -638,7 +663,7 @@ class Strings
|
|
|
638
663
|
|
|
639
664
|
$flags = ($captureOffset ? PREG_OFFSET_CAPTURE : 0) | ($unmatchedAsNull ? PREG_UNMATCHED_AS_NULL : 0);
|
|
640
665
|
if ($utf8) {
|
|
641
|
-
$pattern
|
|
666
|
+
$pattern = is_array($pattern) ? array_map(fn($item) => $item . 'u', $pattern) : $pattern . 'u';
|
|
642
667
|
if ($captureOffset) {
|
|
643
668
|
$replacement = fn($m) => $replacement(self::bytesToChars($subject, [$m])[0]);
|
|
644
669
|
}
|
|
@@ -659,6 +684,10 @@ class Strings
|
|
|
659
684
|
}
|
|
660
685
|
|
|
661
686
|
|
|
687
|
+
/**
|
|
688
|
+
* @param list<array<array{string, int}>> $groups
|
|
689
|
+
* @return list<array<array{string, int}>>
|
|
690
|
+
*/
|
|
662
691
|
private static function bytesToChars(string $s, array $groups): array
|
|
663
692
|
{
|
|
664
693
|
$lastBytes = $lastChars = 0;
|
|
@@ -679,8 +708,12 @@ class Strings
|
|
|
679
708
|
}
|
|
680
709
|
|
|
681
710
|
|
|
682
|
-
/**
|
|
683
|
-
|
|
711
|
+
/**
|
|
712
|
+
* @param callable-string $func
|
|
713
|
+
* @param list<mixed> $args
|
|
714
|
+
* @internal
|
|
715
|
+
*/
|
|
716
|
+
public static function pcre(string $func, array $args): mixed
|
|
684
717
|
{
|
|
685
718
|
$res = Callback::invokeSafe($func, $args, function (string $message) use ($args): void {
|
|
686
719
|
// compile-time error, not detectable by preg_last_error
|
|
@@ -688,7 +721,7 @@ class Strings
|
|
|
688
721
|
});
|
|
689
722
|
|
|
690
723
|
if (($code = preg_last_error()) // run-time error, but preg_last_error & return code are liars
|
|
691
|
-
&& ($res === null || !in_array($func, ['preg_filter', 'preg_replace_callback', 'preg_replace'], true))
|
|
724
|
+
&& ($res === null || !in_array($func, ['preg_filter', 'preg_replace_callback', 'preg_replace'], strict: true))
|
|
692
725
|
) {
|
|
693
726
|
throw new RegexpException(preg_last_error_msg()
|
|
694
727
|
. ' (pattern: ' . implode(' or ', (array) $args[0]) . ')', $code);
|
|
@@ -10,7 +10,7 @@ declare(strict_types=1);
|
|
|
10
10
|
namespace Nette\Utils;
|
|
11
11
|
|
|
12
12
|
use Nette;
|
|
13
|
-
use function array_map, array_search, array_splice, count, explode, implode, is_a, is_resource, is_string, strcasecmp, strtolower, substr, trim;
|
|
13
|
+
use function array_map, array_search, array_splice, array_values, count, explode, implode, is_a, is_resource, is_string, strcasecmp, strtolower, substr, trim;
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -18,9 +18,9 @@ use function array_map, array_search, array_splice, count, explode, implode, is_
|
|
|
18
18
|
*/
|
|
19
19
|
final readonly class Type
|
|
20
20
|
{
|
|
21
|
-
/** @var
|
|
21
|
+
/** @var list<string|self> */
|
|
22
22
|
private array $types;
|
|
23
|
-
private
|
|
23
|
+
private ?string $singleName;
|
|
24
24
|
private string $kind; // | &
|
|
25
25
|
|
|
26
26
|
|
|
@@ -40,7 +40,12 @@ final readonly class Type
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
/** @return ($asObject is true ? self : self|string) */
|
|
44
|
+
private static function fromReflectionType(
|
|
45
|
+
\ReflectionType $type,
|
|
46
|
+
\ReflectionFunctionAbstract|\ReflectionParameter|\ReflectionProperty $of,
|
|
47
|
+
bool $asObject,
|
|
48
|
+
): self|string
|
|
44
49
|
{
|
|
45
50
|
if ($type instanceof \ReflectionNamedType) {
|
|
46
51
|
$name = self::resolve($type->getName(), $of);
|
|
@@ -107,34 +112,40 @@ final readonly class Type
|
|
|
107
112
|
*/
|
|
108
113
|
public static function resolve(
|
|
109
114
|
string $type,
|
|
110
|
-
\
|
|
115
|
+
\ReflectionFunction|\ReflectionMethod|\ReflectionParameter|\ReflectionProperty $of,
|
|
111
116
|
): string
|
|
112
117
|
{
|
|
113
118
|
$lower = strtolower($type);
|
|
114
119
|
if ($of instanceof \ReflectionFunction) {
|
|
115
120
|
return $type;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
$class = $of->getDeclaringClass();
|
|
124
|
+
if ($class === null) {
|
|
125
|
+
return $type;
|
|
116
126
|
} elseif ($lower === 'self') {
|
|
117
|
-
return $
|
|
127
|
+
return $class->name;
|
|
118
128
|
} elseif ($lower === 'static') {
|
|
119
|
-
return ($of instanceof ReflectionMethod ? $of->getOriginalClass() : $
|
|
120
|
-
} elseif ($lower === 'parent' && $
|
|
121
|
-
return $
|
|
129
|
+
return ($of instanceof ReflectionMethod ? $of->getOriginalClass() : $class)->name;
|
|
130
|
+
} elseif ($lower === 'parent' && $class->getParentClass()) {
|
|
131
|
+
return $class->getParentClass()->name;
|
|
122
132
|
} else {
|
|
123
133
|
return $type;
|
|
124
134
|
}
|
|
125
135
|
}
|
|
126
136
|
|
|
127
137
|
|
|
138
|
+
/** @param array<string|self> $types */
|
|
128
139
|
private function __construct(array $types, string $kind = '|')
|
|
129
140
|
{
|
|
130
141
|
$o = array_search('null', $types, strict: true);
|
|
131
142
|
if ($o !== false) { // null as last
|
|
132
|
-
array_splice($types, $o, 1);
|
|
143
|
+
array_splice($types, (int) $o, 1);
|
|
133
144
|
$types[] = 'null';
|
|
134
145
|
}
|
|
135
146
|
|
|
136
|
-
$this->types = $types;
|
|
137
|
-
$this->
|
|
147
|
+
$this->types = array_values($types);
|
|
148
|
+
$this->singleName = is_string($types[0]) && ($types[1] ?? 'null') === 'null' ? $types[0] : null;
|
|
138
149
|
$this->kind = count($types) > 1 ? $kind : '';
|
|
139
150
|
}
|
|
140
151
|
|
|
@@ -142,8 +153,8 @@ final readonly class Type
|
|
|
142
153
|
public function __toString(): string
|
|
143
154
|
{
|
|
144
155
|
$multi = count($this->types) > 1;
|
|
145
|
-
if ($this->
|
|
146
|
-
return ($multi ? '?' : '') . $this->
|
|
156
|
+
if ($this->singleName !== null) {
|
|
157
|
+
return ($multi ? '?' : '') . $this->singleName;
|
|
147
158
|
}
|
|
148
159
|
|
|
149
160
|
$res = [];
|
|
@@ -173,7 +184,7 @@ final readonly class Type
|
|
|
173
184
|
|
|
174
185
|
/**
|
|
175
186
|
* Returns the array of subtypes that make up the compound type as strings.
|
|
176
|
-
* @return array<
|
|
187
|
+
* @return list<string|array<string|array<mixed>>>
|
|
177
188
|
*/
|
|
178
189
|
public function getNames(): array
|
|
179
190
|
{
|
|
@@ -182,8 +193,8 @@ final readonly class Type
|
|
|
182
193
|
|
|
183
194
|
|
|
184
195
|
/**
|
|
185
|
-
* Returns the array of subtypes that make up the compound type as Type objects
|
|
186
|
-
* @return self
|
|
196
|
+
* Returns the array of subtypes that make up the compound type as Type objects.
|
|
197
|
+
* @return list<self>
|
|
187
198
|
*/
|
|
188
199
|
public function getTypes(): array
|
|
189
200
|
{
|
|
@@ -196,9 +207,7 @@ final readonly class Type
|
|
|
196
207
|
*/
|
|
197
208
|
public function getSingleName(): ?string
|
|
198
209
|
{
|
|
199
|
-
return $this->
|
|
200
|
-
? $this->types[0]
|
|
201
|
-
: null;
|
|
210
|
+
return $this->singleName;
|
|
202
211
|
}
|
|
203
212
|
|
|
204
213
|
|
|
@@ -225,14 +234,14 @@ final readonly class Type
|
|
|
225
234
|
*/
|
|
226
235
|
public function isSimple(): bool
|
|
227
236
|
{
|
|
228
|
-
return $this->
|
|
237
|
+
return $this->singleName !== null;
|
|
229
238
|
}
|
|
230
239
|
|
|
231
240
|
|
|
232
241
|
#[\Deprecated('use isSimple()')]
|
|
233
242
|
public function isSingle(): bool
|
|
234
243
|
{
|
|
235
|
-
return $this->
|
|
244
|
+
return $this->singleName !== null;
|
|
236
245
|
}
|
|
237
246
|
|
|
238
247
|
|
|
@@ -241,7 +250,7 @@ final readonly class Type
|
|
|
241
250
|
*/
|
|
242
251
|
public function isBuiltin(): bool
|
|
243
252
|
{
|
|
244
|
-
return $this->
|
|
253
|
+
return $this->singleName !== null && Validators::isBuiltinType($this->singleName);
|
|
245
254
|
}
|
|
246
255
|
|
|
247
256
|
|
|
@@ -250,7 +259,7 @@ final readonly class Type
|
|
|
250
259
|
*/
|
|
251
260
|
public function isClass(): bool
|
|
252
261
|
{
|
|
253
|
-
return $this->
|
|
262
|
+
return $this->singleName !== null && !Validators::isBuiltinType($this->singleName);
|
|
254
263
|
}
|
|
255
264
|
|
|
256
265
|
|
|
@@ -259,7 +268,7 @@ final readonly class Type
|
|
|
259
268
|
*/
|
|
260
269
|
public function isClassKeyword(): bool
|
|
261
270
|
{
|
|
262
|
-
return $this->
|
|
271
|
+
return $this->singleName !== null && Validators::isClassKeyword($this->singleName);
|
|
263
272
|
}
|
|
264
273
|
|
|
265
274
|
|
|
@@ -279,6 +288,7 @@ final readonly class Type
|
|
|
279
288
|
}
|
|
280
289
|
|
|
281
290
|
|
|
291
|
+
/** @param array<string> $givenTypes */
|
|
282
292
|
private function allowsAny(array $givenTypes): bool
|
|
283
293
|
{
|
|
284
294
|
return $this->isUnion()
|
|
@@ -287,13 +297,17 @@ final readonly class Type
|
|
|
287
297
|
}
|
|
288
298
|
|
|
289
299
|
|
|
300
|
+
/**
|
|
301
|
+
* @param array<string> $ourTypes
|
|
302
|
+
* @param array<string> $givenTypes
|
|
303
|
+
*/
|
|
290
304
|
private function allowsAll(array $ourTypes, array $givenTypes): bool
|
|
291
305
|
{
|
|
292
306
|
return Arrays::every(
|
|
293
307
|
$ourTypes,
|
|
294
|
-
fn($ourType) => Arrays::some(
|
|
308
|
+
fn(string $ourType) => Arrays::some(
|
|
295
309
|
$givenTypes,
|
|
296
|
-
fn($givenType) => Validators::isBuiltinType($ourType)
|
|
310
|
+
fn(string $givenType) => Validators::isBuiltinType($ourType)
|
|
297
311
|
? strcasecmp($ourType, $givenType) === 0
|
|
298
312
|
: is_a($givenType, $ourType, allow_string: true),
|
|
299
313
|
),
|
|
@@ -26,7 +26,7 @@ class Validators
|
|
|
26
26
|
'never' => 1, 'true' => 1,
|
|
27
27
|
];
|
|
28
28
|
|
|
29
|
-
/** @var array<string
|
|
29
|
+
/** @var array<string, ?(callable(mixed): bool)> */
|
|
30
30
|
protected static $validators = [
|
|
31
31
|
// PHP types
|
|
32
32
|
'array' => 'is_array',
|
|
@@ -76,7 +76,7 @@ class Validators
|
|
|
76
76
|
'type' => [self::class, 'isType'],
|
|
77
77
|
];
|
|
78
78
|
|
|
79
|
-
/** @var array<string,callable> */
|
|
79
|
+
/** @var array<string, callable(mixed): int> */
|
|
80
80
|
protected static $counters = [
|
|
81
81
|
'string' => 'strlen',
|
|
82
82
|
'unicode' => [Strings::class, 'length'],
|
|
@@ -120,16 +120,16 @@ class Validators
|
|
|
120
120
|
*/
|
|
121
121
|
public static function assertField(
|
|
122
122
|
array $array,
|
|
123
|
-
$key,
|
|
123
|
+
int|string $key,
|
|
124
124
|
?string $expected = null,
|
|
125
125
|
string $label = "item '%' in array",
|
|
126
126
|
): void
|
|
127
127
|
{
|
|
128
128
|
if (!array_key_exists($key, $array)) {
|
|
129
|
-
throw new AssertionException('Missing ' . str_replace('%', $key, $label) . '.');
|
|
129
|
+
throw new AssertionException('Missing ' . str_replace('%', (string) $key, $label) . '.');
|
|
130
130
|
|
|
131
131
|
} elseif ($expected) {
|
|
132
|
-
static::assert($array[$key], $expected, str_replace('%', $key, $label));
|
|
132
|
+
static::assert($array[$key], $expected, str_replace('%', (string) $key, $label));
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -159,7 +159,7 @@ class Validators
|
|
|
159
159
|
if (!static::$validators[$type]($value)) {
|
|
160
160
|
continue;
|
|
161
161
|
}
|
|
162
|
-
} catch (\TypeError
|
|
162
|
+
} catch (\TypeError) {
|
|
163
163
|
continue;
|
|
164
164
|
}
|
|
165
165
|
} elseif ($type === 'pattern') {
|
|
@@ -261,7 +261,7 @@ class Validators
|
|
|
261
261
|
|
|
262
262
|
/**
|
|
263
263
|
* Checks if the value is 0, '', false or null.
|
|
264
|
-
* @return ($value is 0|''|false|null ? true : false)
|
|
264
|
+
* @return ($value is 0|0.0|''|false|null ? true : false)
|
|
265
265
|
*/
|
|
266
266
|
public static function isNone(mixed $value): bool
|
|
267
267
|
{
|
|
@@ -290,6 +290,7 @@ class Validators
|
|
|
290
290
|
/**
|
|
291
291
|
* Checks if the value is in the given range [min, max], where the upper or lower limit can be omitted (null).
|
|
292
292
|
* Numbers, strings and DateTime objects can be compared.
|
|
293
|
+
* @param array{int|float|string|\DateTimeInterface|null, int|float|string|\DateTimeInterface|null} $range
|
|
293
294
|
*/
|
|
294
295
|
public static function isInRange(mixed $value, array $range): bool
|
|
295
296
|
{
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
{do $colors = [
|
|
2
|
-
'include' => '#00000052',
|
|
3
|
-
'extends' => '#cd1c1c7d',
|
|
4
|
-
'import' => '#17c35b8f',
|
|
5
|
-
'includeblock' => '#17c35b8f',
|
|
6
|
-
'embed' => '#4f1ccd7d',
|
|
7
|
-
'sandbox' => 'black',
|
|
8
|
-
]}
|
|
9
|
-
|
|
10
|
-
<style class="tracy-debug">
|
|
11
|
-
#tracy-debug .LattePanel td {
|
|
12
|
-
white-space: nowrap;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
#tracy-debug .LattePanel-php {
|
|
16
|
-
background: #8993be;
|
|
17
|
-
color: white;
|
|
18
|
-
border-radius: 79px;
|
|
19
|
-
padding: 1px 4px 3px 4px;
|
|
20
|
-
font-size: 75%;
|
|
21
|
-
font-style: italic;
|
|
22
|
-
font-weight: bold;
|
|
23
|
-
vertical-align: text-top;
|
|
24
|
-
opacity: .5;
|
|
25
|
-
margin-left: 2ex;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
#tracy-debug .LattePanel-type {
|
|
29
|
-
border-radius: 2px;
|
|
30
|
-
padding: 2px 4px;
|
|
31
|
-
font-size: 80%;
|
|
32
|
-
color: white;
|
|
33
|
-
font-weight: bold;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
#tracy-debug .LattePanel-include {
|
|
37
|
-
background: #00000052;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
#tracy-debug .LattePanel-extends {
|
|
41
|
-
background: #cd1c1c7d;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
#tracy-debug .LattePanel-import,
|
|
45
|
-
#tracy-debug .LattePanel-includeblock {
|
|
46
|
-
background: #17c35b8f;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
#tracy-debug .LattePanel-embed {
|
|
50
|
-
background: #4f1ccd7d;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
#tracy-debug .LattePanel-sandbox {
|
|
54
|
-
background: black;
|
|
55
|
-
}
|
|
56
|
-
</style>
|
|
57
|
-
|
|
58
|
-
<h1>Rendered Templates</h1>
|
|
59
|
-
|
|
60
|
-
<div class="tracy-inner LattePanel">
|
|
61
|
-
<table>
|
|
62
|
-
{foreach $list as $item}
|
|
63
|
-
<tr>
|
|
64
|
-
<td>
|
|
65
|
-
{if $item->template->getReferenceType()}
|
|
66
|
-
<span style="margin-left: {$item->depth * 4}ex"></span>└
|
|
67
|
-
<span class="LattePanel-type" style="background: {$colors[$item->template->getReferenceType()]}">{$item->template->getReferenceType()}</span>
|
|
68
|
-
{/if}
|
|
69
|
-
|
|
70
|
-
{Tracy\Helpers::editorLink($item->template->getName())}
|
|
71
|
-
|
|
72
|
-
<a href="{Tracy\Helpers::editorUri($item->phpFile)}" class="LattePanel-php">php</a>
|
|
73
|
-
</td>
|
|
74
|
-
|
|
75
|
-
<td>{$item->count > 1 ? $item->count . '×' : ''}</td>
|
|
76
|
-
</tr>
|
|
77
|
-
{/foreach}
|
|
78
|
-
</table>
|
|
79
|
-
|
|
80
|
-
{if $dumpParameters}
|
|
81
|
-
<h2>Parameters</h2>
|
|
82
|
-
|
|
83
|
-
<div class="tracy-inner">
|
|
84
|
-
<table class="tracy-sortable">
|
|
85
|
-
{foreach reset($list)->template->getParameters() as $k => $v}
|
|
86
|
-
<tr>
|
|
87
|
-
<th>{$k}</th>
|
|
88
|
-
<td>{Tracy\Dumper::toHtml($v, [Tracy\Dumper::LIVE => true])}</td>
|
|
89
|
-
</tr>
|
|
90
|
-
{/foreach}
|
|
91
|
-
</table>
|
|
92
|
-
</div>
|
|
93
|
-
{/if}
|
|
94
|
-
</div>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<span title="Latte Templates">
|
|
2
|
-
<svg viewBox="0 0 1793.77 1538.57">
|
|
3
|
-
<path fill="#F1A443" d="M934.87 1166.46c41.84,-2.2 75.14,-17.07 99.91,-44.59 24.77,-27.53 37.16,-58.9 37.16,-94.13 0,-38.53 -12.38,-71.01 -37.16,-97.43 -24.77,-26.42 -58.08,-45.14 -99.91,-56.15l0 292.31zm-67.71 -786.08c-40.74,2.2 -72.66,15.41 -95.79,39.63 -23.12,24.22 -34.68,52.29 -34.68,84.22 0,33.03 11.29,63.03 33.86,90 22.57,26.98 54.77,43.21 96.61,48.72l0 -262.58zm0 1013.98l0 -64.41c-61.66,-5.5 -114.22,-15.97 -157.71,-31.38 -43.49,-15.41 -79.27,-37.43 -107.34,-66.06 -28.07,-28.63 -48.72,-64.13 -61.93,-106.52 -13.21,-42.39 -19.82,-92.76 -19.82,-151.11l198.18 0c4.4,35.23 10.18,64.41 17.34,87.53 7.16,23.12 16.51,41.84 28.07,56.15 11.56,14.31 25.6,25.05 42.11,32.2 16.51,7.16 36.88,12.39 61.1,15.69l0 -318.73c-55.05,-14.31 -102.94,-30.55 -143.67,-48.72 -40.74,-18.16 -74.59,-39.63 -101.57,-64.41 -26.97,-24.77 -47.34,-53.4 -61.1,-85.88 -13.76,-32.48 -20.64,-71.29 -20.64,-116.43 0,-42.93 8.26,-83.39 24.77,-121.38 16.51,-37.98 39.36,-71.29 68.53,-99.91 29.18,-28.63 63.58,-51.19 103.22,-67.71 39.63,-16.51 83.12,-25.32 130.46,-26.42l0 -72.67 67.71 0 0 72.67c203.68,6.6 310.47,113.4 320.38,320.38l-194.87 0c-5.5,-59.45 -18.44,-99.91 -38.81,-121.38 -20.37,-21.47 -49.27,-33.31 -86.7,-35.51l0 284.05c73.76,24.22 132.94,47.89 177.53,71.01 44.59,23.12 78.72,47.61 102.39,73.49 23.67,25.87 39.36,54.22 47.07,85.05 7.71,30.83 11.56,66.61 11.56,107.34 0,48.44 -7.98,92.2 -23.94,131.29 -15.97,39.08 -38.81,72.94 -68.54,101.56 -29.72,28.63 -65.5,51.2 -107.34,67.71 -41.84,16.51 -88.08,25.87 -138.72,28.07l0 64.41 -67.71 0z"/>
|
|
4
|
-
<path fill="#5F4D36" d="M462.33 1411.31c-54.32,0 -98.33,-4.78 -132.03,-14.33 -33.7,-9.56 -59.85,-24.14 -78.46,-43.76 -18.61,-19.62 -30.93,-44.51 -36.97,-74.69 -6.04,-30.18 -9.05,-65.38 -9.05,-105.62 0,-9.05 0.5,-22.13 1.51,-39.23 1.01,-17.1 1.76,-35.21 2.27,-54.32 0.5,-19.11 1.26,-36.97 2.26,-53.56 1.01,-16.6 1.51,-28.42 1.51,-35.46 0,-58.34 -8.8,-99.08 -26.41,-122.22 -17.6,-23.13 -50.05,-34.7 -97.33,-34.7l0 -129.76c47.28,0 79.72,-11.82 97.33,-35.46 17.6,-23.64 26.41,-64.63 26.41,-122.97 0,-7.04 -0.5,-18.86 -1.51,-35.46 -1.01,-16.6 -1.76,-33.95 -2.26,-52.06 -0.5,-18.11 -1.26,-35.71 -2.27,-52.81 -1.01,-17.1 -1.51,-30.18 -1.51,-39.23 0,-40.24 3.02,-75.45 9.05,-105.62 6.03,-30.18 18.36,-55.08 36.97,-74.69 18.61,-19.62 44.76,-34.2 78.46,-43.76 33.7,-9.56 77.71,-14.34 132.03,-14.34l55.83 0 0 123.73 -33.2 0c-44.26,0 -74.18,7.04 -89.78,21.12 -15.59,14.08 -23.39,38.73 -23.39,73.94 0,45.27 1.51,90.03 4.53,134.29 3.02,44.26 4.53,89.02 4.53,134.29 0,21.12 -4.53,40.49 -13.58,58.09 -9.05,17.6 -20.87,33.19 -35.46,46.77 -14.59,13.58 -31.69,24.4 -51.3,32.44 -19.62,8.05 -39.98,13.58 -61.11,16.6 21.12,3.02 41.49,8.55 61.11,16.59 19.61,8.05 36.72,18.86 51.3,32.44 14.59,13.58 26.41,29.17 35.46,46.77 9.05,17.6 13.58,36.97 13.58,58.09 0,45.27 -1.51,90.28 -4.53,135.04 -3.02,44.76 -4.53,89.78 -4.53,135.05 0,35.21 7.79,59.85 23.39,73.94 15.59,14.08 45.52,21.12 89.78,21.12l33.2 0 0 123.73 -55.83 0z"/>
|
|
5
|
-
<path fill="#5F4D36" d="M1275.61 1411.31l0 -123.73 33.2 0c44.26,0 74.19,-7.04 89.78,-21.12 15.59,-14.08 23.39,-38.73 23.39,-73.94 0,-45.27 -1.51,-90.28 -4.53,-135.05 -3.02,-44.76 -4.53,-89.78 -4.53,-135.04 0,-21.12 4.53,-40.49 13.58,-58.09 9.05,-17.6 20.87,-33.19 35.46,-46.77 14.59,-13.58 31.69,-24.4 51.3,-32.44 19.61,-8.05 39.98,-13.58 61.11,-16.59 -21.12,-3.02 -41.5,-8.55 -61.11,-16.6 -19.62,-8.05 -36.72,-18.86 -51.3,-32.44 -14.59,-13.58 -26.41,-29.17 -35.46,-46.77 -9.05,-17.6 -13.58,-36.97 -13.58,-58.09 0,-45.27 1.51,-90.03 4.53,-134.29 3.02,-44.26 4.53,-89.02 4.53,-134.29 0,-35.21 -7.8,-59.85 -23.39,-73.94 -15.59,-14.08 -45.52,-21.12 -89.78,-21.12l-33.2 0 0 -123.73 55.83 0c54.32,0 98.33,4.78 132.03,14.34 33.7,9.55 59.85,24.14 78.46,43.76 18.61,19.61 30.93,44.51 36.97,74.69 6.03,30.17 9.05,65.38 9.05,105.62 0,9.05 -0.5,22.13 -1.51,39.23 -1.01,17.1 -1.76,34.7 -2.26,52.81 -0.5,18.11 -1.26,35.46 -2.27,52.06 -1.01,16.59 -1.51,28.41 -1.51,35.46 0,58.34 8.8,99.33 26.41,122.97 17.6,23.64 50.04,35.46 97.32,35.46l0 129.76c-47.28,0 -79.72,11.57 -97.32,34.7 -17.6,23.14 -26.41,63.88 -26.41,122.22 0,7.04 0.5,18.86 1.51,35.46 1.01,16.6 1.76,34.45 2.27,53.56 0.5,19.11 1.26,37.22 2.26,54.32 1.01,17.1 1.51,30.18 1.51,39.23 0,40.24 -3.02,75.44 -9.05,105.62 -6.04,30.18 -18.36,55.07 -36.97,74.69 -18.61,19.61 -44.76,34.2 -78.46,43.76 -33.7,9.55 -77.7,14.33 -132.03,14.33l-55.83 0z"/>
|
|
6
|
-
</svg
|
|
7
|
-
><span class="tracy-label">{$name}</span>
|
|
8
|
-
</span>
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
-
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
|
-
namespace Latte;
|
|
11
|
-
|
|
12
|
-
use Latte\Compiler\Position;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/** @internal */
|
|
16
|
-
trait PositionAwareException
|
|
17
|
-
{
|
|
18
|
-
public ?string $sourceCode = null;
|
|
19
|
-
public ?string $sourceName = null;
|
|
20
|
-
public ?Position $position = null;
|
|
21
|
-
private string $origMessage;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
public function setSource(string $code, ?string $name = null): self
|
|
25
|
-
{
|
|
26
|
-
$this->sourceCode = $code;
|
|
27
|
-
$this->sourceName = $name;
|
|
28
|
-
$this->generateMessage();
|
|
29
|
-
return $this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
private function generateMessage(): void
|
|
34
|
-
{
|
|
35
|
-
$this->origMessage ??= $this->message;
|
|
36
|
-
$info = [];
|
|
37
|
-
if ($this->sourceName && @is_file($this->sourceName)) { // @ - may trigger error
|
|
38
|
-
$info[] = "in '" . str_replace(dirname($this->sourceName, 2), '...', $this->sourceName) . "'";
|
|
39
|
-
}
|
|
40
|
-
if ($this->position) {
|
|
41
|
-
$info[] = $this->position;
|
|
42
|
-
}
|
|
43
|
-
$this->message = $info
|
|
44
|
-
? rtrim($this->origMessage, '.') . ' (' . implode(' ', $info) . ')'
|
|
45
|
-
: $this->origMessage;
|
|
46
|
-
}
|
|
47
|
-
}
|