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
callable type definition is not properly matched when using yield in a short arrow function #7031
Comments
Another example I just ran into : https://phpstan.org/r/7b966730-9115-483d-aee6-a491901fdb1a @ondrejmirtes You tagged it as easy fixes, any pointer as to how this could be fixed ? I might be willing to give it a try as it's quite impacting in my codebase (we use arrow functions a lot). |
The root issue is this: https://phpstan.org/r/ede09df7-f502-4c7f-89d8-3220607e818a Which means the problem is really specific only to arrow functions. Inspecting the code reveals that the handling of closures is much more complex than the handling of arrow functions, and it looks like there's some specific code to So the handling of long anonymous functions needs to somehow be replicated for arrow functions as well. |
I don't consider this a priority for myself or the project, but since it's blocking you, I'm willing to fix this for 500 EUR paid against an invoice I'd issue :) |
Sorry, it's not really blocking, just "too bad it doesn't work". 🤷♂️ |
Here are some other weird cases (using full function, not short arrow ones) :
Should I create separate issues / discussions for these ? (even though it all relates to "properly inferring the key of an iterable") |
Looks like a separate issue, please open a new one. |
Yet another case : https://phpstan.org/r/6e6ce30f-e130-42c3-8cff-59549be39e97 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Hello there,
I've already noticed in the past that PHPStan tends to report inspections when checking against a callable type depending on how the closure is written at call-site. I've had the issue again today and managed to reproduce it in the playground.
Code snippet that reproduces the problem
https://phpstan.org/r/7dc2492d-309e-4249-95f7-5250786a4e2c
Expected output
No inspection. The 4 different syntaxes (short+return, short+yield, full+return, full+yield) should all produce the same results.
Did PHPStan help you today? Did it make you happy in any way?
As always, it helps with my confidence when doing refactorings. :)
The text was updated successfully, but these errors were encountered: