From 103ee3e7a3a5751a58d3d08bbac2f733a91b37de Mon Sep 17 00:00:00 2001 From: Navarr Barnier Date: Wed, 23 Jun 2021 15:15:45 -0400 Subject: [PATCH] Properly handle non-php files in directories --- src/Command/WhyBlockCommand.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Command/WhyBlockCommand.php b/src/Command/WhyBlockCommand.php index 92efac8..6f18087 100644 --- a/src/Command/WhyBlockCommand.php +++ b/src/Command/WhyBlockCommand.php @@ -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; @@ -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); } }