@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
|
@@ -22,21 +22,24 @@ final class Callback
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Invokes internal PHP function with own error handler.
|
|
25
|
+
* @param callable-string $function
|
|
26
|
+
* @param list<mixed> $args
|
|
27
|
+
* @param callable(string, int): (bool|void|null) $onError
|
|
25
28
|
*/
|
|
26
29
|
public static function invokeSafe(string $function, array $args, callable $onError): mixed
|
|
27
30
|
{
|
|
28
|
-
$prev = set_error_handler(function ($severity, $message, $file) use ($onError, &$prev, $function):
|
|
31
|
+
$prev = set_error_handler(function (int $severity, string $message, string $file, int $line) use ($onError, &$prev, $function): bool {
|
|
29
32
|
if ($file === __FILE__) {
|
|
30
33
|
$msg = ini_get('html_errors')
|
|
31
34
|
? Html::htmlToText($message)
|
|
32
35
|
: $message;
|
|
33
|
-
$msg = preg_replace("#^$function\\(.*?\\): #", '', $msg);
|
|
36
|
+
$msg = (string) preg_replace("#^$function\\(.*?\\): #", '', $msg);
|
|
34
37
|
if ($onError($msg, $severity) !== false) {
|
|
35
|
-
return
|
|
38
|
+
return true;
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
return $prev ? $prev(...func_get_args()) : false;
|
|
42
|
+
return $prev ? $prev(...func_get_args()) !== false : false;
|
|
40
43
|
});
|
|
41
44
|
|
|
42
45
|
try {
|
|
@@ -53,7 +56,7 @@ final class Callback
|
|
|
53
56
|
* @return callable
|
|
54
57
|
* @throws Nette\InvalidArgumentException
|
|
55
58
|
*/
|
|
56
|
-
public static function check(mixed $callable, bool $syntax = false)
|
|
59
|
+
public static function check(mixed $callable, bool $syntax = false): mixed
|
|
57
60
|
{
|
|
58
61
|
if (!is_callable($callable, $syntax)) {
|
|
59
62
|
throw new Nette\InvalidArgumentException(
|
|
@@ -87,7 +90,7 @@ final class Callback
|
|
|
87
90
|
* @param callable $callable type check is escalated to ReflectionException
|
|
88
91
|
* @throws \ReflectionException if callback is not valid
|
|
89
92
|
*/
|
|
90
|
-
public static function toReflection($callable): \ReflectionMethod|\ReflectionFunction
|
|
93
|
+
public static function toReflection(mixed $callable): \ReflectionMethod|\ReflectionFunction
|
|
91
94
|
{
|
|
92
95
|
if ($callable instanceof \Closure) {
|
|
93
96
|
$callable = self::unwrap($callable);
|
|
@@ -100,6 +103,7 @@ final class Callback
|
|
|
100
103
|
} elseif (is_object($callable) && !$callable instanceof \Closure) {
|
|
101
104
|
return new ReflectionMethod($callable, '__invoke');
|
|
102
105
|
} else {
|
|
106
|
+
assert($callable instanceof \Closure || is_string($callable));
|
|
103
107
|
return new \ReflectionFunction($callable);
|
|
104
108
|
}
|
|
105
109
|
}
|
|
@@ -116,8 +120,9 @@ final class Callback
|
|
|
116
120
|
|
|
117
121
|
/**
|
|
118
122
|
* Unwraps closure created by Closure::fromCallable().
|
|
123
|
+
* @return callable|array{object|class-string, string}|string
|
|
119
124
|
*/
|
|
120
|
-
public static function unwrap(\Closure $closure): callable|array
|
|
125
|
+
public static function unwrap(\Closure $closure): callable|array|string
|
|
121
126
|
{
|
|
122
127
|
$r = new \ReflectionFunction($closure);
|
|
123
128
|
$class = $r->getClosureScopeClass()?->name;
|
|
@@ -142,7 +142,7 @@ class DateTime extends \DateTime implements \JsonSerializable
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
|
|
145
|
-
private function apply(string $datetime, $timezone = null, bool $ctr = false): void
|
|
145
|
+
private function apply(string $datetime, ?\DateTimeZone $timezone = null, bool $ctr = false): void
|
|
146
146
|
{
|
|
147
147
|
$relPart = '';
|
|
148
148
|
$absPart = preg_replace_callback(
|
|
@@ -19,14 +19,12 @@ use const DIRECTORY_SEPARATOR;
|
|
|
19
19
|
*/
|
|
20
20
|
final class FileInfo extends \SplFileInfo
|
|
21
21
|
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
22
|
+
public function __construct(
|
|
23
|
+
string $file,
|
|
24
|
+
private readonly string $relativePath = '',
|
|
25
|
+
) {
|
|
27
26
|
parent::__construct($file);
|
|
28
|
-
$this->setInfoClass(
|
|
29
|
-
$this->relativePath = $relativePath;
|
|
27
|
+
$this->setInfoClass(self::class);
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
|
|
@@ -52,14 +52,15 @@ final class FileSystem
|
|
|
52
52
|
} elseif (is_dir($origin)) {
|
|
53
53
|
static::createDir($target);
|
|
54
54
|
foreach (new \FilesystemIterator($target) as $item) {
|
|
55
|
+
\assert($item instanceof \SplFileInfo);
|
|
55
56
|
static::delete($item->getPathname());
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($origin, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
|
|
59
60
|
if ($item->isDir()) {
|
|
60
|
-
static::createDir($target . '/' . $iterator->
|
|
61
|
+
static::createDir($target . '/' . $iterator->getSubPathname());
|
|
61
62
|
} else {
|
|
62
|
-
static::copy($item->getPathname(), $target . '/' . $iterator->
|
|
63
|
+
static::copy($item->getPathname(), $target . '/' . $iterator->getSubPathname());
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
} else {
|
|
@@ -112,6 +113,7 @@ final class FileSystem
|
|
|
112
113
|
}
|
|
113
114
|
} elseif (is_dir($path)) {
|
|
114
115
|
foreach (new \FilesystemIterator($path) as $item) {
|
|
116
|
+
\assert($item instanceof \SplFileInfo);
|
|
115
117
|
static::delete($item->getPathname());
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -251,6 +253,7 @@ final class FileSystem
|
|
|
251
253
|
}
|
|
252
254
|
} elseif (is_dir($path)) {
|
|
253
255
|
foreach (new \FilesystemIterator($path) as $item) {
|
|
256
|
+
\assert($item instanceof \SplFileInfo);
|
|
254
257
|
static::makeWritable($item->getPathname(), $dirMode, $fileMode);
|
|
255
258
|
}
|
|
256
259
|
|
|
@@ -32,24 +32,25 @@ class Finder implements \IteratorAggregate
|
|
|
32
32
|
/** @var string[] */
|
|
33
33
|
private array $in = [];
|
|
34
34
|
|
|
35
|
-
/** @var
|
|
35
|
+
/** @var array<\Closure(FileInfo): bool> */
|
|
36
36
|
private array $filters = [];
|
|
37
37
|
|
|
38
|
-
/** @var
|
|
38
|
+
/** @var array<\Closure(FileInfo): bool> */
|
|
39
39
|
private array $descentFilters = [];
|
|
40
40
|
|
|
41
41
|
/** @var array<string|self> */
|
|
42
42
|
private array $appends = [];
|
|
43
43
|
private bool $childFirst = false;
|
|
44
44
|
|
|
45
|
-
/** @var ?
|
|
46
|
-
private $sort;
|
|
45
|
+
/** @var ?(\Closure(FileInfo, FileInfo): int) */
|
|
46
|
+
private ?\Closure $sort = null;
|
|
47
47
|
private int $maxDepth = -1;
|
|
48
48
|
private bool $ignoreUnreadableDirs = true;
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Begins search for files and directories matching mask.
|
|
53
|
+
* @param string|list<string> $masks
|
|
53
54
|
*/
|
|
54
55
|
public static function find(string|array $masks = ['*']): static
|
|
55
56
|
{
|
|
@@ -60,6 +61,7 @@ class Finder implements \IteratorAggregate
|
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* Begins search for files matching mask.
|
|
64
|
+
* @param string|list<string> $masks
|
|
63
65
|
*/
|
|
64
66
|
public static function findFiles(string|array $masks = ['*']): static
|
|
65
67
|
{
|
|
@@ -70,6 +72,7 @@ class Finder implements \IteratorAggregate
|
|
|
70
72
|
|
|
71
73
|
/**
|
|
72
74
|
* Begins search for directories matching mask.
|
|
75
|
+
* @param string|list<string> $masks
|
|
73
76
|
*/
|
|
74
77
|
public static function findDirectories(string|array $masks = ['*']): static
|
|
75
78
|
{
|
|
@@ -80,6 +83,7 @@ class Finder implements \IteratorAggregate
|
|
|
80
83
|
|
|
81
84
|
/**
|
|
82
85
|
* Finds files matching the specified masks.
|
|
86
|
+
* @param string|list<string> $masks
|
|
83
87
|
*/
|
|
84
88
|
public function files(string|array $masks = ['*']): static
|
|
85
89
|
{
|
|
@@ -89,6 +93,7 @@ class Finder implements \IteratorAggregate
|
|
|
89
93
|
|
|
90
94
|
/**
|
|
91
95
|
* Finds directories matching the specified masks.
|
|
96
|
+
* @param string|list<string> $masks
|
|
92
97
|
*/
|
|
93
98
|
public function directories(string|array $masks = ['*']): static
|
|
94
99
|
{
|
|
@@ -96,6 +101,7 @@ class Finder implements \IteratorAggregate
|
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
|
|
104
|
+
/** @param list<string> $masks */
|
|
99
105
|
private function addMask(array $masks, string $mode): static
|
|
100
106
|
{
|
|
101
107
|
foreach ($masks as $mask) {
|
|
@@ -117,6 +123,7 @@ class Finder implements \IteratorAggregate
|
|
|
117
123
|
|
|
118
124
|
/**
|
|
119
125
|
* Searches in the given directories. Wildcards are allowed.
|
|
126
|
+
* @param string|list<string> $paths
|
|
120
127
|
*/
|
|
121
128
|
public function in(string|array $paths): static
|
|
122
129
|
{
|
|
@@ -128,6 +135,7 @@ class Finder implements \IteratorAggregate
|
|
|
128
135
|
|
|
129
136
|
/**
|
|
130
137
|
* Searches recursively from the given directories. Wildcards are allowed.
|
|
138
|
+
* @param string|list<string> $paths
|
|
131
139
|
*/
|
|
132
140
|
public function from(string|array $paths): static
|
|
133
141
|
{
|
|
@@ -137,6 +145,7 @@ class Finder implements \IteratorAggregate
|
|
|
137
145
|
}
|
|
138
146
|
|
|
139
147
|
|
|
148
|
+
/** @param list<string> $paths */
|
|
140
149
|
private function addLocation(array $paths, string $ext): void
|
|
141
150
|
{
|
|
142
151
|
foreach ($paths as $path) {
|
|
@@ -175,7 +184,7 @@ class Finder implements \IteratorAggregate
|
|
|
175
184
|
*/
|
|
176
185
|
public function sortBy(callable $callback): static
|
|
177
186
|
{
|
|
178
|
-
$this->sort = $callback;
|
|
187
|
+
$this->sort = $callback(...);
|
|
179
188
|
return $this;
|
|
180
189
|
}
|
|
181
190
|
|
|
@@ -192,6 +201,7 @@ class Finder implements \IteratorAggregate
|
|
|
192
201
|
|
|
193
202
|
/**
|
|
194
203
|
* Adds the specified paths or appends a new finder that returns.
|
|
204
|
+
* @param string|list<string>|null $paths
|
|
195
205
|
*/
|
|
196
206
|
public function append(string|array|null $paths = null): static
|
|
197
207
|
{
|
|
@@ -209,6 +219,7 @@ class Finder implements \IteratorAggregate
|
|
|
209
219
|
|
|
210
220
|
/**
|
|
211
221
|
* Skips entries that matches the given masks relative to the ones defined with the in() or from() methods.
|
|
222
|
+
* @param string|list<string> $masks
|
|
212
223
|
*/
|
|
213
224
|
public function exclude(string|array $masks): static
|
|
214
225
|
{
|
|
@@ -239,7 +250,7 @@ class Finder implements \IteratorAggregate
|
|
|
239
250
|
*/
|
|
240
251
|
public function filter(callable $callback): static
|
|
241
252
|
{
|
|
242
|
-
$this->filters[] =
|
|
253
|
+
$this->filters[] = $callback(...);
|
|
243
254
|
return $this;
|
|
244
255
|
}
|
|
245
256
|
|
|
@@ -250,7 +261,7 @@ class Finder implements \IteratorAggregate
|
|
|
250
261
|
*/
|
|
251
262
|
public function descentFilter(callable $callback): static
|
|
252
263
|
{
|
|
253
|
-
$this->descentFilters[] =
|
|
264
|
+
$this->descentFilters[] = $callback(...);
|
|
254
265
|
return $this;
|
|
255
266
|
}
|
|
256
267
|
|
|
@@ -267,6 +278,7 @@ class Finder implements \IteratorAggregate
|
|
|
267
278
|
|
|
268
279
|
/**
|
|
269
280
|
* Restricts the search by size. $operator accepts "[operator] [size] [unit]" example: >=10kB
|
|
281
|
+
* @param '>'|'>='|'<'|'<='|'='|'=='|'==='|'!='|'!=='|'<>' $operator or predicate string
|
|
270
282
|
*/
|
|
271
283
|
public function size(string $operator, ?int $size = null): static
|
|
272
284
|
{
|
|
@@ -277,7 +289,7 @@ class Finder implements \IteratorAggregate
|
|
|
277
289
|
|
|
278
290
|
[, $operator, $size, $unit] = $matches;
|
|
279
291
|
$units = ['' => 1, 'k' => 1e3, 'm' => 1e6, 'g' => 1e9];
|
|
280
|
-
$size
|
|
292
|
+
$size = (float) $size * $units[strtolower($unit)];
|
|
281
293
|
$operator = $operator ?: '=';
|
|
282
294
|
}
|
|
283
295
|
|
|
@@ -287,6 +299,7 @@ class Finder implements \IteratorAggregate
|
|
|
287
299
|
|
|
288
300
|
/**
|
|
289
301
|
* Restricts the search by modified time. $operator accepts "[operator] [date]" example: >1978-01-23
|
|
302
|
+
* @param '>'|'>='|'<'|'<='|'='|'=='|'==='|'!='|'!=='|'<>' $operator or predicate string
|
|
290
303
|
*/
|
|
291
304
|
public function date(string $operator, string|int|\DateTimeInterface|null $date = null): static
|
|
292
305
|
{
|
|
@@ -401,6 +414,7 @@ class Finder implements \IteratorAggregate
|
|
|
401
414
|
}
|
|
402
415
|
|
|
403
416
|
|
|
417
|
+
/** @param iterable<string> $pathNames */
|
|
404
418
|
private function convertToFiles(iterable $pathNames, string $relativePath, bool $absolute): \Generator
|
|
405
419
|
{
|
|
406
420
|
foreach ($pathNames as $pathName) {
|
|
@@ -413,6 +427,10 @@ class Finder implements \IteratorAggregate
|
|
|
413
427
|
}
|
|
414
428
|
|
|
415
429
|
|
|
430
|
+
/**
|
|
431
|
+
* @param (\Closure(FileInfo): bool)[] $filters
|
|
432
|
+
* @param array<int, bool> $cache
|
|
433
|
+
*/
|
|
416
434
|
private function proveFilters(array $filters, FileInfo $file, array &$cache): bool
|
|
417
435
|
{
|
|
418
436
|
foreach ($filters as $filter) {
|
|
@@ -468,6 +486,7 @@ class Finder implements \IteratorAggregate
|
|
|
468
486
|
|
|
469
487
|
/**
|
|
470
488
|
* Since glob() does not know ** wildcard, we divide the path into a part for glob and a part for manual traversal.
|
|
489
|
+
* @return array{string, string, bool}
|
|
471
490
|
*/
|
|
472
491
|
private static function splitRecursivePart(string $path): array
|
|
473
492
|
{
|
|
@@ -14,6 +14,9 @@ use function array_unique, ini_get, levenshtein, max, min, ob_end_clean, ob_get_
|
|
|
14
14
|
use const PHP_OS_FAMILY;
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Miscellaneous utilities.
|
|
19
|
+
*/
|
|
17
20
|
class Helpers
|
|
18
21
|
{
|
|
19
22
|
public const IsWindows = PHP_OS_FAMILY === 'Windows';
|
|
@@ -21,6 +24,7 @@ class Helpers
|
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* Executes a callback and returns the captured output as a string.
|
|
27
|
+
* @param callable(): void $func
|
|
24
28
|
*/
|
|
25
29
|
public static function capture(callable $func): string
|
|
26
30
|
{
|
|
@@ -37,7 +41,7 @@ class Helpers
|
|
|
37
41
|
|
|
38
42
|
/**
|
|
39
43
|
* Returns the last occurred PHP error or an empty string if no error occurred. Unlike error_get_last(),
|
|
40
|
-
* it is
|
|
44
|
+
* it is not affected by the PHP directive html_errors and always returns text, not HTML.
|
|
41
45
|
*/
|
|
42
46
|
public static function getLastError(): string
|
|
43
47
|
{
|
|
@@ -59,6 +63,7 @@ class Helpers
|
|
|
59
63
|
|
|
60
64
|
/**
|
|
61
65
|
* Returns value clamped to the inclusive range of min and max.
|
|
66
|
+
* @return ($value is float ? float : ($min is float ? float : ($max is float ? float : int)))
|
|
62
67
|
*/
|
|
63
68
|
public static function clamp(int|float $value, int|float $min, int|float $max): int|float
|
|
64
69
|
{
|
|
@@ -91,6 +96,7 @@ class Helpers
|
|
|
91
96
|
|
|
92
97
|
/**
|
|
93
98
|
* Compares two values in the same way that PHP does. Recognizes operators: >, >=, <, <=, =, ==, ===, !=, !==, <>
|
|
99
|
+
* @param '>'|'>='|'<'|'<='|'='|'=='|'==='|'!='|'!=='|'<>' $operator
|
|
94
100
|
*/
|
|
95
101
|
public static function compare(mixed $left, string $operator, mixed $right): bool
|
|
96
102
|
{
|