Skip to content

Generic.WhiteSpace.ScopeIndent false positive when using ternary operator with short arrays #2702

@SpazzMarticus

Description

@SpazzMarticus

Generic.WhiteSpace.ScopeIndent expects 4 more whitespace characters when using a ternary operator:

function failure($a)
{
    $a = $a === true ? [
        'a' => 1,
        'b' => 2,
        ] : [
        'a' => 100,
        'b' => 99,
    ]; //Line indented incorrectly; expected at least 8 spaces, found 4
}

Alternatives using ?: or ?? work fine with only 4 whitespace characters:

function success1($a)
{
    $a = $a === true ?: [
        'a' => 1,
        'b' => 2,
    ];
}

function success2($a)
{
    $a = $a === true ?? [
        'a' => 1,
        'b' => 2,
    ];
}

Is this expected behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions