Skip to content

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

@p4veI

Description

@p4veI

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions