Skip to content

Nested Anonymous Functions Causing False Negative [PSR2] #367

@baileylo

Description

@baileylo

The following code sample is valid in 1.5 but causes errors in 2.0.

bar([
    'foo' => foo(function () {
        return 'foo';
    })
]);
$ php vendor/bin/phpcs --standard=PSR2 -sv test.php
Registering sniffs in the PSR2 standard... DONE (40 sniffs registered)
Creating file list... DONE (1 files in queue)
Changing into directory /var/lib/phpcs-test/
Processing test.php [PHP => 35 tokens in 7 lines]... DONE in 3ms (1 errors, 0 warnings)

FILE: /var/lib/phpcs-test/test.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 7 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 0
   |       |     (Generic.WhiteSpace.ScopeIndent.Incorrect)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 25ms; Memory: 3.5Mb

I tested this specifically on 2.0.0, but am seeing it on master as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions