File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 28
28
use PHPStan \Type \IterableType ;
29
29
use PHPStan \Type \KeyOfType ;
30
30
use PHPStan \Type \MixedType ;
31
+ use PHPStan \Type \NullType ;
31
32
use PHPStan \Type \ObjectShapeType ;
32
33
use PHPStan \Type \ObjectType ;
33
34
use PHPStan \Type \ObjectWithoutClassType ;
@@ -132,6 +133,7 @@ public function check(
132
133
&& $ boundTypeClass !== GenericObjectType::class
133
134
&& $ boundTypeClass !== KeyOfType::class
134
135
&& $ boundTypeClass !== IterableType::class
136
+ && $ boundTypeClass !== NullType::class
135
137
&& !$ boundType instanceof UnionType
136
138
&& !$ boundType instanceof IntersectionType
137
139
&& !$ boundType instanceof TemplateType
Original file line number Diff line number Diff line change @@ -17,10 +17,20 @@ public function doFoo(?int $p): ?int
17
17
return $ p ;
18
18
}
19
19
20
+ /**
21
+ * @template T of null
22
+ * @return T
23
+ */
24
+ public function nullTemplate (): mixed
25
+ {
26
+ return null ;
27
+ }
28
+
20
29
}
21
30
22
31
function (Foo $ f , ?int $ i ): void {
23
32
assertType ('null ' , $ f ->doFoo (null ));
24
33
assertType ('1 ' , $ f ->doFoo (1 ));
25
34
assertType ('int|null ' , $ f ->doFoo ($ i ));
35
+ assertType ('null ' , $ f ->nullTemplate ());
26
36
};
You can’t perform that action at this time.
0 commit comments