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
@require-extends
not recognized for @throws
#10475
Comments
Hmm, actually the interface can (in addition) extend But then I would still expect that the information added by the |
Yes, this should be supported, but you should |
Yes, 100% agreed. When finding out I could just |
@ondrejmirtes I might wanna try to fix this, depending on how easy the "easy fix" is :). Am I correct in that this is something which possibly PHPDocNodeResolver::resolveThrowsTags() should handle? By getting the (reflection?) class of the given type (in the Or is this possibly even something which could / should be handled by a |
No, this is just something the respective rule that reports this problem should handle. |
Which means iterating over the type(s) resolved by |
ClassReflection has a method to get |
Thanks. Then I'll try to fix this over the weekend 👍🏻 |
So I tried to get this working. But an issue I'm running into is when the declared So I presume this results in some specific handling where it needs to be checked if the Or another solution might be to recreate a type by replacing any type with an intersection of the named type combined with the types set in the What do you think about this? Is either of these directions correct? And which do you prefer then? Or is there some other solution I should choose for this? |
I don't know, just submit what you have as a PR and also add some tests that are failing. |
Done, as phpstan/phpstan-src#2890 |
Implemented phpstan/phpstan-src#2890 |
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
Personally I would expect that if I have an interface with
@phpstan-require-extends \Exception
that I can use@throws <this interface>
and it will work fine. This as it is known that every implementation of the interface will extend\Exception
and thus is a throwable. But this isn't the case, and an error is reported that " is not subtype of Throwable"Code snippet that reproduces the problem
https://phpstan.org/r/fe5464f1-7d2e-4570-a61f-c86b0a82b669
Expected output
No error
Did PHPStan help you today? Did it make you happy in any way?
No response
The text was updated successfully, but these errors were encountered: