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:
- ClassMethod\AddReturnTypeDeclarationRector::class,
- ClassMethod\ReturnTypeFromReturnDirectArrayRector::class,
- ClassMethod\ReturnTypeFromStrictNewArrayRector::class,
Steps to reproduce
Proposed resolution
Install rector
composer require --dev rector/rector
Configure rector.php file
<?php
use Rector\TypeDeclaration\Rector\ClassMethod;
return Rector\Config\RectorConfig::configure()
->withPaths([
__DIR__ . '/core/modules/*/tests/modules',
])
// Additional rules above level 22 that are useful
->withRules([
ClassMethod\AddReturnTypeDeclarationRector::class,
ClassMethod\ReturnTypeFromReturnDirectArrayRector::class,
ClassMethod\ReturnTypeFromStrictNewArrayRector::class,
]);
Run rector
$ ./vendor/bin/rector
Fix code style
Update baseline
$ composer phpstan-baseline
Diff stat
$ git diff --shortstat main
149 files changed, 287 insertions(+), 816 deletions(-)
$ git diff --shortstat main core/.phpstan-baseline.php
1 file changed, 528 deletions(-)
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3643938
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
Comment #3
quietone commentedThis also required changing some
@return stringdeclarations and the related description.Comment #4
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. 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 #5
quietone commentedComment #6
smustgrave commentedSeems straight forward and a good chunk from the baseline.