From 82d1a3f1c58655a1f0a5ac4a8019af146338086a Mon Sep 17 00:00:00 2001 From: "Lucas S. Vieira" Date: Sat, 11 Oct 2025 17:29:38 +0100 Subject: [PATCH 1/2] chore[php-8.4]: handle php 8.4 deprecations --- src/AQL/Functions/AQLFunction.php | 2 +- src/Admin/Task/Task.php | 8 ++++---- src/Auth/Exceptions/AuthException.php | 2 +- src/Auth/Exceptions/UserException.php | 2 +- src/Auth/User.php | 2 +- src/Document/Document.php | 2 +- src/Document/Edge.php | 2 +- src/Exceptions/BaseException.php | 2 +- src/Graph/Graph.php | 2 +- src/Graph/Traversal/Traversal.php | 2 +- src/Validation/Exceptions/InvalidKeyOptionException.php | 2 +- src/Validation/Exceptions/InvalidParameterException.php | 2 +- src/Validation/Exceptions/MissingParameterException.php | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/AQL/Functions/AQLFunction.php b/src/AQL/Functions/AQLFunction.php index e6b7673..57d0af0 100644 --- a/src/AQL/Functions/AQLFunction.php +++ b/src/AQL/Functions/AQLFunction.php @@ -60,7 +60,7 @@ class AQLFunction implements EntityInterface * @param bool $isDeterministic Indicates if the function results are deterministic. * @param bool $isNew Indicates if the function object is a new one or not. */ - public function __construct(string $name, string $code, Connection $connection = null, bool $isDeterministic = true, bool $isNew = true) + public function __construct(string $name, string $code, ?Connection $connection = null, bool $isDeterministic = true, bool $isNew = true) { $this->name = $name; $this->code = $code; diff --git a/src/Admin/Task/Task.php b/src/Admin/Task/Task.php index 29e3ed4..02f7667 100644 --- a/src/Admin/Task/Task.php +++ b/src/Admin/Task/Task.php @@ -27,14 +27,14 @@ class Task implements EntityInterface * * @var string */ - protected $id; + protected string $id; /** * Task type. * * @var string */ - protected $type = 'unknown'; + protected string $type = 'unknown'; /** * Attributes of task. @@ -79,7 +79,7 @@ class Task implements EntityInterface * * @throws InvalidParameterException|MissingParameterException */ - public function __construct(string $name, string $command, Connection $connection = null, array $options = []) + public function __construct(string $name, string $command, ?Connection $connection = null, array $options = []) { $attributes = array_merge($this->defaultOptions, ['name' => $name, 'command' => $command], $options); $validator = new TaskValidator($attributes); @@ -186,7 +186,7 @@ public function setCommand(string $command): void * * @param Connection $connection Connection object to use. */ - public function setConnection(Connection $connection) + public function setConnection(Connection $connection): void { $this->connection = $connection; } diff --git a/src/Auth/Exceptions/AuthException.php b/src/Auth/Exceptions/AuthException.php index f631698..2d0b783 100644 --- a/src/Auth/Exceptions/AuthException.php +++ b/src/Auth/Exceptions/AuthException.php @@ -22,7 +22,7 @@ class AuthException extends BaseException * @param Throwable|null $previous * @param int $code */ - public function __construct(string $message, Throwable $previous = null, $code = 0) + public function __construct(string $message, ?Throwable $previous = null, $code = 0) { parent::__construct($message, $previous, $code); } diff --git a/src/Auth/Exceptions/UserException.php b/src/Auth/Exceptions/UserException.php index 48fd83b..d2cf52e 100644 --- a/src/Auth/Exceptions/UserException.php +++ b/src/Auth/Exceptions/UserException.php @@ -22,7 +22,7 @@ class UserException extends BaseException * @param Throwable|null $previous * @param int $code */ - public function __construct(string $message, Throwable $previous = null, int $code = 0) + public function __construct(string $message, ?Throwable $previous = null, int $code = 0) { parent::__construct($message, $previous, $code); } diff --git a/src/Auth/User.php b/src/Auth/User.php index 9157299..d00a6c9 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -62,7 +62,7 @@ class User implements EntityInterface * * @throws InvalidParameterException|MissingParameterException */ - public function __construct(array $attributes = [], Connection $connection = null, bool $isNew = true) + public function __construct(array $attributes = [], ?Connection $connection = null, bool $isNew = true) { $validator = new UserValidator($attributes); $validator->validate(); diff --git a/src/Document/Document.php b/src/Document/Document.php index 2f9a043..11707b2 100644 --- a/src/Document/Document.php +++ b/src/Document/Document.php @@ -112,7 +112,7 @@ class Document implements EntityInterface * * @throws InvalidParameterException */ - public function __construct(array $attributes = [], Collection $collection = null) + public function __construct(array $attributes = [], ?Collection $collection = null) { $this->validator = new DocumentValidator($attributes); $this->validator->validate(); diff --git a/src/Document/Edge.php b/src/Document/Edge.php index a193315..63271f2 100644 --- a/src/Document/Edge.php +++ b/src/Document/Edge.php @@ -49,7 +49,7 @@ class Edge extends Document * * @throws InvalidParameterException|MissingParameterException */ - public function __construct(array $attributes = [], Collection $collection = null) + public function __construct(array $attributes = [], ?Collection $collection = null) { $validator = new EdgeValidator($attributes); $validator->validate(); diff --git a/src/Exceptions/BaseException.php b/src/Exceptions/BaseException.php index c704576..7113522 100644 --- a/src/Exceptions/BaseException.php +++ b/src/Exceptions/BaseException.php @@ -21,7 +21,7 @@ abstract class BaseException extends \Exception * @param Throwable|null $previous Previous exception or error. * @param int $code Error code. */ - public function __construct(string $message, Throwable $previous = null, $code = 0) + public function __construct(string $message, ?Throwable $previous = null, $code = 0) { parent::__construct($message, $code, $previous); } diff --git a/src/Graph/Graph.php b/src/Graph/Graph.php index 1d92de7..555a94f 100644 --- a/src/Graph/Graph.php +++ b/src/Graph/Graph.php @@ -106,7 +106,7 @@ class Graph implements \JsonSerializable * * @throws InvalidParameterException|MissingParameterException|ArangoException */ - public function __construct(string $name, array $attributes = [], Database $database = null) + public function __construct(string $name, array $attributes = [], ?Database $database = null) { $this->name = $this->key = $name; diff --git a/src/Graph/Traversal/Traversal.php b/src/Graph/Traversal/Traversal.php index 59abc88..6008e81 100644 --- a/src/Graph/Traversal/Traversal.php +++ b/src/Graph/Traversal/Traversal.php @@ -72,7 +72,7 @@ class Traversal * * @throws CursorException|GuzzleException */ - public function __construct(Statement $statement, Connection $connection = null) + public function __construct(Statement $statement, ?Connection $connection = null) { $this->statement = $statement; $this->connection = $connection; diff --git a/src/Validation/Exceptions/InvalidKeyOptionException.php b/src/Validation/Exceptions/InvalidKeyOptionException.php index f5d94a2..3180152 100644 --- a/src/Validation/Exceptions/InvalidKeyOptionException.php +++ b/src/Validation/Exceptions/InvalidKeyOptionException.php @@ -36,7 +36,7 @@ class InvalidKeyOptionException extends BaseException * @param string $value Parameter value. * @param Throwable|null $previous Previous exception or error. */ - public function __construct(string $parameter, $value, Throwable $previous = null) + public function __construct(string $parameter, $value, ?Throwable $previous = null) { $message = "Parameter '$parameter' can not be used for collection with key type of '$value'."; parent::__construct($message, $previous); diff --git a/src/Validation/Exceptions/InvalidParameterException.php b/src/Validation/Exceptions/InvalidParameterException.php index eba0b36..44232f6 100644 --- a/src/Validation/Exceptions/InvalidParameterException.php +++ b/src/Validation/Exceptions/InvalidParameterException.php @@ -36,7 +36,7 @@ class InvalidParameterException extends BaseException * @param mixed $value Parameter value. * @param Throwable|null $previous Previous exception or error. */ - public function __construct($parameter, $value, Throwable $previous = null) + public function __construct($parameter, $value, ?Throwable $previous = null) { $this->value = is_array($value) ? json_encode($value) : $value; $this->parameter = $parameter; diff --git a/src/Validation/Exceptions/MissingParameterException.php b/src/Validation/Exceptions/MissingParameterException.php index 2a714b2..93d845d 100644 --- a/src/Validation/Exceptions/MissingParameterException.php +++ b/src/Validation/Exceptions/MissingParameterException.php @@ -28,7 +28,7 @@ class MissingParameterException extends BaseException * @param string $parameter Parameter name. * @param Throwable|null $previous Previous exception or error. */ - public function __construct(string $parameter, Throwable $previous = null) + public function __construct(string $parameter, ?Throwable $previous = null) { $this->parameter = $parameter; $message = "Missing '$parameter' on: " . $this->getFile() . " in line " . $this->getLine(); From 738cc634ae1d44667af4f5740f4e8ee6791c256d Mon Sep 17 00:00:00 2001 From: "Lucas S. Vieira" Date: Sat, 11 Oct 2025 17:41:35 +0100 Subject: [PATCH 2/2] chore[php-8.4]: revert enforcing strict type on 'Admin\Task\Task::' --- src/Admin/Task/Task.php | 2 +- tests/TestCase.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Admin/Task/Task.php b/src/Admin/Task/Task.php index 02f7667..4cfd6d6 100644 --- a/src/Admin/Task/Task.php +++ b/src/Admin/Task/Task.php @@ -27,7 +27,7 @@ class Task implements EntityInterface * * @var string */ - protected string $id; + protected $id; /** * Task type. diff --git a/tests/TestCase.php b/tests/TestCase.php index fd900e4..188d505 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -35,7 +35,7 @@ public function loadEnvironment(): void * @throws \GuzzleHttp\Exception\GuzzleException * @throws \ReflectionException */ - public function getConnectionObject(MockHandler $mock = null): Connection + public function getConnectionObject(?MockHandler $mock = null): Connection { $connection = new Connection([ 'username' => $_ENV['ARANGODB_USERNAME'],