PHP Класс Generic_Sniffs_PHP_DisallowAlternativePHPTagsSniff, PHP_CodeSniffer

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.
Автор: Greg Sherwood ([email protected])
Автор: Marc McIntyre ([email protected])
Наследование: implements PHP_CodeSniffer_Sniff
Показать файл Открыть проект

Открытые методы

Метод Описание
process ( PHP_CodeSniffer_File $phpcsFile, integer $stackPtr ) : void Processes this test, when one of its tokens is encountered.
register ( ) : array Returns an array of tokens this test wants to listen for.

Защищенные методы

Метод Описание
addChangeset ( PHP_CodeSniffer_File $phpcsFile, array $tokens, integer $open_tag_pointer, integer $close_tag_pointer, boolean $echo = false ) : void Add a changeset to replace the alternative PHP tags.
findClosingTag ( PHP_CodeSniffer_File $phpcsFile, array $tokens, integer $stackPtr, string $content ) : integer | false Try and find a matching PHP closing tag.
getSnippet ( string $content, string $start_at = '', integer $length = 40 ) : string Get a snippet from a HTML token.

Описание методов

addChangeset() защищенный Метод

Add a changeset to replace the alternative PHP tags.
protected addChangeset ( PHP_CodeSniffer_File $phpcsFile, array $tokens, integer $open_tag_pointer, integer $close_tag_pointer, boolean $echo = false ) : void
$phpcsFile PHP_CodeSniffer_File The file being scanned.
$tokens array The token stack.
$open_tag_pointer integer Stack pointer to the PHP open tag.
$close_tag_pointer integer Stack pointer to the PHP close tag.
$echo boolean Whether to add 'echo' or not.
Результат void

findClosingTag() защищенный Метод

Try and find a matching PHP closing tag.
protected findClosingTag ( PHP_CodeSniffer_File $phpcsFile, array $tokens, integer $stackPtr, string $content ) : integer | false
$phpcsFile PHP_CodeSniffer_File The file being scanned.
$tokens array The token stack.
$stackPtr integer 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.
Результат integer | 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_at = '', integer $length = 40 ) : string
$content string The content of the HTML token.
$start_at string Partial string to use as a starting point for the snippet.
$length integer The target length of the snippet to get. Defaults to 40.
Результат string

process() публичный Метод

Processes this test, when one of its tokens is encountered.
public process ( PHP_CodeSniffer_File $phpcsFile, integer $stackPtr ) : void
$phpcsFile PHP_CodeSniffer_File The file being scanned.
$stackPtr integer The position of the current token in the stack passed in $tokens.
Результат void

register() публичный Метод

Returns an array of tokens this test wants to listen for.
public register ( ) : array
Результат array