[8.4] Fix implicitly nullable type declarations in core/modules

Created on 29 April 2024, 8 months ago
Updated 9 May 2024, 8 months ago

Problem/Motivation

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

Start with https://git.drupalcode.org/project/drupal/-/merge_requests/7783/diffs?co...

Steps to reproduce

$ docker run --rm -v $(pwd):/var/www/html drupalci/php-8.4-ubuntu-apache:dev php -d error_reporting="E_ALL" -l core/modules/*/*/*/*/*/*|grep deprecated

Proposed resolution

Extract changes that require manual fixes to 📌 [8.4] Fix implicitly nullable type declarations for phpstan job Needs review

Run following to make sure getting the same result

$ composer global require friendsofphp/php-cs-fixer  --dev
~/.config/composer/vendor/bin/php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value core/modules/

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Closed: won't fix

Version

11.0 🔥

Component
Base  →

Last updated 2 days 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
    8 months ago
    #159340
  • Status changed to Needs review 8 months ago
  • Pipeline finished with Failed
    8 months ago
    Total: 185s
    #159353
  • Pipeline finished with Success
    8 months ago
    Total: 625s
    #159355
  • 🇮🇳India onkararun

    Hi @andypost i have tested MR !7816 3444026-8.4-fix-null-modules 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-3444026 https://git.drupalcode.org/issue/drupal-3444026.git
    3). git fetch drupal-3444026
    4). git checkout -b '3444026-8.4-fix-null-modules' --track drupal-3444026/'3444026-8.4-fix-null-modules'

    During testing the code i found some error on following files
    1. core/modules/node/src/NodeForm.php - when i cheked this file using php -d error_reporting="E_ALL" -l core/modules/node/src/NodeForm.php|grep deprecated then i didn't get anything but when i checked the same 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
    ----------------------------------------------------------------------
    240 | ERROR | Missing parameter type
    242 | ERROR | Missing parameter type
    ----------------------------------------------------------------------

    So i removed this error by adding parameter type like below :-

    /**
    * Form submission handler for the 'preview' action.
    *
    * @param array $form
    * An associative array containing the structure of the form.
    * @param \Drupal\Core\Form\FormStateInterface $form_state
    * The current state of the form.
    */

    before the above comment was like below :-

    /**
    * Form submission handler for the 'preview' action.
    *
    * @param $form
    * An associative array containing the structure of the form.
    * @param $form_state
    * The current state of the form.
    */
    except this all the files code are fine

  • 🇫🇷France andypost

    @Arun.k thank you, I moved this manual changes to separate issue 📌 [8.4] Fix implicitly nullable type declarations for phpstan job Needs review

  • 🇫🇷France andypost

    I think we should automate conversion and file separate issue to exceptions and manual fixes for docs

    Using ~/.config/composer/vendor/bin/php-cs-fixer fix --config .php-cs-fixer.dist.php -vvv

    # .php-cs-fixer.dist.php
    
    $finder = \PhpCsFixer\Finder::create()
    #    ->in(__DIR__)
        ->in("core/modules")
        ->name('*.engine')
        ->name('*.module')
        ->name('*.profile')
        ->name('*.theme')
        ->name('*.inc')
        ->name('*.php');
    
    $config = new \PhpCsFixer\Config();
    
    return $config->setRules([
            'nullable_type_declaration_for_default_null_value' => true,
        ])
        ->setFinder($finder);
    
    
  • Pipeline finished with Failed
    8 months ago
    Total: 295s
    #160293
  • 🇮🇳India onkararun

    @andypost Now then We Need to move RTBC
    Thanks

  • Status changed to Closed: won't fix 8 months ago
Production build 0.71.5 2024