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
In the following two examples, which make use of integer-backed enums, PHPStan seems to be certain that an integer variable has the value 0 after a switch statement, when that's not the case. As a result, it emits a misleading error message when the variable is tested:
In the second example, the error message also suggests that it may be confused about the value of the enumeration constants.
If the enums are removed and replaced by integers, PHPStan correctly reports no errors. Here are the plain integer (no-enum) equivalents of the cases above:
For the first two cases with integer-backed enums above, PHPStan should not have reported an error message. It should have behaved exactly like the pure integer non-enum cases.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan is integrated into our continuous integration pipeline. It improves code quality by helping catch easy-to-make but hard-to-spot errors straight away, during development. It also forces us to be more precise and to think more carefully about validation and error handling, therefore making the code more robust. One area where we can see an improvement is in code handling rare failure cases. Before PHPStan, it was more likely that glitches in such parts of the code would have made their way through to testing, or past testing - possibly until a long time after deployment - when that rare failure case actually occurred. Thank you PHPStan!
The text was updated successfully, but these errors were encountered:
Bug report
In the following two examples, which make use of integer-backed enums, PHPStan seems to be certain that an integer variable has the value 0 after a switch statement, when that's not the case. As a result, it emits a misleading error message when the variable is tested:
In the second example, the error message also suggests that it may be confused about the value of the enumeration constants.
If the enums are removed and replaced by integers, PHPStan correctly reports no errors. Here are the plain integer (no-enum) equivalents of the cases above:
Code snippet that reproduces the problem
See above
Expected output
For the first two cases with integer-backed enums above, PHPStan should not have reported an error message. It should have behaved exactly like the pure integer non-enum cases.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan is integrated into our continuous integration pipeline. It improves code quality by helping catch easy-to-make but hard-to-spot errors straight away, during development. It also forces us to be more precise and to think more carefully about validation and error handling, therefore making the code more robust. One area where we can see an improvement is in code handling rare failure cases. Before PHPStan, it was more likely that glitches in such parts of the code would have made their way through to testing, or past testing - possibly until a long time after deployment - when that rare failure case actually occurred. Thank you PHPStan!
The text was updated successfully, but these errors were encountered: