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 761aed9 commit 899d961
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 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,17 @@ 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
$mainIterator = $this;
$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 899d961

Please sign in to comment.