-
Notifications
You must be signed in to change notification settings - Fork 546
Fix bitwise on mixed #4423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bitwise on mixed #4423
Conversation
| { | ||
| $mask = substr($mask, 0, strlen($data)); | ||
| $data ^= $mask; | ||
| return(base64_encode($data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was reporting an error on level 5 on php 7.4 https://phpstan.org/r/12e63cdd-d516-4db2-a314-51da4f5c3101
d80297a to
ca5edd1
Compare
ca5edd1 to
34385de
Compare
| { | ||
| assertType('int', $a & $b); | ||
| assertNativeType('int', $a & $b); | ||
| assertNativeType('*ERROR*', $a & $b); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to mixed & mixed which is now reported as an error. (we can't be sure it's an int, it could be string & string for instance or worst, int & string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we can't know what it is, why is it an ERROR then? shouldn't it be mixed instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current mixed behavior is weird. A good example of the issue is
int ^ mixed = ? // currently int ; so no error is reported InvalidBinaryOperationRule
string ^ mixed = ? // currently Error ; an error is reported by InvalidBinaryOperationRule
mixed ^ mixed = ? // currently int ; so no error is reported by InvalidBinaryOperationRule
I'm not sure what should be done. Either error for all or something like
int ^ mixed = int
string ^ mixed = string
mixed ^ mixed = (int|string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried another solution, tell me your opinion about it @staabm :)
5866d4a to
6e91d05
Compare
6e91d05 to
03cd5a4
Compare
|
Thank you! |
Closes phpstan/phpstan#8094