ArrayBraceSpacingSniff
in package
implements
Sniff
Enforce consistent spacing for the open/close braces of arrays.
The sniff allows for having different settings for:
- space between the
arraykeyword and the open parenthesis for long arrays; - spaces on the inside of the braces for single-line arrays;
- spaces on the inside of the braces for multi-line arrays;
- spaces on the inside of the braces for empty arrays.
Note: If 'newline' is expected and no new line is encountered, a new line will be added, but no assumptions will be made about the intended indentation of the code. This should be handled by a (separate) indentation sniff.
Tags
Table of Contents
Interfaces
Properties
- $keywordSpacing : int|false
- Number of spaces which should be between the `array` keyword and the open parenthesis for long arrays.
- $spacesMultiLine : string|int|false
- Number of spaces which should be on the inside of array braces for a multi-line array.
- $spacesSingleLine : int|false
- Number of spaces which should be on the inside of array braces for a single-line array.
- $spacesWhenEmpty : string|int|false
- Number of spaces to enforce between the braces for an empty array.
Methods
- process() : void
- Processes this test when one of its tokens is encountered.
- register() : array<string|int, int|string>
- Returns an array of tokens this test wants to listen for.
Properties
$keywordSpacing
Number of spaces which should be between the `array` keyword and the open parenthesis for long arrays.
public
int|false
$keywordSpacing
= 0
Accepted values:
- (int) number of spaces.
- or
falseto turn this check off.
Defaults to 0 spaces.
Tags
$spacesMultiLine
Number of spaces which should be on the inside of array braces for a multi-line array.
public
string|int|false
$spacesMultiLine
= 'newline'
Accepted values:
- (string) 'newline'
- (int) number of spaces.
- or
falseto turn this check off.
Defaults to 'newline'.
Tags
$spacesSingleLine
Number of spaces which should be on the inside of array braces for a single-line array.
public
int|false
$spacesSingleLine
= 0
Accepted values:
- (int) number of spaces.
- or
falseto turn this check off.
Defaults to 0 spaces.
Tags
$spacesWhenEmpty
Number of spaces to enforce between the braces for an empty array.
public
string|int|false
$spacesWhenEmpty
= 0
Accepted values:
- (string) 'newline'
- (int) number of spaces.
- or
falseto turn this check off.
Defaults to 0 spaces.
Tags
Methods
process()
Processes this test when one of its tokens is encountered.
public
process(File $phpcsFile, int $stackPtr) : void
Parameters
- $phpcsFile : File
-
The PHP_CodeSniffer file where the token was found.
- $stackPtr : int
-
The position in the PHP_CodeSniffer file's token stack where the token was found.
Tags
register()
Returns an array of tokens this test wants to listen for.
public
register() : array<string|int, int|string>