You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Essentially, a case where we want to do an explicit try/catch because expectExceptionObject() doesn't cut it (want to catch a Throwable instead of test some state of the exception besides message/code), it is easy to forget a fail() statement and leading to a risky test.
Maybe it leading as a risky is fine... But maybe it's a kinda of issue that PHPStan could detect & report. Just an idea.
Did PHPStan help you today? Did it make you happy in any way?
Today it did not help, but I didn't run it either so cannot blame it :) I like PHPStan otherwise!
in this simple example, I think we could e.g. detect that there is a path thru the test which does not contain any assertions.
but as soon as there would be a singe assertion in the try-block this would no longer work.
I think this is another application of a "missing return" rule idea. There could be an ExecutionEndNode rule, looking at statement throw points, and if there's not a single throw point for AssertionFailedError, then report an error.
Activity
staabm commentedon Nov 19, 2025
I think this might be hard to detect.
in this simple example, I think we could e.g. detect that there is a path thru the test which does not contain any assertions.
but as soon as there would be a singe assertion in the try-block this would no longer work.
ondrejmirtes commentedon Nov 19, 2025
I think this is another application of a "missing return" rule idea. There could be an ExecutionEndNode rule, looking at statement throw points, and if there's not a single throw point for
AssertionFailedError, then report an error.