PHP_CodeSniffer
[ class tree: PHP_CodeSniffer ] [ index: PHP_CodeSniffer ] [ all elements ]

Class: PHP_CodeSniffer_Tokens

Source Location: /PHP_CodeSniffer-0.7.0/CodeSniffer/Tokens.php

Class Overview


The Tokens class contains weightings for tokens based on their probability of occurance in a file.


Author(s):

Version:

  • Release: 0.7.0

Copyright:

  • 2006 Squiz Pty Ltd (ABN 77 084 670 600)

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 66]
The Tokens class contains weightings for tokens based on their probability of occurance in a file.

The less the chance of a high occurance of an abitrary token, the higher the weighting.



[ Top ]


Class Variables

$arithmeticTokens = array(
                                       T_PLUS,
                                       T_MINUS,
                                       T_MULTIPLY,
                                       T_DIVIDE,
                                       T_MODULUS,
                                      )

[line 191]

Tokens that represent arithmetic operators.
  • Access: public

Type:   array(int)


[ Top ]

$assignmentTokens = array(
                                       T_EQUAL,
                                       T_AND_EQUAL,
                                       T_CONCAT_EQUAL,
                                       T_DIV_EQUAL,
                                       T_MINUS_EQUAL,
                                       T_MOD_EQUAL,
                                       T_MUL_EQUAL,
                                       T_PLUS_EQUAL,
                                       T_XOR_EQUAL,
                                      )

[line 144]

Tokens that represent assignments.
  • Access: public

Type:   array(int)


[ Top ]

$blockOpeners = array(
                                   T_OPEN_CURLY_BRACKET,
                                   T_OPEN_SQUARE_BRACKET,
                                   T_OPEN_PARENTHESIS,
                                  )

[line 285]

Tokens that perform operations.
  • Access: public

Type:   array(int)


[ Top ]

$castTokens = array(
                                 T_INT_CAST,
                                 T_STRING_CAST,
                                 T_DOUBLE_CAST,
                                 T_ARRAY_CAST,
                                 T_BOOL_CAST,
                                 T_OBJECT_CAST,
                                 T_UNSET_CAST
                                )

[line 204]

Tokens that represent casting.
  • Access: public

Type:   array(int)


[ Top ]

$commentTokens = array(
                                    T_COMMENT,
                                    T_DOC_COMMENT,
                                   )

[line 307]

Tokens that are comments.
  • Access: public

Type:   array(int)


[ Top ]

$comparisonTokens = array(
                                       T_IS_EQUAL,
                                       T_IS_IDENTICAL,
                                       T_IS_NOT_EQUAL,
                                       T_IS_NOT_IDENTICAL,
                                       T_LESS_THAN,
                                       T_GREATER_THAN,
                                       T_IS_SMALLER_OR_EQUAL,
                                       T_IS_GREATER_OR_EQUAL,
                                      )

[line 175]

Tokens that represent comparison operator.
  • Access: public

Type:   array(int)


[ Top ]

$emptyTokens = array(
                                  T_WHITESPACE,
                                  T_COMMENT,
                                  T_DOC_COMMENT,
                                 )

[line 296]

Tokens that don't represent code.
  • Access: public

Type:   array(int)


[ Top ]

$equalityTokens = array(
                                     T_IS_EQUAL,
                                     T_IS_NOT_EQUAL,
                                     T_IS_IDENTICAL,
                                     T_IS_NOT_IDENTICAL,
                                     T_IS_SMALLER_OR_EQUAL,
                                     T_IS_GREATER_OR_EQUAL,
                                    )

[line 161]

Tokens that represent equality comparisons.
  • Access: public

Type:   array(int)


[ Top ]

$includeTokens = array(
                                    T_REQUIRE_ONCE,
                                    T_REQUIRE,
                                    T_INCLUDE_ONCE,
                                    T_INCLUDE,
                                   )

[line 329]

Tokens that include files.
  • Access: public

Type:   array(int)


[ Top ]

$operators = array(
                                T_MINUS,
                                T_PLUS,
                                T_MULTIPLY,
                                T_DIVIDE,
                                T_MODULUS,
                                T_POWER,
                                T_BITWISE_AND,
                                T_BITWISE_OR,
                               )

[line 269]

Tokens that perform operations.
  • Access: public

Type:   array(int)


[ Top ]

$parenthesisOpeners = array(
                                         T_ARRAY,
                                         T_FUNCTION,
                                         T_WHILE,
                                         T_FOR,
                                         T_FOREACH,
                                         T_SWITCH,
                                         T_IF,
                                         T_ELSEIF,
                                         T_CATCH,
                                        )

[line 219]

Token types that open parethesis.
  • Access: public

Type:   array(int)


[ Top ]

$scopeModifiers = array(
                                     T_PRIVATE,
                                     T_PUBLIC,
                                     T_PROTECTED,
                                    )

[line 258]

Tokens that represent scope modifiers.
  • Access: public

Type:   array(int)


[ Top ]

$scopeOpeners = array(
                                   T_CLASS,
                                   T_FUNCTION,
                                   T_IF,
                                   T_SWITCH,
                                   T_CASE,
                                   T_DEFAULT,
                                   T_WHILE,
                                   T_ELSE,
                                   T_ELSEIF,
                                   T_FOR,
                                   T_FOREACH,
                                   T_DO,
                                   T_TRY,
                                   T_CATCH,
                                  )

[line 236]

Tokens that are allowed to open scopes.
  • Access: public

Type:   array(int)


[ Top ]

$stringTokens = array(
                                   T_CONSTANT_ENCAPSED_STRING,
                                   T_DOUBLE_QUOTED_STRING,
                                  )

[line 319]

Tokens that represent strings.

Note that T_STRINGS are NOT represented in this list.

  • Access: public

Type:   array(int)


[ Top ]

$weightings = array(
                                 T_CLASS               => 1000,
                                 T_FUNCTION            => 100,

                                 /*
                                     Conditions.
                                 */

                                 T_WHILE               => 50,
                                 T_FOR                 => 50,
                                 T_FOREACH             => 50,
                                 T_IF                  => 50,
                                 T_ELSE                => 50,
                                 T_ELSEIF              => 50,
                                 T_WHILE               => 50,
                                 T_DO                  => 50,
                                 T_TRY                 => 50,
                                 T_CATCH               => 50,
                                 T_SWITCH              => 50,

                                 T_SELF                => 25,
                                 T_PARENT              => 25,

                                 /*
                                     Operators and arithmetic.
                                 */

                                 T_BITWISE_AND         => 8,
                                 T_BITWISE_OR          => 8,

                                 T_MULTIPLY            => 5,
                                 T_DIVIDE              => 5,
                                 T_PLUS                => 5,
                                 T_MINUS               => 5,
                                 T_MODULUS             => 5,
                                 T_POWER               => 5,

                                 T_EQUAL               => 5,
                                 T_AND_EQUAL           => 5,
                                 T_CONCAT_EQUAL        => 5,
                                 T_DIV_EQUAL           => 5,
                                 T_MINUS_EQUAL         => 5,
                                 T_MOD_EQUAL           => 5,
                                 T_MUL_EQUAL           => 5,
                                 T_OR_EQUAL            => 5,
                                 T_PLUS_EQUAL          => 5,
                                 T_XOR_EQUAL           => 5,

                                 T_BOOLEAN_AND         => 5,
                                 T_BOOLEAN_OR          => 5,

                                 /*
                                     Equality.
                                 */

                                 T_IS_EQUAL            => 5,
                                 T_IS_NOT_EQUAL        => 5,
                                 T_IS_IDENTICAL        => 5,
                                 T_IS_NOT_IDENTICAL    => 5,
                                 T_IS_SMALLER_OR_EQUAL => 5,
                                 T_IS_GREATER_OR_EQUAL => 5,

                                 T_WHITESPACE          => 0,
                                )

[line 74]

The token weightings.
  • Var: => int)
  • Access: public

Type:   array(int


[ Top ]



Method Detail

getHighestWeightedToken   [line 363]

int getHighestWeightedToken( array $tokens)

Returns the highest weighted token type.

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 apprear very infrequently in a file, and therefore have a high weighting.

Returns false if there are no weightings for any of the specified tokens.

  • Return: The highest weighted token.
  • Access: public

Parameters:

array(int)   $tokens   —  The token types to get the highest weighted type for.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:06:36 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.