Skip to content

Commit 6373c84

Browse files
authored
Faster IntersectionType->getFiniteTypes()
1 parent 7c5aa63 commit 6373c84

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

phpstan-baseline.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,12 @@ parameters:
14251425
count: 1
14261426
path: src/Type/IntersectionType.php
14271427

1428+
-
1429+
rawMessage: 'Doing instanceof PHPStan\Type\Enum\EnumCaseObjectType is error-prone and deprecated. Use Type::getEnumCases() instead.'
1430+
identifier: phpstanApi.instanceofType
1431+
count: 1
1432+
path: src/Type/IntersectionType.php
1433+
14281434
-
14291435
rawMessage: Doing instanceof PHPStan\Type\IntersectionType is error-prone and deprecated.
14301436
identifier: phpstanApi.instanceofType

src/Type/IntersectionType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,10 @@ public function getFiniteTypes(): array
13451345
foreach ($this->types as $type) {
13461346
$oneType = [];
13471347
foreach ($type->getFiniteTypes() as $finiteType) {
1348+
if ($finiteType instanceof EnumCaseObjectType) {
1349+
$oneType[$finiteType->getClassName() . '::' . $finiteType->getEnumCaseName()] = $finiteType;
1350+
continue;
1351+
}
13481352
$oneType[$finiteType->describe(VerbosityLevel::typeOnly())] = $finiteType;
13491353
}
13501354
$compare[] = $oneType;

0 commit comments

Comments
 (0)