Skip to content

Commit

Permalink
qa: resolving psalm issues
Browse files Browse the repository at this point in the history
- remove unused variable
- add assertion to reduce possible types from `TEnumCase`
- use `TypeCombiner` to provide proper `Union` containing all literals

Signed-off-by: Maximilian Bösing <[email protected]>
  • Loading branch information
boesing committed Aug 25, 2023
1 parent cd3e294 commit 9c9558a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2963,7 +2963,6 @@ private static function reconcileValueOf(

// For now, only enums are supported here
foreach ($assertion_type->type->getAtomicTypes() as $atomic_type) {
$class_name = null;
$enum_case_to_assert = null;
if ($atomic_type instanceof TClassConstant) {
$class_name = $atomic_type->fq_classlike_name;
Expand All @@ -2990,6 +2989,7 @@ private static function reconcileValueOf(
// For value-of<MyBackedEnum>, the assertion is meant to return *ANY* value of *ANY* enum case
if ($enum_case_to_assert === null) {
foreach ($class_storage->enum_cases as $enum_case) {
assert($enum_case->value !== null, 'Verified enum type above, value is either string or int.');
$reconciled_types[] = Type::getLiteral($enum_case->value);
}

Expand All @@ -3004,7 +3004,7 @@ private static function reconcileValueOf(
$reconciled_types[] = Type::getLiteral($enum_case->value);
}

return new Union($reconciled_types);
return TypeCombiner::combine($reconciled_types, $codebase, false, false);
}

/**
Expand Down

0 comments on commit 9c9558a

Please sign in to comment.