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 with static short closure #2570

Closed
sspat opened this issue Aug 1, 2019 · 5 comments
Closed

Generic.WhiteSpace.ScopeIndent error with static short closure #2570

sspat opened this issue Aug 1, 2019 · 5 comments

Comments

@sspat
Copy link

sspat commented Aug 1, 2019

Versions

codesniffer@dev-master
php 7.4.0beta1

Description

When adding static to a short syntax closure which is an argument of a multi-line function call an incorrect indent error is raised.

<?php

declare(strict_types=1);

$numbers = [1, 2, 3];

$result = array_map(
    static fn(int $number) : int => $number + 1,
    $numbers
);
 8 | [ERROR | [x] [Line indented incorrectly; expected 0 spaces, found 4 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)

Expected behavior

The same code with a non-static short closure raises no errors, the same should apply to a static one.

<?php

declare(strict_types=1);

$numbers = [1, 2, 3];

$result = array_map(
    fn(int $number) : int => $number + 1,
    $numbers
);
@jrfnl
Copy link
Contributor

jrfnl commented Aug 1, 2019

Arrow functions are not supported yet. Please see: #2523

@sspat
Copy link
Author

sspat commented Aug 1, 2019

@jrfnl Sorry, missed that one. What is the best way i can help with the issues i find for short closures currently, and is it helpful at all?

@jrfnl
Copy link
Contributor

jrfnl commented Aug 2, 2019

@sspat For now, not much can be done until a decision is taken about #2523 and the T_FN token is backfilled.

Once that's done, it'll be useful to know which sniffs need looking at. I'd suggest adding code samples like the one above and the other issues reported to the thread in #2523 to keep things together (or at the very least to link the issues by mentioning the canonical issue number).

For anything missed in the initial accounting for arrow functions, so things found after #2523 has been addressed and closed, new issues would seem appropriate.

@gsherwood
Copy link
Member

@sspat As @jrfnl, the best thing to do is put comments on the main issue so it can all be addressed at once. I'll merge the 3 issues you submitted with the main one, but can you please add more comments to #2523 if you come across more examples. Thanks.

@gsherwood gsherwood mentioned this issue Aug 9, 2019
6 tasks
@gsherwood
Copy link
Member

Closing as merged with #2523

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

No branches or pull requests

3 participants