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
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
$_aspTags
Whether ASP tags are enabled or not.
private
bool
$_aspTags
= alse
$_phpVersion
The current PHP version.
private
int
$_phpVersion
=
ull
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.