Skip to content

Dead catch - DivisionByZeroError when divisor is dynamic #6349

@gbirke

Description

@gbirke

Bug report

I have code that gets a divisor out of an array that might or might not exist or might be zero. I'm wrapping that with a try/catch block checking for DivisionByZeroError, but apparently PHPStan doesn't "see" that there is a division occurring with a dynamic divisor.

Code snippet that reproduces the problem

https://phpstan.org/r/ece3fd89-f67b-44ec-9e6a-b7b5c1b77b0e

Expected output

No output.

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

Today, PHPStan has helped me to detect unused properties, making my classes leaner and my code more readable. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions