From 0ba3d314e4ceaacb586826f1313875d120e3c2bc Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Sat, 22 Feb 2025 12:02:09 +0100 Subject: [PATCH] fix(php): Fix PHP 8.4 nullable types warnings --- src/Drupal/Driver/Cores/AbstractCore.php | 2 +- src/Drupal/Driver/Cores/CoreInterface.php | 2 +- src/Drupal/Driver/DrushDriver.php | 2 +- src/Drupal/Driver/Exception/BootstrapException.php | 2 +- src/Drupal/Driver/Exception/Exception.php | 2 +- .../Driver/Exception/UnsupportedDriverActionException.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Drupal/Driver/Cores/AbstractCore.php b/src/Drupal/Driver/Cores/AbstractCore.php index 89b1e015..8797e0c2 100644 --- a/src/Drupal/Driver/Cores/AbstractCore.php +++ b/src/Drupal/Driver/Cores/AbstractCore.php @@ -34,7 +34,7 @@ abstract class AbstractCore implements CoreInterface { /** * {@inheritdoc} */ - public function __construct($drupal_root, $uri = 'default', Random $random = NULL) { + public function __construct($drupal_root, $uri = 'default', ?Random $random = NULL) { $this->drupalRoot = realpath($drupal_root); $this->uri = $uri; if (!isset($random)) { diff --git a/src/Drupal/Driver/Cores/CoreInterface.php b/src/Drupal/Driver/Cores/CoreInterface.php index 03f728d5..12e146ef 100644 --- a/src/Drupal/Driver/Cores/CoreInterface.php +++ b/src/Drupal/Driver/Cores/CoreInterface.php @@ -19,7 +19,7 @@ interface CoreInterface { * @param \Drupal\Component\Utility\Random $random * Random string generator. */ - public function __construct($drupal_root, $uri = 'default', Random $random = NULL); + public function __construct($drupal_root, $uri = 'default', ?Random $random = NULL); /** * Return random generator. diff --git a/src/Drupal/Driver/DrushDriver.php b/src/Drupal/Driver/DrushDriver.php index 8bcd116b..1026c8da 100644 --- a/src/Drupal/Driver/DrushDriver.php +++ b/src/Drupal/Driver/DrushDriver.php @@ -78,7 +78,7 @@ class DrushDriver extends BaseDriver { * @throws \Drupal\Driver\Exception\BootstrapException * Thrown when a required parameter is missing. */ - public function __construct($alias = NULL, $root_path = NULL, $binary = 'drush', Random $random = NULL) { + public function __construct($alias = NULL, $root_path = NULL, $binary = 'drush', ?Random $random = NULL) { if (!empty($alias)) { // Trim off the '@' symbol if it has been added. $alias = ltrim($alias, '@'); diff --git a/src/Drupal/Driver/Exception/BootstrapException.php b/src/Drupal/Driver/Exception/BootstrapException.php index 0ac7a1d2..3f020650 100644 --- a/src/Drupal/Driver/Exception/BootstrapException.php +++ b/src/Drupal/Driver/Exception/BootstrapException.php @@ -17,7 +17,7 @@ class BootstrapException extends Exception { * @param \Exception $previous * Optional previous exception that was thrown. */ - public function __construct($message, $code = 0, \Exception $previous = NULL) { + public function __construct($message, $code = 0, ?\Exception $previous = NULL) { parent::__construct($message, NULL, $code, $previous); } diff --git a/src/Drupal/Driver/Exception/Exception.php b/src/Drupal/Driver/Exception/Exception.php index af1f8580..08a5343c 100644 --- a/src/Drupal/Driver/Exception/Exception.php +++ b/src/Drupal/Driver/Exception/Exception.php @@ -28,7 +28,7 @@ abstract class Exception extends \Exception { * @param \Exception $previous * Optional previous exception that was thrown. */ - public function __construct($message, DriverInterface $driver = NULL, $code = 0, \Exception $previous = NULL) { + public function __construct($message, ?DriverInterface $driver = NULL, $code = 0, ?\Exception $previous = NULL) { $this->driver = $driver; parent::__construct($message, $code, $previous); diff --git a/src/Drupal/Driver/Exception/UnsupportedDriverActionException.php b/src/Drupal/Driver/Exception/UnsupportedDriverActionException.php index 9fac49b4..33a66ddc 100644 --- a/src/Drupal/Driver/Exception/UnsupportedDriverActionException.php +++ b/src/Drupal/Driver/Exception/UnsupportedDriverActionException.php @@ -21,7 +21,7 @@ class UnsupportedDriverActionException extends Exception { * @param \Exception $previous * Previous exception. */ - public function __construct($template, DriverInterface $driver, $code = 0, \Exception $previous = NULL) { + public function __construct($template, DriverInterface $driver, $code = 0, ?\Exception $previous = NULL) { $message = sprintf($template, get_class($driver)); parent::__construct($message, $driver, $code, $previous);