diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7a4d38545e..592bca4964 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1425,6 +1425,12 @@ parameters: count: 1 path: src/Type/IntersectionType.php + - + rawMessage: 'Doing instanceof PHPStan\Type\Enum\EnumCaseObjectType is error-prone and deprecated. Use Type::getEnumCases() instead.' + identifier: phpstanApi.instanceofType + count: 1 + path: src/Type/IntersectionType.php + - rawMessage: Doing instanceof PHPStan\Type\IntersectionType is error-prone and deprecated. identifier: phpstanApi.instanceofType diff --git a/src/Type/IntersectionType.php b/src/Type/IntersectionType.php index e676153e02..5896143ac9 100644 --- a/src/Type/IntersectionType.php +++ b/src/Type/IntersectionType.php @@ -1345,6 +1345,10 @@ public function getFiniteTypes(): array foreach ($this->types as $type) { $oneType = []; foreach ($type->getFiniteTypes() as $finiteType) { + if ($finiteType instanceof EnumCaseObjectType) { + $oneType[$finiteType->getClassName() . '::' . $finiteType->getEnumCaseName()] = $finiteType; + continue; + } $oneType[$finiteType->describe(VerbosityLevel::typeOnly())] = $finiteType; } $compare[] = $oneType;