Documentation

CastStructureSpacingSniff extends Sniff

FinalYes

Ensure cast statements are preceded by whitespace.

Tags
link
https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#space-usage
since
0.3.0
since
0.11.0

This sniff now has the ability to fix the issues it flags.

since
0.11.0

The error level for all errors thrown by this sniff has been raised from warning to error.

since
0.12.0

This class now extends the WordPressCS native Sniff class.

since
0.13.0

Class name changed: this class is now namespaced.

since
1.2.0

Removed the NoSpaceAfterCloseParenthesis error code in favour of the upstream Generic.Formatting.SpaceAfterCast.NoSpace error.

since
2.2.0

Added exception for whitespace between spread operator and cast.

Table of Contents

Properties

$phpcsFile  : File
The current file being sniffed.
$tokens  : array<string|int, mixed>
The list of tokens in the current file being sniffed.

Methods

process()  : int|void
Set sniff properties and hand off to child class for processing of the token.
process_token()  : void
Processes this test, when one of its tokens is encountered.
register()  : array<string|int, mixed>
Returns an array of tokens this test wants to listen for.

Properties

$phpcsFile

The current file being sniffed.

protected File $phpcsFile
Tags
since
0.4.0

$tokens

The list of tokens in the current file being sniffed.

protected array<string|int, mixed> $tokens
Tags
since
0.4.0

Methods

process()

Set sniff properties and hand off to child class for processing of the token.

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

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

process_token()

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

public process_token(int $stackPtr) : void
Parameters
$stackPtr : int

The position of the current token in the stack.

register()

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

public register() : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results