Problem/Motivation

PHP 8.4 has deprecated implicit nullable types.

Steps to reproduce

Use in a PHP 8.4 environment

CommentFileSizeAuthor
#11 3500340-11-mr69.patch3.76 KBwebflo

Issue fork s3fs-3500340

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

pcambra created an issue. See original summary.

pcambra’s picture

Status: Active » Needs review
cmlara’s picture

Status: Needs review » Postponed
Related issues: +#3500147: Set minimum supported PHP version to 7.1

Postponed on #3500147: Set minimum supported PHP version to 7.1 being solved first.

We also might need to work around #3496517: Improve phpunit default configuration and make it customisable to get working tests before any new code changes go in.

pcambra’s picture

Just realised I had missed a few

cmlara’s picture

Note:
This issue contains fixes that are detected by phpcs and automatically fixed by phpcbf.

This issue will not receive D.O. issue credit under Abuse of the Contribution Credit system.

pcambra’s picture

I don't think phpcbf fixes this one, I wish :(

Just trying to update a project to 8.4 and share it, don't need you to give me credit but I am definitely not abusing the system.

To further proof that this is not automated (sadly) with a concrete example, as it doesn't fall in any of the categories of abuse linked above:

/var/www/html$ ./vendor/bin/phpcs -p web/modules/contrib/codemirror_editor/ --standard=PHPCompatibility
.............................W..... 35 / 35 (100%)

FILE: /var/www/html/web/modules/contrib/codemirror_editor/src/CodeMirrorPluginTrait.php
------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------------
 66 | WARNING | Implicitly marking a parameter as nullable is deprecated since PHP 8.4. Update the type to be explicitly nullable instead.
    |         | Found implicitly nullable parameter: $keys.
------------------------------------------------------------------------------------------------------------------------------------------------

Time: 153ms; Memory: 10MB

/var/www/html$ ./vendor/bin/phpcbf -p web/modules/contrib/codemirror_editor/ --standard=PHPCompatibility
................................... 35 / 35 (100%)

No fixable errors were found
cmlara’s picture

I don't think phpcbf fixes this one, I wish :(

The sniff is: SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.Null

The sniff is part of the Drupal standard published in recent druapl/coder releases.

The sniff is marked as fixable by phpcbf in the logs: https://git.drupalcode.org/project/s3fs/-/jobs/4029235#L119

Just trying to update a project to 8.4 and share it, don't need you to give me credit but I am

I belive you mean PHP9 (which has not yet been announced) as a deprecations do not stop the code from working in PHP 8.4,

pcambra’s picture

> The sniff is: SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.Null

You are right :facepalm: sorry for the noise.

> do not stop the code from working in PHP 8.4

I'm seeing warnings in the interface and drush, just wanted to fix those.

Feel free to close this one if you think it's not useful.

cmlara’s picture

I'm seeing warnings in the interface and drush, just wanted to fix those.

That is usually error_reporting including E_DEPRECATED, often used in debug labs however not generally recommended in production or any other location that warnings are not significantly useful.

sYou are right :facepalm: sorry for the noise.

To be fair I’m surprised this made it into the Drupal standard, I really expected it to be more likely to make it into a Rector rule.

This will eventually get fixed (either in a new major or we make the decision to drop PHP7.0)

Just more pointing out that with existing automation this deprecation is already well know and we are attempting to avoid dealing with the routine credit farming that we see on D.O.

Even with the warning I wouldn’t be surprised to see one of the companies listed in #3432188: [META] Tracking issue for organisations who received educational messages do a drive-by of adding RTBC that the patch applies (gitlab already tells us that) and that the issue is solved (PHPCS already confirms that).

webflo’s picture

StatusFileSize
new3.76 KB

Stable patch for 3.x / PHP 8.4.

cmlara’s picture

Status: Postponed » Needs review

PHP Min is now committed at 7.1 allowing this to proceed.

cmlara’s picture

Version: 8.x-3.x-dev » 4.0.x-dev
Status: Needs review » Patch (to be ported)

Committed to dev. We will likely have a new release to add D11.2/D10.4 support in the near future.

Tagging for 4.x as we likely need this there eventually.

  • cmlara committed 1158d44a on 8.x-3.x authored by pcambra
    Issue #3500340 by pcambra: Nullable types must be explicit