1
0
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:
Matthew Brown 2017-04-07 00:19:55 -04:00
parent 40427839ea
commit 8910e4226c

View File

@ -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()) {