-
Notifications
You must be signed in to change notification settings - Fork 545
Fix param-out generics via stubs #2952
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
Conversation
@rvanvelzen may I ask you for your opinion on these conditional types involved, as I think you are the expert :)?
I am wondering why we resolve @param differently compared to @param-out
phpstan-src/src/Reflection/ResolvedFunctionVariant.php
Lines 75 to 83 in 39dc97b
vs.
phpstan-src/src/Reflection/ResolvedFunctionVariant.php
Lines 85 to 93 in 39dc97b
harmonizing this does not yet make a difference though, as the conditional types involved are not ConditionalTypeForParameter for param-out. so I am wondering whether phpdoc-parser needs adjustments to produce ConditionalTypeForParameter instead of ConditionalType for param-out...?
The reason the added tests fail is because anonymous functions don't support phpdocs, so the parameter type is never set correctly.
Why sort etc. didn't work before is because coming from the signature map they're defined as PassedByReference::readsArgument() instead of PassedByReference::createsNewVariable(), so the out-type is never used.
As for the conditional parameters: it probably hasn't been a use-case for now. I didn't implement param-out types 😉
What was the issue you were trying to use @staabm
rsort seems to handle list/non-empty https://phpstan.org/r/3a1f2bc6-5d8d-4662-937a-f3b10c84fe43
should we close this ?
Also param out seems to support conditional
@VincentLanglet I think motivation is the comments in ee737e6#commitcomment-138984141
@VincentLanglet I think motivation is the comments in ee737e6#commitcomment-138984141
Then I think it can be close because the issue is solved for both rsort and custom method with generic conditional param out
https://phpstan.org/r/95c69276-87cf-4a5b-b436-fd571c5b0255
triggered by discussion in ee737e6#commitcomment-138984141