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
New annotation: @psalm-if-this-is on methods #3782
Conversation
Not sure if the types should be compared with equality or with something else? |
You should instead use |
👍 |
@muglug Even when using |
This is seriously useful, can't wait to see it merged! :) |
Didn't work on it much lately. Maybe should give it another go... |
Hi @olleharstedt! Do you intend to work on that again? |
Maybe, if there's interest. Alternatively help someone else take over. I was waiting for muglug to respond to my comment, but now I've learned he's not involved in Vimeo and Psalm anymore. I don't know even know if anyone is merging or reviewing pull requests at the moment. I'd probably have to start a new PR, I assume lots have changed the last year... |
That would be me.
Me and @orklah (and anyone interested in doing that, really). |
Oh, ok! Well, this feature kind of need alias control to be tight. You want to close old PRs? |
No rush, I just wanted to clean up PR is they were abandoned, but we can keep this open if needed |
Right. Here are some brainfarts I wrote down related to a possible no-alias feature, needed to make type-state safe: #3766 One use-case for this feature is a type-safe query builder, as discussed here: #3740 |
I think it could even be used in Psalm's tests itself instead of using an external array of assertions |
Not sure I get it. What could be used? What's an external array of assertions? |
This is what a unit test looks like in Psalm: https://github.com/vimeo/psalm/blob/master/tests/ArgTest.php#L23 it's a little code snippet with variable and the goal is to make Psalm succeed (by not emitting any issue). The other goal is to make variables in the snippet match an assertion array provided just below where each variable must match with a type. This works great but it's limited to variable in the global scope (I think). With @psalm-if-this-is, I think we should be able to insert those assertions anywhere in the snippet |
Resumed work on this PR in https://github.com/zoonru/psalm/tree/if-this-is, IDK if I should make a separate PR :) |
Awesome! Yes, open a new PR and then I'll close this one. |
As discussed: #3740
Todo in another PR:
psalm-self-out
should change topsalm-this-out
.Ignore the commit history, it's because I'm using the same fork for all my PRs. Or I'm stupid. 😄