Skip to content

Commit

Permalink
Properly handle non-php files in directories
Browse files Browse the repository at this point in the history
  • Loading branch information
navarr authored Jun 23, 2021
1 parent 7ed4a09 commit 103ee3e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Command/WhyBlockCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ private static function getAllFilesForAutoload(string $basePath, array $autoload
if ($realDir === false) {
continue;
}
$results = static::getAllPhpFiles($realDir, $results);
if (is_file($realDir)) {
$results[] = $realDir;
continue;
}
if (is_dir($realDir)) {
$results = static::getAllPhpFiles($realDir, $results);
}
}
}
return $results;
Expand Down Expand Up @@ -182,7 +188,7 @@ private static function getAllPhpFiles(string $dir, array $results = []): array

if (!is_dir($path) && substr($path, -4) === '.php') {
$results[] = $path;
} elseif (!in_array($value, ['.', '..'])) {
} elseif (is_dir($path) && !in_array($value, ['.', '..'])) {
$results = static::getAllPhpFiles($path, $results);
}
}
Expand Down

0 comments on commit 103ee3e

Please sign in to comment.