Documentation

NoLeadingBackslashSniff
in package
implements Sniff

FinalYes

Verifies that names being imported in import use statements do not start with a leading backslash.

This sniff handles all types of import use statements supported by PHP, in contrast to any of the other sniffs for the same in, for instance, the PSR12 or the Slevomat standard, all of which are incomplete.

Tags
since
1.0.0

Table of Contents

Interfaces

Sniff

Constants

METRIC_NAME  = 'Import use with leading backslash'
Name of the metric.

Methods

process()  : void
Processes this test, when one of its tokens is encountered.
register()  : array<string|int, int|string>
Returns an array of tokens this test wants to listen for.
processImport()  : bool
Examine an individual import statement.

Constants

METRIC_NAME

Name of the metric.

public string METRIC_NAME = 'Import use with leading backslash'
Tags
since
1.0.0

Methods

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.0.0

register()

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

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

processImport()

Examine an individual import statement.

private processImport(File $phpcsFile, int $stackPtr, int $endOfStatement[, bool $groupUse = false ]) : bool
Parameters
$phpcsFile : File

The file being scanned.

$stackPtr : int

The position of the current token.

$endOfStatement : int

End token for the current import statement.

$groupUse : bool = false

Whether the current statement is a partial one within a group use statement.

Return values
bool

Whether or not to continue examining this import use statement.


        
On this page

Search results