Skip to content

Squiz.Arrays.ArrayBracketSpacing.SpaceBeforeBracket false positive match for short list syntax #1284

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

Closed
niconoe- opened this issue Jan 18, 2017 · 1 comment

Comments

@niconoe-
Copy link

I'm running PHPCS 2.7.1 to sniff PHP 7.1 code.

I got a PHPCS error with this kind of code:

if ($foo == 'bar') {
    //... do some stuff
}
[$myFirstElement, $mySecondElement] = $arrayOfTwoElements;

The issue is between } and [ as the sniff does not handle yet the PHP 7.1 list new syntax.

Is this already fixed in v3.0.0?

Thanks a lot.
Regards,

@gsherwood gsherwood changed the title Squiz.Arrays.ArrayBracketSpacing.SpaceBeforeBracket false positive match on PHP 7.1 Squiz.Arrays.ArrayBracketSpacing.SpaceBeforeBracket false positive match for short list syntax Jan 20, 2017
gsherwood added a commit that referenced this issue Jan 20, 2017
… false positive match for short list syntax
@gsherwood
Copy link
Member

The problem was that this array was not being changed to the custom T_[OPEN/CLOSE]_SHORT_ARRAY tokens because the } before the array was making PHPCS think it was in the form $c->{$var}[ ] = 2;. I've fixed this now. Thanks for reporting the issue.

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