@@ -20,11 +20,12 @@ final class DefaultStubFilesProvider implements StubFilesProvider
20
20
21
21
/**
22
22
* @param string[] $stubFiles
23
+ * @param string[] $composerAutoloaderProjectPaths
23
24
*/
24
25
public function __construct (
25
26
private Container $ container ,
26
27
private array $ stubFiles ,
27
- private string $ currentWorkingDirectory ,
28
+ private array $ composerAutoloaderProjectPaths ,
28
29
)
29
30
{
30
31
}
@@ -52,19 +53,22 @@ public function getProjectStubFiles(): array
52
53
return $ this ->cachedProjectFiles ;
53
54
}
54
55
55
- $ composerConfig = ComposerHelper::getComposerConfig ($ this ->currentWorkingDirectory );
56
+ $ filteredStubFiles = $ this ->getStubFiles ();
57
+ foreach ($ this ->composerAutoloaderProjectPaths as $ composerAutoloaderProjectPath ) {
58
+ $ composerConfig = ComposerHelper::getComposerConfig ($ composerAutoloaderProjectPath );
59
+ if ($ composerConfig === null ) {
60
+ continue ;
61
+ }
56
62
57
- if ($ composerConfig === null ) {
58
- return $ this ->getStubFiles ();
63
+ $ vendorDir = ComposerHelper::getVendorDirFromComposerConfig ($ composerAutoloaderProjectPath , $ composerConfig );
64
+ $ vendorDir = strtr ($ vendorDir , '\\' , '/ ' );
65
+ $ filteredStubFiles = array_filter (
66
+ $ filteredStubFiles ,
67
+ static fn (string $ file ): bool => !str_contains (strtr ($ file , '\\' , '/ ' ), $ vendorDir )
68
+ );
59
69
}
60
70
61
- $ vendorDir = ComposerHelper::getVendorDirFromComposerConfig ($ this ->currentWorkingDirectory , $ composerConfig );
62
- $ vendorDir = strtr ($ vendorDir , '\\' , '/ ' );
63
-
64
- return $ this ->cachedProjectFiles = array_values (array_filter (
65
- $ this ->getStubFiles (),
66
- static fn (string $ file ): bool => !str_contains (strtr ($ file , '\\' , '/ ' ), $ vendorDir )
67
- ));
71
+ return $ this ->cachedProjectFiles = array_values ($ filteredStubFiles );
68
72
}
69
73
70
74
}
0 commit comments