Documentation

Squiz_Sniffs_Classes_SelfMemberReferenceSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff
in package

Tests self member references.

Verifies that :

  • self:: is used instead of Self::
  • self:: is used for local static member reference
  • self:: is used instead of self ::
Tags
category

PHP

author

Greg Sherwood gsherwood@squiz.net

author

Marc McIntyre mmcintyre@squiz.net

copyright

2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)

license

https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence

version

Release: @package_version@

link
http://pear.php.net/package/PHP_CodeSniffer

Table of Contents

$_listenOutside  : bool
True if this test should fire on tokens outside of the scope.
$_scopeTokens  : string
The type of scope opener tokens that this test wishes to listen to.
$_tokens  : array<string|int, mixed>
The token types that this test wishes to listen to within the scope.
__construct()  : mixed
Constructs a Squiz_Sniffs_Classes_SelfMemberReferenceSniff.
process()  : void
Processes the tokens that this test is listening for.
register()  : array<string|int, int>
The method that is called to register the tokens this test wishes to listen to.
getDeclarationNameWithNamespace()  : string
Returns the declaration names for classes/interfaces/functions with a namespace.
getNamespaceOfScope()  : string
Returns the namespace declaration of a file.
processTokenOutsideScope()  : void
Processes a token that is found outside the scope that this test is listening to.
processTokenWithinScope()  : void
Processes the function tokens within the class.

Properties

$_listenOutside

True if this test should fire on tokens outside of the scope.

private bool $_listenOutside = alse

$_scopeTokens

The type of scope opener tokens that this test wishes to listen to.

private string $_scopeTokens = array()

$_tokens

The token types that this test wishes to listen to within the scope.

private array<string|int, mixed> $_tokens = array()

Methods

__construct()

Constructs a Squiz_Sniffs_Classes_SelfMemberReferenceSniff.

public __construct() : mixed
Return values
mixed

process()

Processes the tokens that this test is listening for.

public final process(PHP_CodeSniffer_File $phpcsFile, int $stackPtr) : void
Parameters
$phpcsFile : PHP_CodeSniffer_File

The file where this token was found.

$stackPtr : int

The position in the stack where this token was found.

Tags
see
processTokenWithinScope()
Return values
void

register()

The method that is called to register the tokens this test wishes to listen to.

public final register() : array<string|int, int>

DO NOT OVERRIDE THIS METHOD. Use the constructor of this class to register for the desired tokens and scope.

Tags
see
__constructor()
Return values
array<string|int, int>

getDeclarationNameWithNamespace()

Returns the declaration names for classes/interfaces/functions with a namespace.

protected getDeclarationNameWithNamespace(array<string|int, mixed> $tokens, int $stackPtr) : string
Parameters
$tokens : array<string|int, mixed>

Token stack for this file

$stackPtr : int

The position where the namespace building will start.

Return values
string

getNamespaceOfScope()

Returns the namespace declaration of a file.

protected getNamespaceOfScope(PHP_CodeSniffer_File $phpcsFile, int $stackPtr) : string
Parameters
$phpcsFile : PHP_CodeSniffer_File

The file where this token was found.

$stackPtr : int

The position where the search for the namespace declaration will start.

Return values
string

processTokenOutsideScope()

Processes a token that is found outside the scope that this test is listening to.

protected processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, int $stackPtr) : void
Parameters
$phpcsFile : PHP_CodeSniffer_File

The file where this token was found.

$stackPtr : int

The position in the stack where this token was found.

Return values
void

processTokenWithinScope()

Processes the function tokens within the class.

protected processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, int $stackPtr, int $currScope) : void
Parameters
$phpcsFile : PHP_CodeSniffer_File

The file where this token was found.

$stackPtr : int

The position where the token was found.

$currScope : int

The current scope opener token.

Return values
void

Search results