mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 09:37:59 +01:00
Fix a few type errors
This commit is contained in:
parent
a6850a8f3c
commit
5c132ba8b8
@ -401,10 +401,10 @@ abstract class Type
|
||||
throw new \InvalidArgumentException('You must pass at least one type to combineTypes');
|
||||
}
|
||||
|
||||
/** @var array<string,array<string,Union>> */
|
||||
/** @var array<string, array<string, Union>> */
|
||||
$key_types = [];
|
||||
|
||||
/** @var array<string,array<string,Union>> */
|
||||
/** @var array<string, array<string, Union>> */
|
||||
$value_types = [];
|
||||
|
||||
foreach ($types as $type) {
|
||||
@ -447,7 +447,7 @@ abstract class Type
|
||||
}
|
||||
elseif ($type instanceof ObjectLike) {
|
||||
if (!isset($value_types['object-like'])) {
|
||||
/** @var array<string,Union> */
|
||||
/** @var array<string, Union> */
|
||||
$value_types['object-like'] = [];
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,12 @@ class ParseTree
|
||||
throw new \InvalidArgumentException('Cannot parse comma in non-generic/array type');
|
||||
}
|
||||
|
||||
if (!$current_parent) {
|
||||
throw new \InvalidArgumentException('Cannot parse comma in with no parent node');
|
||||
}
|
||||
|
||||
if ($context_node->value === self::GENERIC && $current_parent->value !== self::GENERIC) {
|
||||
if (!$current_parent->parent->value) {
|
||||
if (!isset($current_parent->parent) || !$current_parent->parent->value) {
|
||||
throw new \InvalidArgumentException('Cannot parse comma in non-generic/array type');
|
||||
}
|
||||
|
||||
@ -110,7 +114,7 @@ class ParseTree
|
||||
do {
|
||||
$current_leaf = $current_leaf->parent;
|
||||
}
|
||||
while ($current_leaf->parent->value !== self::OBJECT_LIKE);
|
||||
while ($current_leaf->parent && $current_leaf->parent->value !== self::OBJECT_LIKE);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -163,6 +167,11 @@ class ParseTree
|
||||
}
|
||||
|
||||
$new_leaf = new self($type_token, $current_leaf->parent);
|
||||
|
||||
if (!isset($current_leaf->parent)) {
|
||||
throw new \InvalidArgumentException('Current leaf must have a parent');
|
||||
}
|
||||
|
||||
$current_leaf->parent->children[] = $new_leaf;
|
||||
|
||||
$current_leaf = $new_leaf;
|
||||
|
@ -160,13 +160,7 @@ class Union extends Type
|
||||
/** @return bool */
|
||||
public function isEmpty()
|
||||
{
|
||||
if ($this instanceof Atomic) {
|
||||
return $this->value === 'empty';
|
||||
}
|
||||
|
||||
if ($this instanceof Union) {
|
||||
return isset($this->types['empty']);
|
||||
}
|
||||
return isset($this->types['empty']);
|
||||
}
|
||||
|
||||
public function removeObjects()
|
||||
|
Loading…
Reference in New Issue
Block a user