Core: add section about trait use statement rules with select new sniffs #2303
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refs:
The WP rules for traits are very akin to the PSR12 rules with only a few exceptions:
use
statement.use
statements with conflict resolution. PSR12 always demands multi-line in that case.The upstream PSR12 trait use sniff therefore seems like a good fit.
I propose to exclude the "blank line before first
use
" error code to address the first point mentioned above.As for the second point, the code sample which showed the single-line
use
statement in the docs has been updated to multi-line in PR WordPress/wpcs-docs#130.With that change and taking into consideration that these rules are new to WPCS anyway, it makes sense to actually apply the PSR version of the rule demanding that conflict resolution must always be multi-line.
Other than that, this PR contains one more exclusion to prevent duplicate error messages about a spacing issue already covered via another sniff.
Note: this exclusion won't work (yet) as there is a typo in the upstream sniff. PR squizlabs/PHP_CodeSniffer#3856 is open to fix this.