From 30dc06cbe745ad2aed17cec38b9c0f7e3c9ca621 Mon Sep 17 00:00:00 2001 From: Tomas Date: Mon, 24 Feb 2025 11:35:29 +0200 Subject: [PATCH] Fix PHP 8.4 deprecations --- src/Nodes/SVGNodeContainer.php | 2 +- src/Nodes/Shapes/SVGPath.php | 2 +- src/Nodes/Shapes/SVGPolygonalShape.php | 6 +++--- src/Nodes/Structures/SVGClipPath.php | 2 +- src/Rasterization/Transform/TransformParser.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Nodes/SVGNodeContainer.php b/src/Nodes/SVGNodeContainer.php index 57c9be0..af72bc8 100644 --- a/src/Nodes/SVGNodeContainer.php +++ b/src/Nodes/SVGNodeContainer.php @@ -41,7 +41,7 @@ public function __construct() * * @return $this This node instance, for call chaining. */ - public function addChild(SVGNode $node, int $index = null): SVGNodeContainer + public function addChild(SVGNode $node, ?int $index = null): SVGNodeContainer { if ($node === $this || $node->parent === $this) { return $this; diff --git a/src/Nodes/Shapes/SVGPath.php b/src/Nodes/Shapes/SVGPath.php index 1f7560b..e1aab20 100644 --- a/src/Nodes/Shapes/SVGPath.php +++ b/src/Nodes/Shapes/SVGPath.php @@ -19,7 +19,7 @@ class SVGPath extends SVGNodeContainer /** * @param string|null $d The path description. */ - public function __construct(string $d = null) + public function __construct(?string $d = null) { parent::__construct(); diff --git a/src/Nodes/Shapes/SVGPolygonalShape.php b/src/Nodes/Shapes/SVGPolygonalShape.php index ec580e4..4765984 100644 --- a/src/Nodes/Shapes/SVGPolygonalShape.php +++ b/src/Nodes/Shapes/SVGPolygonalShape.php @@ -12,13 +12,13 @@ abstract class SVGPolygonalShape extends SVGNodeContainer { /** - * @param array[] $points Array of points (float 2-tuples). + * @param array[]|null $points Array of points (float 2-tuples). */ - public function __construct(array $points = null) + public function __construct(?array $points = null) { parent::__construct(); - if (isset($points)) { + if ($points !== null) { $this->setAttribute('points', self::joinPoints($points)); } } diff --git a/src/Nodes/Structures/SVGClipPath.php b/src/Nodes/Structures/SVGClipPath.php index 4eab646..78affdd 100644 --- a/src/Nodes/Structures/SVGClipPath.php +++ b/src/Nodes/Structures/SVGClipPath.php @@ -12,7 +12,7 @@ class SVGClipPath extends SVGNodeContainer { public const TAG_NAME = 'clipPath'; - public function __construct(string $id = null) + public function __construct(?string $id = null) { parent::__construct(); diff --git a/src/Rasterization/Transform/TransformParser.php b/src/Rasterization/Transform/TransformParser.php index fec46ee..af7f520 100644 --- a/src/Rasterization/Transform/TransformParser.php +++ b/src/Rasterization/Transform/TransformParser.php @@ -15,7 +15,7 @@ final class TransformParser * @param Transform|null $applyTo The optional starting Transform. If not provided, the identity will be used. * @return Transform Either the mutated argument transform, or the newly computed transform. */ - public static function parseTransformString(?string $input, Transform $applyTo = null): Transform + public static function parseTransformString(?string $input, ?Transform $applyTo = null): Transform { $transform = $applyTo ?? Transform::identity(); if ($input === null) {