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

PHP tokenizer resolves bitwise xor operator as power operator #765

Closed
smatyas opened this issue Nov 11, 2015 · 2 comments
Closed

PHP tokenizer resolves bitwise xor operator as power operator #765

smatyas opened this issue Nov 11, 2015 · 2 comments

Comments

@smatyas
Copy link

smatyas commented Nov 11, 2015

The exponentiation arithmetic operator in PHP is **, and only exists since PHP 5.6
The ^ operator is only the bitwise XOR operator.

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

The wrong code is here: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Tokenizers/PHP.php#L1307

        case '^':
            $newToken['type'] = 'T_POWER';
            break;

I'm not familiar enough with PHP_CodeSniffer's code yet, so I cannot make a PR now, but I'm sure that this is a tokenizer bug.

@gsherwood
Copy link
Member

I'm pretty sure that's always been like that, and I have no idea why. Thanks for picking it up.

gsherwood added a commit that referenced this issue Nov 11, 2015
@smatyas
Copy link
Author

smatyas commented Nov 12, 2015

Thanks for the fix, great work! :)

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

No branches or pull requests

2 participants