-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Squiz.Arrays.ArrayDeclaration sniff gives incorrect NoComma error for multiline string values #584
Comments
That's tricky, because it's a multi-line string, that is tokenized as single token and only line number it has is when it starts. |
This basically synchronizes it with `Squiz.Arrays.ArrayDeclaration`. The upstream version is similar, except that we exclude a few errors. Unfortunately we have to actually comment out the code rather than just using the upstream sniff and `<exclude>` in our ruleset, due to a bug (squizlabs/PHP_CodeSniffer#582). (I’ve also included a fix for another bug, squizlabs/PHP_CodeSniffer#584.) Because of this, we cannot yet eliminate duplicated logic from this child sniff. I think this pretty much maintains the previous behavior, except that I have added a warning for extra whitespace at the edges of multiline arrays.
Nope, it isn't tokenized as a single token, each line is a separate token. |
Then instead of removing |
Yeah, but I can't figure out what that check is even for. I'm not sure it's needed. |
…NoComma error for multiline string values
Thanks for reporting. Issue is fixed now. Just needed to treat multi-line strings as one argument, like the sniff does for other multi-line values such as closures. |
Thanks for the quick fix @gsherwood! 🎉 |
…r-php-add-tests-heredoc-nowdoc Tokenizer/PHP: add tests for heredoc/nowdoc tokenization
Consider this code (I didn't write it):
You will get two
Squiz.Arrays.ArrayDeclaration.NoComma
errors, even though both array values are followed by commas.This change fixes it for me, but I don't know if it breaks anything else:
Related: #582.
The text was updated successfully, but these errors were encountered: