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

Xor operation on strings on PHP 7.x is viewed as conversion to int #8094

Open
nach-code opened this issue Oct 2, 2022 · 1 comment
Open
Labels
Milestone

Comments

@nach-code
Copy link

PHP allows strings to be xor'd. From: https://www.php.net/manual/en/language.operators.bitwise.php

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. In all other cases, both operands will be converted to integers and the result will be an integer.

However, when this is done, PHPStan on PHP 7.x now thinks the string has been converted into an integer.

https://phpstan.org/r/12e63cdd-d516-4db2-a314-51da4f5c3101

The output should not have errors here, but PHPStan thinks that the string is now an int, that cannot be passed to base64_encode: Parameter #1 $str of function base64_encode expects string, int given.

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