Skip to content

Commit 4d47c6e

Browse files
committed
Check if there is a namespace statement before going further
1 parent 7a3710e commit 4d47c6e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ModelFinder.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ protected function getFullyQualifiedClassNameFromFile(string $path): string
5757
return $statement instanceof Namespace_;
5858
})->first();
5959

60+
if (! $root_statement) {
61+
return '';
62+
}
63+
6064
return collect($root_statement->stmts)
6165
->filter(function ($statement) {
6266
return $statement instanceof Class_;
@@ -66,5 +70,4 @@ protected function getFullyQualifiedClassNameFromFile(string $path): string
6670
})
6771
->first() ?? '';
6872
}
69-
7073
}

0 commit comments

Comments
 (0)