How to avoid `DivisionByZeroError`
For a code like this:
$lin = (int) (($value - $min) / ($d === 0.0 ? 0.5 : $d));
It is impossible for the error to occur. Nonetheless, this extension will produce an error in PHPStan. Is there a way to avoid it without editing the code itself?
It is, because $d === 0.0 ? 0.5 : $d is resolved as float, not SubtracedType<float, 0>. But this scenario must be implemented on the phpstan side. See https://github.com/phpstan/phpstan-src/pull/185
Ok, so in the meantime, is there any way at all to divide by variable without throwing this error?
@patrickkusebauch No, there's no way to ignore all cases with variable, but ignoring these cases by inline phpdoc as a temporary solution looks OK (https://phpstan.org/user-guide/ignoring-errors#ignoring-in-code-using-phpdocs).
It would be good if we could avoid this error by typing a variable as @var positive-int.