Math
Math copied to clipboard
Type hinting PHPStan for Facing
It may be useful to specify the expected return type of Facing functions with: value-of<Facing::ALL>.
This can break many static analyses, because depending on the PHPstan levels, it will carry over if you pass a simple integer into a function accepting just a few values.
I think this option is worth considering, as it could prevent certain runtime errors in the event of an unaccepted value being supplied?
A better option is likely to just turn Facing into an enum. The PHPStan annotations of that sort have caused a great deal of headaches in the past due to easily lost type information when doing almost anything with the values.