Skip to content

Commit 788865b

Browse files
fix: check glob result before foreach
1 parent 8e11c9a commit 788865b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Theme.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,10 @@ public function listLayouts()
368368
$layoutDirs = $this->getViewPaths('layouts');
369369

370370
foreach ($layoutDirs as $layoutDir) {
371-
foreach (glob($layoutDir . '/{**/*,*}.php', GLOB_BRACE) as $layout) {
372-
$layouts->put($layout, basename($layout, '.blade.php'));
371+
if ($layoutFiles = glob($layoutDir . '/{**/*,*}.php', GLOB_BRACE)) {
372+
foreach ($layoutFiles as $layout) {
373+
$layouts->put($layout, basename($layout, '.blade.php'));
374+
}
373375
}
374376
}
375377

src/Traits/HasViews.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ protected function loadVendorViews(): void
3838
$vendorViewsPath = $this->getPath('resources/views/vendor');
3939

4040
if (file_exists($vendorViewsPath)) {
41-
$directories = glob($vendorViewsPath . '/*', GLOB_ONLYDIR);
42-
43-
foreach ($directories as $path) {
44-
View::prependNamespace(basename($path), $path);
41+
if ($directories = glob($vendorViewsPath . '/*', GLOB_ONLYDIR)) {
42+
foreach ($directories as $path) {
43+
View::prependNamespace(basename($path), $path);
44+
}
4545
}
4646
}
4747
}

0 commit comments

Comments
 (0)