Documentation

ConcatPositionSniff
in package
implements Sniff

FinalYes

Enforces that the concatenation operator in multi-line concatenations is in a preferred position, either always at the start of the next line or always at the end of the previous line.

Note: this sniff has no opinion on spacing before/after the concatenation operator. It will normalize based on the "one space before/after" PSR-12 industry standard. If different spacing is preferred, use the Squiz.Strings.ConcatenationSpacing to enforce/correct that.

Tags
since
1.2.0

Table of Contents

Interfaces

Sniff

Constants

METRIC_NAME  = 'Multi-line concatenation operator position'
The phrase to use for the metric recorded by this sniff.
POSITION_END  = 'end'
Position indication: end of previous line.
POSITION_STANDALONE  = 'stand-alone'
Position indication: neither start of next line nor end of previous line.
POSITION_START  = 'start'
Position indication: start of next line.

Properties

$allowOnly  : string
Preferred position for the concatenation operator.

Methods

process()  : int|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

The phrase to use for the metric recorded by this sniff.

public string METRIC_NAME = 'Multi-line concatenation operator position'
Tags
since
1.2.0

POSITION_END

Position indication: end of previous line.

public string POSITION_END = 'end'
Tags
since
1.2.0

POSITION_STANDALONE

Position indication: neither start of next line nor end of previous line.

public string POSITION_STANDALONE = 'stand-alone'
Tags
since
1.2.0

POSITION_START

Position indication: start of next line.

public string POSITION_START = 'start'
Tags
since
1.2.0

Properties

$allowOnly

Preferred position for the concatenation operator.

public string $allowOnly = self::POSITION_START

Valid values are: 'start' and 'end'. Defaults to 'start'.

Tags
since
1.2.0

Methods

process()

Processes this test, when one of its tokens is encountered.

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
since
1.2.0
Return values
int|void

Integer stack pointer to skip forward or void to continue normal file processing.

register()

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

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

        
On this page

Search results