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

& bitwise operator is interpreted as "reference" operator by unary_operator_spaces #7861

Closed
niconoe- opened this issue Mar 1, 2024 · 0 comments · Fixed by #7862
Closed
Labels

Comments

@niconoe-
Copy link

niconoe- commented Mar 1, 2024

Bug report

Hi! Thank you for PHP-CS-Fixer! I'm having an issue with version 3.51.0 (and probably those before too).

Description

When trying to fix the current snippet, PHP-CS-Fixer wants to edit it the wrong way, interpreting the & character as a unary operator (for reference I guess) instead of bitwise operator "AND".

- static fn(Token $t): bool => 8 === ($t->flags & 8)
+ static fn(Token $t): bool => 8 === ($t->flags &8)

To me, this is incorrect as I have the binary_operator_spaces enabled which takes care of that bitwise operator.

I know it cold be super hard to detect how to interpret & character from static analysis, but at least maybe handling the case where right operand is a constant so it can't be a reference could help a bit? Or if you know a better way to handle this conflicting case…

Thanks a lot!

Runtime version

PHP-CS-Fixer: 3.51.0
PHP: 8.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant