Skip to content

Commit 103ee3e

Browse files
authored
Properly handle non-php files in directories
1 parent 7ed4a09 commit 103ee3e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Command/WhyBlockCommand.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,13 @@ private static function getAllFilesForAutoload(string $basePath, array $autoload
154154
if ($realDir === false) {
155155
continue;
156156
}
157-
$results = static::getAllPhpFiles($realDir, $results);
157+
if (is_file($realDir)) {
158+
$results[] = $realDir;
159+
continue;
160+
}
161+
if (is_dir($realDir)) {
162+
$results = static::getAllPhpFiles($realDir, $results);
163+
}
158164
}
159165
}
160166
return $results;
@@ -182,7 +188,7 @@ private static function getAllPhpFiles(string $dir, array $results = []): array
182188

183189
if (!is_dir($path) && substr($path, -4) === '.php') {
184190
$results[] = $path;
185-
} elseif (!in_array($value, ['.', '..'])) {
191+
} elseif (is_dir($path) && !in_array($value, ['.', '..'])) {
186192
$results = static::getAllPhpFiles($path, $results);
187193
}
188194
}

0 commit comments

Comments
 (0)