mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
qa: resolving psalm issues
- 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 <2189546+boesing@users.noreply.github.com>
This commit is contained in:
parent
cd3e294bfd
commit
f93ac70a0a
@ -2963,7 +2963,6 @@ class SimpleAssertionReconciler extends Reconciler
|
||||
|
||||
// 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;
|
||||
@ -2990,6 +2989,7 @@ class SimpleAssertionReconciler extends Reconciler
|
||||
// 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 can not contain `null` anymore.');
|
||||
$reconciled_types[] = Type::getLiteral($enum_case->value);
|
||||
}
|
||||
|
||||
@ -3001,10 +3001,11 @@ class SimpleAssertionReconciler extends Reconciler
|
||||
return null;
|
||||
}
|
||||
|
||||
assert($enum_case->value !== null, 'Verified enum type above, value can not contain `null` anymore.');
|
||||
$reconciled_types[] = Type::getLiteral($enum_case->value);
|
||||
}
|
||||
|
||||
return new Union($reconciled_types);
|
||||
return TypeCombiner::combine($reconciled_types, $codebase, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -269,7 +269,7 @@ abstract class Type
|
||||
return new TLiteralInt($value);
|
||||
}
|
||||
|
||||
return new TLiteralString($value);
|
||||
return TLiteralString::make($value);
|
||||
}
|
||||
|
||||
public static function getString(?string $value = null): Union
|
||||
|
Loading…
Reference in New Issue
Block a user