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

NoSpaceAfter reported on -INF const with PSR12 and Squiz rulesets #3695

Closed
p4veI opened this issue Oct 17, 2022 · 4 comments
Closed

NoSpaceAfter reported on -INF const with PSR12 and Squiz rulesets #3695

p4veI opened this issue Oct 17, 2022 · 4 comments

Comments

@p4veI
Copy link

p4veI commented Oct 17, 2022

Describe the bug
I'm using the INF const in our codebase along with a case for -INF, this triggers rule Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter on the following example, which is unexpected.

Code sample

return match ($value) {
        'Infinity' => INF,
        '-Infinity' => -INF,
        default => (float) $value,
};

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
ERROR | [x] Expected at least 1 space after "-"; 0 found (PSR12.Operators.OperatorSpacing.NoSpaceAfter)
ERROR | [x] Expected 1 space after "-"; 0 found (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)

Expected behavior
space after - is not required

Versions (please complete the following information):

  • PHP: 8.1
  • PHPCS: 3.7.1
  • Standard: Slevomat, PSR12, Squiz

Additional context
this also conflicts with SlevomatCodingStandard.Operators.NegationOperatorSpacing.InvalidSpaceAfterMinus that correctly recognises INF as a number

@jrfnl
Copy link
Contributor

jrfnl commented Oct 17, 2022

Duplicate. This was already fixed by #3653 which will be included in the PHPCS 3.7.2 release.

@jrfnl
Copy link
Contributor

jrfnl commented Oct 17, 2022

P.S.: the issue has nothing to do with INF, but everything with match constructs.

@p4veI
Copy link
Author

p4veI commented Oct 17, 2022

my bad, thx!

@jrfnl
Copy link
Contributor

jrfnl commented Oct 17, 2022

I suggest you close the issue as it has already been fixed.

@p4veI p4veI closed this as completed Oct 17, 2022
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

2 participants