PHP Class 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.
Author: Greg Sherwood ([email protected])
Author: Marc McIntyre ([email protected])
Inheritance: implements PHP_CodeSniffer_Sniff
Afficher le fichier Open project: squizlabs/php_codesniffer

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
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.

Method Details

addChangeset() protected méthode

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.
Résultat void

findClosingTag() protected méthode

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.
Résultat integer | false Pointer to the position in the stack for the closing tag or false if not found.

getSnippet() protected méthode

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.
Résultat string

process() public méthode

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.
Résultat void

register() public méthode

Returns an array of tokens this test wants to listen for.
public register ( ) : array
Résultat array