Skip to content

Commit

Permalink
Checker: AppendIterator replaced with Finder
Browse files Browse the repository at this point in the history
AppendIterator->rewind() can throw "Cannot traverse an already closed generator" when Finder->getIterator() is empty
  • Loading branch information
dg committed Oct 11, 2023
1 parent 6dde8f8 commit a6e1345
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Checker.php
Expand Up @@ -46,22 +46,22 @@ public function run($paths): bool

echo "Scanning {$this->console->color('white', implode(', ', $paths))}\n";

$iterator = new \AppendIterator;
$finder = new Finder;
foreach ($paths as $path) {
$iterator->append(
is_file($path)
? new \ArrayIterator([$path])
: Finder::findFiles($this->accept)
if (is_file($path)) {
$finder->append($path);
} else {
$finder->append()
->files($this->accept)
->exclude($this->ignore)
->from($path)
->exclude($this->ignore)
->getIterator(),
);
->exclude($this->ignore);
}
}

$counter = 0;
$success = true;
foreach ($iterator as $file) {
foreach ($finder as $file) {
if ($this->showProgress) {
echo str_pad(str_repeat('.', $counter++ % 40), 40), "\x0D";
}
Expand Down

0 comments on commit a6e1345

Please sign in to comment.