File tree 5 files changed +77
-0
lines changed
5 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 18
18
"nette/utils" : " <2.3.0"
19
19
},
20
20
"require-dev" : {
21
+ "nette/application" : " ^3.0" ,
21
22
"nette/forms" : " ^3.0" ,
22
23
"nette/utils" : " ^2.3.0 || ^3.0.0" ,
23
24
"nikic/php-parser" : " ^4.13.2" ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ parameters:
7
7
stubFiles :
8
8
- stubs/Application/Routers/RouteList.stub
9
9
- stubs/Application/UI/Component.stub
10
+ - stubs/Application/UI/Multiplier.stub
10
11
- stubs/ComponentModel/Component.stub
11
12
- stubs/ComponentModel/Container.stub
12
13
- stubs/ComponentModel/IComponent.stub
@@ -31,6 +32,9 @@ parameters:
31
32
- Nette\Http\SessionSection
32
33
- Nette\Security\Identity
33
34
- Nette\Security\SimpleIdentity
35
+ featureToggles :
36
+ skipCheckGenericClasses :
37
+ - Nette\Application\UI\Multiplier
34
38
earlyTerminatingMethodCalls :
35
39
Nette\Application\UI\Component :
36
40
- error
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
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
+ }
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ namespace PHPStan \Type \Nette ;
4
+
5
+ use PHPStan \Testing \TypeInferenceTestCase ;
6
+
7
+ class MultiplierTest extends TypeInferenceTestCase
8
+ {
9
+
10
+ /** @return iterable<mixed> */
11
+ public function dataFileAsserts (): iterable
12
+ {
13
+ yield from $ this ->gatherAssertTypes (__DIR__ . '/data/multiplier.php ' );
14
+ }
15
+
16
+ /**
17
+ * @dataProvider dataFileAsserts
18
+ * @param mixed ...$args
19
+ */
20
+ public function testFileAsserts (
21
+ string $ assertType ,
22
+ string $ file ,
23
+ ...$ args
24
+ ): void
25
+ {
26
+ $ this ->assertFileAsserts ($ assertType , $ file , ...$ args );
27
+ }
28
+
29
+ public static function getAdditionalConfigFiles (): array
30
+ {
31
+ return [
32
+ __DIR__ . '/../../../extension.neon ' ,
33
+ ];
34
+ }
35
+
36
+ }
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ use Nette \Application \UI \Form ;
4
+ use Nette \Application \UI \Multiplier ;
5
+
6
+ use function PHPStan \Testing \assertType ;
7
+
8
+ /** @var Multiplier<Form> $multiplier */
9
+ $ multiplier = new Multiplier (function (string $ name ): Form {
10
+ return new Form ();
11
+ });
12
+
13
+ assertType ('Nette\Application\UI\Multiplier<Nette\Application\UI\Form> ' , $ multiplier );
14
+
15
+ $ form = $ multiplier ->createComponent ('foo ' );
16
+
17
+ assertType (Form::class, $ form );
You can’t perform that action at this time.
0 commit comments