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 false positive when using negation with string concat #3170

Closed
wants to merge 1 commit into from

Conversation

simPod
Copy link

@simPod simPod commented Nov 21, 2020

I don't know how to fix but OperatorSpacing sniff wrongly requires space when negating var/constant in string concatenation

Ok, I don't understand how this test was meant. My point I was trying to make is that

private const A = -PHP_INT_MAX; // is valid
private const B = 'a ' . -PHP_INT_MAX; // is not valid
private const C = 'a ' . - PHP_INT_MAX; // is valid

I cannot negate a constant when used within string concatenation without having a space after negation.

@gsherwood gsherwood changed the title Add failing Operator spacing test Squiz.WhiteSpace.OperatorSpacing false positive when using negation with string concat Nov 23, 2020
@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Nov 23, 2020
@gsherwood gsherwood added this to the 3.6.0 milestone Nov 23, 2020
@gsherwood
Copy link
Member

The issues exists in the Squiz sniffs, but it also impacts the PSR12 sniff as it extends that Squiz one.

gsherwood added a commit that referenced this pull request Nov 23, 2020
gsherwood added a commit that referenced this pull request Nov 23, 2020
@gsherwood
Copy link
Member

Thanks a lot of this bug report. I didn't end up merging you PR as I put tests into the main Squiz sniff where the fix needed to go, but the code samples were clear and helpful. This fix will be in the 3.6.0 release.

@gsherwood gsherwood closed this Nov 23, 2020
PHPCS v3 Development automation moved this from Idea Bank to Ready for Release Nov 23, 2020
@simPod
Copy link
Author

simPod commented Nov 24, 2020

Thank you, appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PHPCS v3 Development
Ready for Release
Development

Successfully merging this pull request may close these issues.

None yet

2 participants