PHP Class Generic_Sniffs_WhiteSpace_ScopeIndentSniff, PHP_CodeSniffer

Checks that control structures are structured correctly, and their content is indented correctly. This sniff will throw errors if tabs are used for indentation rather than spaces.
Author: Greg Sherwood ([email protected])
Author: Marc McIntyre ([email protected])
Inheritance: implements PHP_CodeSniffer_Sniff
ファイルを表示 Open project: squizlabs/php_codesniffer Class Usage Examples

Public Properties

Property Type Description
$exact boolean If TRUE, indent needs to be exactly $indent spaces. If FALSE, indent needs to be at least $indent spaces (but can be more).
$ignoreIndentationTokens int[] Useful to allow Sniffs based on this to easily ignore/skip some tokens from verification. For example, inline HTML sections or PHP open/close tags can escape from here and have their own rules elsewhere.
$indent integer The number of spaces code should be indented.
$supportedTokenizers array A list of tokenizers this sniff supports.
$tabIndent boolean If TRUE, fixes will be made using tabs instead of spaces. The size of each tab is important, so it should be specified using the --tab-width CLI argument.

Protected Properties

Property Type Description
$nonIndentingScopes int[] Any scope openers that should not cause an indent.

Public Methods

Method Description
process ( PHP_CodeSniffer_File $phpcsFile, integer $stackPtr ) : void Processes this test, when one of its tokens is encountered.
register ( ) : array Returns an array of tokens this test wants to listen for.

Method Details

process() public method

Processes this test, when one of its tokens is encountered.
public process ( PHP_CodeSniffer_File $phpcsFile, integer $stackPtr ) : void
$phpcsFile PHP_CodeSniffer_File All the tokens found in the document.
$stackPtr integer The position of the current token in the stack passed in $tokens.
return void

register() public method

Returns an array of tokens this test wants to listen for.
public register ( ) : array
return array

Property Details

$exact public_oe property

If TRUE, indent needs to be exactly $indent spaces. If FALSE, indent needs to be at least $indent spaces (but can be more).
public bool $exact
return boolean

$ignoreIndentationTokens public_oe property

Useful to allow Sniffs based on this to easily ignore/skip some tokens from verification. For example, inline HTML sections or PHP open/close tags can escape from here and have their own rules elsewhere.
public int[] $ignoreIndentationTokens
return int[]

$indent public_oe property

The number of spaces code should be indented.
public int $indent
return integer

$nonIndentingScopes protected_oe property

Any scope openers that should not cause an indent.
protected int[] $nonIndentingScopes
return int[]

$supportedTokenizers public_oe property

A list of tokenizers this sniff supports.
public array $supportedTokenizers
return array

$tabIndent public_oe property

If TRUE, fixes will be made using tabs instead of spaces. The size of each tab is important, so it should be specified using the --tab-width CLI argument.
public bool $tabIndent
return boolean