Skip to content

Commit ee2d74e

Browse files
committed
Merge branch 'master' of github.com:beyondcode/laravel-er-diagram-generator
2 parents 6698320 + ff3c934 commit ee2d74e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ You can install Graphviz on MacOS via homebrew:
1919
brew install graphviz
2020
```
2121

22+
Or, if you are using Homestead:
23+
24+
```bash
25+
sudo apt-get install graphviz
26+
```
27+
2228
## Installation
2329

2430
You can install the package via composer:

src/ModelFinder.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PhpParser\NodeTraverser;
66
use PhpParser\ParserFactory;
77
use PhpParser\Node\Stmt\Class_;
8+
use PhpParser\Node\Stmt\Namespace_;
89
use Illuminate\Support\Collection;
910
use Illuminate\Filesystem\Filesystem;
1011
use PhpParser\NodeVisitor\NameResolver;
@@ -42,10 +43,14 @@ protected function getFullyQualifiedClassNameFromFile(string $path): string
4243
$code = file_get_contents($path);
4344

4445
$statements = $parser->parse($code);
45-
4646
$statements = $traverser->traverse($statements);
47+
48+
// get the first namespace declaration in the file
49+
$root_statement = collect($statements)->filter(function ($statement) {
50+
return $statement instanceof Namespace_;
51+
})->first();
4752

48-
return collect($statements[0]->stmts)
53+
return collect($root_statement->stmts)
4954
->filter(function ($statement) {
5055
return $statement instanceof Class_;
5156
})
@@ -55,4 +60,4 @@ protected function getFullyQualifiedClassNameFromFile(string $path): string
5560
->first() ?? '';
5661
}
5762

58-
}
63+
}

0 commit comments

Comments
 (0)