From 9a29c92c62deddf186271e6ccc161f407b517992 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 12 Jan 2026 09:22:39 +0100 Subject: [PATCH 1/3] Faster IntersectionType->getFiniteTypes() --- src/Type/IntersectionType.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Type/IntersectionType.php b/src/Type/IntersectionType.php index e676153e02..ef746e908f 100644 --- a/src/Type/IntersectionType.php +++ b/src/Type/IntersectionType.php @@ -54,6 +54,7 @@ use function in_array; use function is_int; use function ksort; +use function md5; use function sprintf; use function strcasecmp; use function strlen; @@ -1345,6 +1346,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; From 67e58f28faf0ba315a928c58bc344723b21bae57 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 12 Jan 2026 09:29:10 +0100 Subject: [PATCH 2/3] Update IntersectionType.php --- src/Type/IntersectionType.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Type/IntersectionType.php b/src/Type/IntersectionType.php index ef746e908f..5896143ac9 100644 --- a/src/Type/IntersectionType.php +++ b/src/Type/IntersectionType.php @@ -54,7 +54,6 @@ use function in_array; use function is_int; use function ksort; -use function md5; use function sprintf; use function strcasecmp; use function strlen; @@ -1347,7 +1346,7 @@ public function getFiniteTypes(): array $oneType = []; foreach ($type->getFiniteTypes() as $finiteType) { if ($finiteType instanceof EnumCaseObjectType) { - $oneType[$finiteType->getClassName().'::'.$finiteType->getEnumCaseName()] = $finiteType; + $oneType[$finiteType->getClassName() . '::' . $finiteType->getEnumCaseName()] = $finiteType; continue; } $oneType[$finiteType->describe(VerbosityLevel::typeOnly())] = $finiteType; From 3add726eb3261b792e700391bc8cbd016e843349 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 12 Jan 2026 09:40:05 +0100 Subject: [PATCH 3/3] Update phpstan-baseline.neon --- phpstan-baseline.neon | 6 ++++++ 1 file changed, 6 insertions(+) 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