This is a bit of a nitpick, but should be an easy fix and I actually ran into this.
Please consider the following code:
https://phpstan.org/r/4cc8f7c3-c43f-478d-ad29-dfdb1f168c04
<?php
function foo(): void {
try {
trigger_error("hello", E_USER_ERROR);
print "world\n";
}
catch (\Exception $e) {}
print "reachable\n";
}
It gives the following errors:
6 Unreachable statement - code above always terminates.
8 Dead catch - Exception is never thrown in the try block.
9 Unreachable statement - code above always terminates.
Of those, only the one at the line 6 print "world\n"; is correct, as this
line is indeed not reachable.
But the catch and the subsequent unreachable statement are false positive,
as demonstrated by this snippet:
https://3v4l.org/FERFO
set_error_handler(function($c, $m) {
print "ERR: $m\n";
throw new \Exception("foo");
});
foo();
So the idea is that E_USER_ERROR can either terminate or throw.
This is a bit of a nitpick, but should be an easy fix and I actually ran into this.
Please consider the following code:
https://phpstan.org/r/4cc8f7c3-c43f-478d-ad29-dfdb1f168c04
It gives the following errors:
Of those, only the one at the line 6
print "world\n";is correct, as thisline is indeed not reachable.
But the catch and the subsequent unreachable statement are false positive,
as demonstrated by this snippet:
https://3v4l.org/FERFO
So the idea is that
E_USER_ERRORcan either terminate or throw.