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 error on multi-line function call with static closure argument #1761

Closed
hews opened this issue Nov 25, 2017 · 2 comments
Milestone

Comments

@hews
Copy link

hews commented Nov 25, 2017

When passing an anonymous function to another function (eg, array_map()), and putting both the called arguments on new lines, Generic.WhiteSpace.ScopeIndent identifies the arguments and correctly allows the following:

array_map(
    function ( $item ) {
        echo $item;
    },
    $some_array
);

However, when using the static keyword on the anonymous function, as in:

 1 | array_map(
 2 |     static function ( $item ) {
 3 |         echo $item;
 4 |     },
 5 |     $some_array
 6 | );

The following error is triggered:

  2 | ERROR | [x] Line indented incorrectly; expected 0 tabs, found 1 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
@hews hews changed the title Generic.WhiteSpace.ScopeIndent misses new scope on multi-line function call with static anonymous function argument Generic.WhiteSpace.ScopeIndent triggers error on multi-line function call with static anonymous function as an argument Nov 25, 2017
@Jasu
Copy link

Jasu commented Nov 27, 2017

Came here to report the same bug - this occurs with PHPCS 3.1.1.

@gsherwood gsherwood added this to the 3.2.0 milestone Nov 28, 2017
@gsherwood gsherwood changed the title Generic.WhiteSpace.ScopeIndent triggers error on multi-line function call with static anonymous function as an argument Generic.WhiteSpace.ScopeIndent error on multi-line function call with static closure argument Nov 28, 2017
gsherwood added a commit that referenced this issue Nov 28, 2017
…function call with static closure argument
@gsherwood
Copy link
Member

Error was caused by the sniff enforcing exact indent rules for method prefixes, but didn't ignore this for closures. Now it does, and the error is resolved.

Thanks for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants