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 when using array destructuring with exact indent checking #2479

Closed
dingo-d opened this issue Apr 14, 2019 · 3 comments

Comments

@dingo-d
Copy link

dingo-d commented Apr 14, 2019

I'm having issues with this sniff. If I don't use exact property (which I've read I shouldn't in the customisation wiki), then I may miss on over indented code (and I wouldn't like this). If I use it, the errors for over indentation will happen (yay), but then I get errors reported in destructured arrays inside class methods

class TestClass {
  public function test() {
    $options = [
      'enabled'     => true,
      'compression' => 'gzip',
    ];

    [
      'enabled'     => $enabled,
      'compression' => $compression,
    ] = $options;
  }
}

This will report issues on lines 9 and 10, telling me to indent them 4 instead of 6 spaces (I'm using 2 space indent without tabs).

When I write this outside class, I don't get any errors. Also just assigning an array to a variable doesn't cause any errors (in or out of class).

If I don't use exactthe error isn't shown, because I 'should' indent them 4 spaces, but they are indented 6 so it's not exact and it's ok (and it's not).

Is this a bug?

@gsherwood
Copy link
Member

Is this a bug?

Yes, I think there is something wrong here. This sniff disables exact indenting between arrays, but it's not working in this specific case. I think I know why though, so just looking into it.

@gsherwood gsherwood added this to Backlog in PHPCS v3 Development via automation Apr 14, 2019
@gsherwood gsherwood added this to the 3.5.0 milestone Apr 15, 2019
@gsherwood gsherwood changed the title Generic.WhiteSpace.ScopeIndent destructuring indentation error in class context? Generic.WhiteSpace.ScopeIndent error when using array destructuring with exact indent checking Apr 15, 2019
gsherwood added a commit that referenced this issue Apr 15, 2019
…ay destructuring with exact indent checking
@gsherwood
Copy link
Member

This is now fixed and will be in the next release. Thanks for reporting it.

PHPCS v3 Development automation moved this from Backlog to Ready for Release Apr 15, 2019
@dingo-d
Copy link
Author

dingo-d commented Apr 15, 2019

Awesome! Thanks!

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