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:

  1. ClassMethod\AddReturnTypeDeclarationRector::class,
  2. ClassMethod\ReturnTypeFromReturnDirectArrayRector::class,
  3. 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

Issue fork drupal-3643938

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

quietone created an issue. See original summary.

quietone’s picture

Issue summary: View changes
Status: Active » Needs review

This also required changing some @return string declarations and the related description.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new98 bytes

The 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.

quietone’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems straight forward and a good chunk from the baseline.