Skip to content

Commit dea29dd

Browse files
authored
Merge pull request #28 from ThibaudDauce/fix-class-without-namespace
Classes without namespace break the ModelFinder
2 parents 33b734a + 4d47c6e commit dea29dd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-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
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
class SomeClassWithoutNamespace
4+
{
5+
6+
}

0 commit comments

Comments
 (0)