diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml index e536767d..c8b1b08a 100644 --- a/.github/workflows/code_analysis.yaml +++ b/.github/workflows/code_analysis.yaml @@ -55,9 +55,4 @@ jobs: # composer install cache - https://github.com/ramsey/composer-install - uses: "ramsey/composer-install@v3" - # Override code from symplify/coding-standard shipped with ECS - - run: | - rm -rf vendor/symplify/easy-coding-standard/vendor/symplify/coding-standard/src - ln -s $PWD/src vendor/symplify/easy-coding-standard/vendor/symplify/coding-standard/ - - run: ${{ matrix.actions.run }} diff --git a/README.md b/README.md index e3a83490..2a6368e2 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ [![Downloads](https://img.shields.io/packagist/dt/symplify/coding-standard.svg?style=flat-square)](https://packagist.org/packages/symplify/coding-standard/stats) +> [!WARNING] +> **This package is deprecated.** Use [Easy Coding Standard (ECS)](https://github.com/easy-coding-standard/easy-coding-standard) instead, where these rules and coding standard work out of the box—no extra setup needed. + Coding standard rules for clean, consistent, and readable PHP code. No configuration needed—just install and let it handle the rest. They run best with [ECS](https://github.com/symplify/easy-coding-standard). diff --git a/src/Fixer/Annotation/RemoveMethodNameDuplicateDescriptionFixer.php b/src/Fixer/Annotation/RemoveMethodNameDuplicateDescriptionFixer.php index 3fcc29e0..6ece9c59 100644 --- a/src/Fixer/Annotation/RemoveMethodNameDuplicateDescriptionFixer.php +++ b/src/Fixer/Annotation/RemoveMethodNameDuplicateDescriptionFixer.php @@ -70,8 +70,7 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void $docblockLines = explode("\n", $originalDocContent); foreach ($docblockLines as $key => $docblockLine) { - $spacelessDocblockLine = Regex::replace($docblockLine, '#[\s\n]+#', ''); - if (strtolower($spacelessDocblockLine) !== strtolower('*' . $methodName)) { + if (! $this->isMethodNameDescriptionLine($docblockLine, $methodName)) { continue; } @@ -86,4 +85,20 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void $tokens[$index] = new Token([T_DOC_COMMENT, implode("\n", $docblockLines)]); } } + + private function isMethodNameDescriptionLine(string $docblockLine, string $methodName): bool + { + $normalizedLine = strtolower(ltrim(trim($docblockLine), '*')); + + // drop articles, so "Get the API helper" still matches getApiHelper() + $words = array_filter( + explode(' ', $normalizedLine), + static fn (string $word): bool => ! in_array(trim($word, '.,!:;'), ['a', 'an', 'the'], true) + ); + + // strip whitespace and trailing punctuation + $spacelessLine = Regex::replace(implode(' ', $words), '#[^a-z0-9]+#', ''); + + return $spacelessLine === strtolower($methodName); + } } diff --git a/tests/Fixer/Annotation/RemoveMethodNameDuplicateDescriptionFixer/Fixture/with_articles.php.inc b/tests/Fixer/Annotation/RemoveMethodNameDuplicateDescriptionFixer/Fixture/with_articles.php.inc new file mode 100644 index 00000000..8ad42dda --- /dev/null +++ b/tests/Fixer/Annotation/RemoveMethodNameDuplicateDescriptionFixer/Fixture/with_articles.php.inc @@ -0,0 +1,34 @@ + +----- +