File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ public function getClassNameFromFile($file)
4646 }
4747 }
4848
49- if ($ tokens [$ i ][0 ] === \T_CLASS ) {
49+ $ token = $ tokens [$ i ][0 ];
50+ if ($ token === \T_INTERFACE || $ token === \T_CLASS || $ token === \T_TRAIT ) {
5051 for ($ j = $ i + 1 ; $ j < count ($ tokens ); $ j ++) {
5152 if ($ tokens [$ j ][0 ] === \T_STRING ) {
5253 $ class = $ tokens [$ i + 2 ][1 ];
Original file line number Diff line number Diff line change 66use Phpactor \ClassFileConverter \Domain \FilePathCandidates ;
77use Phpactor \ClassFileConverter \Domain \ClassName ;
88use Phpactor \ClassFileConverter \Domain \FilePath ;
9+ use RecursiveDirectoryIterator ;
10+ use RecursiveIteratorIterator ;
11+ use RegexIterator ;
912
1013class SimpleClassToFile implements ClassToFile
1114{
@@ -29,15 +32,19 @@ public function classToFileCandidates(ClassName $className): FilePathCandidates
2932 {
3033 $ candidates = [];
3134 $ pattern = sprintf (
32- '%s/**/%s.php ' ,
33- $ this ->cwd ,
35+ '{^.*/%s.php$} ' ,
3436 $ className ->name ()
3537 );
36- foreach (glob ($ pattern ) as $ phpFile ) {
38+
39+ $ iterator = new RecursiveDirectoryIterator ($ this ->cwd );
40+ $ iterator = new RecursiveIteratorIterator ($ iterator );
41+ $ iterator = new RegexIterator ($ iterator , $ pattern );
42+
43+ foreach ($ iterator as $ phpFile ) {
3744 if (ClassName::fromString (
38- $ this ->classScanner ->getClassNameFromFile ($ phpFile )
45+ $ this ->classScanner ->getClassNameFromFile ($ phpFile-> getPathName () )
3946 ) == $ className ) {
40- $ candidates [] = FilePath::fromString ($ phpFile );
47+ $ candidates [] = FilePath::fromString ($ phpFile-> getPathName () );
4148 }
4249 }
4350
You can’t perform that action at this time.
0 commit comments