Documentation

ForbiddenStylesSniff
in package
implements Sniff

Interfaces, Classes and Traits

Sniff

Table of Contents

$error  : bool
If true, an error will be thrown; otherwise a warning.
$supportedTokenizers  : array<string|int, mixed>
A list of tokenizers this sniff supports.
$forbiddenStyleNames  : array<string|int, string>
A cache of forbidden style names, for faster lookups.
$forbiddenStyles  : array<string, string|null>
A list of forbidden styles with their alternatives.
$patternMatch  : bool
If true, forbidden styles will be considered regular expressions.
process()  : void
Processes this test, when one of its tokens is encountered.
register()  : array<string|int, mixed>
Returns an array of tokens this test wants to listen for.
addError()  : void
Generates the error or warning for this sniff.

Properties

$supportedTokenizers

A list of tokenizers this sniff supports.

public array<string|int, mixed> $supportedTokenizers = ['CSS']

$forbiddenStyleNames

A cache of forbidden style names, for faster lookups.

protected array<string|int, string> $forbiddenStyleNames = []

$forbiddenStyles

A list of forbidden styles with their alternatives.

protected array<string, string|null> $forbiddenStyles = ['-moz-border-radius' => 'border-radius', '-webkit-border-radius' => 'border-radius', '-moz-border-radius-topleft' => 'border-top-left-radius', '-moz-border-radius-topright' => 'border-top-right-radius', '-moz-border-radius-bottomright' => 'border-bottom-right-radius', '-moz-border-radius-bottomleft' => 'border-bottom-left-radius', '-moz-box-shadow' => 'box-shadow', '-webkit-box-shadow' => 'box-shadow']

The value is NULL if no alternative exists. i.e., the style should just not be used.

$patternMatch

If true, forbidden styles will be considered regular expressions.

protected bool $patternMatch = false

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.

Return values
void

register()

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

public register() : array<string|int, mixed>
Return values
array<string|int, mixed>

addError()

Generates the error or warning for this sniff.

protected addError(File $phpcsFile, int $stackPtr, string $style[, string $pattern = null ]) : void
Parameters
$phpcsFile : File

The file being scanned.

$stackPtr : int

The position of the forbidden style in the token array.

$style : string

The name of the forbidden style.

$pattern : string = null

The pattern used for the match.

Return values
void

Search results