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 dba13cc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Finder.php
Original file line number Diff line number Diff line change
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,18 @@ 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+)
$this->append(new \IteratorIterator(new LazyIterator(function () {
$iterator = clone $this;
$iterator->ignoreDotFiles(false);
$iterator->name('~^\.php_cs(?:\..+)?$~is');

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

0 comments on commit dba13cc

Please sign in to comment.