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

Squiz.WhiteSpace.OperatorSpacing incorrectly adds space after bitwise operator #3922

Closed
2 tasks done
kkmuffme opened this issue Nov 14, 2023 · 3 comments
Closed
2 tasks done

Comments

@kkmuffme
Copy link

Describe the bug

Space added before bitwise or

Code sample

array_multisort(
	array_column( $test, 's' ),
	SORT_DESC,
	SORT_NATURAL|SORT_FLAG_CASE,
	$test
);

Custom ruleset

Using WordPress https://github.com/WordPress/WordPress-Coding-Standards

To reproduce

Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs test.php ...
  3. See error message displayed
Squiz.WhiteSpace.OperatorSpacing:216 replaced token 49 (T_BITWISE_OR on line ...

With phpcbf it get's autofixed to

array_multisort(
	array_column( $test, 's' ),
	SORT_DESC,
	SORT_NATURAL |SORT_FLAG_CASE,
	$test
);

Expected behavior

No error/change.

Afaik this worked correctly before.

Versions (please complete the following information)

Operating System Linux
PHP version 8.2
PHP_CodeSniffer version 3.7.2
Standard WordPress (however the error is in Squiz)
Install type composer

Please confirm:

  • I have searched the issue list and am not opening a duplicate issue.
  • I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
  • [] I have verified the issue still exists in the master branch of PHP_CodeSniffer.
@jrfnl
Copy link
Contributor

jrfnl commented Nov 14, 2023

Closing as invalid. This behaviour is unchanged. I've tested all the way back to PHPCS 2.6.0 and also tested with WPCS 2.3.0.

@jrfnl jrfnl closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2023
@kkmuffme
Copy link
Author

But it's still wrong - there's no code standard that wants a space before a binary or, is there?

@jrfnl
Copy link
Contributor

jrfnl commented Nov 15, 2023

But it's still wrong - there's no code standard that wants a space before a binary or, is there?

No, it's not wrong. Nearly all sniffs are opinionated in one way or another. Clearly the standard you are using is of the opinion that there should be a space as they selected and enabled this sniff.

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