-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
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
Improve return types for psalm #321
Conversation
Psalm 5.16 has been released yesterday and adds many new issues. I guess we will have to add them to the baseline. |
Can you please run:
|
Psalm cannot always infer the types when not defining the CollectionInterface<Key, Value> type. This makes sure that psalm is aware of the implemented interface and the Collection class.
98ddf8d
to
e35bab9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! Much appreciated 👍
There's one missing thing. The CollectionDecorator class also needs to be updated with the same changes, and then it's good to go.
@drupol Missed that one as I haven't used it before 😅 . Will update soon! |
Merci ❤️ |
Tried to implement something similar for the CollectionDecorator but now phpstan is complaining. I will need to do more investigation to be able to fix this. |
Oh curious, what are the issues? |
After changing the /**
* @template UKey
* @template U
*
* @param iterable<UKey, U> $iterable
*
* @return CollectionInterface<UKey, U>&static<UKey, U>
*/
public static function fromIterable(iterable $iterable): CollectionInterface
{
return new static(Collection::fromIterable($iterable));
} I get the psalm error:
And phpstan spits out:
|
OK fair enough, let's not update Was the closing of the PR intentional ? |
Nope sorry :) |
OK cool ! :) Let me know when it's done for you and I'll take care of the rest. |
@Matth-- Is it ready to be merged for you? |
I would say yes for now. 🚀 I'd like to find the root of the problem when i have some more time. Might have to look at the psalm package then. |
OK, let's do that. Let me know if I can do further things to improve this project! Thanks again for your contribution, keep them coming 👍 |
Psalm cannot always infer the types when not defining the CollectionInterface<Key, Value> type. This makes sure that psalm is aware of the implemented interface and the Collection class.
This PR:
Still open for debate as it changes the static constructor types.