Documentation

StaticInFinalClassSniff
in package
implements Sniff

FinalYes

Forbid the use of the `static` keyword for late static binding in OO constructs which are final.

Tags
since
1.0.0

Table of Contents

Interfaces

Sniff

Properties

$validOOScopes  : array<string|int, int|string>
OO Scopes in which late static binding is useless.

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.
handleError()  : void
Throw and potentially fix the error.

Properties

$validOOScopes

OO Scopes in which late static binding is useless.

private array<string|int, int|string> $validOOScopes = [ \T_CLASS, // Only if final. \T_ANON_CLASS, // Final by nature. \T_ENUM, ]

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.0.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.0.0
Return values
array<string|int, int|string>

handleError()

Throw and potentially fix the error.

private handleError(File $phpcsFile, int $stackPtr, string $errorCode, string $extraMsg) : void
Parameters
$phpcsFile : File

The file being scanned.

$stackPtr : int

The position of erroneous T_STATIC token.

$errorCode : string

The error code for the message.

$extraMsg : string

Addition to the error message.

Tags
since
1.0.0

        
On this page

Search results