-
Notifications
You must be signed in to change notification settings - Fork 546
Implements BackedEnumFromDynamicStaticMethodThrowTypeExtension #4156
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
base: 2.1.x
Are you sure you want to change the base?
Conversation
8746ed7 to
105dc08
Compare
105dc08 to
33866c1
Compare
ondrejmirtes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't want people to discourage from defensive code. I don't want to report an error when someone catches an exception because the argument type is only guarded with a PHPDoc for example.
| return $methodReflection->getThrowType(); | ||
| } | ||
|
|
||
| $valueType = $scope->getType($arguments[0]->value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getNativeType please
If I use This is the same than DynamicReturnTypeExtension which remove
Shouldn't it be at least conditioned by Or maybe but what I try to avoid is the error Can't the DynamicMethodThrowTypeExtension return a "BenevolentThrowType" then ? Something like an unchecked exception or an implicit throw point ? |
|
Friendly ping @ondrejmirtes Cf my comment #4156 (comment) I dunno how to move on this PR. If I use the nativeType as asked
Moreover I feel like writing is kinda weird, because it's the purpose of the method |
33866c1 to
843387f
Compare
|
I don't think the mutant is relevant because the whole if could be removed since there is later a check It's just an early return to reduce the computation. |
Closes phpstan/phpstan#13297
Currently, even doing a simple
Enum::from(1)where1is a value valid, reports missing@throwsphpdoc.