Skip to content

Commit

Permalink
allow collapsing enum cases under named object in combiner
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Feb 12, 2022
1 parent 6355597 commit 60feb5f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Psalm/Internal/Type/TypeCombiner.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Psalm\Type\Atomic\TClassString;
use Psalm\Type\Atomic\TClassStringMap;
use Psalm\Type\Atomic\TEmptyMixed;
use Psalm\Type\Atomic\TEnumCase;
use Psalm\Type\Atomic\TFalse;
use Psalm\Type\Atomic\TFloat;
use Psalm\Type\Atomic\TGenericObject;
Expand Down Expand Up @@ -334,6 +335,11 @@ public static function combine(
}

if ($combination->named_object_types !== null) {
foreach ($combination->value_types as $key => $atomic_type) {
if ($atomic_type instanceof TEnumCase && isset($combination->named_object_types[$atomic_type->value])) {
unset($combination->value_types[$key]);
}
}
$combination->value_types += $combination->named_object_types;
}

Expand Down

0 comments on commit 60feb5f

Please sign in to comment.