PHP Class PHP_CodeSniffer_Tokens, PHP_CodeSniffer

The less the chance of a high occurrence of an arbitrary token, the higher the weighting.
Author: Greg Sherwood ([email protected])
Author: Marc McIntyre ([email protected])
Show file Open project: squizlabs/php_codesniffer Class Usage Examples

Public Properties

Property Type Description
$arithmeticTokens array(int) Tokens that represent arithmetic operators.
$assignmentTokens array(int) Tokens that represent assignments.
$blockOpeners array(int) Tokens that open code blocks.
$booleanOperators array(int) Tokens that perform boolean operations.
$bracketTokens array(int) Tokens that represent brackets and parenthesis.
$castTokens array(int) Tokens that represent casting.
$commentTokens array(int) Tokens that are comments.
$comparisonTokens array(int) Tokens that represent comparison operator.
$emptyTokens array(int) Tokens that don't represent code.
$equalityTokens array(int) Tokens that represent equality comparisons.
$functionNameTokens array(int) Mostly, these are just strings. But PHP tokeizes some language constructs and functions using their own tokens.
$heredocTokens array(int) Tokens that make up a heredoc string.
$includeTokens array(int) Tokens that include files.
$knownLengths The token weightings.
$methodPrefixes array(int) Tokens that can prefix a method name
$operators array(int) Tokens that perform operations.
$parenthesisOpeners array(int) Token types that open parenthesis.
$scopeModifiers array(int) Tokens that represent scope modifiers.
$scopeOpeners array(int) Tokens that are allowed to open scopes.
$stringTokens array(int) Note that T_STRINGS are NOT represented in this list.
$weightings The token weightings.

Public Methods

Method Description
getHighestWeightedToken ( array $tokens ) : integer Returns the highest weighted token type.

Private Methods

Method Description
__construct ( ) A PHP_CodeSniffer_Tokens class cannot be constructed.

Method Details

getHighestWeightedToken() public static method

Tokens are weighted by their approximate frequency of appearance in code - the less frequently they appear in the code, the higher the weighting. For example T_CLASS tokens appear very infrequently in a file, and therefore have a high weighting. Returns false if there are no weightings for any of the specified tokens.
public static getHighestWeightedToken ( array $tokens ) : integer
$tokens array
return integer The highest weighted token.

Property Details

$arithmeticTokens public static property

Tokens that represent arithmetic operators.
public static array(int) $arithmeticTokens
return array(int)

$assignmentTokens public static property

Tokens that represent assignments.
public static array(int) $assignmentTokens
return array(int)

$blockOpeners public static property

Tokens that open code blocks.
public static array(int) $blockOpeners
return array(int)

$booleanOperators public static property

Tokens that perform boolean operations.
public static array(int) $booleanOperators
return array(int)

$bracketTokens public static property

Tokens that represent brackets and parenthesis.
public static array(int) $bracketTokens
return array(int)

$castTokens public static property

Tokens that represent casting.
public static array(int) $castTokens
return array(int)

$commentTokens public static property

Tokens that are comments.
public static array(int) $commentTokens
return array(int)

$comparisonTokens public static property

Tokens that represent comparison operator.
public static array(int) $comparisonTokens
return array(int)

$emptyTokens public static property

Tokens that don't represent code.
public static array(int) $emptyTokens
return array(int)

$equalityTokens public static property

Tokens that represent equality comparisons.
public static array(int) $equalityTokens
return array(int)

$functionNameTokens public static property

Mostly, these are just strings. But PHP tokeizes some language constructs and functions using their own tokens.
public static array(int) $functionNameTokens
return array(int)

$heredocTokens public static property

Tokens that make up a heredoc string.
public static array(int) $heredocTokens
return array(int)

$includeTokens public static property

Tokens that include files.
public static array(int) $includeTokens
return array(int)

$knownLengths public static property

The token weightings.
public static $knownLengths

$methodPrefixes public static property

Tokens that can prefix a method name
public static array(int) $methodPrefixes
return array(int)

$operators public static property

Tokens that perform operations.
public static array(int) $operators
return array(int)

$parenthesisOpeners public static property

Token types that open parenthesis.
public static array(int) $parenthesisOpeners
return array(int)

$scopeModifiers public static property

Tokens that represent scope modifiers.
public static array(int) $scopeModifiers
return array(int)

$scopeOpeners public static property

Tokens that are allowed to open scopes.
public static array(int) $scopeOpeners
return array(int)

$stringTokens public static property

Note that T_STRINGS are NOT represented in this list.
public static array(int) $stringTokens
return array(int)

$weightings public static property

The token weightings.
public static $weightings