Documentation

KeywordSpacingSniff
in package
implements Sniff

FinalYes

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
since
1.1.0

Table of Contents

Interfaces

Sniff

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
since
1.1.0

METRIC_NAME_BEFORE

Name of the metric for spacing before.

public string METRIC_NAME_BEFORE = 'Space before "%s" keyword in import use statement'
Tags
since
1.1.0

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
since
1.1.0

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
since
1.1.0

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
since
1.1.0

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
since
1.1.0

register()

Returns an array of tokens this sniff wants to listen for.

public register() : array<string|int, int|string>
Tags
since
1.1.0
Return values
array<string|int, int|string>

        
On this page

Search results