Documentation

DisallowInlineTabsSniff
in package
implements Sniff

FinalYes

Enforces using spaces for mid-line alignment.

While tab versus space based indentation is a question of preference, for mid-line alignment, spaces should always be preferred, as using tabs will result in inconsistent formatting depending on the dev-user's chosen tab width.

This sniff is especially useful for tab-indentation based standards which use the Generic.Whitespace.DisallowSpaceIndent sniff to enforce this.

DO make sure to set the PHPCS native tab-width configuration for the best results.

The PHPCS native Generic.Whitespace.DisallowTabIndent sniff oversteps its reach and silently does mid-line tab to space replacements as well. However, the sister-sniff Generic.Whitespace.DisallowSpaceIndent leaves mid-line tabs/spaces alone. This sniff fills that gap.

Tags
since
1.0.0

Table of Contents

Interfaces

Sniff

Properties

$find  : array<int|string, true>
Tokens to check for mid-line tabs.
$tabWidth  : int
The --tab-width CLI value that is being used.

Methods

process()  : int
Processes this test, when one of its tokens is encountered.
register()  : array<string|int, int|string>
Registers the tokens that this sniff wants to listen for.

Properties

$find

Tokens to check for mid-line tabs.

private array<int|string, true> $find = [\T_WHITESPACE => true, \T_DOC_COMMENT_WHITESPACE => true, \T_DOC_COMMENT_STRING => true, \T_COMMENT => true]
Tags
since
1.0.0

Methods

process()

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

public process(File $phpcsFile, int $stackPtr) : int
Parameters
$phpcsFile : File

The file being scanned.

$stackPtr : int

The position of the current token in the stack passed in $tokens.

Tags
since
1.0.0
Return values
int

Integer stack pointer to skip the rest of the file.

register()

Registers the tokens that this sniff wants to listen for.

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

        
On this page

Search results