Remove @file annotation from test classes

Created on 5 November 2023, 11 months ago
Updated 11 November 2023, 10 months ago

Problem/Motivation

There are a number of test classes that still contain the @file annotation. This causes formatting issues when using \Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector to add strict types. Since the @file annotation is redundant it's easier to just remove them.

Steps to reproduce

List of files can be found with these commands:

git grep --all-match -l -e '\* @file' -e 'namespace Drupal\\.*Tests\\' core

Proposed resolution

Remove @file annotation from all test classes.

We can use php-cs-fixer for this.

composer require --dev friendsofphp/php-cs-fixer
FILES=$(git grep --all-match -l -e '\* @file' -e 'namespace Drupal\\.*Tests\\' core)
for file in $FILES; do
  php ./vendor/bin/php-cs-fixer fix $file --rules='{"general_phpdoc_annotation_remove": {"annotations": ["file"]}, "no_empty_phpdoc": true, "blank_lines_before_namespace": {"max_line_breaks": 2, "min_line_breaks": 1}}';
done;

Remaining tasks

Review and merge.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

📌 Task
Status

Fixed

Version

10.1 ✨

Component
PHPUnit  →

Last updated about 2 hours ago

Created by

🇦🇺Australia mstrelan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024