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

Invalid warning in multiple assignments alignment with closure or anon class #1870

Closed
Dacaspex opened this issue Jan 31, 2018 · 1 comment · Fixed by #1924
Closed

Invalid warning in multiple assignments alignment with closure or anon class #1870

Dacaspex opened this issue Jan 31, 2018 · 1 comment · Fixed by #1924
Milestone

Comments

@Dacaspex
Copy link

Dacaspex commented Jan 31, 2018

The following example is marked as invalid by phpcs

1 $foobarbaz = array_map(
2    function ($n) {
3         return $n * $n;
4     },
5     [1, 2, 3]
6 );
7 $foo       = 5;

This causes the following warning on line 7:

Generic.Formatting.MultipleStatementAlignment.IncorrectWarning

Basically, the $foo is considered to be a new assignment block. The reason for this, I think, is the semicolon in the function closure on line 3. Phpcs thinks the assignment block has ended because the semicolon is in a different context.

The reason I think this should not happen is because PHPStorm automatically aligns the equals sign like the example given above. This is because of the code style option Assignment statement -> Align consecutive assignments in PHPStorm.

Hence my question whether this can be added/fixed in phpcs?

@gsherwood gsherwood changed the title Invalid warning in multiple assignments alignement with function closure Invalid warning in multiple assignments alignment with closure or anon class Jan 31, 2018
@gsherwood gsherwood added this to the 3.2.3 milestone Jan 31, 2018
gsherwood added a commit that referenced this issue Jan 31, 2018
@gsherwood
Copy link
Member

Thanks for reporting this. There was also a problem when using anon classes in the similar way.

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