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/devel_entity_updates/src/DevelEntityDefinitionUpdateManager.php
-----------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
 191 | ERROR | [x] Parameter $storage_definition has null default value, but is not marked as nullable.
 191 | ERROR | [x] Parameter $original_storage_definition has null default value, but is not marked as nullable.
-----------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------
CommentFileSizeAuthor
#3 3519207-devel-entity-update-3.patch1.09 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

Status: Needs work » Needs review
StatusFileSize
new1.09 KB

Exported MR into patch to use in composer.

liam morland’s picture

Version: 4.2.x-dev » 5.0.x-dev

The merge request should have its target switched to 5.0.x. If desired, once merged, this can be cherry-picked onto 4.2.x.

plach’s picture

Status: Needs review » Fixed

Approved/merged, thanks!

  • plach committed 29b3f05a on 5.0.x
    Issue #3519207: Fix PHP 8.4 nullable type declarations.
    

  • plach committed 1433cffd on 4.2.x
    Issue #3519207: Fix PHP 8.4 nullable type declarations.
    
    (cherry picked...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.