Skip to content
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

Some invalid operands not detected #833

Closed
muglug opened this issue Jun 22, 2018 · 3 comments
Closed

Some invalid operands not detected #833

muglug opened this issue Jun 22, 2018 · 3 comments
Labels

Comments

@muglug
Copy link
Collaborator

muglug commented Jun 22, 2018

from @Majkl578:

Invalid:

echo "x" ^ 1;
echo "x" | new stdClass();

Valid:

echo "x" ^ "y";
echo 4 ^ 5;
@muglug muglug added the bug label Jun 22, 2018
@weirdan
Copy link
Collaborator

weirdan commented Jun 22, 2018

If both operands for the &, | and ^ operators are strings, then the operation will be performed on the ASCII values of the characters that make up the strings and the result will be a string.

http://php.net/manual/en/language.operators.bitwise.php

So echo "x" ^ "y"; is not invalid.

@Majkl578
Copy link

Majkl578 commented Jun 22, 2018

Yup, it's a modified example from phpstan/phpstan#1082.

"x" ^ 1 is invalid though. #php

@muglug
Copy link
Collaborator Author

muglug commented Jun 22, 2018

Good points, I've updated the ticket

@muglug muglug closed this as completed in 7e0928d Jan 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants