Skip to content

Commit c56d866

Browse files
committed
Remove TypeCombinator::CONSTANT_SCALAR_UNION_THRESHOLD
1 parent 66fb725 commit c56d866

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

src/Type/TypeCombinator.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
class TypeCombinator
2424
{
2525

26-
private const CONSTANT_SCALAR_UNION_THRESHOLD = 8;
27-
2826
public static function addNull(Type $type): Type
2927
{
3028
return self::union($type, new NullType());
@@ -289,15 +287,6 @@ public static function union(Type ...$types): Type
289287
continue;
290288
}
291289
foreach ($scalarTypeItems as $type) {
292-
if (count($scalarTypeItems) > self::CONSTANT_SCALAR_UNION_THRESHOLD) {
293-
$types[] = $type->generalize(GeneralizePrecision::moreSpecific());
294-
295-
if ($type instanceof ConstantStringType) {
296-
continue;
297-
}
298-
299-
break;
300-
}
301290
$types[] = $type;
302291
}
303292
}

tests/PHPStan/Analyser/data/bug-2677.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ function ()
4444
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);
4545

4646
foreach ($classes as $class) {
47-
assertType('class-string', $class);
47+
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);
4848
}
4949
};

tests/PHPStan/Type/TypeCombinatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,8 @@ public function dataUnion(): array
841841
new ConstantStringType('loremm'),
842842
new ConstantStringType('loremmm'),
843843
],
844-
IntersectionType::class,
845-
'non-empty-string',
844+
UnionType::class,
845+
"'bar'|'barr'|'baz'|'bazz'|'foo'|'fooo'|'lorem'|'loremm'|'loremmm'",
846846
],
847847
[
848848
[

0 commit comments

Comments
 (0)