diff --git a/src/Type/TypeCombinator.php b/src/Type/TypeCombinator.php index 1958c21029..3e56b8c24a 100644 --- a/src/Type/TypeCombinator.php +++ b/src/Type/TypeCombinator.php @@ -23,8 +23,6 @@ class TypeCombinator { - private const CONSTANT_SCALAR_UNION_THRESHOLD = 8; - public static function addNull(Type $type): Type { return self::union($type, new NullType()); @@ -289,15 +287,6 @@ public static function union(Type ...$types): Type continue; } foreach ($scalarTypeItems as $type) { - if (count($scalarTypeItems) > self::CONSTANT_SCALAR_UNION_THRESHOLD) { - $types[] = $type->generalize(GeneralizePrecision::moreSpecific()); - - if ($type instanceof ConstantStringType) { - continue; - } - - break; - } $types[] = $type; } } diff --git a/tests/PHPStan/Analyser/data/bug-2677.php b/tests/PHPStan/Analyser/data/bug-2677.php index aaf1201b2f..c191dd1f3d 100644 --- a/tests/PHPStan/Analyser/data/bug-2677.php +++ b/tests/PHPStan/Analyser/data/bug-2677.php @@ -44,6 +44,6 @@ function () assertType('array(\'Bug2677\\\\A\', \'Bug2677\\\\B\', \'Bug2677\\\\C\', \'Bug2677\\\\D\', \'Bug2677\\\\E\', \'Bug2677\\\\F\', \'Bug2677\\\\G\', \'Bug2677\\\\H\', \'Bug2677\\\\I\', \'Bug2677\\\\J\', \'Bug2677\\\\K\', \'Bug2677\\\\L\', \'Bug2677\\\\M\', \'Bug2677\\\\N\', \'Bug2677\\\\O\', \'Bug2677\\\\P\')', $classes); foreach ($classes as $class) { - assertType('class-string', $class); + assertType('\'Bug2677\\\\A\'|\'Bug2677\\\\B\'|\'Bug2677\\\\C\'|\'Bug2677\\\\D\'|\'Bug2677\\\\E\'|\'Bug2677\\\\F\'|\'Bug2677\\\\G\'|\'Bug2677\\\\H\'|\'Bug2677\\\\I\'|\'Bug2677\\\\J\'|\'Bug2677\\\\K\'|\'Bug2677\\\\L\'|\'Bug2677\\\\M\'|\'Bug2677\\\\N\'|\'Bug2677\\\\O\'|\'Bug2677\\\\P\'', $class); } }; diff --git a/tests/PHPStan/Type/TypeCombinatorTest.php b/tests/PHPStan/Type/TypeCombinatorTest.php index aa3c4ac0cb..86ceaae854 100644 --- a/tests/PHPStan/Type/TypeCombinatorTest.php +++ b/tests/PHPStan/Type/TypeCombinatorTest.php @@ -841,8 +841,8 @@ public function dataUnion(): array new ConstantStringType('loremm'), new ConstantStringType('loremmm'), ], - IntersectionType::class, - 'non-empty-string', + UnionType::class, + "'bar'|'barr'|'baz'|'bazz'|'foo'|'fooo'|'lorem'|'loremm'|'loremmm'", ], [ [