@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
|
@@ -24,7 +24,7 @@ use const IMG_BMP, IMG_FLIP_BOTH, IMG_FLIP_HORIZONTAL, IMG_FLIP_VERTICAL, IMG_GI
|
|
|
24
24
|
* $image->send();
|
|
25
25
|
* </code>
|
|
26
26
|
*
|
|
27
|
-
* @method Image affine(array $affine, ?array $clip = null)
|
|
27
|
+
* @method Image affine(array<int, float|int> $affine, ?array{x: int, y: int, width: int, height: int} $clip = null)
|
|
28
28
|
* @method void alphaBlending(bool $enable)
|
|
29
29
|
* @method void antialias(bool $enable)
|
|
30
30
|
* @method void arc(int $centerX, int $centerY, int $width, int $height, int $startAngle, int $endAngle, ImageColor $color)
|
|
@@ -41,51 +41,51 @@ use const IMG_BMP, IMG_FLIP_BOTH, IMG_FLIP_HORIZONTAL, IMG_FLIP_VERTICAL, IMG_GI
|
|
|
41
41
|
* @method int colorResolve(int $red, int $green, int $blue)
|
|
42
42
|
* @method int colorResolveAlpha(int $red, int $green, int $blue, int $alpha)
|
|
43
43
|
* @method void colorSet(int $index, int $red, int $green, int $blue, int $alpha = 0)
|
|
44
|
-
* @method array colorsForIndex(int $color)
|
|
44
|
+
* @method array{red: int, green: int, blue: int, alpha: int} colorsForIndex(int $color)
|
|
45
45
|
* @method int colorsTotal()
|
|
46
46
|
* @method int colorTransparent(?int $color = null)
|
|
47
|
-
* @method void convolution(array $matrix, float $div, float $offset)
|
|
47
|
+
* @method void convolution(array<int, array<int, float>> $matrix, float $div, float $offset)
|
|
48
48
|
* @method void copy(Image $src, int $dstX, int $dstY, int $srcX, int $srcY, int $srcW, int $srcH)
|
|
49
49
|
* @method void copyMerge(Image $src, int $dstX, int $dstY, int $srcX, int $srcY, int $srcW, int $srcH, int $pct)
|
|
50
50
|
* @method void copyMergeGray(Image $src, int $dstX, int $dstY, int $srcX, int $srcY, int $srcW, int $srcH, int $pct)
|
|
51
51
|
* @method void copyResampled(Image $src, int $dstX, int $dstY, int $srcX, int $srcY, int $dstW, int $dstH, int $srcW, int $srcH)
|
|
52
52
|
* @method void copyResized(Image $src, int $dstX, int $dstY, int $srcX, int $srcY, int $dstW, int $dstH, int $srcW, int $srcH)
|
|
53
|
-
* @method Image cropAuto(int $mode =
|
|
53
|
+
* @method Image cropAuto(int $mode = 0, float $threshold = .5, ?ImageColor $color = null)
|
|
54
54
|
* @method void ellipse(int $centerX, int $centerY, int $width, int $height, ImageColor $color)
|
|
55
55
|
* @method void fill(int $x, int $y, ImageColor $color)
|
|
56
56
|
* @method void filledArc(int $centerX, int $centerY, int $width, int $height, int $startAngle, int $endAngle, ImageColor $color, int $style)
|
|
57
57
|
* @method void filledEllipse(int $centerX, int $centerY, int $width, int $height, ImageColor $color)
|
|
58
|
-
* @method void filledPolygon(array $points, ImageColor $color)
|
|
58
|
+
* @method void filledPolygon(array<int, int> $points, ImageColor $color)
|
|
59
59
|
* @method void filledRectangle(int $x1, int $y1, int $x2, int $y2, ImageColor $color)
|
|
60
60
|
* @method void fillToBorder(int $x, int $y, ImageColor $borderColor, ImageColor $color)
|
|
61
61
|
* @method void filter(int $filter, ...$args)
|
|
62
62
|
* @method void flip(int $mode)
|
|
63
|
-
* @method array ftText(float $size, float $angle, int $x, int $y, ImageColor $color, string $fontFile, string $text, array $options = [])
|
|
63
|
+
* @method array<int, int> ftText(float $size, float $angle, int $x, int $y, ImageColor $color, string $fontFile, string $text, array<string, mixed> $options = [])
|
|
64
64
|
* @method void gammaCorrect(float $inputgamma, float $outputgamma)
|
|
65
|
-
* @method array getClip()
|
|
65
|
+
* @method array{int, int, int, int} getClip()
|
|
66
66
|
* @method int getInterpolation()
|
|
67
67
|
* @method int interlace(?bool $enable = null)
|
|
68
68
|
* @method bool isTrueColor()
|
|
69
69
|
* @method void layerEffect(int $effect)
|
|
70
70
|
* @method void line(int $x1, int $y1, int $x2, int $y2, ImageColor $color)
|
|
71
|
-
* @method void openPolygon(array $points, ImageColor $color)
|
|
71
|
+
* @method void openPolygon(array<int, int> $points, ImageColor $color)
|
|
72
72
|
* @method void paletteCopy(Image $source)
|
|
73
73
|
* @method void paletteToTrueColor()
|
|
74
|
-
* @method void polygon(array $points, ImageColor $color)
|
|
74
|
+
* @method void polygon(array<int, int> $points, ImageColor $color)
|
|
75
75
|
* @method void rectangle(int $x1, int $y1, int $x2, int $y2, ImageColor $color)
|
|
76
76
|
* @method mixed resolution(?int $resolutionX = null, ?int $resolutionY = null)
|
|
77
77
|
* @method Image rotate(float $angle, ImageColor $backgroundColor)
|
|
78
78
|
* @method void saveAlpha(bool $enable)
|
|
79
|
-
* @method Image scale(int $newWidth, int $newHeight = -1, int $mode =
|
|
79
|
+
* @method Image scale(int $newWidth, int $newHeight = -1, int $mode = 3)
|
|
80
80
|
* @method void setBrush(Image $brush)
|
|
81
81
|
* @method void setClip(int $x1, int $y1, int $x2, int $y2)
|
|
82
|
-
* @method void setInterpolation(int $method =
|
|
82
|
+
* @method void setInterpolation(int $method = 3)
|
|
83
83
|
* @method void setPixel(int $x, int $y, ImageColor $color)
|
|
84
|
-
* @method void setStyle(array $style)
|
|
84
|
+
* @method void setStyle(array<int, int> $style)
|
|
85
85
|
* @method void setThickness(int $thickness)
|
|
86
86
|
* @method void setTile(Image $tile)
|
|
87
87
|
* @method void trueColorToPalette(bool $dither, int $ncolors)
|
|
88
|
-
* @method array ttfText(float $size, float $angle, int $x, int $y, ImageColor $color, string $fontfile, string $text, array $options = [])
|
|
88
|
+
* @method array<int, int> ttfText(float $size, float $angle, int $x, int $y, ImageColor $color, string $fontfile, string $text, array<string, mixed> $options = [])
|
|
89
89
|
* @property-read positive-int $width
|
|
90
90
|
* @property-read positive-int $height
|
|
91
91
|
* @property-read \GdImage $imageResource
|
|
@@ -146,6 +146,7 @@ class Image
|
|
|
146
146
|
/**
|
|
147
147
|
* Returns RGB color (0..255) and transparency (0..127).
|
|
148
148
|
* @deprecated use ImageColor::rgb()
|
|
149
|
+
* @return array{red: int, green: int, blue: int, alpha: int}
|
|
149
150
|
*/
|
|
150
151
|
public static function rgb(int $red, int $green, int $blue, int $transparency = 0): array
|
|
151
152
|
{
|
|
@@ -192,6 +193,7 @@ class Image
|
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
|
|
196
|
+
/** @param callable-string $func */
|
|
195
197
|
private static function invokeSafe(string $func, string $arg, string $message, string $callee): static
|
|
196
198
|
{
|
|
197
199
|
$errors = [];
|
|
@@ -213,6 +215,7 @@ class Image
|
|
|
213
215
|
* Creates a new true color image of the given dimensions. The default color is black.
|
|
214
216
|
* @param positive-int $width
|
|
215
217
|
* @param positive-int $height
|
|
218
|
+
* @param ImageColor|array{red: int, green: int, blue: int, alpha?: int}|null $color
|
|
216
219
|
* @throws Nette\NotSupportedException if gd extension is not loaded
|
|
217
220
|
*/
|
|
218
221
|
public static function fromBlank(int $width, int $height, ImageColor|array|null $color = null): static
|
|
@@ -224,9 +227,9 @@ class Image
|
|
|
224
227
|
|
|
225
228
|
$image = new static(imagecreatetruecolor($width, $height));
|
|
226
229
|
if ($color) {
|
|
227
|
-
$image->
|
|
228
|
-
$image->
|
|
229
|
-
$image->
|
|
230
|
+
$image->alphaBlending(false);
|
|
231
|
+
$image->filledRectangle(0, 0, $width - 1, $height - 1, self::normalizeColor($color));
|
|
232
|
+
$image->alphaBlending(true);
|
|
230
233
|
}
|
|
231
234
|
|
|
232
235
|
return $image;
|
|
@@ -235,9 +238,11 @@ class Image
|
|
|
235
238
|
|
|
236
239
|
/**
|
|
237
240
|
* Returns the type of image from file.
|
|
238
|
-
* @
|
|
241
|
+
* @param-out ?int $width
|
|
242
|
+
* @param-out ?int $height
|
|
243
|
+
* @return ?ImageType::*
|
|
239
244
|
*/
|
|
240
|
-
public static function detectTypeFromFile(string $file, &$width = null, &$height = null): ?int
|
|
245
|
+
public static function detectTypeFromFile(string $file, mixed &$width = null, mixed &$height = null): ?int
|
|
241
246
|
{
|
|
242
247
|
[$width, $height, $type] = Helpers::falseToNull(@getimagesize($file)); // @ - files smaller than 12 bytes causes read error
|
|
243
248
|
return $type && isset(self::Formats[$type]) ? $type : null;
|
|
@@ -246,9 +251,11 @@ class Image
|
|
|
246
251
|
|
|
247
252
|
/**
|
|
248
253
|
* Returns the type of image from string.
|
|
249
|
-
* @
|
|
254
|
+
* @param-out ?int $width
|
|
255
|
+
* @param-out ?int $height
|
|
256
|
+
* @return ?ImageType::*
|
|
250
257
|
*/
|
|
251
|
-
public static function detectTypeFromString(string $s, &$width = null, &$height = null): ?int
|
|
258
|
+
public static function detectTypeFromString(string $s, mixed &$width = null, mixed &$height = null): ?int
|
|
252
259
|
{
|
|
253
260
|
[$width, $height, $type] = Helpers::falseToNull(@getimagesizefromstring($s)); // @ - strings smaller than 12 bytes causes read error
|
|
254
261
|
return $type && isset(self::Formats[$type]) ? $type : null;
|
|
@@ -314,7 +321,7 @@ class Image
|
|
|
314
321
|
}
|
|
315
322
|
|
|
316
323
|
|
|
317
|
-
/** @return ImageType[] */
|
|
324
|
+
/** @return ImageType::*[] */
|
|
318
325
|
public static function getSupportedTypes(): array
|
|
319
326
|
{
|
|
320
327
|
self::ensureExtension();
|
|
@@ -386,6 +393,10 @@ class Image
|
|
|
386
393
|
public function resize(int|string|null $width, int|string|null $height, int $mode = self::OrSmaller): static
|
|
387
394
|
{
|
|
388
395
|
if ($mode & self::Cover) {
|
|
396
|
+
if ($width === null || $height === null) {
|
|
397
|
+
throw new Nette\InvalidArgumentException('Both width and height must be set for Cover mode.');
|
|
398
|
+
}
|
|
399
|
+
|
|
389
400
|
return $this->resize($width, $height, self::OrBigger)->crop('50%', '50%', $width, $height);
|
|
390
401
|
}
|
|
391
402
|
|
|
@@ -419,12 +430,13 @@ class Image
|
|
|
419
430
|
/**
|
|
420
431
|
* Calculates dimensions of resized image. Width and height accept pixels or percent.
|
|
421
432
|
* @param int-mask-of<self::OrSmaller|self::OrBigger|self::Stretch|self::Cover|self::ShrinkOnly> $mode
|
|
433
|
+
* @return array{int<1, max>, int<1, max>}
|
|
422
434
|
*/
|
|
423
435
|
public static function calculateSize(
|
|
424
436
|
int $srcWidth,
|
|
425
437
|
int $srcHeight,
|
|
426
|
-
$newWidth,
|
|
427
|
-
$newHeight,
|
|
438
|
+
int|string|null $newWidth,
|
|
439
|
+
int|string|null $newHeight,
|
|
428
440
|
int $mode = self::OrSmaller,
|
|
429
441
|
): array
|
|
430
442
|
{
|
|
@@ -468,19 +480,19 @@ class Image
|
|
|
468
480
|
}
|
|
469
481
|
|
|
470
482
|
if ($mode & self::OrBigger) {
|
|
471
|
-
$scale = [max($scale)];
|
|
483
|
+
$scale = [max($scale ?: [1])];
|
|
472
484
|
}
|
|
473
485
|
|
|
474
486
|
if ($mode & self::ShrinkOnly) {
|
|
475
487
|
$scale[] = 1;
|
|
476
488
|
}
|
|
477
489
|
|
|
478
|
-
$scale = min($scale);
|
|
490
|
+
$scale = min($scale ?: [1]);
|
|
479
491
|
$newWidth = (int) round($srcWidth * $scale);
|
|
480
492
|
$newHeight = (int) round($srcHeight * $scale);
|
|
481
493
|
}
|
|
482
494
|
|
|
483
|
-
return [max($newWidth, 1), max($newHeight, 1)];
|
|
495
|
+
return [max((int) $newWidth, 1), max((int) $newHeight, 1)];
|
|
484
496
|
}
|
|
485
497
|
|
|
486
498
|
|
|
@@ -495,7 +507,7 @@ class Image
|
|
|
495
507
|
$this->image = imagecrop($this->image, $r);
|
|
496
508
|
imagesavealpha($this->image, true);
|
|
497
509
|
} else {
|
|
498
|
-
$newImage = static::fromBlank($r['width'], $r['height'], ImageColor::rgb(0, 0, 0, 0))->getImageResource();
|
|
510
|
+
$newImage = static::fromBlank(max(1, $r['width']), max(1, $r['height']), ImageColor::rgb(0, 0, 0, 0))->getImageResource();
|
|
499
511
|
imagecopy($newImage, $this->image, 0, 0, $r['x'], $r['y'], $r['width'], $r['height']);
|
|
500
512
|
$this->image = $newImage;
|
|
501
513
|
}
|
|
@@ -506,6 +518,7 @@ class Image
|
|
|
506
518
|
|
|
507
519
|
/**
|
|
508
520
|
* Calculates dimensions of cutout in image. Arguments accepts pixels or percent.
|
|
521
|
+
* @return array{int, int, int, int}
|
|
509
522
|
*/
|
|
510
523
|
public static function calculateCutout(
|
|
511
524
|
int $srcWidth,
|
|
@@ -516,21 +529,10 @@ class Image
|
|
|
516
529
|
int|string $newHeight,
|
|
517
530
|
): array
|
|
518
531
|
{
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
if (self::isPercent($newHeight)) {
|
|
524
|
-
$newHeight = (int) round($srcHeight / 100 * $newHeight);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
if (self::isPercent($left)) {
|
|
528
|
-
$left = (int) round(($srcWidth - $newWidth) / 100 * $left);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
if (self::isPercent($top)) {
|
|
532
|
-
$top = (int) round(($srcHeight - $newHeight) / 100 * $top);
|
|
533
|
-
}
|
|
532
|
+
$newWidth = (int) (self::isPercent($newWidth) ? round($srcWidth / 100 * $newWidth) : $newWidth);
|
|
533
|
+
$newHeight = (int) (self::isPercent($newHeight) ? round($srcHeight / 100 * $newHeight) : $newHeight);
|
|
534
|
+
$left = (int) (self::isPercent($left) ? round(($srcWidth - $newWidth) / 100 * $left) : $left);
|
|
535
|
+
$top = (int) (self::isPercent($top) ? round(($srcHeight - $newHeight) / 100 * $top) : $top);
|
|
534
536
|
|
|
535
537
|
if ($left < 0) {
|
|
536
538
|
$newWidth += $left;
|
|
@@ -575,14 +577,8 @@ class Image
|
|
|
575
577
|
|
|
576
578
|
$width = $image->getWidth();
|
|
577
579
|
$height = $image->getHeight();
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
$left = (int) round(($this->getWidth() - $width) / 100 * $left);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
if (self::isPercent($top)) {
|
|
584
|
-
$top = (int) round(($this->getHeight() - $height) / 100 * $top);
|
|
585
|
-
}
|
|
580
|
+
$left = (int) (self::isPercent($left) ? round(($this->getWidth() - $width) / 100 * $left) : $left);
|
|
581
|
+
$top = (int) (self::isPercent($top) ? round(($this->getHeight() - $height) / 100 * $top) : $top);
|
|
586
582
|
|
|
587
583
|
$output = $input = $image->image;
|
|
588
584
|
if ($opacity < 100) {
|
|
@@ -595,7 +591,7 @@ class Image
|
|
|
595
591
|
imagealphablending($output, false);
|
|
596
592
|
if (!$image->isTrueColor()) {
|
|
597
593
|
$input = $output;
|
|
598
|
-
imagefilledrectangle($output, 0, 0, $width, $height, imagecolorallocatealpha($output, 0, 0, 0, 127));
|
|
594
|
+
imagefilledrectangle($output, 0, 0, $width, $height, (int) imagecolorallocatealpha($output, 0, 0, 0, 127));
|
|
599
595
|
imagecopy($output, $image->image, 0, 0, 0, 0, $width, $height);
|
|
600
596
|
}
|
|
601
597
|
|
|
@@ -626,6 +622,8 @@ class Image
|
|
|
626
622
|
|
|
627
623
|
/**
|
|
628
624
|
* Calculates the bounding box for a TrueType text. Returns keys left, top, width and height.
|
|
625
|
+
* @param array<string, mixed> $options
|
|
626
|
+
* @return array{left: int, top: int, width: int, height: int}
|
|
629
627
|
*/
|
|
630
628
|
public static function calculateTextBox(
|
|
631
629
|
string $text,
|
|
@@ -670,7 +668,7 @@ class Image
|
|
|
670
668
|
|
|
671
669
|
/**
|
|
672
670
|
* Saves image to the file. Quality is in the range 0..100 for JPEG (default 85), WEBP (default 80) and AVIF (default 30) and 0..9 for PNG (default 9).
|
|
673
|
-
* @param ImageType
|
|
671
|
+
* @param ?ImageType::* $type
|
|
674
672
|
* @throws ImageException
|
|
675
673
|
*/
|
|
676
674
|
public function save(string $file, ?int $quality = null, ?int $type = null): void
|
|
@@ -746,6 +744,7 @@ class Image
|
|
|
746
744
|
|
|
747
745
|
/**
|
|
748
746
|
* Call to undefined method.
|
|
747
|
+
* @param mixed[] $args
|
|
749
748
|
* @throws Nette\MemberAccessException
|
|
750
749
|
*/
|
|
751
750
|
public function __call(string $name, array $args): mixed
|
|
@@ -760,6 +759,7 @@ class Image
|
|
|
760
759
|
$args[$key] = $value->getImageResource();
|
|
761
760
|
|
|
762
761
|
} elseif ($value instanceof ImageColor || (is_array($value) && isset($value['red']))) {
|
|
762
|
+
/** @var ImageColor|array{red: int, green: int, blue: int, alpha?: int} $value */
|
|
763
763
|
$args[$key] = $this->resolveColor($value);
|
|
764
764
|
}
|
|
765
765
|
}
|
|
@@ -775,10 +775,11 @@ class Image
|
|
|
775
775
|
{
|
|
776
776
|
ob_start(fn() => '');
|
|
777
777
|
imagepng($this->image, null, 0);
|
|
778
|
-
$this->setImageResource(imagecreatefromstring(ob_get_clean()));
|
|
778
|
+
$this->setImageResource(imagecreatefromstring(ob_get_clean()) ?: throw new Nette\ShouldNotHappenException);
|
|
779
779
|
}
|
|
780
780
|
|
|
781
781
|
|
|
782
|
+
/** @param-out int|float $num */
|
|
782
783
|
private static function isPercent(int|string &$num): bool
|
|
783
784
|
{
|
|
784
785
|
if (is_string($num) && str_ends_with($num, '%')) {
|
|
@@ -802,13 +803,30 @@ class Image
|
|
|
802
803
|
}
|
|
803
804
|
|
|
804
805
|
|
|
806
|
+
/**
|
|
807
|
+
* @param ImageColor|array{red: int, green: int, blue: int, alpha?: int} $color
|
|
808
|
+
*/
|
|
805
809
|
public function resolveColor(ImageColor|array $color): int
|
|
806
810
|
{
|
|
807
|
-
$color = $color
|
|
811
|
+
$color = self::normalizeColor($color)->toRGBA();
|
|
808
812
|
return imagecolorallocatealpha($this->image, ...$color) ?: imagecolorresolvealpha($this->image, ...$color);
|
|
809
813
|
}
|
|
810
814
|
|
|
811
815
|
|
|
816
|
+
/** @param ImageColor|array{red: int, green: int, blue: int, alpha?: int} $color */
|
|
817
|
+
private static function normalizeColor(ImageColor|array $color): ImageColor
|
|
818
|
+
{
|
|
819
|
+
return $color instanceof ImageColor
|
|
820
|
+
? $color
|
|
821
|
+
: ImageColor::rgb(
|
|
822
|
+
$color['red'],
|
|
823
|
+
$color['green'],
|
|
824
|
+
$color['blue'],
|
|
825
|
+
(127 - ($color['alpha'] ?? 0)) / 127,
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
|
|
812
830
|
private static function ensureExtension(): void
|
|
813
831
|
{
|
|
814
832
|
if (!extension_loaded('gd')) {
|
|
@@ -22,6 +22,7 @@ final class Iterables
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Tests for the presence of value.
|
|
25
|
+
* @param iterable<mixed> $iterable
|
|
25
26
|
*/
|
|
26
27
|
public static function contains(iterable $iterable, mixed $value): bool
|
|
27
28
|
{
|
|
@@ -36,6 +37,7 @@ final class Iterables
|
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Tests for the presence of key.
|
|
40
|
+
* @param iterable<mixed> $iterable
|
|
39
41
|
*/
|
|
40
42
|
public static function containsKey(iterable $iterable, mixed $key): bool
|
|
41
43
|
{
|
|
@@ -52,9 +54,11 @@ final class Iterables
|
|
|
52
54
|
* Returns the first item (matching the specified predicate if given). If there is no such item, it returns result of invoking $else or null.
|
|
53
55
|
* @template K
|
|
54
56
|
* @template V
|
|
57
|
+
* @template E
|
|
55
58
|
* @param iterable<K, V> $iterable
|
|
56
59
|
* @param ?callable(V, K, iterable<K, V>): bool $predicate
|
|
57
|
-
* @
|
|
60
|
+
* @param ?callable(): E $else
|
|
61
|
+
* @return ($else is null ? ?V : V|E)
|
|
58
62
|
*/
|
|
59
63
|
public static function first(iterable $iterable, ?callable $predicate = null, ?callable $else = null): mixed
|
|
60
64
|
{
|
|
@@ -71,9 +75,11 @@ final class Iterables
|
|
|
71
75
|
* Returns the key of first item (matching the specified predicate if given). If there is no such item, it returns result of invoking $else or null.
|
|
72
76
|
* @template K
|
|
73
77
|
* @template V
|
|
78
|
+
* @template E
|
|
74
79
|
* @param iterable<K, V> $iterable
|
|
75
80
|
* @param ?callable(V, K, iterable<K, V>): bool $predicate
|
|
76
|
-
* @
|
|
81
|
+
* @param ?callable(): E $else
|
|
82
|
+
* @return ($else is null ? ?K : K|E)
|
|
77
83
|
*/
|
|
78
84
|
public static function firstKey(iterable $iterable, ?callable $predicate = null, ?callable $else = null): mixed
|
|
79
85
|
{
|
|
@@ -161,11 +167,11 @@ final class Iterables
|
|
|
161
167
|
* Iterator that transforms keys and values by calling $transformer. If it returns null, the element is skipped.
|
|
162
168
|
* @template K
|
|
163
169
|
* @template V
|
|
164
|
-
* @template ResV
|
|
165
170
|
* @template ResK
|
|
171
|
+
* @template ResV
|
|
166
172
|
* @param iterable<K, V> $iterable
|
|
167
|
-
* @param callable(V, K, iterable<K, V>): ?array{
|
|
168
|
-
* @return \Generator<
|
|
173
|
+
* @param callable(V, K, iterable<K, V>): ?array{ResK, ResV} $transformer
|
|
174
|
+
* @return \Generator<ResK, ResV>
|
|
169
175
|
*/
|
|
170
176
|
public static function mapWithKeys(iterable $iterable, callable $transformer): \Generator
|
|
171
177
|
{
|
|
@@ -188,9 +194,10 @@ final class Iterables
|
|
|
188
194
|
*/
|
|
189
195
|
public static function repeatable(callable $factory): \IteratorAggregate
|
|
190
196
|
{
|
|
191
|
-
return new class ($factory) implements \IteratorAggregate {
|
|
197
|
+
return new class ($factory(...)) implements \IteratorAggregate {
|
|
192
198
|
public function __construct(
|
|
193
|
-
|
|
199
|
+
/** @var \Closure(): iterable<mixed, mixed> */
|
|
200
|
+
private \Closure $factory,
|
|
194
201
|
) {
|
|
195
202
|
}
|
|
196
203
|
|
|
@@ -215,7 +222,8 @@ final class Iterables
|
|
|
215
222
|
{
|
|
216
223
|
return new class (self::toIterator($iterable)) implements \IteratorAggregate {
|
|
217
224
|
public function __construct(
|
|
218
|
-
private \Iterator $iterator,
|
|
225
|
+
private readonly \Iterator $iterator,
|
|
226
|
+
/** @var array<array{mixed, mixed}> */
|
|
219
227
|
private array $cache = [],
|
|
220
228
|
) {
|
|
221
229
|
}
|
|
@@ -17,17 +17,17 @@ use Nette;
|
|
|
17
17
|
*
|
|
18
18
|
* @property int $page
|
|
19
19
|
* @property-read int $firstPage
|
|
20
|
-
* @property-read int
|
|
20
|
+
* @property-read ?int $lastPage
|
|
21
21
|
* @property-read int<0,max> $firstItemOnPage
|
|
22
22
|
* @property-read int<0,max> $lastItemOnPage
|
|
23
23
|
* @property int $base
|
|
24
24
|
* @property-read bool $first
|
|
25
25
|
* @property-read bool $last
|
|
26
|
-
* @property-read int<0,max
|
|
26
|
+
* @property-read ?int<0,max> $pageCount
|
|
27
27
|
* @property positive-int $itemsPerPage
|
|
28
|
-
* @property int<0,max
|
|
28
|
+
* @property ?int<0,max> $itemCount
|
|
29
29
|
* @property-read int<0,max> $offset
|
|
30
|
-
* @property-read int<0,max
|
|
30
|
+
* @property-read ?int<0,max> $countdownOffset
|
|
31
31
|
* @property-read int<0,max> $length
|
|
32
32
|
*/
|
|
33
33
|
class Paginator
|
|
@@ -41,13 +41,10 @@ class Paginator
|
|
|
41
41
|
|
|
42
42
|
private int $page = 1;
|
|
43
43
|
|
|
44
|
-
/** @var int<0, max
|
|
44
|
+
/** @var ?int<0, max> */
|
|
45
45
|
private ?int $itemCount = null;
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
/**
|
|
49
|
-
* Sets current page number.
|
|
50
|
-
*/
|
|
51
48
|
public function setPage(int $page): static
|
|
52
49
|
{
|
|
53
50
|
$this->page = $page;
|
|
@@ -55,27 +52,18 @@ class Paginator
|
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
|
|
58
|
-
/**
|
|
59
|
-
* Returns current page number.
|
|
60
|
-
*/
|
|
61
55
|
public function getPage(): int
|
|
62
56
|
{
|
|
63
57
|
return $this->base + $this->getPageIndex();
|
|
64
58
|
}
|
|
65
59
|
|
|
66
60
|
|
|
67
|
-
/**
|
|
68
|
-
* Returns first page number.
|
|
69
|
-
*/
|
|
70
61
|
public function getFirstPage(): int
|
|
71
62
|
{
|
|
72
63
|
return $this->base;
|
|
73
64
|
}
|
|
74
65
|
|
|
75
66
|
|
|
76
|
-
/**
|
|
77
|
-
* Returns last page number.
|
|
78
|
-
*/
|
|
79
67
|
public function getLastPage(): ?int
|
|
80
68
|
{
|
|
81
69
|
return $this->itemCount === null
|
|
@@ -106,9 +94,6 @@ class Paginator
|
|
|
106
94
|
}
|
|
107
95
|
|
|
108
96
|
|
|
109
|
-
/**
|
|
110
|
-
* Sets first page (base) number.
|
|
111
|
-
*/
|
|
112
97
|
public function setBase(int $base): static
|
|
113
98
|
{
|
|
114
99
|
$this->base = $base;
|
|
@@ -116,9 +101,6 @@ class Paginator
|
|
|
116
101
|
}
|
|
117
102
|
|
|
118
103
|
|
|
119
|
-
/**
|
|
120
|
-
* Returns first page (base) number.
|
|
121
|
-
*/
|
|
122
104
|
public function getBase(): int
|
|
123
105
|
{
|
|
124
106
|
return $this->base;
|
|
@@ -138,18 +120,12 @@ class Paginator
|
|
|
138
120
|
}
|
|
139
121
|
|
|
140
122
|
|
|
141
|
-
/**
|
|
142
|
-
* Is the current page the first one?
|
|
143
|
-
*/
|
|
144
123
|
public function isFirst(): bool
|
|
145
124
|
{
|
|
146
125
|
return $this->getPageIndex() === 0;
|
|
147
126
|
}
|
|
148
127
|
|
|
149
128
|
|
|
150
|
-
/**
|
|
151
|
-
* Is the current page the last one?
|
|
152
|
-
*/
|
|
153
129
|
public function isLast(): bool
|
|
154
130
|
{
|
|
155
131
|
return $this->itemCount === null
|
|
@@ -159,20 +135,16 @@ class Paginator
|
|
|
159
135
|
|
|
160
136
|
|
|
161
137
|
/**
|
|
162
|
-
*
|
|
163
|
-
* @return int<0, max>|null
|
|
138
|
+
* @return ?int<0, max>
|
|
164
139
|
*/
|
|
165
140
|
public function getPageCount(): ?int
|
|
166
141
|
{
|
|
167
142
|
return $this->itemCount === null
|
|
168
143
|
? null
|
|
169
|
-
: (int) ceil($this->itemCount / $this->itemsPerPage);
|
|
144
|
+
: max(0, (int) ceil($this->itemCount / $this->itemsPerPage));
|
|
170
145
|
}
|
|
171
146
|
|
|
172
147
|
|
|
173
|
-
/**
|
|
174
|
-
* Sets the number of items to display on a single page.
|
|
175
|
-
*/
|
|
176
148
|
public function setItemsPerPage(int $itemsPerPage): static
|
|
177
149
|
{
|
|
178
150
|
$this->itemsPerPage = max(1, $itemsPerPage);
|
|
@@ -181,7 +153,6 @@ class Paginator
|
|
|
181
153
|
|
|
182
154
|
|
|
183
155
|
/**
|
|
184
|
-
* Returns the number of items to display on a single page.
|
|
185
156
|
* @return positive-int
|
|
186
157
|
*/
|
|
187
158
|
public function getItemsPerPage(): int
|
|
@@ -190,9 +161,6 @@ class Paginator
|
|
|
190
161
|
}
|
|
191
162
|
|
|
192
163
|
|
|
193
|
-
/**
|
|
194
|
-
* Sets the total number of items.
|
|
195
|
-
*/
|
|
196
164
|
public function setItemCount(?int $itemCount = null): static
|
|
197
165
|
{
|
|
198
166
|
$this->itemCount = $itemCount === null ? null : max(0, $itemCount);
|
|
@@ -201,8 +169,7 @@ class Paginator
|
|
|
201
169
|
|
|
202
170
|
|
|
203
171
|
/**
|
|
204
|
-
*
|
|
205
|
-
* @return int<0, max>|null
|
|
172
|
+
* @return ?int<0, max>
|
|
206
173
|
*/
|
|
207
174
|
public function getItemCount(): ?int
|
|
208
175
|
{
|
|
@@ -222,7 +189,7 @@ class Paginator
|
|
|
222
189
|
|
|
223
190
|
/**
|
|
224
191
|
* Returns the absolute index of the first item on current page in countdown paging.
|
|
225
|
-
* @return int<0, max
|
|
192
|
+
* @return ?int<0, max>
|
|
226
193
|
*/
|
|
227
194
|
public function getCountdownOffset(): ?int
|
|
228
195
|
{
|
|
@@ -240,6 +207,6 @@ class Paginator
|
|
|
240
207
|
{
|
|
241
208
|
return $this->itemCount === null
|
|
242
209
|
? $this->itemsPerPage
|
|
243
|
-
: min($this->itemsPerPage, $this->itemCount - $this->getPageIndex() * $this->itemsPerPage);
|
|
210
|
+
: max(0, min($this->itemsPerPage, $this->itemCount - $this->getPageIndex() * $this->itemsPerPage));
|
|
244
211
|
}
|
|
245
212
|
}
|
|
@@ -38,7 +38,7 @@ final class Reflection
|
|
|
38
38
|
public static function getParameterDefaultValue(\ReflectionParameter $param): mixed
|
|
39
39
|
{
|
|
40
40
|
if ($param->isDefaultValueConstant()) {
|
|
41
|
-
$const = $orig = $param->getDefaultValueConstantName();
|
|
41
|
+
$const = $orig = $param->getDefaultValueConstantName() ?? throw new Nette\ShouldNotHappenException;
|
|
42
42
|
$pair = explode('::', $const);
|
|
43
43
|
if (isset($pair[1])) {
|
|
44
44
|
$pair[0] = Type::resolve($pair[0], $param);
|
|
@@ -68,6 +68,7 @@ final class Reflection
|
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Returns a reflection of a class or trait that contains a declaration of given property. Property can also be declared in the trait.
|
|
71
|
+
* @return \ReflectionClass<object>
|
|
71
72
|
*/
|
|
72
73
|
public static function getPropertyDeclaringClass(\ReflectionProperty $prop): \ReflectionClass
|
|
73
74
|
{
|
|
@@ -151,6 +152,7 @@ final class Reflection
|
|
|
151
152
|
/**
|
|
152
153
|
* Expands the name of the class to full name in the given context of given class.
|
|
153
154
|
* Thus, it returns how the PHP parser would understand $name if it were written in the body of the class $context.
|
|
155
|
+
* @param \ReflectionClass<object> $context
|
|
154
156
|
* @throws Nette\InvalidArgumentException
|
|
155
157
|
*/
|
|
156
158
|
public static function expandClassName(string $name, \ReflectionClass $context): string
|
|
@@ -189,7 +191,10 @@ final class Reflection
|
|
|
189
191
|
}
|
|
190
192
|
|
|
191
193
|
|
|
192
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* @param \ReflectionClass<object> $class
|
|
196
|
+
* @return array<string, class-string> of [alias => class]
|
|
197
|
+
*/
|
|
193
198
|
public static function getUseStatements(\ReflectionClass $class): array
|
|
194
199
|
{
|
|
195
200
|
if ($class->isAnonymous()) {
|
|
@@ -201,7 +206,7 @@ final class Reflection
|
|
|
201
206
|
if ($class->isInternal()) {
|
|
202
207
|
$cache[$name] = [];
|
|
203
208
|
} else {
|
|
204
|
-
$code = file_get_contents($class->getFileName());
|
|
209
|
+
$code = (string) file_get_contents((string) $class->getFileName());
|
|
205
210
|
$cache = self::parseUseStatements($code, $name) + $cache;
|
|
206
211
|
}
|
|
207
212
|
}
|
|
@@ -212,6 +217,7 @@ final class Reflection
|
|
|
212
217
|
|
|
213
218
|
/**
|
|
214
219
|
* Parses PHP code to [class => [alias => class, ...]]
|
|
220
|
+
* @return array<string, array<string, string>>
|
|
215
221
|
*/
|
|
216
222
|
private static function parseUseStatements(string $code, ?string $forClass = null): array
|
|
217
223
|
{
|
|
@@ -256,8 +262,8 @@ final class Reflection
|
|
|
256
262
|
$name = ltrim($name, '\\');
|
|
257
263
|
if (self::fetch($tokens, '{')) {
|
|
258
264
|
while ($suffix = self::fetch($tokens, $nameTokens)) {
|
|
259
|
-
if (self::fetch($tokens, T_AS)) {
|
|
260
|
-
$uses[
|
|
265
|
+
if (self::fetch($tokens, T_AS) && ($alias = self::fetch($tokens, T_STRING))) {
|
|
266
|
+
$uses[$alias] = $name . $suffix;
|
|
261
267
|
} else {
|
|
262
268
|
$tmp = explode('\\', $suffix);
|
|
263
269
|
$uses[end($tmp)] = $name . $suffix;
|
|
@@ -267,8 +273,8 @@ final class Reflection
|
|
|
267
273
|
break;
|
|
268
274
|
}
|
|
269
275
|
}
|
|
270
|
-
} elseif (self::fetch($tokens, T_AS)) {
|
|
271
|
-
$uses[
|
|
276
|
+
} elseif (self::fetch($tokens, T_AS) && ($alias = self::fetch($tokens, T_STRING))) {
|
|
277
|
+
$uses[$alias] = $name;
|
|
272
278
|
|
|
273
279
|
} else {
|
|
274
280
|
$tmp = explode('\\', $name);
|
|
@@ -301,6 +307,10 @@ final class Reflection
|
|
|
301
307
|
}
|
|
302
308
|
|
|
303
309
|
|
|
310
|
+
/**
|
|
311
|
+
* @param \PhpToken[] $tokens
|
|
312
|
+
* @param string|int|int[] $take
|
|
313
|
+
*/
|
|
304
314
|
private static function fetch(array &$tokens, string|int|array $take): ?string
|
|
305
315
|
{
|
|
306
316
|
$res = null;
|