[PHP 8.4] Fix implicitly nullable type declarations

Created on 15 April 2025, 12 days ago

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/external_entities/src/Entity/ExternalEntity.php
------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------
 184 | ERROR | [x] Parameter $annotation has null default value, but is not marked as nullable.
------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------


FILE: /app/docroot/modules/contrib/external_entities/src/ExternalEntityAccessControlHandler.php
-----------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------
 89 | ERROR | [x] Parameter $items has null default value, but is not marked as nullable.
-----------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------


FILE: /app/docroot/modules/contrib/external_entities/src/StorageClient/ExternalEntityStorageClientInterface.php
---------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------
 40 | ERROR | [x] Parameter $ids has null default value, but is not marked as nullable.
---------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------


FILE: /app/docroot/modules/contrib/external_entities/src/Plugin/ExternalEntities/StorageClient/Rest.php
-------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------
 279 | ERROR | [x] Parameter $ids has null default value, but is not marked as nullable.
-------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------


FILE: /app/docroot/modules/contrib/external_entities/src/RouteProcessor/RouteProcessorExternalEntityType.php
------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------
 43 | ERROR | [x] Parameter $bubbleable_metadata has null default value, but is not marked as nullable.
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------


FILE: /app/docroot/modules/contrib/external_entities/src/ExternalEntityInterface.php
-----------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------
 55 | ERROR | [x] Parameter $annotation has null default value, but is not marked as nullable.
-----------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------


FILE: /app/docroot/modules/contrib/external_entities/src/ExternalEntityStorage.php
-----------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------
 223 | ERROR | [x] Parameter $ids has null default value, but is not marked as nullable.
 257 | ERROR | [x] Parameter $ids has null default value, but is not marked as nullable.
-----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------
📌 Task
Status

Needs work

Version

2.0

Component

Code

Created by

🇷🇺Russia kiseleva.t

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024