From 2f345d7a4343af5ee56282d77ef6c96607d29ee1 Mon Sep 17 00:00:00 2001 From: tomasJancar Date: Mon, 3 Aug 2026 13:47:11 +0200 Subject: [PATCH 1/2] DE-175591 fix: adapt to the Skipper collaborators removed in Rector 2.5.9 Rector 2.5.9 (rectorphp/rector-src#8226, "Collapse single-use Skipper collaborators") removed Rector\Skipper\FileSystem\FnMatchPathNormalizer, Rector\Skipper\Fnmatcher and Rector\Skipper\RealpathMatcher, inlining them as private methods of FileInfoMatcher. FileInfoMatcher itself stays, but ends up with an empty constructor and without its doesFileInfoMatchPatterns() method. Both neon files registered the three removed classes as services, so every consumer's PHPStan run died before analysing anything: Service (Rector\Skipper\FileSystem\FnMatchPathNormalizer::__construct()): Class 'Rector\Skipper\FileSystem\FnMatchPathNormalizer' not found. Since no repository here commits a composer.lock, CI resolves the newest matching dependency, so the PHPStan and Rector jobs broke across all consumers the day 2.5.9 was published - on branches that changed nothing related. The three services are gone from both neon files, the two rules call matchPattern() (which returns the matched pattern or null and exists in every supported version), and the test instantiates FileInfoMatcher without arguments. FileInfoMatcher is no longer listed either: with an empty constructor it does not need to be, and the rules receive it through the existing autowiring. The rector/rector floor moves to ^2.5.9, because the constructor change cannot be satisfied for both sides at once - neon cannot register a service conditionally and PHPStan autowires the constructor, so <=2.5.8 needs the three collaborators in the service list while >=2.5.9 must not have them. Verified with a fresh install of Rector 2.5.9 and 2.6.0: PHPStan clean, 80 tests green, Rector dry-run clean, ECS clean on both. Co-Authored-By: Claude Opus 5 (1M context) --- composer.json | 2 +- default-phpstan.neon | 4 ---- phpstan.neon | 4 ---- .../DisallowConstantsInTestsRule.php | 6 ++++-- .../DisallowConstantsInTestsRuleTest.php | 5 +---- .../DisallowConstantsInTestsRector.php | 6 ++++-- 6 files changed, 10 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index d7c5246..c92921c 100755 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "phpstan/phpstan-nette": "^2.0", "phpstan/phpstan-phpunit": "^2.0", "phpstan/phpstan-strict-rules": "^2.0", - "rector/rector": "^2.3", + "rector/rector": "^2.5.9", "slevomat/coding-standard": "^8.15.0", "squizlabs/php_codesniffer": "^3.9.2", "symplify/easy-coding-standard": "^12.1.14", diff --git a/default-phpstan.neon b/default-phpstan.neon index 4b9fdd1..5e2b510 100644 --- a/default-phpstan.neon +++ b/default-phpstan.neon @@ -10,12 +10,8 @@ includes: services: # Handy services from Rector package - Rector\NodeNameResolver\NodeNameResolver - - Rector\Skipper\Matcher\FileInfoMatcher - Rector\CodingStyle\Naming\ClassNaming - Rector\NodeAnalyzer\CallAnalyzer - - Rector\Skipper\FileSystem\FnMatchPathNormalizer - - Rector\Skipper\Fnmatcher - - Rector\Skipper\RealpathMatcher parameters: level: max diff --git a/phpstan.neon b/phpstan.neon index 824d929..05928df 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,12 +9,8 @@ includes: services: # Handy services from Rector package - Rector\NodeNameResolver\NodeNameResolver - - Rector\Skipper\Matcher\FileInfoMatcher - Rector\CodingStyle\Naming\ClassNaming - Rector\NodeAnalyzer\CallAnalyzer - - Rector\Skipper\FileSystem\FnMatchPathNormalizer - - Rector\Skipper\Fnmatcher - - Rector\Skipper\RealpathMatcher - class: BrandEmbassyCodingStandard\PhpStan\Rules\Mockery\TestsExtendMockeryTestCaseRule\TestsExtendMockeryTestCaseRule diff --git a/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRule.php b/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRule.php index 87eed35..86123f0 100644 --- a/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRule.php +++ b/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRule.php @@ -99,10 +99,12 @@ public function processNode(Node $node, Scope $scope): array return []; } - if ($this->fileInfoMatcher->doesFileInfoMatchPatterns( + // matchPattern() returns the matched pattern, or null when none matched. It replaces + // doesFileInfoMatchPatterns(), which Rector 2.5.9 removed. + if ($this->fileInfoMatcher->matchPattern( $constantClassReflection->getFileName() ?? '', $this->allowedPatterns, - )) { + ) !== null) { return []; } diff --git a/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRuleTest.php b/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRuleTest.php index 3331312..47b0918 100644 --- a/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRuleTest.php +++ b/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRuleTest.php @@ -5,10 +5,7 @@ use BrandEmbassyCodingStandard\PhpStan\Rules\DisallowConstantsInTestsRule\__fixtures__\AllowedConstant; use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; -use Rector\Skipper\FileSystem\FnMatchPathNormalizer; -use Rector\Skipper\Fnmatcher; use Rector\Skipper\Matcher\FileInfoMatcher; -use Rector\Skipper\RealpathMatcher; /** * @extends RuleTestCase @@ -19,7 +16,7 @@ protected function getRule(): Rule { return new DisallowConstantsInTestsRule( $this->createReflectionProvider(), - new FileInfoMatcher(new FnMatchPathNormalizer(), new Fnmatcher(), new RealpathMatcher()), + new FileInfoMatcher(), ['*AllowedPattern.php'], [AllowedConstant::class], ); diff --git a/src/BrandEmbassyCodingStandard/Rector/DisallowConstantsInTestsRector/DisallowConstantsInTestsRector.php b/src/BrandEmbassyCodingStandard/Rector/DisallowConstantsInTestsRector/DisallowConstantsInTestsRector.php index c8b6064..bbe6c2f 100644 --- a/src/BrandEmbassyCodingStandard/Rector/DisallowConstantsInTestsRector/DisallowConstantsInTestsRector.php +++ b/src/BrandEmbassyCodingStandard/Rector/DisallowConstantsInTestsRector/DisallowConstantsInTestsRector.php @@ -146,10 +146,12 @@ public function refactor(Node $node) return null; } - if ($this->fileInfoMatcher->doesFileInfoMatchPatterns( + // matchPattern() returns the matched pattern, or null when none matched. It replaces + // doesFileInfoMatchPatterns(), which Rector 2.5.9 removed. + if ($this->fileInfoMatcher->matchPattern( $constantClassReflection->getFileName() ?? '', $this->allowedPatterns, - )) { + ) !== null) { return null; } From 96ad8ea178163c796b67cb2496c366648decb2f2 Mon Sep 17 00:00:00 2001 From: tomasJancar Date: Tue, 4 Aug 2026 11:47:21 +0200 Subject: [PATCH 2/2] DE-175591 chore: drop explanatory comments per review Co-Authored-By: Claude Fable 5 --- .../DisallowConstantsInTestsRule.php | 2 -- .../DisallowConstantsInTestsRector.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRule.php b/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRule.php index 86123f0..c30f05e 100644 --- a/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRule.php +++ b/src/BrandEmbassyCodingStandard/PhpStan/Rules/DisallowConstantsInTestsRule/DisallowConstantsInTestsRule.php @@ -99,8 +99,6 @@ public function processNode(Node $node, Scope $scope): array return []; } - // matchPattern() returns the matched pattern, or null when none matched. It replaces - // doesFileInfoMatchPatterns(), which Rector 2.5.9 removed. if ($this->fileInfoMatcher->matchPattern( $constantClassReflection->getFileName() ?? '', $this->allowedPatterns, diff --git a/src/BrandEmbassyCodingStandard/Rector/DisallowConstantsInTestsRector/DisallowConstantsInTestsRector.php b/src/BrandEmbassyCodingStandard/Rector/DisallowConstantsInTestsRector/DisallowConstantsInTestsRector.php index bbe6c2f..79dbbd1 100644 --- a/src/BrandEmbassyCodingStandard/Rector/DisallowConstantsInTestsRector/DisallowConstantsInTestsRector.php +++ b/src/BrandEmbassyCodingStandard/Rector/DisallowConstantsInTestsRector/DisallowConstantsInTestsRector.php @@ -146,8 +146,6 @@ public function refactor(Node $node) return null; } - // matchPattern() returns the matched pattern, or null when none matched. It replaces - // doesFileInfoMatchPatterns(), which Rector 2.5.9 removed. if ($this->fileInfoMatcher->matchPattern( $constantClassReflection->getFileName() ?? '', $this->allowedPatterns,