Skip to content

Commit

Permalink
Allow to manage dot files as usual
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Apr 5, 2021
1 parent ce3b917 commit 25b8d26
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Finder.php
Expand Up @@ -13,6 +13,7 @@
namespace PhpCsFixer;

use Symfony\Component\Finder\Finder as BaseFinder;
use Symfony\Component\Finder\Iterator\LazyIterator;

/**
* @author Fabien Potencier <fabien@symfony.com>
Expand All @@ -27,11 +28,19 @@ public function __construct()
$this
->files()
->name('*.php')
->ignoreDotFiles(false)
->notPath('~(^|/)\.(?!php_cs(\.dist)?(/|$)).+(/|$)~')
->name('.php_cs')
->name('.php_cs.dist')
->exclude('vendor')
;

// add config files even if dot files are ignored
if (class_exists(LazyIterator::class)) { // LazyIterator class is available since Symfony 4.4 (which requires PHP 7+)
$mainIterator = $this; // @phpstan-ignore-line
$this->append(new \IteratorIterator(new LazyIterator(function () use ($mainIterator) {
$iterator = clone $mainIterator;
$iterator->ignoreDotFiles(false);
$iterator->name('~^\.(php_cs(\..+)?$~is');

return $iterator;
})));
}
}
}

0 comments on commit 25b8d26

Please sign in to comment.