Skip to content

Commit

Permalink
Amend unionizeIterables to support TList
Browse files Browse the repository at this point in the history
https://psalm.dev/docs/annotating_code/type_syntax/array_types/#lists

> A list type is of the form list<SomeType>, where SomeType is any permitted union type supported by Psalm.
> 
> * `list` is a subtype of `array<int, mixed>`
> * `list<Foo>` is a subtype of `array<int, Foo>`.
  • Loading branch information
SignpostMarv authored Dec 17, 2019
1 parent 1dcd8ff commit 0981c34
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hooks/TestCaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ private static function unionizeIterables(Codebase $codebase, Type\Union $iterab
$value_types[] = $type->getGenericValueType();
} elseif ($type instanceof Type\Atomic\TNamedObject || $type instanceof Type\Atomic\TIterable) {
list($key_types[], $value_types[]) = $codebase->getKeyValueParamsForTraversableObject($type);
} elseif ($type instanceof Type\Atomic\TList) {
$key_types[] = Type::getInt();
$value_types[] = $type->type_param;
} else {
throw new \RuntimeException('unexpected type');
}
Expand Down

0 comments on commit 0981c34

Please sign in to comment.