From 41825bd431e9a4f3308fbf06768bb7162665979b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Tue, 8 Jul 2025 00:10:25 +0200 Subject: [PATCH 1/4] Add test --- README.md | 2 +- tests/Fixer/PhpdocNoSuperfluousParamFixerTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 63788c9e..d92e4277 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Latest stable version](https://img.shields.io/packagist/v/kubawerlos/php-cs-fixer-custom-fixers.svg?label=current%20version)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers) [![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net) [![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE) -![Tests](https://img.shields.io/badge/tests-3800-brightgreen.svg) +![Tests](https://img.shields.io/badge/tests-3801-brightgreen.svg) [![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers) [![CI status](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml/badge.svg)](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml) diff --git a/tests/Fixer/PhpdocNoSuperfluousParamFixerTest.php b/tests/Fixer/PhpdocNoSuperfluousParamFixerTest.php index 78ab56b2..b9f31962 100644 --- a/tests/Fixer/PhpdocNoSuperfluousParamFixerTest.php +++ b/tests/Fixer/PhpdocNoSuperfluousParamFixerTest.php @@ -299,5 +299,18 @@ function foo($x) {} function foo($x) {} PHP, ]; + + yield [ + <<<'PHP' + Date: Tue, 8 Jul 2025 00:21:25 +0200 Subject: [PATCH 2/4] Add fix in `PhpdocNoSuperfluousParamFixer` --- src/Fixer/PhpdocNoSuperfluousParamFixer.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/Fixer/PhpdocNoSuperfluousParamFixer.php b/src/Fixer/PhpdocNoSuperfluousParamFixer.php index b2e0b570..f9320221 100644 --- a/src/Fixer/PhpdocNoSuperfluousParamFixer.php +++ b/src/Fixer/PhpdocNoSuperfluousParamFixer.php @@ -15,7 +15,6 @@ use PhpCsFixer\FixerDefinition\CodeSample; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; -use PhpCsFixer\Preg; use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; @@ -122,7 +121,7 @@ private static function getFilteredDocComment(string $comment, array $paramNames $foundParamNames = []; foreach ($doc->getAnnotationsOfType('param') as $annotation) { - $paramName = self::getParamName($annotation->getContent()); + $paramName = $annotation->getVariableName(); if (\in_array($paramName, $paramNames, true) && !\in_array($paramName, $foundParamNames, true)) { $foundParamNames[] = $paramName; @@ -134,18 +133,4 @@ private static function getFilteredDocComment(string $comment, array $paramNames return $doc->getContent(); } - - private static function getParamName(string $annotation): ?string - { - Preg::match('/@param\\s+(?:[^\\$]+)?\\s*(\\$[a-zA-Z_\\x80-\\xff][a-zA-Z0-9_\\x80-\\xff]*)\\b/', $annotation, $matches); - - if (!\array_key_exists(1, $matches)) { - return null; - } - - // @phpstan-ignore function.alreadyNarrowedType - \assert(\is_string($matches[1])); - - return $matches[1]; - } } From 78afd6ac5d17a3a76aaecb3c2f5295dcaa1335b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Tue, 8 Jul 2025 00:31:22 +0200 Subject: [PATCH 3/4] Use fork --- composer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8777b9bc..800e11d9 100644 --- a/composer.json +++ b/composer.json @@ -13,11 +13,17 @@ "php": "^7.4 || ^8.0", "ext-filter": "*", "ext-tokenizer": "*", - "friendsofphp/php-cs-fixer": "^3.77" + "friendsofphp/php-cs-fixer": "dev-fix_PhpdocToParamTypeFixer as 3.82.0" }, "require-dev": { "phpunit/phpunit": "^9.6.22 || 10.5.45 || ^11.5.7" }, + "repositories": [ + { + "type": "vcs", + "url": "git@github.com:6b7562617765726c6f73/PHP-CS-Fixer.git" + } + ], "autoload": { "psr-4": { "PhpCsFixerCustomFixers\\": "src" From 4912f990c21e7ce8ba8e660d2294e6e3761fd7a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Tue, 8 Jul 2025 00:46:46 +0200 Subject: [PATCH 4/4] Update minimum PHP CS Fixer version to 3.82.0 --- CHANGELOG.md | 3 +++ composer.json | 8 +------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87db3237..7fc683b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG for PHP CS Fixer: custom fixers +## v3.30.0 +- Update minimum PHP CS Fixer version to 3.82.0 + ## v3.29.0 - Update minimum PHP CS Fixer version to 3.77.0 diff --git a/composer.json b/composer.json index 800e11d9..c01245b8 100644 --- a/composer.json +++ b/composer.json @@ -13,17 +13,11 @@ "php": "^7.4 || ^8.0", "ext-filter": "*", "ext-tokenizer": "*", - "friendsofphp/php-cs-fixer": "dev-fix_PhpdocToParamTypeFixer as 3.82.0" + "friendsofphp/php-cs-fixer": "^3.82" }, "require-dev": { "phpunit/phpunit": "^9.6.22 || 10.5.45 || ^11.5.7" }, - "repositories": [ - { - "type": "vcs", - "url": "git@github.com:6b7562617765726c6f73/PHP-CS-Fixer.git" - } - ], "autoload": { "psr-4": { "PhpCsFixerCustomFixers\\": "src"