Open fluffycondor opened 3 years ago
I found these snippets:
I vaguely remember reading that docblock with templates are not inherited by design but I couldn't find the source.
However, I think it would be really dangerous to do.
T
in Collection::toArray
docblock may not have the same signification than T
in ArrayCollection::toArray
because they're just letters. What about https://psalm.dev/r/5bde6e0da5? Should it be an error? Should it realize T was overrided by V in @implements and replace it by V automatically?
I really think you're better of repeating the docblock in the child
I found these snippets:
Should it be an error? Should it realize T was overrided by V in @implements and replace it by V automatically?
It's a complicated question. From my point of view, if you pass V to @implements, then it should be mapped to parent's T. What if you implement two interfaces like this: https://psalm.dev/r/7da72473ce You have no choice but to rename one template.
But if you consider {@inheritDoc}
as a dangerous behavior that shouldn't work, it works right now: https://psalm.dev/r/26c8d82b95
It is broken in the example in the first post, when you extends a class that have {@inheritDoc}
, but the class itself works fine, and generic annotations are inherited.
I found these snippets:
This is a simplified snippet of Doctrine's ArrayCollection: https://psalm.dev/r/562ef4433e When you try to extend ArrayCollection, you got erased generic types in all methods that documented as
{@inheritDoc}
. If you replace/** {@inheritDoc} */
on line 27 with/** @return array<TKey, T> */
, everything works as expected.