From d7fede84d2194e9af5a692327a2b0c897558079e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Thu, 16 Dec 2021 15:04:59 +0100 Subject: [PATCH 1/2] Add tests --- tests/FinderTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/FinderTest.php b/tests/FinderTest.php index 36883c0ac7f..0b9c24d4ef4 100644 --- a/tests/FinderTest.php +++ b/tests/FinderTest.php @@ -15,6 +15,7 @@ namespace PhpCsFixer\Tests; use PhpCsFixer\Finder; +use Symfony\Component\Finder\SplFileInfo; /** * @internal @@ -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()) + ) + ); + } } From 678a82e25628b90abcc94c867de0429e5bf5c063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Thu, 16 Dec 2021 15:22:29 +0100 Subject: [PATCH 2/2] Add fix --- src/Finder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Finder.php b/src/Finder.php index 161937e1fda..419354ef467 100644 --- a/src/Finder.php +++ b/src/Finder.php @@ -28,7 +28,7 @@ public function __construct() $this ->files() - ->name('*.php') + ->name('/\.php$/') ->exclude('vendor') ; }