Core: add section about import use statement rules with select new sniffs #2252
+31
−1
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.NoLeadingBackslash
sniff PHPCSStandards/PHPCSExtra#46Universal.UseStatements.LowercaseFunctionConst
sniff PHPCSStandards/PHPCSExtra#58Notes:
PSR12.Files.FileHeader.IncorrectOrder
sniff.This sniff will flag incorrect order when a
use
statement is part of the file header, but will not pick up onuse
statements which are not at the top of the file.My research shows the following:
PSR12.Files.FileHeader
sniff 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.
use
keyword via theGeneric.WhiteSpace.LanguageConstructSpacing
sniff, which was moved toCore
in Core: move rules related to include/require statements fromExtra
toCore
#2097.PHPCSExtra 1.1.0 will contain a new
Universal.UseStatements.KeywordSpacing
sniff which can check the spacing around thefunction
,const
andas
keywords.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.NoUselessAliases
sniff which will be able to check this.PHPCSExtra 1.1.0 will contain a new
Universal.UseStatements.DisallowMixedGroupUse
sniff which will be able to check this.Other notes: