mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Allow scalar type refinement
This commit is contained in:
parent
40427839ea
commit
8910e4226c
@ -340,6 +340,20 @@ class TypeChecker
|
||||
}
|
||||
}
|
||||
|
||||
if ($new_var_type === 'scalar') {
|
||||
$scalar_types = [];
|
||||
|
||||
foreach ($existing_var_type->types as $type) {
|
||||
if ($type instanceof Scalar) {
|
||||
$scalar_types[] = $type;
|
||||
}
|
||||
}
|
||||
|
||||
if ($scalar_types) {
|
||||
return new Type\Union($scalar_types);
|
||||
}
|
||||
}
|
||||
|
||||
$new_type = Type::parseString($new_var_type);
|
||||
|
||||
if ($existing_var_type->isMixed()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user