-
-
Notifications
You must be signed in to change notification settings - Fork 934
Open
Description
Bug report
Following this update in version 2.1.31, a new parameter checkTooWideReturnTypesInProtectedAndPublicMethods was added to look for unexpectedly thrown exceptions in protected/public methods.
However this seems to work only for methods inheriting from a parent.
See : https://phpstan.org/r/12bd44c9-c653-4ef9-9b23-e57509f35255
However, checkTooWideThrowTypesInProtectedAndPublicMethods: true cannot be set in playground.
The result is :
------ ---------------------------------------------------------------------------
Line Foo.php
------ ---------------------------------------------------------------------------
25 Method Bar::foo() has MyOtherE in PHPDoc @throws tag but it's not thrown.
🪪 throws.unusedType
------ ---------------------------------------------------------------------------
Reading the code from TooWideMethodThrowTypeRule, I believe it is linked to the $isFirstDeclaration check but I am afraid I am not sure of the purpose.
Code snippet that reproduces the problem
https://phpstan.org/r/12bd44c9-c653-4ef9-9b23-e57509f35255
Expected output
------ ---------------------------------------------------------------------------
Line Foo.php
------ ---------------------------------------------------------------------------
12 Method Foo::foo() has MyOtherE in PHPDoc @throws tag but it's not thrown.
🪪 throws.unusedType
25 Method Bar::foo() has MyOtherE in PHPDoc @throws tag but it's not thrown.
🪪 throws.unusedType
------ ---------------------------------------------------------------------------
Did PHPStan help you today? Did it make you happy in any way?
Everyday 🫶
Metadata
Metadata
Assignees
Labels
No labels