We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I would not expect to see this error since list<E> and array<int, E> are practically the same.
list<E>
array<int, E>
https://psalm.dev/r/25b06d9cfd
The text was updated successfully, but these errors were encountered:
I found these snippets:
<?php /** * @template E as object */ final class Foo { /** * @psalm-var list<E> * @var array<int, object> **/ private $elements; /** * @psalm-param array<array-key, E> $elements * @param array<int|string, object> $elements */ public function __construct(array $elements = []) { $this->elements = array_values($elements); } /** * @psalm-param E $element */ public function bar(int $index, object $element) : void { array_splice($this->elements, $index, 0, [$element]); } }
Psalm output (using commit 8926f1d): ERROR: PropertyTypeCoercion - 27:22 - $this->elements expects 'list<E:Foo as object>', parent type 'array<int, E:Foo as object>' provided
Sorry, something went wrong.
It shouldn't complain here, not for the reason you state (list and array<int,_> are different), but because array_splice on lists outputs lists.
list
array<int,_>
array_splice
5b4ed6b
No branches or pull requests
I would not expect to see this error since
list<E>
andarray<int, E>
are practically the same.https://psalm.dev/r/25b06d9cfd
The text was updated successfully, but these errors were encountered: