File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ You can install Graphviz on MacOS via homebrew:
19
19
brew install graphviz
20
20
```
21
21
22
+ Or, if you are using Homestead:
23
+
24
+ ``` bash
25
+ sudo apt-get install graphviz
26
+ ```
27
+
22
28
## Installation
23
29
24
30
You can install the package via composer:
Original file line number Diff line number Diff line change 5
5
use PhpParser \NodeTraverser ;
6
6
use PhpParser \ParserFactory ;
7
7
use PhpParser \Node \Stmt \Class_ ;
8
+ use PhpParser \Node \Stmt \Namespace_ ;
8
9
use Illuminate \Support \Collection ;
9
10
use Illuminate \Filesystem \Filesystem ;
10
11
use PhpParser \NodeVisitor \NameResolver ;
@@ -42,10 +43,14 @@ protected function getFullyQualifiedClassNameFromFile(string $path): string
42
43
$ code = file_get_contents ($ path );
43
44
44
45
$ statements = $ parser ->parse ($ code );
45
-
46
46
$ 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 ();
47
52
48
- return collect ($ statements [ 0 ] ->stmts )
53
+ return collect ($ root_statement ->stmts )
49
54
->filter (function ($ statement ) {
50
55
return $ statement instanceof Class_;
51
56
})
@@ -55,4 +60,4 @@ protected function getFullyQualifiedClassNameFromFile(string $path): string
55
60
->first () ?? '' ;
56
61
}
57
62
58
- }
63
+ }
You can’t perform that action at this time.
0 commit comments