I am using phpstan version 0.12.92.
function sayHello(float $y): float {
$x = 0.0;
if($y > 0) {
$x += 1;
}
if($x > 0) {
return 5 / $x;
}
return 1.0;
}
Even though I check for > 0 before division, phpstan complains about division by zero:
Binary operation "/" between 5 and 0.0|1.0 results in an error.
Reproducer here
The same code changed to integers does not raise any issue.
I stumbled upon that issue while slowly increasing phpstan check level on a legacy codebase fixing all newly found code issues.
I really appreciate your great work on phpstan. Makes life much easier and code more reliable.
I am using phpstan version 0.12.92.
Even though I check for
> 0before division, phpstan complains about division by zero:Reproducer here
The same code changed to integers does not raise any issue.
I stumbled upon that issue while slowly increasing phpstan check level on a legacy codebase fixing all newly found code issues.
I really appreciate your great work on phpstan. Makes life much easier and code more reliable.