-
-
Notifications
You must be signed in to change notification settings - Fork 586
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
Add psalm specific generic return type for deserialize #1091
Conversation
These annotations tell the Psalm static analyser that the object returned by |
Im fine with this, but is there a way to test it? |
@goetas Probably if you want to have this work reliably you'd need need to add psalm to the build pipeline for serializer, firstly to check that it doesn't error when parsing this docblock, and then also to make sure that it infers the type correctly when a caller uses this method. For now you can see how this allows psalm to detect a spelling mistake when calling a function on the DTO at https://psalm.dev/r/1f725d788b |
thanks |
You're welcome, thanks for the quick response. Do you have any plan for when this would be in a release? I don't know if there are any set release dates or roadmaps for this project. |
this project does not have "time scheduled" releases. Generally when I have some time I create a changelog and do the release. |
Thanks @goetas . Let me know if you and other maintainers would like a PR to add psalm to the travis build. Psalm has a baselining feature so any issues it finds in when first set up don't have to be immediately fixed. |
Having some basic Psalm integration into the serializer would be very nice. I guess is not any easy task, but would be happy to see a PR with that |
@bdsl How are we supposed to annotate the classes that we pass to the |
@carusogabriel This PR didn't change anything about how you should use deserialize. It just means that when you write something like I'm not sure if that answers your question. |
I'm getting some PHPStan 0.12 errors, like:
|
@carusogabriel hmm, probably best to raise a new issue for that, either here or at https://github.com/phpstan/phpstan/issues , with a minimal reproducing example if possible. I haven't actually used PHPStan myself yet. |
@carusogabriel How did you get on? Will you make a new issue report? |
When I figure out what's happening in how to reproduce, yes, I'll report an issue here 👍 |
Ok, feel free to tag me in when you do - I might have some time to look into how to fix it. Worth linking to this PR as well. |
See https://psalm.dev/ and
https://medium.com/vimeo-engineering-blog/uncovering-php-bugs-with-template-a4ca46eb9aeb