Documentation

PSR1_Sniffs_Files_SideEffectsSniff
in package
implements PHP_CodeSniffer_Sniff

PSR1_Sniffs_Files_SideEffectsSniff.

Ensures a file declare new symbols and causes no other side effects, or executes logic with side effects, but not both.

Tags
category

PHP

author

Greg Sherwood gsherwood@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

Interfaces, Classes and Traits

PHP_CodeSniffer_Sniff
Represents a PHP_CodeSniffer sniff for sniffing coding standards.

Table of Contents

process()  : void
Processes this sniff, when one of its tokens is encountered.
register()  : array<string|int, mixed>
Returns an array of tokens this test wants to listen for.
_searchForConflict()  : array<string|int, mixed>
Searches for symbol declarations and side effects.

Methods

process()

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

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

The file being scanned.

$stackPtr : int

The position of the current token in the token stack.

Return values
void

register()

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

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

_searchForConflict()

Searches for symbol declarations and side effects.

private _searchForConflict(PHP_CodeSniffer_File $phpcsFile, int $start, int $end, array<string|int, mixed> $tokens) : array<string|int, mixed>

Returns the positions of both the first symbol declared and the first side effect in the file. A NULL value for either indicates nothing was found.

Parameters
$phpcsFile : PHP_CodeSniffer_File

The file being scanned.

$start : int

The token to start searching from.

$end : int

The token to search to.

$tokens : array<string|int, mixed>

The stack of tokens that make up the file.

Return values
array<string|int, mixed>

Search results