Skip to content

Change of @throws handling in base classes report false positives #13696

@finwe

Description

@finwe

Bug report

Apparently, the change from #13258 started to report an error in Symfony Console, where the parent method is annotated with @throws and actually throws the exception, but the overriding method is not annotated and does not throw the exception.

Method App\Pricing\Console\AdHocDataCommand::execute() has Symfony\Component\Console\Exception\LogicException in PHPDoc  
         @throws tag but it's not thrown.                                                                                         
         🪪  throws.unusedType                                                                                                    
         💡  You can narrow the thrown type with PHPDoc tag @throws void. 

I was able to get rid of the error by setting tooWideImplicitThrows: false featureFlag to false, but i guess this is not the clean approach.

The error does not make much sense to me. What would be the correct way to mitigate this?

The error is reported only for a single symfony command in my codebase. The fact, that the command is final makes a difference, but the error is not reported for other final commands.

Code snippet that reproduces the problem

https://phpstan.org/r/56a58e40-719b-432e-8fdd-fe9bd577c9ad

Expected output

No errors expected for classes extending Symfony Console commands not throwing the LogicException

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions