NoLeadingBackslashSniff
in package
implements
Sniff
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
Table of Contents
Interfaces
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
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
register()
Returns an array of tokens this test wants to listen for.
public
register() : array<string|int, int|string>
Tags
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.