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

Array sniffs: ignore short lists #1780

Merged
merged 2 commits into from Jul 28, 2019

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jul 27, 2019

While we should probably define rules for long/short list constructs, WPCS at this time, does not have an opinion on the formatting of these.

The Arrays sniffs, however, would all treat short lists as if they were short arrays and apply the array rules on them.

This PR fixes this by bowing out early if a short array is in actual fact a short list.

Includes unit tests in each of the sniffs in the Arrays category affected by this issue.

Fixes #1692


This PR also adds a new Sniff::is_short_list() utility method to determine whether a short array token is in actual fact representing a PHP 7.1+ short list.

This method will be short-lived in WPCS as it will be introduced in WPCS 3.5.0 and can be deprecated/removed once the minimum required PHPCS version goes up.

New utility method to determine whether a _short array_ token is in actual fact representing a PHP 7.1+ short list.

This method will be short-lived in WPCS as it will be introduced in WPCS 3.5.0 and can be deprecated once the minimum required PHPCS version goes up.
While we should probably define rules for long/short list constructs, WPCS at this time, does not have a opinion on the formatting of these.

The `Arrays` sniffs, however, would all treat _short lists_ as if they were _short arrays_ and apply the array rules on them.

This PR fixes this by bowing out early if a short array is in actual fact a short list.

Includes unit tests in each of the sniffs in the `Arrays` category affected by this issue.

Fixes 1692
@dingo-d dingo-d merged commit d6050e8 into develop Jul 28, 2019
@jrfnl jrfnl deleted the feature/1692-array-sniffs-should-ignore-short-lists branch July 28, 2019 16:21
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.

Destructuring arrays
3 participants