Documentation

Squiz_Sniffs_CSS_ForbiddenStylesSniff
in package
implements PHP_CodeSniffer_Sniff

Squiz_Sniffs_CSS_ForbiddenStylesSniff.

Bans the use of some styles, such as deprecated or browser-specific styles.

Tags
category

PHP

author

Greg Sherwood gsherwood@squiz.net

copyright

2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)

license

https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence

version

Release: @package_version@

link
http://pear.php.net/package/PHP_CodeSniffer

Interfaces, Classes and Traits

PHP_CodeSniffer_Sniff
Represents a PHP_CodeSniffer sniff for sniffing coding standards.

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, mixed>|(string)
A cache of forbidden style names, for faster lookups.
$forbiddenStyles  : mixed
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 = array('CSS')

$forbiddenStyleNames

A cache of forbidden style names, for faster lookups.

protected array<string|int, mixed>|(string) $forbiddenStyleNames = array()

$forbiddenStyles

A list of forbidden styles with their alternatives.

protected mixed $forbiddenStyles = array('-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 function should just not be used.

$patternMatch

If true, forbidden styles will be considered regular expressions.

protected bool $patternMatch = alse

Methods

process()

Processes this test, when one of its tokens is encountered.

public process(PHP_CodeSniffer_File $phpcsFile, int $stackPtr) : void
Parameters
$phpcsFile : PHP_CodeSniffer_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(PHP_CodeSniffer_File $phpcsFile, int $stackPtr, string $style[, string $pattern = null ]) : void
Parameters
$phpcsFile : PHP_CodeSniffer_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