Skip to content

Commit

Permalink
Prevented infinite recursion in getAllFiles() #48
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Jan 17, 2020
1 parent 3fd5c38 commit 0ebcdea
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,17 @@ protected function reorderFiles(): void
}
}

protected function getAllFiles(string $name): array
protected function getAllFiles(string $name, array $stack = []): array
{
if (empty($this->files[$name])) {
return[];
}
$res = [];
foreach ($this->files[$name] as $file) {
if (strncmp($file, '$', 1) === 0) {
$res = array_merge($res, $this->getAllFiles(substr($file, 1)));
if (!in_array($name, $stack, true)) {
$res = array_merge($res, $this->getAllFiles(substr($file, 1), array_merge($stack, [$name])));
}
} else {
$res[] = $file;
}
Expand Down

0 comments on commit 0ebcdea

Please sign in to comment.