From 1b6482cd046aacc1c3e137f8850d84035e19b22b Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 23 Dec 2025 11:35:58 +0100 Subject: [PATCH 1/4] Speedup TypeCombinator --- src/Type/TypeCombinator.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Type/TypeCombinator.php b/src/Type/TypeCombinator.php index b4a8a0152e..8b5d141366 100644 --- a/src/Type/TypeCombinator.php +++ b/src/Type/TypeCombinator.php @@ -204,21 +204,22 @@ public static function union(Type ...$types): Type if ($types[$i]->isBoolean()->yes()) { $hasGenericScalarTypes[ConstantBooleanType::class] = true; } - if ($types[$i]->isFloat()->yes()) { + else if ($types[$i]->isFloat()->yes()) { $hasGenericScalarTypes[ConstantFloatType::class] = true; } - if ($types[$i]->isInteger()->yes() && !$types[$i] instanceof IntegerRangeType) { + else if ($types[$i]->isInteger()->yes() && !$types[$i] instanceof IntegerRangeType) { $hasGenericScalarTypes[ConstantIntegerType::class] = true; } - if ($types[$i]->isString()->yes() && $types[$i]->isClassString()->no() && TypeUtils::getAccessoryTypes($types[$i]) === []) { + else if ($types[$i]->isString()->yes() && $types[$i]->isClassString()->no() && TypeUtils::getAccessoryTypes($types[$i]) === []) { $hasGenericScalarTypes[ConstantStringType::class] = true; - } - $enumCases = $types[$i]->getEnumCases(); - if (count($enumCases) === 1) { - $enumCaseTypes[$types[$i]->describe(VerbosityLevel::cache())] = $types[$i]; + } else { + $enumCases = $types[$i]->getEnumCases(); + if (count($enumCases) === 1) { + $enumCaseTypes[$types[$i]->describe(VerbosityLevel::cache())] = $types[$i]; - unset($types[$i]); - continue; + unset($types[$i]); + continue; + } } if ($types[$i] instanceof IntegerRangeType) { From 45309c4711e7a8b7b0cc31e1efa18c96f6fa4782 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 23 Dec 2025 11:38:51 +0100 Subject: [PATCH 2/4] cs --- src/Type/TypeCombinator.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Type/TypeCombinator.php b/src/Type/TypeCombinator.php index 8b5d141366..549e9e7a80 100644 --- a/src/Type/TypeCombinator.php +++ b/src/Type/TypeCombinator.php @@ -203,14 +203,11 @@ public static function union(Type ...$types): Type } if ($types[$i]->isBoolean()->yes()) { $hasGenericScalarTypes[ConstantBooleanType::class] = true; - } - else if ($types[$i]->isFloat()->yes()) { + } elseif ($types[$i]->isFloat()->yes()) { $hasGenericScalarTypes[ConstantFloatType::class] = true; - } - else if ($types[$i]->isInteger()->yes() && !$types[$i] instanceof IntegerRangeType) { + } elseif ($types[$i]->isInteger()->yes() && !$types[$i] instanceof IntegerRangeType) { $hasGenericScalarTypes[ConstantIntegerType::class] = true; - } - else if ($types[$i]->isString()->yes() && $types[$i]->isClassString()->no() && TypeUtils::getAccessoryTypes($types[$i]) === []) { + } elseif ($types[$i]->isString()->yes() && $types[$i]->isClassString()->no() && TypeUtils::getAccessoryTypes($types[$i]) === []) { $hasGenericScalarTypes[ConstantStringType::class] = true; } else { $enumCases = $types[$i]->getEnumCases(); From 24ec0f8cf24e0bab45207da14e881cfd6bc228f7 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 23 Dec 2025 11:44:31 +0100 Subject: [PATCH 3/4] Update TypeCombinator.php --- src/Type/TypeCombinator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Type/TypeCombinator.php b/src/Type/TypeCombinator.php index 549e9e7a80..c0aecedea1 100644 --- a/src/Type/TypeCombinator.php +++ b/src/Type/TypeCombinator.php @@ -201,6 +201,7 @@ public static function union(Type ...$types): Type unset($types[$i]); continue; } + if ($types[$i]->isBoolean()->yes()) { $hasGenericScalarTypes[ConstantBooleanType::class] = true; } elseif ($types[$i]->isFloat()->yes()) { From d0e370b4503c3d554c73a9e85ecb4c33ac23c598 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 23 Dec 2025 11:47:52 +0100 Subject: [PATCH 4/4] Update TypeCombinator.php --- src/Type/TypeCombinator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Type/TypeCombinator.php b/src/Type/TypeCombinator.php index c0aecedea1..e0a6767b98 100644 --- a/src/Type/TypeCombinator.php +++ b/src/Type/TypeCombinator.php @@ -201,7 +201,7 @@ public static function union(Type ...$types): Type unset($types[$i]); continue; } - + if ($types[$i]->isBoolean()->yes()) { $hasGenericScalarTypes[ConstantBooleanType::class] = true; } elseif ($types[$i]->isFloat()->yes()) {