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.OperatorSpacingSniff doesn't detect negative numbers correctly #429

Closed
Konafets opened this issue Jan 12, 2015 · 4 comments

Comments

@Konafets
Copy link
Contributor

The sniff doesn't check the right withespace. The following code doesn't raise an error. I would expect that there is no whitespace allowed after the minus operator.

$y = - 10 + 2;
@gsherwood
Copy link
Member

You can use the Squiz.Formatting.OperatorBracket sniff if you want to enforce this. The error message you get is No space allowed between minus sign and number.

The OperatorSpacing sniff is only concerned with arithmetic operators and specifically excludes minus signs that are used for making a number negative.

@Konafets
Copy link
Contributor Author

I will look into that. Thanks!

@carusogabriel
Copy link
Contributor

@gsherwood I come with this same issue with the following code:

$x = -1;

My ruleset in specific forbids "useless" parentheses, witch the OperatorBracket enforces them. Is there another way to fix this issue with negative numbers?

@jrfnl
Copy link
Contributor

jrfnl commented May 22, 2019

@carusogabriel I have a suspicion that this is fixed in commit 82366db which is part of PR #2456.

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

No branches or pull requests

4 participants