Documentation

NoLongClosuresSniff
in package
implements Sniff

FinalYes

Forbids long closures.

Tags
since
1.1.0

Table of Contents

Interfaces

Sniff

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
since
1.1.0

METRIC_NAME_CODE

Name of the metric.

public string METRIC_NAME_CODE = 'Closure length (code only)'
Tags
since
1.1.0

METRIC_NAME_COMMENTS

Name of the metric.

public string METRIC_NAME_COMMENTS = 'Closure length (code + comments)'
Tags
since
1.1.0

Properties

$ignoreCommentLines

Whether or not to exclude lines which only contain documentation in the line count.

public bool $ignoreCommentLines = true

Defaults to true.

Tags
since
1.1.0

$ignoreEmptyLines

Whether or not to exclude empty lines from the line count.

public bool $ignoreEmptyLines = true

Defaults to true.

Tags
since
1.1.0

$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
since
1.1.0

$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
since
1.1.0

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
since
1.1.0

register()

Returns an array of tokens this test wants to listen for.

public register() : array<string|int, int|string>
Tags
since
1.1.0
Return values
array<string|int, int|string>

        
On this page

Search results