Problem/Motivation

#3562868: Add types to class properties in core/tests code via Rector - round 3 completed using Rector on core/tests code with withPreparedSets(typeDeclarations: true).

Now we can rerun it every now and then to see if more code can be automatically refactored.

Proposed resolution

Use rector with type coverage on core/tests.

Install rector

$ composer require --dev rector/rector

Configure rector.php file

<?php

declare(strict_types=1);

return Rector\Config\RectorConfig::configure()
  ->withBootstrapFiles([
      __DIR__ . '/vendor/[#/drupal-rector/config/drupal-phpunit-bootstrap-file.php',
  ])
  ->withPaths([
    __DIR__ . '/core/tests',
  ])
  ->withSkip([
    '*/*ixture*/*',
    '*/Annotation/Doctrine/*',
  ])
  ->withPreparedSets(typeDeclarations: true)
  ->withImportNames(
    importDocBlockNames: false,
    importShortClasses: false,
    removeUnusedImports: false,
  );

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

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3584406

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

mondrake created an issue. See original summary.

mondrake’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Seems straight forward, nothing to add. Thanks!

  • amateescu committed fb02153b on main
    task: #3584406 Refactor core/tests code via Rector
    
    By: mondrake
    
amateescu’s picture

Status: Reviewed & tested by the community » Fixed

Committed fb02153 and pushed to main. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.