mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Prevent creating empty objectlike
This commit is contained in:
parent
73b5eb1530
commit
066b1e011e
@ -950,9 +950,18 @@ class FetchChecker
|
||||
? [$string_key_value => $keyed_assignment_type]
|
||||
: [];
|
||||
|
||||
$assignment_type = new Type\Union([
|
||||
new Type\Atomic\ObjectLike($properties)
|
||||
]);
|
||||
if ($properties) {
|
||||
$assignment_type = new Type\Union([
|
||||
new Type\Atomic\ObjectLike($properties)
|
||||
]);
|
||||
} else {
|
||||
$assignment_type = new Type\Union([
|
||||
new Type\Atomic\TArray([
|
||||
$key_type,
|
||||
$keyed_assignment_type
|
||||
])
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
if (!$keyed_assignment_type) {
|
||||
throw new \UnexpectedValueException('$keyed_assignment_type cannot be null');
|
||||
|
@ -687,6 +687,12 @@ class ExpressionChecker
|
||||
}
|
||||
} else {
|
||||
$item_value_type = Type::getMixed();
|
||||
|
||||
if ($item->key instanceof PhpParser\Node\Scalar\String_) {
|
||||
$property_types[$item->key->value] = Type::getMixed();
|
||||
} else {
|
||||
$can_create_objectlike = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user