ArrayDeclarationSpacingSniff
extends Sniff
in package
Enforces WordPress array spacing format.
- Checks that associative arrays are multi-line.
- Checks that each array item in a multi-line array starts on a new line.
Tags
Table of Contents
Properties
- $allow_single_item_single_line_associative_arrays : bool
- Whether or not to allow single item associative arrays to be single line.
- $phpcsFile : File
- The current file being sniffed.
- $tokens : array<string|int, mixed>
- The list of tokens in the current file being sniffed.
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.
- process_multi_line_array() : void
- Process a multi-line array.
- process_single_line_array() : void
- Check that associative arrays are always multi-line.
Properties
$allow_single_item_single_line_associative_arrays
Whether or not to allow single item associative arrays to be single line.
public
bool
$allow_single_item_single_line_associative_arrays
= true
Defaults to true.
Tags
$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
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.
Tags
register()
Returns an array of tokens this test wants to listen for.
public
register() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>process_multi_line_array()
Process a multi-line array.
protected
process_multi_line_array(int $stackPtr, int $opener) : void
Parameters
- $stackPtr : int
-
The position of the current token in the stack.
- $opener : int
-
The position of the array opener.
Tags
process_single_line_array()
Check that associative arrays are always multi-line.
protected
process_single_line_array(int $stackPtr, int $opener, int $closer) : void
Parameters
- $stackPtr : int
-
The position of the current token in the stack.
- $opener : int
-
The position of the array opener.
- $closer : int
-
The position of the array closer.