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.Arrays.ArrayIndent is indenting sub-arrays incorrectly when comma not used after the last value #1881

Closed
michaelarnauts opened this issue Feb 7, 2018 · 1 comment
Milestone

Comments

@michaelarnauts
Copy link

Generic.Arrays.ArrayIndentSniff is indenting the first line of the last entry incorrectly.

<?php

return [
    [
        'id' => 1,
        'status' => 2,
    ],
    [
        'id' => 2,
        'status' => 2,
    ],
    [
        'id' => 3, // <- line 13
        'status' => 2,
    ] // <- no comma
];

Throws:

 13 | ERROR | [x] Array key not indented correctly; expected 4 spaces but found 8 (Generic.Arrays.ArrayIndent.KeyIncorrect)

When indenting it with 4 spaces:

 13 | ERROR | [x] Array key not indented correctly; expected 8 spaces but found 4 (Generic.Arrays.ArrayIndent.KeyIncorrect)

And now, for fun, when indenting it with 6 spaces.

 13 | ERROR | [x] Array key not indented correctly; expected 4 spaces but found 6 (Generic.Arrays.ArrayIndent.KeyIncorrect)
 13 | ERROR | [x] Array key not indented correctly; expected 8 spaces but found 6 (Generic.Arrays.ArrayIndent.KeyIncorrect)

I did notice that when I add an comma to the last item (marked with // <- no comma), the Sniff works fine.

@gsherwood gsherwood added this to the 3.3.0 milestone Mar 19, 2018
@gsherwood gsherwood changed the title Generic.Arrays.ArrayIndentSniff is indenting the last entry incorrectly Generic.Arrays.ArrayIndentSniff is indenting sub-array entries incorrectly when a comma is not used after the last value Mar 19, 2018
@gsherwood gsherwood changed the title Generic.Arrays.ArrayIndentSniff is indenting sub-array entries incorrectly when a comma is not used after the last value Generic.Arrays.ArrayIndent is indenting sub-array entries incorrectly when a comma is not used after the last value Mar 19, 2018
@gsherwood gsherwood changed the title Generic.Arrays.ArrayIndent is indenting sub-array entries incorrectly when a comma is not used after the last value Generic.Arrays.ArrayIndent is indenting sub-arrays incorrectly when comma not used after the last value Mar 19, 2018
gsherwood added a commit that referenced this issue Mar 19, 2018
…incorrectly when comma not used after the last value
@gsherwood
Copy link
Member

Thanks for reporting this. It will be fixed in 3.3.0

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

2 participants