Skip to content

Commit

Permalink
fix unable to rewind
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Apr 5, 2021
1 parent dba13cc commit 33f033a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/Finder.php
Expand Up @@ -30,16 +30,24 @@ public function __construct()
->name('*.php')
->exclude('vendor')
;
}

public function getIterator()
{
// 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;
})));
$configFilenameRegex = '\.php_cs(?:\..+)?';
$this->name('~^' . $configFilenameRegex . '$~is');

$isDotFilesIgnored = \Closure::bind(function () {
return $this->ignore & static::IGNORE_DOT_FILES;
}, $this, parent::class)();
if ($isDotFilesIgnored) {
$this
->ignoreDotFiles(false)
->notPath('~(?:^|/)(?!' . $configFilenameRegex . '(?:/|$))\..*(?:/|$)~')
;
}

return parent::getIterator();
}
}

0 comments on commit 33f033a

Please sign in to comment.