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 2
2
3
3
namespace PHPStan \PhpDoc ;
4
4
5
+ use PHPStan \DependencyInjection \Container ;
5
6
use PHPStan \Parser \Parser ;
6
7
use PHPStan \Type \FileTypeMapper ;
7
8
@@ -12,6 +13,8 @@ class StubPhpDocProviderFactory
12
13
13
14
private \PHPStan \Type \FileTypeMapper $ fileTypeMapper ;
14
15
16
+ private Container $ container ;
17
+
15
18
/** @var string[] */
16
19
private array $ stubFiles ;
17
20
@@ -22,20 +25,31 @@ class StubPhpDocProviderFactory
22
25
public function __construct (
23
26
Parser $ parser ,
24
27
FileTypeMapper $ fileTypeMapper ,
28
+ Container $ container ,
25
29
array $ stubFiles
26
30
)
27
31
{
28
32
$ this ->parser = $ parser ;
29
33
$ this ->fileTypeMapper = $ fileTypeMapper ;
34
+ $ this ->container = $ container ;
30
35
$ this ->stubFiles = $ stubFiles ;
31
36
}
32
37
33
38
public function create (): StubPhpDocProvider
34
39
{
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
+
35
49
return new StubPhpDocProvider (
36
50
$ this ->parser ,
37
51
$ this ->fileTypeMapper ,
38
- $ this -> stubFiles
52
+ $ stubFiles
39
53
);
40
54
}
41
55
You can’t perform that action at this time.
0 commit comments