From 6d4a1afd4324a01dbfefa771f88770d683ec2f49 Mon Sep 17 00:00:00 2001 From: Toon Verwerft Date: Thu, 28 Mar 2024 07:19:56 +0100 Subject: [PATCH] PHP84 explicit nullable types --- .php-cs-fixer.dist.php | 1 + src/Xml/Dom/Xpath.php | 6 +++--- src/Xml/Dom/Xpath/Locator/evaluate.php | 2 +- src/Xml/Dom/Xpath/Locator/query.php | 2 +- src/Xml/Dom/Xpath/Locator/query_single.php | 2 +- src/Xml/Encoding/Exception/EncodingException.php | 2 +- src/Xml/Exception/RuntimeException.php | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index f538f792..d9fbaa5f 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -55,5 +55,6 @@ 'static_lambda' => true, 'strict_comparison' => true, 'strict_param' => true, + 'nullable_type_declaration_for_default_null_value' => true, ]) ; diff --git a/src/Xml/Dom/Xpath.php b/src/Xml/Dom/Xpath.php index ab1baee2..f75467b0 100644 --- a/src/Xml/Dom/Xpath.php +++ b/src/Xml/Dom/Xpath.php @@ -64,7 +64,7 @@ public function locate(callable $locator) * @throws RuntimeException * @return NodeList<\DOM\Node> */ - public function query(string $expression, \DOM\Node $contextNode = null): NodeList + public function query(string $expression, ?\DOM\Node $contextNode = null): NodeList { return $this->locate(query($expression, $contextNode)); } @@ -73,7 +73,7 @@ public function query(string $expression, \DOM\Node $contextNode = null): NodeLi * @throws RuntimeException * @throws InvalidArgumentException */ - public function querySingle(string $expression, \DOM\Node $contextNode = null): \DOM\Node + public function querySingle(string $expression, ?\DOM\Node $contextNode = null): \DOM\Node { return $this->locate(query_single($expression, $contextNode)); } @@ -86,7 +86,7 @@ public function querySingle(string $expression, \DOM\Node $contextNode = null): * @return T * @throws RuntimeException */ - public function evaluate(string $expression, TypeInterface $type, \DOM\Node $contextNode = null) + public function evaluate(string $expression, TypeInterface $type, ?\DOM\Node $contextNode = null) { return $this->locate(evaluate($expression, $type, $contextNode)); } diff --git a/src/Xml/Dom/Xpath/Locator/evaluate.php b/src/Xml/Dom/Xpath/Locator/evaluate.php index 9f9e6a3a..bc6b1941 100644 --- a/src/Xml/Dom/Xpath/Locator/evaluate.php +++ b/src/Xml/Dom/Xpath/Locator/evaluate.php @@ -17,7 +17,7 @@ * * @return Closure(\DOM\XPath): T */ -function evaluate(string $query, TypeInterface $type, \DOM\Node $node = null): Closure +function evaluate(string $query, TypeInterface $type, ?\DOM\Node $node = null): Closure { return /** diff --git a/src/Xml/Dom/Xpath/Locator/query.php b/src/Xml/Dom/Xpath/Locator/query.php index a60562e7..f7450a2c 100644 --- a/src/Xml/Dom/Xpath/Locator/query.php +++ b/src/Xml/Dom/Xpath/Locator/query.php @@ -15,7 +15,7 @@ /** * @return Closure(\DOM\XPath): NodeList<\DOM\Node> */ -function query(string $query, \DOM\Node $node = null): Closure +function query(string $query, ?\DOM\Node $node = null): Closure { return static function (\DOM\XPath $xpath) use ($query, $node): NodeList { $node = $node ?? $xpath->document->documentElement; diff --git a/src/Xml/Dom/Xpath/Locator/query_single.php b/src/Xml/Dom/Xpath/Locator/query_single.php index 649c86ac..7899f72a 100644 --- a/src/Xml/Dom/Xpath/Locator/query_single.php +++ b/src/Xml/Dom/Xpath/Locator/query_single.php @@ -18,7 +18,7 @@ /** * @return Closure(\DOM\XPath): \DOM\Node */ -function query_single(string $query, \DOM\Node $node = null): Closure +function query_single(string $query, ?\DOM\Node $node = null): Closure { return /** diff --git a/src/Xml/Encoding/Exception/EncodingException.php b/src/Xml/Encoding/Exception/EncodingException.php index 3ffbda8b..a9494c56 100644 --- a/src/Xml/Encoding/Exception/EncodingException.php +++ b/src/Xml/Encoding/Exception/EncodingException.php @@ -9,7 +9,7 @@ final class EncodingException extends Exception implements ExceptionInterface { - private function __construct(string $message, Exception $previous = null) + private function __construct(string $message, ?Exception $previous = null) { parent::__construct( $message, diff --git a/src/Xml/Exception/RuntimeException.php b/src/Xml/Exception/RuntimeException.php index 61b54aec..689ed125 100644 --- a/src/Xml/Exception/RuntimeException.php +++ b/src/Xml/Exception/RuntimeException.php @@ -9,7 +9,7 @@ final class RuntimeException extends \RuntimeException implements ExceptionInterface { - private function __construct(string $message, Throwable $previous = null) + private function __construct(string $message, ?Throwable $previous = null) { parent::__construct( $message,