[8.4] Fix implicitly nullable type declarations for phpstan job (manual ones)

Created on 29 April 2024, about 1 month ago
Updated 21 May 2024, 12 days ago

Problem/Motivation

Part of 📌 [PHP 8.4] Fix implicitly nullable type declarations Active

Targeted to fix only files that blocking phpstan job to pass for PHP 8.4
This files can't be fixed automatically so using this separate issue

Steps to reproduce

- https://git.drupalcode.org/issue/drupal-3427903/-/jobs/1460070
- https://git.drupalcode.org/issue/drupal-3427999/-/jobs/1556417 (fix with phpcbf)

and manually

$ docker run --rm -v $(pwd):/var/www/html drupalci/php-8.4-ubuntu-apache:dev php -d error_reporting="E_ALL" -l core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php core/lib/Drupal/Core/Template/TwigNodeTrans.php core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php core/modules/node/src/NodeForm.php core/modules/taxonomy/src/VocabularyListBuilder.php core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php >/dev/null

PHP Deprecated:  Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection::__construct(): Implicitly marking parameter $entity_type_bundle_info as nullable is deprecated, the explicit nullable type must be used instead in core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php on line 111
PHP Deprecated:  Drupal\Core\Template\TwigNodeTrans::__construct(): Implicitly marking parameter $plural as nullable is deprecated, the explicit nullable type must be used instead in core/lib/Drupal/Core/Template/TwigNodeTrans.php on line 35
PHP Deprecated:  Drupal\Core\Template\TwigNodeTrans::__construct(): Implicitly marking parameter $count as nullable is deprecated, the explicit nullable type must be used instead in core/lib/Drupal/Core/Template/TwigNodeTrans.php on line 35
PHP Deprecated:  Drupal\Core\Template\TwigNodeTrans::__construct(): Implicitly marking parameter $options as nullable is deprecated, the explicit nullable type must be used instead in core/lib/Drupal/Core/Template/TwigNodeTrans.php on line 35
PHP Deprecated:  Drupal\Tests\language\Unit\ContentLanguageSettingsUnitTest::testLoadByEntityTypeBundle(): Implicitly marking parameter $existing_config as nullable is deprecated, the explicit nullable type must be used instead in core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php on line 247
PHP Deprecated:  Drupal\node\NodeForm::__construct(): Implicitly marking parameter $entity_type_bundle_info as nullable is deprecated, the explicit nullable type must be used instead in core/modules/node/src/NodeForm.php on line 59
PHP Deprecated:  Drupal\node\NodeForm::__construct(): Implicitly marking parameter $time as nullable is deprecated, the explicit nullable type must be used instead in core/modules/node/src/NodeForm.php on line 59
PHP Deprecated:  Drupal\taxonomy\VocabularyListBuilder::__construct(): Implicitly marking parameter $renderer as nullable is deprecated, the explicit nullable type must be used instead in core/modules/taxonomy/src/VocabularyListBuilder.php on line 70
PHP Deprecated:  Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::testGetAddPageRoute(): Implicitly marking parameter $expected as nullable is deprecated, the explicit nullable type must be used instead in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php on line 64
PHP Deprecated:  Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::testGetAddFormRoute(): Implicitly marking parameter $expected as nullable is deprecated, the explicit nullable type must be used instead in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php on line 102
PHP Deprecated:  Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::testGetAddFormRoute(): Implicitly marking parameter $bundle_entity_type as nullable is deprecated, the explicit nullable type must be used instead in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php on line 102
PHP Deprecated:  Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::testGetAddFormRoute(): Implicitly marking parameter $field_storage_definition as nullable is deprecated, the explicit nullable type must be used instead in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php on line 102
PHP Deprecated:  Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::testGetCanonicalRoute(): Implicitly marking parameter $expected as nullable is deprecated, the explicit nullable type must be used instead in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php on line 203
PHP Deprecated:  Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::testGetCanonicalRoute(): Implicitly marking parameter $field_storage_definition as nullable is deprecated, the explicit nullable type must be used instead in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php on line 203
PHP Deprecated:  Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::testGetCollectionRoute(): Implicitly marking parameter $expected as nullable is deprecated, the explicit nullable type must be used instead in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php on line 263
PHP Deprecated:  Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::getEntityType(): Implicitly marking parameter $base_entity_type as nullable is deprecated, the explicit nullable type must be used instead in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php on line 387

Proposed resolution

fix this files

most of them are typos but produce
Deprecated in PHP 8.1: Required parameter $lineno follows optional parameter $options.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

10.3

Component
Base 

Last updated less than a minute ago

Created by

🇫🇷France andypost

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

Merge Requests

Comments & Activities

  • Issue created by @andypost
  • Pipeline finished with Failed
    about 1 month ago
    #160107
  • Pipeline finished with Failed
    about 1 month ago
    Total: 865s
    #160113
  • Pipeline finished with Running
    about 1 month ago
    #160125
  • Status changed to Needs review about 1 month ago
  • 🇮🇳India onkararun

    Hi @andypost i have tested MR !7836 3444232-8.4-fix-implicitly-ordering on Drupal Version 11.x-dev & PHP Version 8.3

    Testing Steps:-
    1). Install Drupal 11.x version.
    2). /projects/drupal/ git remote add drupal-3444232 https://git.drupalcode.org/issue/drupal-3444232.git
    3). git fetch drupal-3444232
    4). git checkout -b '3444232-8.4-fix-implicitly-ordering' --track drupal-3444232/'3444232-8.4-fix-implicitly-ordering'

    During testing the code i found some error on following files
    1. core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php - checked this file using vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php, then i got the error

    FILE: /var/www/html/drupal/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
    ----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------------
    224 | WARNING | [x] '@todo: Use property labels instead of the column name.' should match the format '@todo Fix problem X here.'
    227 | ERROR | [ ] The array declaration extends to column 157 (the limit is 120). The array content should be split up over multiple lines
    ----------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------------------

    2. core/lib/Drupal/Core/Template/TwigNodeTrans.php - checked this file using vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml core/lib/Drupal/Core/Template/TwigNodeTrans.php , then i got the error

    FILE: /var/www/html/drupal/core/lib/Drupal/Core/Template/TwigNodeTrans.php
    ----------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------
    95 | WARNING | [x] There must be no blank line following an inline comment
    ----------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------

    3. core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php - checked this file using vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php , then i got the error

    FILE: /var/www/html/drupal/core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php
    ----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------
    224 | ERROR | The array declaration extends to column 166 (the limit is 120). The array content should be split up over multiple lines
    226 | ERROR | The array declaration extends to column 240 (the limit is 120). The array content should be split up over multiple lines
    ----------------------------------------------------------------------------------------------------------------------------------------

    4. core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php - checked this file using vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php , then i got the error

    FILE: /var/www/html/drupal/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php
    --------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AFFECTING 5 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------
    8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\DependencyInjection\ContainerBuilder.
    154 | ERROR | [x] Missing function doc comment
    183 | ERROR | [x] Missing function doc comment
    217 | ERROR | [x] Missing function doc comment
    284 | ERROR | [x] Missing function doc comment
    --------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------

    5. core/modules/node/src/NodeForm.php - checked this file using vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml core/modules/node/src/NodeForm.php , then i got the error

    FILE: /var/www/html/drupal/core/modules/node/src/NodeForm.php
    ----------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ----------------------------------------------------------------------
    247 | ERROR | Missing parameter type
    249 | ERROR | Missing parameter type
    ----------------------------------------------------------------------

    6. core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php - checked this file using vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php , then i got the error

    FILE: /var/www/html/drupal/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php
    ----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 15 ERRORS AND 5 WARNINGS AFFECTING 15 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------------
    69 | ERROR | [x] Missing function doc comment
    116 | ERROR | [x] Missing function doc comment
    171 | ERROR | [ ] The array declaration extends to column 125 (the limit is 120). The array content should be split up over multiple lines
    179 | ERROR | [ ] The array declaration extends to column 165 (the limit is 120). The array content should be split up over multiple lines
    194 | ERROR | [ ] The array declaration extends to column 165 (the limit is 120). The array content should be split up over multiple lines
    213 | ERROR | [x] Missing function doc comment
    268 | ERROR | [x] Missing function doc comment
    381 | ERROR | [ ] Missing short description in doc comment
    385 | ERROR | [ ] Description for the @return value is missing
    401 | ERROR | [x] Missing class doc comment
    403 | WARNING | [ ] Possible useless method overriding detected
    403 | ERROR | [x] Missing function doc comment
    407 | WARNING | [ ] Possible useless method overriding detected
    407 | ERROR | [x] Missing function doc comment
    411 | WARNING | [ ] Possible useless method overriding detected
    411 | ERROR | [x] Missing function doc comment
    415 | WARNING | [ ] Possible useless method overriding detected
    415 | ERROR | [x] Missing function doc comment
    419 | WARNING | [ ] Possible useless method overriding detected
    419 | ERROR | [x] Missing function doc comment
    ----------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------------------

  • 🇫🇷France andypost

    @Arun.k core has git.drupalcode.org/project/drupal/-/blob/11.x/core/phpcs.xml.dist this file

    but to make sure there's no style issues we have CI which is green https://git.drupalcode.org/issue/drupal-3444232/-/jobs/1470359

  • 🇺🇸United States smustgrave

    Left a comment on the MR.

  • Assigned to amateescu
  • Status changed to Needs work 29 days ago
  • 🇫🇷France andypost

    Thanks, let's get maintainer's POV on it

  • Issue was unassigned.
  • 🇫🇷France andypost

    I split out 📌 [PHP 8.4] Fix phpstan job for ContentModerationConfigureEntityTypesForm Needs review but looks we can just make argument required

  • Pipeline finished with Success
    25 days ago
    Total: 1294s
    #166596
  • 🇫🇷France andypost

    Make title clear

  • Status changed to Needs review 24 days ago
  • 🇫🇷France andypost

    Re-rolled after 📌 [PHP 8.4] Fix phpstan job for ContentModerationConfigureEntityTypesForm Needs review and added 10.3.x MR to make sure it's backportable

  • Pipeline finished with Success
    24 days ago
    Total: 696s
    #167644
  • Pipeline finished with Success
    24 days ago
    Total: 633s
    #167653
  • 🇫🇷France andypost

    updated steps to reproduce

  • Pipeline finished with Canceled
    21 days ago
    Total: 209s
    #170981
  • Pipeline finished with Success
    21 days ago
    Total: 584s
    #170983
  • Pipeline finished with Success
    21 days ago
    #170985
  • Status changed to RTBC 18 days ago
  • 🇺🇸United States smustgrave

    This set was much easier to work with then the others haha

    Reviewed the changes and don't see any issue.

    • catch committed 30b48c11 on 11.0.x
      Issue #3444232 by andypost, smustgrave: [8.4] Fix implicitly nullable...
    • catch committed 4556add5 on 11.x
      Issue #3444232 by andypost, smustgrave: [8.4] Fix implicitly nullable...
    • catch committed ceba2409 on 10.3.x
      Issue #3444232 by andypost, smustgrave: [8.4] Fix implicitly nullable...
    • catch committed 631c33c7 on 10.4.x
      Issue #3444232 by andypost, smustgrave: [8.4] Fix implicitly nullable...
  • Status changed to Fixed 12 days ago
  • 🇬🇧United Kingdom catch

    This looks good. Committed/pushed to 11.x/11.0.x/10.4.x/10.3.x respectively, thanks!

  • 🇫🇷France andypost

    Thank you! Now only automated fxes left 📌 [PHP 8.4] Fix implicitly nullable type declarations Active

Production build 0.69.0 2024