Documentation

Generic_Sniffs_PHP_DisallowAlternativePHPTagsSniff
in package
implements PHP_CodeSniffer_Sniff

Generic_Sniffs_PHP_DisallowAlternativePHPTagsSniff.

Verifies that no alternative PHP tags are used.

If alternative PHP open tags are found, this sniff can fix both the open and close tags.

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

Interfaces, Classes and Traits

PHP_CodeSniffer_Sniff
Represents a PHP_CodeSniffer sniff for sniffing coding standards.

Table of Contents

$_aspTags  : bool
Whether ASP tags are enabled or not.
$_phpVersion  : int
The current PHP version.
process()  : 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.
addChangeset()  : void
Add a changeset to replace the alternative PHP tags.
findClosingTag()  : int|false
Try and find a matching PHP closing tag.
getSnippet()  : string
Get a snippet from a HTML token.

Properties

Methods

process()

Processes this test, 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 stack passed in $tokens.

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>

addChangeset()

Add a changeset to replace the alternative PHP tags.

protected addChangeset(PHP_CodeSniffer_File $phpcsFile, array<string|int, mixed> $tokens, int $open_tag_pointer, int $close_tag_pointer[, bool $echo = false ]) : void
Parameters
$phpcsFile : PHP_CodeSniffer_File

The file being scanned.

$tokens : array<string|int, mixed>

The token stack.

$open_tag_pointer : int

Stack pointer to the PHP open tag.

$close_tag_pointer : int

Stack pointer to the PHP close tag.

$echo : bool = false

Whether to add 'echo' or not.

Return values
void

findClosingTag()

Try and find a matching PHP closing tag.

protected findClosingTag(PHP_CodeSniffer_File $phpcsFile, array<string|int, mixed> $tokens, int $stackPtr, string $content) : int|false
Parameters
$phpcsFile : PHP_CodeSniffer_File

The file being scanned.

$tokens : array<string|int, mixed>

The token stack.

$stackPtr : int

The position of the current token in the stack passed in $tokens.

$content : string

The expected content of the closing tag to match the opener.

Return values
int|false

Pointer to the position in the stack for the closing tag or false if not found.

getSnippet()

Get a snippet from a HTML token.

protected getSnippet(string $content[, string $start = '' ][, int $length = 40 ]) : string
Parameters
$content : string

The content of the HTML token.

$start : string = ''

Partial string to use as a starting point for the snippet.

$length : int = 40

The target length of the snippet to get. Defaults to 40.

Return values
string

Search results