Skip to content

Commit f7250db

Browse files
committed
Fix TemplateTypeMap::isEmpty()
1 parent cee6f68 commit f7250db

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Type/Generic/TemplateTypeMap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ public static function createEmpty(): self
6565

6666
public function isEmpty(): bool
6767
{
68-
return count($this->types) === 0;
68+
return $this->count() === 0;
6969
}
7070

7171
public function count(): int
7272
{
73-
return count($this->types);
73+
return count($this->types + $this->lowerBoundTypes);
7474
}
7575

7676
/** @return array<string,\PHPStan\Type\Type> */

tests/PHPStan/Type/Generic/TemplateTypeMapTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public function dataUnionWithLowerBoundTypes(): iterable
1515
'T' => new ObjectType(\Exception::class),
1616
]))->convertToLowerBoundTypes();
1717

18+
yield [
19+
$map,
20+
\Exception::class,
21+
];
22+
1823
yield [
1924
$map->union(new TemplateTypeMap([
2025
'T' => new ObjectType(\InvalidArgumentException::class),
@@ -51,6 +56,7 @@ public function dataUnionWithLowerBoundTypes(): iterable
5156
/** @dataProvider dataUnionWithLowerBoundTypes */
5257
public function testUnionWithLowerBoundTypes(TemplateTypeMap $map, string $expectedTDescription): void
5358
{
59+
$this->assertFalse($map->isEmpty());
5460
$t = $map->getType('T');
5561
$this->assertNotNull($t);
5662
$this->assertSame($expectedTDescription, $t->describe(VerbosityLevel::precise()));

0 commit comments

Comments
 (0)