Problem/Motivation

In PHP 8.4, declaring functions/methods with parameters containing null as a default value, but without null as one of the types (either as a nullable syntax or as a Union type with null) is deprecated.

https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullabl...

Steps to reproduce

phpcs --standard=SlevomatCodingStandard --sniffs=SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue

FILE: /app/docroot/modules/contrib/allowed_languages/src/AllowedLanguagesManagerInterface.php
---------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------------------
 25 | ERROR | [x] Parameter $account has null default value, but is not marked as nullable.
 36 | ERROR | [x] Parameter $account has null default value, but is not marked as nullable.
 49 | ERROR | [x] Parameter $account has null default value, but is not marked as nullable.
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------


FILE: /app/docroot/modules/contrib/allowed_languages/src/AllowedLanguagesManager.php
--------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------
 49 | ERROR | [x] Parameter $account has null default value, but is not marked as nullable.
 66 | ERROR | [x] Parameter $account has null default value, but is not marked as nullable.
 87 | ERROR | [x] Parameter $account has null default value, but is not marked as nullable.
--------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------

CommentFileSizeAuthor
#3 3518707-3.patch3.41 KBkiseleva.t
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kiseleva.t created an issue. See original summary.

kiseleva.t’s picture

Version: 2.0.0 » 2.x-dev
Status: Needs work » Needs review
StatusFileSize
new3.41 KB

Static patch for use in composer.

pavelbo made their first commit to this issue’s fork.