NoLongClosuresSniff
in package
implements
Sniff
Forbids long closures.
Tags
Table of Contents
Interfaces
Constants
- METRIC_NAME_ALL = 'Closure length (code + comments + blank lines)'
- Name of the metric.
- METRIC_NAME_CODE = 'Closure length (code only)'
- Name of the metric.
- METRIC_NAME_COMMENTS = 'Closure length (code + comments)'
- Name of the metric.
Properties
- $ignoreCommentLines : bool
- Whether or not to exclude lines which only contain documentation in the line count.
- $ignoreEmptyLines : bool
- Whether or not to exclude empty lines from the line count.
- $maxLines : int
- Maximum number of lines allowed before a closure is considered a "long" closure.
- $recommendedLines : int
- Maximum number of lines allowed before a closure is considered a "long" closure.
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_ALL
Name of the metric.
public
string
METRIC_NAME_ALL
= 'Closure length (code + comments + blank lines)'
Tags
METRIC_NAME_CODE
Name of the metric.
public
string
METRIC_NAME_CODE
= 'Closure length (code only)'
Tags
METRIC_NAME_COMMENTS
Name of the metric.
public
string
METRIC_NAME_COMMENTS
= 'Closure length (code + comments)'
Tags
Properties
$ignoreCommentLines
Whether or not to exclude lines which only contain documentation in the line count.
public
bool
$ignoreCommentLines
= true
Defaults to true.
Tags
$ignoreEmptyLines
Whether or not to exclude empty lines from the line count.
public
bool
$ignoreEmptyLines
= true
Defaults to true.
Tags
$maxLines
Maximum number of lines allowed before a closure is considered a "long" closure.
public
int
$maxLines
= 8
Defaults to 8 lines, i.e. when a closure contains 9 lines, an error will be thrown.
Tags
$recommendedLines
Maximum number of lines allowed before a closure is considered a "long" closure.
public
int
$recommendedLines
= 5
Defaults to 5 lines, i.e. when a closure contains 6 lines, a warning will be thrown.
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>