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

Squiz.Arrays.ArrayBracketSpacing is removing some comments during fixing #1694

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Oct 9, 2017

As discussed in #1673 (comment), this PR addresses the Squiz.Arrays.ArrayBracketSpacing sniff unintentionally removing comments which were placed adjacent to the brackets.
This should not happen anymore once this PR has been merged.

Includes adjusted and additional unit tests.

While looking at the sniff, I noticed two other improvements begging to be made 😻

  • The sniff still had some checks in it to prevent it acting on short array syntax. As the short array open/close brackets have their own tokens now, these checks are no longer needed.
  • The sniff had a sanity check for parse errors/live coding for the close bracket, but not for the open bracket.

Both of these additional issues have been fixed in separate commits.

The code now removed was outdated. It was previously necessary to distinguish a "normal" square open bracket from a short array open bracket, but since the introduction of the `T_SHORT_ARRAY_OPEN` token, this is no longer necessary.
The parse error/live coding check is now applied to both open as well as close brackets.
@jrfnl jrfnl changed the title Feature/issue 1673 2 dont remove comments in array brackets Squiz/ArrayBracketSpacing: dont remove comments in array brackets Oct 9, 2017
@jrfnl jrfnl changed the title Squiz/ArrayBracketSpacing: dont remove comments in array brackets Squiz/ArrayBracketSpacing: don't remove comments in array brackets Oct 9, 2017
@gsherwood gsherwood added this to the 3.1.1 milestone Oct 10, 2017
@gsherwood gsherwood changed the title Squiz/ArrayBracketSpacing: don't remove comments in array brackets Squiz.Arrays.ArrayBracketSpacing is removing some comments during fixing Oct 10, 2017
@gsherwood gsherwood merged commit fead7ff into squizlabs:master Oct 10, 2017
gsherwood added a commit that referenced this pull request Oct 10, 2017
@gsherwood
Copy link
Member

Thanks a lot for doing that.

@jrfnl jrfnl deleted the feature/issue-1673-2-dont-remove-comments-in-array-brackets branch October 10, 2017 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants