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

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

Closed
adriaanzon opened this issue Feb 1, 2020 · 1 comment

Comments

@adriaanzon
Copy link

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.

@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Feb 2, 2020
@gsherwood gsherwood added this to the 3.5.5 milestone Feb 2, 2020
gsherwood added a commit that referenced this issue Feb 2, 2020
gsherwood added a commit that referenced this issue Feb 2, 2020
@gsherwood
Copy link
Member

Thanks for reporting this. The fix will be in 3.5.5.

PHPCS v3 Development automation moved this from Idea Bank to Ready for Release Feb 2, 2020
tobias-trozowski pushed a commit to tobias-trozowski/PHP_CodeSniffer that referenced this issue Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PHPCS v3 Development
Ready for Release
Development

No branches or pull requests

2 participants