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 2828use PHPStan \Type \IterableType ;
2929use PHPStan \Type \KeyOfType ;
3030use PHPStan \Type \MixedType ;
31+ use PHPStan \Type \NullType ;
3132use PHPStan \Type \ObjectShapeType ;
3233use PHPStan \Type \ObjectType ;
3334use PHPStan \Type \ObjectWithoutClassType ;
@@ -132,6 +133,7 @@ public function check(
132133 && $ boundTypeClass !== GenericObjectType::class
133134 && $ boundTypeClass !== KeyOfType::class
134135 && $ boundTypeClass !== IterableType::class
136+ && $ boundTypeClass !== NullType::class
135137 && !$ boundType instanceof UnionType
136138 && !$ boundType instanceof IntersectionType
137139 && !$ boundType instanceof TemplateType
Original file line number Diff line number Diff line change @@ -17,10 +17,20 @@ public function doFoo(?int $p): ?int
1717 return $ p ;
1818 }
1919
20+ /**
21+ * @template T of null
22+ * @return T
23+ */
24+ public function nullTemplate (): mixed
25+ {
26+ return null ;
27+ }
28+
2029}
2130
2231function (Foo $ f , ?int $ i ): void {
2332 assertType ('null ' , $ f ->doFoo (null ));
2433 assertType ('1 ' , $ f ->doFoo (1 ));
2534 assertType ('int|null ' , $ f ->doFoo ($ i ));
35+ assertType ('null ' , $ f ->nullTemplate ());
2636};
You can’t perform that action at this time.
0 commit comments