Skip to content

"?:" sometimes triggers Squiz.ControlStructures.InlineIfDeclaration.SpacingAfterThen & SpacingBeforeElse #1311

Closed
@puggan

Description

@puggan
<?php
        $c = $argv[1] ?: "";
        $filepath = realpath($argv[1]) ?: $argv[1];

Line 3 triggers both Squiz.ControlStructures.InlineIfDeclaration.SpacingAfterThen & SpacingBeforeElse
Line 2 also uses "?:" but is fine

phpcs /tmp/s.php -s

phpcs /tmp/s.php -s

FILE: /tmp/s.php
-------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------------
 3 | ERROR | Inline shorthand IF statement requires 1 space after THEN; 0 found (Squiz.ControlStructures.InlineIfDeclaration.SpacingAfterThen)
 3 | ERROR | Inline shorthand IF statement requires 1 space before ELSE; 0 found (Squiz.ControlStructures.InlineIfDeclaration.SpacingBeforeElse)
-------------------------------------------------------------------------------------------------------------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions