Problem/Motivation

Splitting up #3550884: Add return types to test module code for smaller scope and easier reviews.

This issue runs the following rector rules on test modules:

  • AddFunctionVoidReturnTypeWhereNoReturnRector
  • AddTestsVoidReturnTypeWhereNoReturnRector
  • AddVoidReturnTypeWhereNoReturnRector

This adds 263 return types across 160 files.

Steps to reproduce

Proposed resolution

Install rector

composer require --dev rector/rector

Configure rector.php file

<?php

use Rector\TypeDeclaration\Rector\Class_\AddTestsVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector;

return Rector\Config\RectorConfig::configure()
  ->withPaths([
    __DIR__ . '/core/modules/*/tests/modules',
    __DIR__ . '/core/modules/config/tests/config_*',
    __DIR__ . '/core/modules/dynamic_page_cache/tests/dynamic_page_cache_test',
    __DIR__ . '/core/modules/file/tests/file_*',
    __DIR__ . '/core/modules/filter/tests/filter_*',
    __DIR__ . '/core/modules/language/tests/language_*',
    __DIR__ . '/core/modules/language/tests/test_module',
    __DIR__ . '/core/modules/menu_link_content/tests/menu_*',
    __DIR__ . '/core/modules/menu_link_content/tests/outbound_*',
    __DIR__ . '/core/modules/navigation/tests/navigation_*',
    __DIR__ . '/core/modules/node/tests/node_*',
    __DIR__ . '/core/modules/options/tests/options_*',
    __DIR__ . '/core/modules/serialization/tests/serialization_test',
  ])
  ->withRules([
    AddFunctionVoidReturnTypeWhereNoReturnRector::class,
    AddTestsVoidReturnTypeWhereNoReturnRector::class,
    AddVoidReturnTypeWhereNoReturnRector::class,
  ]);

Run rector
$ ./vendor/bin/rector

Fix code style
$ composer phpcbf

Update baseline
$ ./vendor/bin/phpstan analyse -c core/phpstan.neon.dist --generate-baseline=core/.phpstan-baseline.php --memory-limit=2G

Diff stat

$ git diff --shortstat core/modules
 160 files changed, 263 insertions(+), 263 deletions(-)
$ git diff --shortstat core/.phpstan-baseline.php
 1 file changed, 1578 deletions(-)

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3586161

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

mstrelan created an issue. See original summary.

mstrelan’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

I did start a new pipeline to make sure that one test was random so sorry for the noise there.

Lets land this one and knock that baseline down a peg.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mstrelan’s picture

Status: Needs work » Reviewed & tested by the community

Baseline conflict. Rebased and regenerated the baseline.

  • amateescu committed ecc804c8 on main
    task: #3586161 Add missing void return types to test modules
    
    By:...
amateescu’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Nice to see so many baseline entries gone :)

Committed ecc804c and pushed to main. Thanks!

We'll need a backport MR for 11.x.