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
Comments
Comment #3
mstrelan commentedComment #4
smustgrave commentedI 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.
Comment #5
needs-review-queue-bot commentedThe 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.
Comment #6
mstrelan commentedBaseline conflict. Rebased and regenerated the baseline.
Comment #8
amateescu commentedNice to see so many baseline entries gone :)
Committed ecc804c and pushed to main. Thanks!
We'll need a backport MR for 11.x.