Documentation

ValidFunctionNameSniff extends Sniff

FinalYes

Enforces WordPress function name and method name format, based upon Squiz code.

Tags
link
https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions
since
0.1.0
since
0.13.0

Class name changed: this class is now namespaced.

since
2.0.0

The get_name_suggestion() method has been moved to the WordPress native Sniff base class as get_snake_case_name_suggestion().

since
2.2.0

Will now ignore functions and methods which are marked as @deprecated.

since
3.0.0

This sniff has been refactored and no longer extends the upstream PEAR.NamingConventions.ValidFunctionName sniff.

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()  : int|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.
process_function_declaration()  : void
Processes a function declaration for a function in the global namespace.
process_method_declaration()  : void
Processes a method declaration.

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) : int|void
Parameters
$stackPtr : int

The position of the current token in the stack.

Tags
since
3.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, mixed>
Tags
since
3.0.0
Return values
array<string|int, mixed>

process_function_declaration()

Processes a function declaration for a function in the global namespace.

protected process_function_declaration(int $stackPtr, string $functionName) : void
Parameters
$stackPtr : int

The position where this token was found.

$functionName : string

The name of the function.

Tags
since
0.1.0
since
3.0.0

Renamed from processTokenOutsideScope() to process_function_declaration(). Method signature has been changed as well as this method no longer overloads a method from the PEAR sniff which was previously the sniff parent.

process_method_declaration()

Processes a method declaration.

protected process_method_declaration(int $stackPtr, string $methodName, int $currScope) : void
Parameters
$stackPtr : int

The position where this token was found.

$methodName : string

The name of the method.

$currScope : int

The position of the current scope.

Tags
since
0.1.0
since
3.0.0

Renamed from processTokenWithinScope() to process_method_declaration(). Method signature has been changed as well, as this method no longer overloads a method from the PEAR sniff which was previously the sniff parent.


        
On this page

Search results