Documentation

Generic_Sniffs_WhiteSpace_ScopeIndentSniff
in package
implements PHP_CodeSniffer_Sniff

Generic_Sniffs_Whitespace_ScopeIndentSniff.

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.

Tags
category

PHP

author

Greg Sherwood gsherwood@squiz.net

author

Marc McIntyre mmcintyre@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

$exact  : bool
Does the indent need to be exactly right?
$ignoreIndentationTokens  : array<string|int, int>
List of tokens not needing to be checked for indentation.
$indent  : int
The number of spaces code should be indented.
$supportedTokenizers  : array<string|int, mixed>
A list of tokenizers this sniff supports.
$tabIndent  : bool
Should tabs be used for indenting?
$nonIndentingScopes  : array<string|int, int>
Any scope openers that should not cause an indent.
$_debug  : bool
Show debug output for this sniff.
$_ignoreIndentationTokens  : array<string|int, int>
List of tokens not needing to be checked for indentation.
$_tabWidth  : int
The --tab-width CLI value that is being used.
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.

Properties

$exact

Does the indent need to be exactly right?

public bool $exact = alse

If TRUE, indent needs to be exactly $indent spaces. If FALSE, indent needs to be at least $indent spaces (but can be more).

$ignoreIndentationTokens

List of tokens not needing to be checked for indentation.

public array<string|int, int> $ignoreIndentationTokens = array()

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

The number of spaces code should be indented.

public int $indent = 4

$supportedTokenizers

A list of tokenizers this sniff supports.

public array<string|int, mixed> $supportedTokenizers = array('PHP', 'JS')

$tabIndent

Should tabs be used for indenting?

public bool $tabIndent = alse

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.

$nonIndentingScopes

Any scope openers that should not cause an indent.

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

$_ignoreIndentationTokens

List of tokens not needing to be checked for indentation.

private array<string|int, int> $_ignoreIndentationTokens = array()

This is a cached copy of the public version of this var, which can be set in a ruleset file, and some core ignored tokens.

$_tabWidth

The --tab-width CLI value that is being used.

private int $_tabWidth = ull

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

All the tokens found in the document.

$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>

Search results