Skip to content

Generic.WhiteSpace.ScopeIndent false positive with arrow function inside array #2849

Closed
@adriaanzon

Description

@adriaanzon

With the following code:

<?php

namespace App\Nova;

class Song
{
    public function fields(Request $request): array
    {
        return [
            Url::make('View Song', fn($song) => $song->url())
                ->onlyOnDetail(),

            new Panel('Information', [
                Text::make('Title')
            ]),
        ];
    }
}

I get this output:

phpcs -s test.php --standard=PSR12

FILE: /Users/adriaan/test.php
----------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------
 15 | ERROR | [x] Line indented incorrectly; expected at least 16 spaces, found 12
    |       |     (Generic.WhiteSpace.ScopeIndent.Incorrect)
----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------

Time: 53ms; Memory: 6MB

When I remove the method call after the arrow function (->onlyOnDetail()), the error goes away.

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