File tree 3 files changed +73
-1
lines changed
3 files changed +73
-1
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ parameters:
9
9
- stubs/Application/UI/Component.stub
10
10
- stubs/Application/UI/Multiplier.stub
11
11
- stubs/ComponentModel/Component.stub
12
- - stubs/ComponentModel/Container.stub
13
12
- stubs/ComponentModel/IComponent.stub
14
13
- stubs/ComponentModel/IContainer.stub
15
14
- stubs/Database/ResultSet.stub
@@ -110,3 +109,8 @@ services:
110
109
class : PHPStan\Rule\Nette\PresenterInjectedPropertiesExtension
111
110
tags :
112
111
- phpstan.properties.readWriteExtension
112
+
113
+ -
114
+ class : PHPStan\Stubs\Nette\StubFilesExtensionLoader
115
+ tags :
116
+ - phpstan.stubFilesExtension
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ namespace PHPStan \Stubs \Nette ;
4
+
5
+ use Composer \InstalledVersions ;
6
+ use OutOfBoundsException ;
7
+ use PHPStan \PhpDoc \StubFilesExtension ;
8
+ use function class_exists ;
9
+ use function dirname ;
10
+ use function version_compare ;
11
+
12
+ class StubFilesExtensionLoader implements StubFilesExtension
13
+ {
14
+
15
+ public function getFiles (): array
16
+ {
17
+ $ stubsDir = dirname (dirname (dirname (__DIR__ ))) . '/stubs ' ;
18
+ $ path = $ stubsDir ;
19
+
20
+ $ files = [];
21
+
22
+ $ componentModelVersion = self ::getInstalledVersion ('nette/component-model ' );
23
+ if ($ componentModelVersion !== null && version_compare ($ componentModelVersion , '3.1.0 ' , '>= ' )) {
24
+ $ files [] = $ path . '/ComponentModel/Container_3_1.stub ' ;
25
+ } else {
26
+ $ files [] = $ path . '/ComponentModel/Container.stub ' ;
27
+ }
28
+
29
+ return $ files ;
30
+ }
31
+
32
+ private static function getInstalledVersion (string $ package ): ?string
33
+ {
34
+ if (!class_exists (InstalledVersions::class)) {
35
+ return null ;
36
+ }
37
+
38
+ try {
39
+ $ installedVersion = InstalledVersions::getVersion ($ package );
40
+ } catch (OutOfBoundsException $ e ) {
41
+ return null ;
42
+ }
43
+
44
+ return $ installedVersion ;
45
+ }
46
+
47
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Nette\ComponentModel;
4
+
5
+ class Container extends Component implements IContainer
6
+ {
7
+
8
+ /**
9
+ * @template T of \Nette\ComponentModel\IComponent
10
+ * @phpstan-param null|class-string<T> $filterType
11
+ * @phpstan-return (
12
+ * $deep is true
13
+ * ? ($filterType is null ? array<int|string, \Nette\ComponentModel\IComponent> : array<int|string, T>)
14
+ * : ($filterType is null ? \Iterator<int|string, \Nette\ComponentModel\IComponent> : \Iterator<int|string, T>)
15
+ * )
16
+ */
17
+ public function getComponents(bool $deep = false, string $filterType = null): \Iterator
18
+ {
19
+ // nothing
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments