Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/Finder/FilesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public static function find(array $sources): array
$finder = Finder::create()
->files()
->in($paths)
// not our code
->notPath('vendor')
->notPath('var/cache')
->sortByName();

return iterator_to_array($finder->getIterator());
Expand Down
1 change: 1 addition & 0 deletions src/Finder/PhpFilesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private static function createFinderForPathsAndExcludedPaths(array $paths, array
$excludedFileNames[] = $excludedPath;
}
}

Assert::allFileExists($excludedFileNames);

return Finder::create()
Expand Down
4 changes: 2 additions & 2 deletions src/Git/ConflictResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions tests/Finder/PhpFilesFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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));

Expand Down
4 changes: 3 additions & 1 deletion tests/Git/ConflictResolver/ConflictResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
3 changes: 3 additions & 0 deletions tests/Git/ConflictResolver/Fixture/another_file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFLICT
>>>>>>>
IS HERE