From 1d96692f2045e7f739f0af73085e2248e66274e3 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 11 Aug 2026 11:39:20 +0200 Subject: [PATCH 1/2] Skip node_modules directory when finding source files --- src/Finder/SourceFinder.php | 2 +- .../Source/node_modules/SkipThisClass.php | 9 +++++++++ tests/Finder/SourceFinderTest.php | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/Finder/SourceFinderSource/Source/node_modules/SkipThisClass.php diff --git a/src/Finder/SourceFinder.php b/src/Finder/SourceFinder.php index 626ee6543b3..cb3077cb28a 100644 --- a/src/Finder/SourceFinder.php +++ b/src/Finder/SourceFinder.php @@ -56,7 +56,7 @@ private function processDirectory(string $directory): array ->ignoreDotFiles(false) ->name($normalizedFileExtensions) ->in($directory) - ->exclude('vendor') + ->exclude(['vendor', 'node_modules']) // skip empty files ->size('> 0') ->sortByName(); diff --git a/tests/Finder/SourceFinderSource/Source/node_modules/SkipThisClass.php b/tests/Finder/SourceFinderSource/Source/node_modules/SkipThisClass.php new file mode 100644 index 00000000000..b48c8310938 --- /dev/null +++ b/tests/Finder/SourceFinderSource/Source/node_modules/SkipThisClass.php @@ -0,0 +1,9 @@ +find([__DIR__ . '/SourceFinderSource/Source']); $this->assertCount(2, $foundFiles); + foreach ($foundFiles as $foundFile) { + $this->assertStringNotContainsString('node_modules', $foundFile); + } + $foundFiles = $sourceFinder->find([__DIR__ . '/SourceFinderSource/Source/SomeClass.php.inc']); $this->assertCount(1, $foundFiles); } From 7800df89b109256c744e19babffbe0e8d1665212 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 11 Aug 2026 11:42:46 +0200 Subject: [PATCH 2/2] Fix CI: drop duplicate rector/type-perfect, bump deps, apply Rector fixes type-coverage 2.3 bundles Rector\TypePerfect, so requiring rector/type-perfect separately registered MethodNodeAnalyser twice and crashed PHPStan boot. --- composer.json | 5 ++--- src/FileSystem/PathNormalizer.php | 2 +- src/Finder/SourceFinder.php | 4 ++-- .../Application/FixerFileProcessor.php | 16 ++++++++-------- src/Skipper/Skipper/Skipper.php | 4 ++-- src/Testing/PHPUnit/AbstractCheckerTestCase.php | 2 +- src/ValueObject/Error/ErrorAndDiffResult.php | 8 ++++---- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 51213550241..f1ed39cf18a 100644 --- a/composer.json +++ b/composer.json @@ -35,12 +35,11 @@ "phpstan/phpstan-webmozart-assert": "^2.0", "phpunit/phpunit": "^13.2", "rector/jack": "^1.0", - "rector/rector": "^2.5", - "rector/type-perfect": "^2.1", + "rector/rector": "^2.6", "symplify/phpstan-rules": "^14.12", "symplify/vendor-patches": "^11.5", "tomasvotruba/class-leak": "^2.1.7", - "tomasvotruba/type-coverage": "^2.2", + "tomasvotruba/type-coverage": "^2.3", "tomasvotruba/unused-public": "^2.2", "tracy/tracy": "^2.12" }, diff --git a/src/FileSystem/PathNormalizer.php b/src/FileSystem/PathNormalizer.php index 49be64625cb..d06eae10e28 100644 --- a/src/FileSystem/PathNormalizer.php +++ b/src/FileSystem/PathNormalizer.php @@ -41,7 +41,7 @@ public function normalizePath(string $originalPath): string $path = $originalPath; } - $normalizedPath = str_replace('\\', '/', (string) $path); + $normalizedPath = str_replace('\\', '/', $path); $path = Strings::replace($normalizedPath, self::TWO_AND_MORE_SLASHES_REGEX, '/'); $pathRoot = str_starts_with($path, '/') ? $directorySeparator : ''; diff --git a/src/Finder/SourceFinder.php b/src/Finder/SourceFinder.php index cb3077cb28a..911251618b6 100644 --- a/src/Finder/SourceFinder.php +++ b/src/Finder/SourceFinder.php @@ -11,12 +11,12 @@ /** * @see \Symplify\EasyCodingStandard\Tests\Finder\SourceFinderTest */ -final class SourceFinder +final readonly class SourceFinder { /** * @var string[] */ - private array $fileExtensions = []; + private array $fileExtensions; public function __construct() { diff --git a/src/FixerRunner/Application/FixerFileProcessor.php b/src/FixerRunner/Application/FixerFileProcessor.php index 6362fff7355..eca60315adc 100644 --- a/src/FixerRunner/Application/FixerFileProcessor.php +++ b/src/FixerRunner/Application/FixerFileProcessor.php @@ -24,24 +24,24 @@ /** * @see \Symplify\EasyCodingStandard\Tests\Error\ErrorCollector\FixerFileProcessorTest */ -final class FixerFileProcessor implements FileProcessorInterface +final readonly class FixerFileProcessor implements FileProcessorInterface { /** * @var FixerInterface[] */ - private array $fixers = []; + private array $fixers; - private readonly bool $isDebug; + private bool $isDebug; /** * @param FixerInterface[] $fixers */ public function __construct( - private readonly FileToTokensParser $fileToTokensParser, - private readonly Skipper $skipper, - private readonly DifferInterface $differ, - private readonly EasyCodingStandardStyle $easyCodingStandardStyle, - private readonly FileDiffFactory $fileDiffFactory, + private FileToTokensParser $fileToTokensParser, + private Skipper $skipper, + private DifferInterface $differ, + private EasyCodingStandardStyle $easyCodingStandardStyle, + private FileDiffFactory $fileDiffFactory, array $fixers ) { $this->fixers = $this->sortFixers($fixers); diff --git a/src/Skipper/Skipper/Skipper.php b/src/Skipper/Skipper/Skipper.php index f7cd23b1ffc..471726195a9 100644 --- a/src/Skipper/Skipper/Skipper.php +++ b/src/Skipper/Skipper/Skipper.php @@ -14,14 +14,14 @@ * @api * @see \Symplify\EasyCodingStandard\Tests\Skipper\Skipper\Skipper\SkipperTest */ -final class Skipper +final readonly class Skipper { private const string FILE_ELEMENT = 'file_elements'; /** * @var SkipVoterInterface[] */ - private array $skipVoters = []; + private array $skipVoters; public function __construct( ClassAndCodeSkipVoter $classAndCodeSkipVoter, diff --git a/src/Testing/PHPUnit/AbstractCheckerTestCase.php b/src/Testing/PHPUnit/AbstractCheckerTestCase.php index b3322e67e2b..060e3874f0b 100644 --- a/src/Testing/PHPUnit/AbstractCheckerTestCase.php +++ b/src/Testing/PHPUnit/AbstractCheckerTestCase.php @@ -69,7 +69,7 @@ protected function doTestFile(string $filePath): void $expectedContents = $fileContents; } - $inputFilePath = sys_get_temp_dir() . '/ecs_tests/' . md5((string) $inputContents) . '.php'; + $inputFilePath = sys_get_temp_dir() . '/ecs_tests/' . md5($inputContents) . '.php'; FileSystem::write($inputFilePath, $inputContents, null); // 1. process php-cs-fixer diff --git a/src/ValueObject/Error/ErrorAndDiffResult.php b/src/ValueObject/Error/ErrorAndDiffResult.php index 64d994af3d2..1a88eb2f58a 100644 --- a/src/ValueObject/Error/ErrorAndDiffResult.php +++ b/src/ValueObject/Error/ErrorAndDiffResult.php @@ -6,17 +6,17 @@ use Symplify\EasyCodingStandard\SniffRunner\ValueObject\Error\CodingStandardError; -final class ErrorAndDiffResult +final readonly class ErrorAndDiffResult { /** * @var CodingStandardError[] */ - private array $codingStandardErrors = []; + private array $codingStandardErrors; /** * @var FileDiff[] */ - private array $fileDiffs = []; + private array $fileDiffs; /** * @param CodingStandardError[] $codingStandardErrors @@ -26,7 +26,7 @@ final class ErrorAndDiffResult public function __construct( array $codingStandardErrors, array $fileDiffs, - private readonly array $systemErrors + private array $systemErrors ) { $this->codingStandardErrors = $this->sortByFileAndLine($codingStandardErrors); $this->fileDiffs = $this->sortByFilePath($fileDiffs);