Psalm: Some invalid operands not detected

Created on 22 Jun 2018  路  3Comments  路  Source: vimeo/psalm

from @Majkl578:

Invalid:

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

Valid:

echo "x" ^ "y";
echo 4 ^ 5;
bug

All 3 comments

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.

Yup, it's a modified example from https://github.com/phpstan/phpstan/issues/1082.

"x" ^ 1 is invalid though. #php

Good points, I've updated the ticket

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Pierstoval picture Pierstoval  路  3Comments

orklah picture orklah  路  3Comments

albe picture albe  路  3Comments

ErikBooijCB picture ErikBooijCB  路  4Comments

roukmoute picture roukmoute  路  3Comments