Issue #3444022 by andypost: [8.4] Fix implicitly nullable type declarations in core/lib/Drupal/Component

(cherry picked from commit 75fbba33d0)
merge-requests/7514/merge
catch 2024-04-29 14:48:06 +01:00
parent 537c4c0c5f
commit 47ea40117e
8 changed files with 9 additions and 9 deletions

View File

@ -31,7 +31,7 @@ class Time implements TimeInterface {
* @param \Symfony\Component\HttpFoundation\RequestStack|null $request_stack
* (Optional) The request stack.
*/
public function __construct(RequestStack $request_stack = NULL) {
public function __construct(?RequestStack $request_stack = NULL) {
$this->requestStack = $request_stack;
}

View File

@ -469,7 +469,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* @return string|object
* A suitable representation of the service reference.
*/
protected function getReferenceCall($id, Reference $reference = NULL) {
protected function getReferenceCall($id, ?Reference $reference = NULL) {
$invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
if ($reference !== NULL) {

View File

@ -25,7 +25,7 @@ interface CategorizingPluginManagerInterface extends PluginManagerInterface {
* @return array[]
* An array of plugin definitions, sorted by category and label.
*/
public function getSortedDefinitions(array $definitions = NULL);
public function getSortedDefinitions(?array $definitions = NULL);
/**
* Gets sorted plugin definitions grouped by category.
@ -41,6 +41,6 @@ interface CategorizingPluginManagerInterface extends PluginManagerInterface {
* Keys are category names, and values are arrays of which the keys are
* plugin IDs and the values are plugin definitions.
*/
public function getGroupedDefinitions(array $definitions = NULL);
public function getGroupedDefinitions(?array $definitions = NULL);
}

View File

@ -28,7 +28,7 @@ class InvalidPluginDefinitionException extends PluginException {
*
* @see \Exception
*/
public function __construct($plugin_id, $message = '', $code = 0, \Exception $previous = NULL) {
public function __construct($plugin_id, $message = '', $code = 0, ?\Exception $previous = NULL) {
$this->pluginId = $plugin_id;
parent::__construct($message, $code, $previous);
}

View File

@ -21,7 +21,7 @@ class PluginNotFoundException extends PluginException {
*
* @see \Exception
*/
public function __construct($plugin_id, $message = '', $code = 0, \Exception $previous = NULL) {
public function __construct($plugin_id, $message = '', $code = 0, ?\Exception $previous = NULL) {
if (empty($message)) {
$message = sprintf("Plugin ID '%s' was not found.", $plugin_id);
}

View File

@ -23,7 +23,7 @@ class EmailValidator extends EmailValidatorUtility implements EmailValidatorInte
* @return bool
* TRUE if the address is valid.
*/
public function isValid($email, EmailValidation $email_validation = NULL) {
public function isValid($email, ?EmailValidation $email_validation = NULL) {
if ($email_validation) {
throw new \BadMethodCallException('Calling \Drupal\Component\Utility\EmailValidator::isValid() with the second argument is not supported. See https://www.drupal.org/node/2997196');
}

View File

@ -358,7 +358,7 @@ class NestedArray {
* @return array
* The filtered array.
*/
public static function filter(array $array, callable $callable = NULL) {
public static function filter(array $array, ?callable $callable = NULL) {
$array = is_callable($callable) ? array_filter($array, $callable) : array_filter($array);
foreach ($array as &$element) {
if (is_array($element)) {

View File

@ -56,7 +56,7 @@ class Xss {
*
* @ingroup sanitization
*/
public static function filter($string, array $allowed_html_tags = NULL) {
public static function filter($string, ?array $allowed_html_tags = NULL) {
if (is_null($allowed_html_tags)) {
$allowed_html_tags = static::$htmlTags;
}