File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ class ClassScanner
1111{
1212 public function getClassNameFromFile ($ file )
1313 {
14+ if (!file_exists ($ file )) {
15+ return null ;
16+ }
17+
1418 $ fp = fopen ($ file , 'r ' );
1519
1620 $ class = $ namespace = $ buffer = '' ;
@@ -54,7 +58,7 @@ public function getClassNameFromFile($file)
5458 }
5559
5660 if (!trim ($ class )) {
57- return ;
61+ return null ;
5862 }
5963
6064 fclose ($ fp );
Original file line number Diff line number Diff line change @@ -38,4 +38,11 @@ public function testFileToNoCandidates()
3838
3939 $ this ->assertEquals (ClassNameCandidates::fromClassNames ([]), $ candidates );
4040 }
41+
42+ public function testFileToClassNotExisting ()
43+ {
44+ $ candidates = $ this ->fileToClass ->fileToClassCandidates (FilePath::fromString (__DIR__ . '/project/notexist/NotExist.php ' ));
45+
46+ $ this ->assertEquals (ClassNameCandidates::fromClassNames ([]), $ candidates );
47+ }
4148}
You can’t perform that action at this time.
0 commit comments