Core: add section about import use statement rules with select new sniffs #2252
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:
Universal.UseStatements.NoLeadingBackslashsniff PHPCSStandards/PHPCSExtra#46Universal.UseStatements.LowercaseFunctionConstsniff PHPCSStandards/PHPCSExtra#58Notes:
PSR12.Files.FileHeader.IncorrectOrdersniff.This sniff will flag incorrect order when a
usestatement is part of the file header, but will not pick up onusestatements which are not at the top of the file.My research shows the following:
PSR12.Files.FileHeadersniff can check both "before" and "after", but will check for exactly one blank line.The problem with that sniff is that it currently is "all or nothing", it does not have modular error codes for the various file headers sections for the blank line check, so we cannot ignore some other things from that sniff (requires blank line between PHP open tag and file docblock), which makes it problematic to include the sniff.
If upstream PR PSR12/FileHeader: make "SpacingAfter" and "SpacingInside" errorcodes modular squizlabs/PHP_CodeSniffer#2729 would (finally) be merged, we could reconsider adding that sniff though.
usekeyword via theGeneric.WhiteSpace.LanguageConstructSpacingsniff, which was moved toCorein Core: move rules related to include/require statements fromExtratoCore#2097.PHPCSExtra 1.1.0 will contain a new
Universal.UseStatements.KeywordSpacingsniff which can check the spacing around thefunction,constandaskeywords.An issue will need to be opened about this in WPCS. The corresponding issue in PHPCSExtra is Sniff to enforce naming conventions for class/function/const aliases PHPCSStandards/PHPCSExtra#232
PHPCSExtra 1.1.0 will contain a new
Universal.UseStatements.NoUselessAliasessniff which will be able to check this.PHPCSExtra 1.1.0 will contain a new
Universal.UseStatements.DisallowMixedGroupUsesniff which will be able to check this.Other notes: