From 30df87cad4bff3694d208adf88e4787a0455ffa8 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 21 Jul 2025 12:12:49 +0200 Subject: [PATCH 1/5] skip /vendor in check-conflicts command --- src/Finder/FilesFinder.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Finder/FilesFinder.php b/src/Finder/FilesFinder.php index bc49c9270..d342f9c6a 100644 --- a/src/Finder/FilesFinder.php +++ b/src/Finder/FilesFinder.php @@ -24,6 +24,8 @@ public static function find(array $sources): array $finder = Finder::create() ->files() ->in($paths) + // not our code + ->notPath('vendor') ->sortByName(); return iterator_to_array($finder->getIterator()); From 1ff9727996bcb45c31000d691ad454d469595395 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 21 Jul 2025 12:13:19 +0200 Subject: [PATCH 2/5] bump --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 096c4f49e..f76f6a730 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ ], "require": { "php": ">=8.2", - "illuminate/container": "^12.18", + "illuminate/container": "^12.19", "nette/robot-loader": "^4.0", "nette/utils": "^4.0", "nikic/php-parser": "^5.5", @@ -22,7 +22,7 @@ "phpstan/phpstan": "^2.1", "phpunit/phpunit": "^11.5", "rector/jack": "^0.2.3", - "rector/rector": "^2.0.18", + "rector/rector": "^2.1", "shipmonk/composer-dependency-analyser": "^1.8", "symfony/config": "^6.4", "symfony/dependency-injection": "^6.4", From e2d398550204b8c1574b2b75042d2019ed16f048 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 21 Jul 2025 12:13:32 +0200 Subject: [PATCH 3/5] fqn --- src/Finder/PhpFilesFinder.php | 1 + tests/Finder/PhpFilesFinderTest.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Finder/PhpFilesFinder.php b/src/Finder/PhpFilesFinder.php index 00f4a2e77..791a3a51d 100644 --- a/src/Finder/PhpFilesFinder.php +++ b/src/Finder/PhpFilesFinder.php @@ -39,6 +39,7 @@ private static function createFinderForPathsAndExcludedPaths(array $paths, array $excludedFileNames[] = $excludedPath; } } + Assert::allFileExists($excludedFileNames); return Finder::create() diff --git a/tests/Finder/PhpFilesFinderTest.php b/tests/Finder/PhpFilesFinderTest.php index 37b7ec82e..6eb1e3ac2 100644 --- a/tests/Finder/PhpFilesFinderTest.php +++ b/tests/Finder/PhpFilesFinderTest.php @@ -4,13 +4,14 @@ namespace Rector\SwissKnife\Tests\Finder; +use Rector\SwissKnife\Finder\PhpFilesFinder; use Rector\SwissKnife\Tests\AbstractTestCase; final class PhpFilesFinderTest extends AbstractTestCase { public function testExcludeByFnMatch(): void { - $files = \Rector\SwissKnife\Finder\PhpFilesFinder::find([__DIR__ . '/Fixture'], ['*Controller.php']); + $files = PhpFilesFinder::find([__DIR__ . '/Fixture'], ['*Controller.php']); $this->assertSame(1, count($files)); @@ -22,7 +23,7 @@ public function testExcludeByFnMatch(): void public function testExcludeByFnMatch2(): void { - $files = \Rector\SwissKnife\Finder\PhpFilesFinder::find([__DIR__ . '/Fixture'], ['*Model.php']); + $files = PhpFilesFinder::find([__DIR__ . '/Fixture'], ['*Model.php']); $this->assertSame(2, count($files)); From 8d112e4eee9bee8258efe20911a4e2c1e92db250 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 21 Jul 2025 12:15:28 +0200 Subject: [PATCH 4/5] skip symfony cache --- src/Finder/FilesFinder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Finder/FilesFinder.php b/src/Finder/FilesFinder.php index d342f9c6a..4dc77f499 100644 --- a/src/Finder/FilesFinder.php +++ b/src/Finder/FilesFinder.php @@ -26,6 +26,7 @@ public static function find(array $sources): array ->in($paths) // not our code ->notPath('vendor') + ->notPath('var/cache') ->sortByName(); return iterator_to_array($finder->getIterator()); From dbf27ce8035134fd0f9eb05e12172497526e3398 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 21 Jul 2025 12:19:23 +0200 Subject: [PATCH 5/5] check conflicts both ways --- src/Git/ConflictResolver.php | 4 ++-- tests/Git/ConflictResolver/ConflictResolverTest.php | 4 +++- tests/Git/ConflictResolver/Fixture/another_file.txt | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 tests/Git/ConflictResolver/Fixture/another_file.txt diff --git a/src/Git/ConflictResolver.php b/src/Git/ConflictResolver.php index 063d9dc3c..5a76534cd 100644 --- a/src/Git/ConflictResolver.php +++ b/src/Git/ConflictResolver.php @@ -13,10 +13,10 @@ final class ConflictResolver { /** - * @see https://regex101.com/r/iYPxCV/2 + * @see https://regex101.com/r/L2CThC/1 * @var string */ - private const CONFLICT_REGEX = '#^<<<<<<<#'; + private const CONFLICT_REGEX = '#^(<<<<<<<|>>>>>>>)#m'; /** * @api diff --git a/tests/Git/ConflictResolver/ConflictResolverTest.php b/tests/Git/ConflictResolver/ConflictResolverTest.php index 2be6cb841..88a0b6bac 100644 --- a/tests/Git/ConflictResolver/ConflictResolverTest.php +++ b/tests/Git/ConflictResolver/ConflictResolverTest.php @@ -27,8 +27,10 @@ public function test(string $filePath, int $expectedConflictCount): void public static function provideData(): Iterator { + yield [__DIR__ . '/Fixture/another_file.txt', 1]; yield [__DIR__ . '/Fixture/some_file.txt', 1]; - yield [__DIR__ . '/Fixture/some_other_file.txt', 1]; + yield [__DIR__ . '/Fixture/some_other_file.txt', 2]; + yield [__DIR__ . '/Fixture/correct_file.txt', 0]; } } diff --git a/tests/Git/ConflictResolver/Fixture/another_file.txt b/tests/Git/ConflictResolver/Fixture/another_file.txt new file mode 100644 index 000000000..7c7c443c3 --- /dev/null +++ b/tests/Git/ConflictResolver/Fixture/another_file.txt @@ -0,0 +1,3 @@ +CONFLICT +>>>>>>> +IS HERE