CommaAfterLastSniff
in package
implements
Sniff
FinalYes
Enforce/forbid a comma after the last item in an array declaration.
Allows for different settings for single-line and multi-line arrays.
Tags
Table of Contents
Interfaces
Constants
- METRIC_NAME = '%s array - comma after last item'
- Name of the metric.
Properties
- $multiLine : string
- Whether or not to enforce a comma after the last array item in a multi-line array.
- $singleLine : string
- Whether or not to enforce a comma after the last array item in a single-line array.
- $validValues : array<string, true>
- The input values to consider as valid for the public properties.
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.
Constants
METRIC_NAME
Name of the metric.
public
string
METRIC_NAME
= '%s array - comma after last item'
Tags
Properties
$multiLine
Whether or not to enforce a comma after the last array item in a multi-line array.
public
string
$multiLine
= 'enforce'
Valid values:
- 'enforce' to always demand a comma after the last item in single-line arrays;
- 'forbid' to disallow a comma after the last item in single-line arrays;
- 'skip' to ignore multi-line arrays.
Defaults to: 'enforce'.
Tags
$singleLine
Whether or not to enforce a comma after the last array item in a single-line array.
public
string
$singleLine
= 'forbid'
Valid values:
- 'enforce' to always demand a comma after the last item in single-line arrays;
- 'forbid' to disallow a comma after the last item in single-line arrays;
- 'skip' to ignore single-line arrays.
Defaults to: 'forbid'.
Tags
$validValues
The input values to consider as valid for the public properties.
private
array<string, true>
$validValues
= ['enforce' => true, 'forbid' => true, 'skip' => true]
Used for input validation.
Tags
Methods
process()
Processes this test, when one of its tokens is encountered.
public
process(File $phpcsFile, int $stackPtr) : void
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the current token in the stack passed in $tokens.
Tags
register()
Returns an array of tokens this test wants to listen for.
public
register() : array<string|int, int|string>