File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace PHPStan \PhpDoc ;
4+
5+ interface StubFilesExtension
6+ {
7+
8+ public const EXTENSION_TAG = 'phpstan.stubFilesExtension ' ;
9+
10+ /** @return string[] */
11+ public function getFiles (): array ;
12+
13+ }
Original file line number Diff line number Diff line change 22
33namespace PHPStan \PhpDoc ;
44
5+ use PHPStan \DependencyInjection \Container ;
56use PHPStan \Parser \Parser ;
67use PHPStan \Type \FileTypeMapper ;
78
@@ -12,6 +13,8 @@ class StubPhpDocProviderFactory
1213
1314 private \PHPStan \Type \FileTypeMapper $ fileTypeMapper ;
1415
16+ private Container $ container ;
17+
1518 /** @var string[] */
1619 private array $ stubFiles ;
1720
@@ -22,20 +25,31 @@ class StubPhpDocProviderFactory
2225 public function __construct (
2326 Parser $ parser ,
2427 FileTypeMapper $ fileTypeMapper ,
28+ Container $ container ,
2529 array $ stubFiles
2630 )
2731 {
2832 $ this ->parser = $ parser ;
2933 $ this ->fileTypeMapper = $ fileTypeMapper ;
34+ $ this ->container = $ container ;
3035 $ this ->stubFiles = $ stubFiles ;
3136 }
3237
3338 public function create (): StubPhpDocProvider
3439 {
40+ $ stubFiles = $ this ->stubFiles ;
41+ $ extensions = $ this ->container ->getServicesByTag (StubFilesExtension::EXTENSION_TAG );
42+ foreach ($ extensions as $ extension ) {
43+ $ extensionFiles = $ extension ->getFiles ();
44+ foreach ($ extensionFiles as $ extensionFile ) {
45+ $ stubFiles [] = $ extensionFile ;
46+ }
47+ }
48+
3549 return new StubPhpDocProvider (
3650 $ this ->parser ,
3751 $ this ->fileTypeMapper ,
38- $ this -> stubFiles
52+ $ stubFiles
3953 );
4054 }
4155
You can’t perform that action at this time.
0 commit comments