ControlStructureSpacingSniff
extends Sniff
in package
Checks that control structures have the correct spacing around brackets, based upon Squiz code.
Tags
Table of Contents
Properties
- $blank_line_after_check : bool
- Check for blank lines after control structures.
- $blank_line_check : bool
- Check for blank lines on start/end of control structures.
- $space_before_colon : string
- Require for space before T_COLON when using the alternative syntax for control structures.
- $phpcsFile : File
- The current file being sniffed.
- $tokens : array<string|int, mixed>
- The list of tokens in the current file being sniffed.
- $ignore_extra_space_after_open_paren : array<string|int, mixed>
- Tokens for which to ignore extra space on the inside of parenthesis.
Methods
- process() : int|void
- Set sniff properties and hand off to child class for processing of the token.
- process_token() : 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
$blank_line_after_check
Check for blank lines after control structures.
public
bool
$blank_line_after_check
= true
$blank_line_check
Check for blank lines on start/end of control structures.
public
bool
$blank_line_check
= false
$space_before_colon
Require for space before T_COLON when using the alternative syntax for control structures.
public
string
$space_before_colon
= 'required'
one of 'required', 'forbidden', 'optional'
$phpcsFile
The current file being sniffed.
protected
File
$phpcsFile
Tags
$tokens
The list of tokens in the current file being sniffed.
protected
array<string|int, mixed>
$tokens
Tags
$ignore_extra_space_after_open_paren
Tokens for which to ignore extra space on the inside of parenthesis.
private
array<string|int, mixed>
$ignore_extra_space_after_open_paren
= array(\T_DO => true, \T_ELSE => true, \T_TRY => true, \T_FINALLY => true)
For do / else / try / finally, there are no parenthesis, so skip it.
Tags
Methods
process()
Set sniff properties and hand off to child class for processing of the token.
public
process(File $phpcsFile, int $stackPtr) : int|void
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the current token in the stack passed in $tokens.
Tags
Return values
int|void —Integer stack pointer to skip forward or void to continue normal file processing.
process_token()
Processes this test, when one of its tokens is encountered.
public
process_token(int $stackPtr) : void
Parameters
- $stackPtr : int
-
The position of the current token in the stack.
register()
Returns an array of tokens this test wants to listen for.
public
register() : array<string|int, mixed>