Skip to content

Commit

Permalink
minor #6189 Finder - fix usage of ignoreDotFiles (kubawerlos)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the master branch (closes #6189).

Discussion
----------

Finder - fix usage of ignoreDotFiles

Commits
-------

0a59bb4 Finder - fix usage of ignoreDotFiles
  • Loading branch information
SpacePossum committed Dec 20, 2021
2 parents a0fe01e + 0a59bb4 commit 45bf9e3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Finder.php
Expand Up @@ -28,7 +28,7 @@ public function __construct()

$this
->files()
->name('*.php')
->name('/\.php$/')
->exclude('vendor')
;
}
Expand Down
20 changes: 20 additions & 0 deletions tests/FinderTest.php
Expand Up @@ -15,6 +15,7 @@
namespace PhpCsFixer\Tests;

use PhpCsFixer\Finder;
use Symfony\Component\Finder\SplFileInfo;

/**
* @internal
Expand All @@ -31,4 +32,23 @@ public function testThatDefaultFinderDoesNotSpecifyAnyDirectory(): void
$finder = Finder::create();
$finder->getIterator();
}

public function testThatFinderFindsDotFilesWhenConfigured(): void
{
$finder = Finder::create()
->in(__DIR__.'/..')
->depth(0)
->ignoreDotFiles(false)
;

static::assertContains(
realpath(__DIR__.'/../.php-cs-fixer.dist.php'),
array_map(
function (SplFileInfo $file): string {
return $file->getRealPath();
},
iterator_to_array($finder->getIterator())
)
);
}
}

0 comments on commit 45bf9e3

Please sign in to comment.