File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
namespace Psalm \LaravelPlugin ;
3
3
4
+ use Illuminate \Foundation \Application ;
4
5
use Psalm \LaravelPlugin \Handlers \Application \ContainerHandler ;
5
6
use Psalm \LaravelPlugin \Handlers \Application \OffsetHandler ;
6
7
use Psalm \LaravelPlugin \Handlers \Eloquent \ModelMethodHandler ;
20
21
use Psalm \Plugin \RegistrationInterface ;
21
22
use SimpleXMLElement ;
22
23
use Throwable ;
24
+ use function array_merge ;
23
25
use function dirname ;
26
+ use function explode ;
24
27
use function glob ;
25
28
26
29
class Plugin implements PluginEntryPointInterface
@@ -39,9 +42,26 @@ public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement
39
42
$ this ->registerStubs ($ registration );
40
43
}
41
44
45
+ protected function getCommonStubs (): array
46
+ {
47
+ return glob (dirname (__DIR__ ) . '/stubs/*.stubphp ' );
48
+ }
49
+
50
+ protected function getStubsForVersion (string $ version ): array
51
+ {
52
+ [$ majorVersion ] = explode ('. ' , $ version );
53
+
54
+ return glob (dirname (__DIR__ ) . '/stubs/ ' .$ majorVersion .'/*.stubphp ' );
55
+ }
56
+
42
57
private function registerStubs (RegistrationInterface $ registration ): void
43
58
{
44
- foreach (glob (dirname (__DIR__ ) . '/stubs/*.stubphp ' ) as $ stubFilePath ) {
59
+ $ stubs = array_merge (
60
+ $ this ->getCommonStubs (),
61
+ $ this ->getStubsForVersion (Application::VERSION ),
62
+ );
63
+
64
+ foreach ($ stubs as $ stubFilePath ) {
45
65
$ registration ->addStubFile ($ stubFilePath );
46
66
}
47
67
You can’t perform that action at this time.
0 commit comments