KeywordSpacingSniff
in package
implements
Sniff
Enforce a single space after the keywords in import `use` statements.
The keywords this sniff check are use, function, const and as.
For as, the space before the keyword is also checked to be a single space.
Tags
Table of Contents
Interfaces
Constants
- METRIC_NAME_AFTER = 'Space after "%s" keyword in import use statement'
- Name of the metric for spacing after.
- METRIC_NAME_BEFORE = 'Space before "%s" keyword in import use statement'
- Name of the metric for spacing before.
Properties
- $keywords : array<string, true>
- A list of keywords that are tokenized as `T_STRING` in import `use` statements.
Methods
- checkSpacingAfterKeyword() : void
- Check the spacing after a found keyword.
- checkSpacingBeforeKeyword() : void
- Check the spacing before a found keyword.
- process() : void
- Processes this test, when one of its tokens is encountered.
- register() : array<string|int, int|string>
- Returns an array of tokens this sniff wants to listen for.
Constants
METRIC_NAME_AFTER
Name of the metric for spacing after.
public
string
METRIC_NAME_AFTER
= 'Space after "%s" keyword in import use statement'
Tags
METRIC_NAME_BEFORE
Name of the metric for spacing before.
public
string
METRIC_NAME_BEFORE
= 'Space before "%s" keyword in import use statement'
Tags
Properties
$keywords
A list of keywords that are tokenized as `T_STRING` in import `use` statements.
protected
array<string, true>
$keywords
= ['const' => true, 'function' => true]
Tags
Methods
checkSpacingAfterKeyword()
Check the spacing after a found keyword.
public
checkSpacingAfterKeyword(File $phpcsFile, int $stackPtr, string $content) : void
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the keyword in the token stack.
- $content : string
-
The keyword as found.
Tags
checkSpacingBeforeKeyword()
Check the spacing before a found keyword.
public
checkSpacingBeforeKeyword(File $phpcsFile, int $stackPtr, string $content) : void
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the keyword in the token stack.
- $content : string
-
The keyword as found.
Tags
process()
Processes this test, when one of its tokens is encountered.
public
process(File $phpcsFile, int $stackPtr) : void
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the current token in the stack passed in $tokens.
Tags
register()
Returns an array of tokens this sniff wants to listen for.
public
register() : array<string|int, int|string>