File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
9494 if ($ type instanceof ConstantStringType) {
9595 $ genericType = $ this ->type ;
9696 if ($ genericType instanceof MixedType) {
97- return TrinaryLogic :: createYes ();
97+ return $ type -> isClassStringType ();
9898 }
9999
100100 if ($ genericType instanceof StaticType) {
Original file line number Diff line number Diff line change @@ -1252,6 +1252,12 @@ public function testBug10049(): void
12521252 $ this ->assertNoErrors ($ errors );
12531253 }
12541254
1255+ public function testBug10076 (): void
1256+ {
1257+ $ errors = $ this ->runAnalyse (__DIR__ . '/data/bug-10076.php ' );
1258+ $ this ->assertNoErrors ($ errors );
1259+ }
1260+
12551261 /**
12561262 * @param string[]|null $allAnalysedFiles
12571263 * @return Error[]
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug10076 ;
4+
5+ /**
6+ * @template T
7+ *
8+ * @param 'object'|'array'|class-string<T> $type
9+ *
10+ * @return list<mixed>
11+ */
12+ function result ($ type = 'object ' ): array
13+ {
14+ return [];
15+ }
16+
17+ result ();
18+ result ('object ' );
19+ result ('array ' );
20+ result (\DateTime::class);
Original file line number Diff line number Diff line change @@ -155,6 +155,16 @@ public function dataIsSuperTypeOf(): array
155155 new ConstantStringType (IntegerType::class),
156156 TrinaryLogic ::createMaybe (),
157157 ],
158+ 19 => [
159+ new GenericClassStringType (TemplateTypeFactory ::create (
160+ TemplateTypeScope ::createWithFunction ('foo ' ),
161+ 'T ' ,
162+ null ,
163+ TemplateTypeVariance ::createInvariant (),
164+ )),
165+ new ConstantStringType ('array ' ),
166+ TrinaryLogic ::createNo (),
167+ ],
158168 ];
159169 }
160170
You can’t perform that action at this time.
0 commit comments