File tree Expand file tree Collapse file tree 3 files changed +59
-1
lines changed Expand file tree Collapse file tree 3 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ parameters:
77 stubFiles :
88 - stubs/Application/Routers/RouteList.stub
99 - stubs/Application/UI/Component.stub
10- - stubs/Application/UI/Multiplier.stub
1110 - stubs/Application/UI/Presenter.stub
1211 - stubs/Caching/Cache.stub
1312 - stubs/ComponentModel/Component.stub
@@ -52,6 +51,11 @@ parameters:
5251 - forward
5352
5453services :
54+ -
55+ class : PHPStan\Stubs\Application\StubFilesExtensionLoader
56+ tags :
57+ - phpstan.stubFilesExtension
58+
5559 -
5660 class : PHPStan\Reflection\Nette\HtmlClassReflectionExtension
5761 tags :
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace PHPStan \Stubs \Application ;
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+ public function getFiles (): array {
15+ $ path = dirname (dirname (dirname (__DIR__ ))) . '/stubs ' ;
16+
17+ try {
18+ $ applicationVersion = class_exists (InstalledVersions::class)
19+ ? InstalledVersions::getVersion ('nette/application ' )
20+ : null ;
21+ } catch (OutOfBoundsException $ e ) {
22+ $ applicationVersion = null ;
23+ }
24+
25+ $ files = [];
26+
27+ if ($ applicationVersion !== null && version_compare ($ applicationVersion , '3.2.5 ' , '>= ' )) {
28+ $ files [] = $ path . '/Application/UI/Multiplier1.stub ' ;
29+ } else {
30+ $ files [] = $ path . '/Application/UI/Multiplier.stub ' ;
31+ }
32+
33+ return $ files ;
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Nette\Application\UI;
4+
5+ /**
6+ * @template T of \Nette\ComponentModel\IComponent|null
7+ */
8+ final class Multiplier extends Component
9+ {
10+ /**
11+ * @param callable(string, self<T>) : T $factory
12+ */
13+ public function __construct(callable $factory);
14+
15+ /**
16+ * @return T
17+ */
18+ protected function createComponent(string $name): ?\Nette\ComponentModel\IComponent;
19+ }
You can’t perform that action at this time.
0 commit comments