File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434use PHPStan \Type \MixedType ;
3535use PHPStan \Type \NullType ;
3636use PHPStan \Type \ObjectType ;
37+ use PHPStan \Type \ObjectWithoutClassType ;
3738use PHPStan \Type \StaticType ;
3839use PHPStan \Type \StringType ;
3940use PHPStan \Type \Traits \ConstantScalarTypeTrait ;
@@ -146,6 +147,10 @@ private function export(string $value): string
146147 public function isSuperTypeOf (Type $ type ): TrinaryLogic
147148 {
148149 if ($ type instanceof GenericClassStringType) {
150+ if ($ this ->isClassStringType ()->no ()) {
151+ return TrinaryLogic ::createNo ();
152+ }
153+
149154 $ genericType = $ type ->getGenericType ();
150155 if ($ genericType instanceof MixedType) {
151156 return TrinaryLogic ::createMaybe ();
Original file line number Diff line number Diff line change @@ -133,6 +133,16 @@ public function dataIsSuperTypeOf(): array
133133 new GenericClassStringType (new StaticType ($ reflectionProvider ->getClass (Throwable::class))),
134134 TrinaryLogic ::createMaybe (),
135135 ],
136+ 16 => [
137+ new ConstantStringType ('array ' ),
138+ new GenericClassStringType (TemplateTypeFactory ::create (
139+ TemplateTypeScope ::createWithFunction ('foo ' ),
140+ 'T ' ,
141+ null ,
142+ TemplateTypeVariance ::createInvariant (),
143+ )),
144+ TrinaryLogic ::createNo (),
145+ ],
136146 ];
137147 }
138148
Original file line number Diff line number Diff line change @@ -4162,6 +4162,19 @@ public function dataIntersect(): iterable
41624162 IntersectionType::class,
41634163 'array{a?: true, c?: true}&non-empty-array ' ,
41644164 ];
4165+ yield [
4166+ [
4167+ new ConstantStringType ('array ' ),
4168+ new GenericClassStringType (TemplateTypeFactory ::create (
4169+ TemplateTypeScope ::createWithFunction ('foo ' ),
4170+ 'T ' ,
4171+ null ,
4172+ TemplateTypeVariance ::createInvariant (),
4173+ )),
4174+ ],
4175+ NeverType::class,
4176+ '*NEVER*=implicit ' ,
4177+ ];
41654178 yield [
41664179 [
41674180 new ConstantStringType (Exception::class),
You can’t perform that action at this time.
0 commit comments