diff --git a/packages/framework/src/Foundation/Kernel/Filesystem.php b/packages/framework/src/Foundation/Kernel/Filesystem.php index e4bef03a93e..840329e5dba 100644 --- a/packages/framework/src/Foundation/Kernel/Filesystem.php +++ b/packages/framework/src/Foundation/Kernel/Filesystem.php @@ -190,6 +190,10 @@ public function smartGlob(string $pattern, int $flags = 0): Collection /** @return \Illuminate\Support\Collection */ public function findFiles(string $directory, string|array|false $matchExtensions = false, bool $recursive = false): Collection { + if (! \Hyde\Facades\Filesystem::isDirectory($directory)) { + return collect(); + } + $finder = Finder::create()->files()->in($this->path($directory)); if ($recursive === false) { diff --git a/packages/framework/tests/Unit/FilesystemFindFilesTest.php b/packages/framework/tests/Unit/FilesystemFindFilesTest.php index 7b3f86cb92f..7193c078679 100644 --- a/packages/framework/tests/Unit/FilesystemFindFilesTest.php +++ b/packages/framework/tests/Unit/FilesystemFindFilesTest.php @@ -8,7 +8,6 @@ use Hyde\Testing\UnitTestCase; use Hyde\Testing\CreatesTemporaryFiles; use Hyde\Foundation\Kernel\Filesystem; -use Symfony\Component\Finder\Exception\DirectoryNotFoundException; /** * @covers \Hyde\Foundation\Kernel\Filesystem::findFiles @@ -151,7 +150,6 @@ public function testFindFilesWithEmptyDirectory() public function testFindFilesWithNonExistentDirectory() { - $this->expectException(DirectoryNotFoundException::class); $this->assertSameArray([], 'nonexistent-directory'); }