From da0d08b7691394fac7f0773b39b62c8ef78343db Mon Sep 17 00:00:00 2001 From: Colin Bird Date: Thu, 4 Jun 2026 10:41:28 -0400 Subject: [PATCH] fix: mark exception $previous parameter nullable for PHP 8.4 PHP 8.4 deprecates implicit nullable parameters on SDK exception constructors. Update rebilly-php-specific DataValidationException template so regeneration keeps the fix. Closes Rebilly/rebilly#20410 Co-authored-by: Cursor --- .changeset/php84-exception-nullable.md | 5 +++++ .../src/Exception/DataValidationException.php.handlebars | 2 +- src/Exception/DataValidationException.php | 2 +- src/Exception/GoneException.php | 2 +- src/Exception/HttpException.php | 2 +- src/Exception/NotFoundException.php | 2 +- src/Exception/TooManyRequestsException.php | 2 +- 7 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changeset/php84-exception-nullable.md diff --git a/.changeset/php84-exception-nullable.md b/.changeset/php84-exception-nullable.md new file mode 100644 index 000000000..f9f990db1 --- /dev/null +++ b/.changeset/php84-exception-nullable.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Fix PHP 8.4 deprecations on exception constructors by marking `$previous` as explicitly nullable. diff --git a/sdk-generator/templates/static/src/Exception/DataValidationException.php.handlebars b/sdk-generator/templates/static/src/Exception/DataValidationException.php.handlebars index 9304956d6..748e8ed87 100644 --- a/sdk-generator/templates/static/src/Exception/DataValidationException.php.handlebars +++ b/sdk-generator/templates/static/src/Exception/DataValidationException.php.handlebars @@ -10,7 +10,7 @@ final class DataValidationException extends HttpException { private array $validationErrors = []; - public function __construct(array $content = [], $message = '', $code = 0, Exception $previous = null) + public function __construct(array $content = [], $message = '', $code = 0, ?Exception $previous = null) { if (isset($content['invalidFields']) && is_array($content['invalidFields'])) { $this->validationErrors = $content['invalidFields']; diff --git a/src/Exception/DataValidationException.php b/src/Exception/DataValidationException.php index c90396f4f..c9c72512c 100644 --- a/src/Exception/DataValidationException.php +++ b/src/Exception/DataValidationException.php @@ -20,7 +20,7 @@ final class DataValidationException extends HttpException { private array $validationErrors = []; - public function __construct(array $content = [], $message = '', $code = 0, Exception $previous = null) + public function __construct(array $content = [], $message = '', $code = 0, ?Exception $previous = null) { if (isset($content['invalidFields']) && is_array($content['invalidFields'])) { $this->validationErrors = $content['invalidFields']; diff --git a/src/Exception/GoneException.php b/src/Exception/GoneException.php index a493585ce..d68ef310e 100644 --- a/src/Exception/GoneException.php +++ b/src/Exception/GoneException.php @@ -18,7 +18,7 @@ final class GoneException extends ClientException { - public function __construct($message = '', $code = 0, Exception $previous = null) + public function __construct($message = '', $code = 0, ?Exception $previous = null) { parent::__construct(410, $message, $code, $previous); } diff --git a/src/Exception/HttpException.php b/src/Exception/HttpException.php index 67d990137..832c37f19 100644 --- a/src/Exception/HttpException.php +++ b/src/Exception/HttpException.php @@ -20,7 +20,7 @@ class HttpException extends Exception { private int $statusCode; - public function __construct($status, $message = '', $code = 0, Exception $previous = null) + public function __construct($status, $message = '', $code = 0, ?Exception $previous = null) { $this->statusCode = (int) $status; parent::__construct($message, $code, $previous); diff --git a/src/Exception/NotFoundException.php b/src/Exception/NotFoundException.php index 393c0acca..207b88c5b 100644 --- a/src/Exception/NotFoundException.php +++ b/src/Exception/NotFoundException.php @@ -18,7 +18,7 @@ final class NotFoundException extends ClientException { - public function __construct($message = '', $code = 0, Exception $previous = null) + public function __construct($message = '', $code = 0, ?Exception $previous = null) { parent::__construct(404, $message, $code, $previous); } diff --git a/src/Exception/TooManyRequestsException.php b/src/Exception/TooManyRequestsException.php index 2cb467d38..1abea0e54 100644 --- a/src/Exception/TooManyRequestsException.php +++ b/src/Exception/TooManyRequestsException.php @@ -22,7 +22,7 @@ final class TooManyRequestsException extends ClientException private int $rateLimit; - public function __construct($retryAfter, $rateLimit = 0, $message = '', $code = 0, Exception $previous = null) + public function __construct($retryAfter, $rateLimit = 0, $message = '', $code = 0, ?Exception $previous = null) { $this->retryAfter = $retryAfter; $this->rateLimit = (int) $rateLimit;