Documentation

Collections

Collections of related tokens as often used and needed for sniffs.

These are additional "token groups" to compliment the ones available through the PHPCS native \PHP_CodeSniffer\Util\Tokens class.

Table of Contents

$alternativeControlStructureSyntaxTokens Control structures which can use the alternative control structure syntax. array
$alternativeControlStructureSyntaxCloserTokens Alternative control structure syntax closer keyword tokens. array
$arrayTokens Tokens which are used to create arrays. array
$arrayTokensBC Tokens which are used to create arrays. array
$classModifierKeywords Modifier keywords which can be used for a class declaration. array
$closedScopes List of tokens which represent "closed" scopes. array
$controlStructureTokens Control structure tokens. array
$listTokens Tokens which are used to create lists. array
$listTokensBC Tokens which are used to create lists. array
$namespaceDeclarationClosers List of tokens which can end a namespace declaration statement. array
$OOCanExtend OO structures which can use the `extends` keyword. array
$OOCanImplement OO structures which can use the `implements` keyword. array
$OOConstantScopes OO scopes in which constants can be declared. array
$OOPropertyScopes OO scopes in which properties can be declared. array
$parameterTypeTokens Token types which can be encountered in a parameter type declaration. array
$propertyModifierKeywords Modifier keywords which can be used for a property declaration. array
$propertyTypeTokens Token types which can be encountered in a property type declaration. array
$returnTypeTokens Token types which can be encountered in a return type declaration. array
$shortArrayTokens Tokens which are used for short arrays. array
$shortArrayTokensBC Tokens which are used for short arrays. array
$shortListTokens Tokens which are used for short lists. array
$shortListTokensBC Tokens which are used for short lists. array
$textStingStartTokens Tokens which can start a - potentially multi-line - text string. array
arrowFunctionTokensBC() Tokens which can represent the arrow function keyword. array

Properties

$alternativeControlStructureSyntaxTokens

Control structures which can use the alternative control structure syntax.

public static array $alternativeControlStructureSyntaxTokens = [\T_IF => \T_IF, \T_ELSEIF => \T_ELSEIF, \T_ELSE => \T_ELSE, \T_FOR => \T_FOR, \T_FOREACH => \T_FOREACH, \T_SWITCH => \T_SWITCH, \T_WHILE => \T_WHILE, \T_DECLARE => \T_DECLARE]

$alternativeControlStructureSyntaxCloserTokens

Alternative control structure syntax closer keyword tokens.

public static array $alternativeControlStructureSyntaxCloserTokens = [\T_ENDIF => \T_ENDIF, \T_ENDFOR => \T_ENDFOR, \T_ENDFOREACH => \T_ENDFOREACH, \T_ENDWHILE => \T_ENDWHILE, \T_ENDSWITCH => \T_ENDSWITCH, \T_ENDDECLARE => \T_ENDDECLARE]

$arrayTokens

Tokens which are used to create arrays.

public static array $arrayTokens = [\T_ARRAY => \T_ARRAY, \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY, \T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY]

$arrayTokensBC

Tokens which are used to create arrays.

public static array $arrayTokensBC = [\T_ARRAY => \T_ARRAY, \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY, \T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY, \T_OPEN_SQUARE_BRACKET => \T_OPEN_SQUARE_BRACKET, \T_CLOSE_SQUARE_BRACKET => \T_CLOSE_SQUARE_BRACKET]
List which is backward-compatible with PHPCS < 3.3.0. Should only be used selectively.

$classModifierKeywords

Modifier keywords which can be used for a class declaration.

public static array $classModifierKeywords = [\T_FINAL => \T_FINAL, \T_ABSTRACT => \T_ABSTRACT]

$closedScopes

List of tokens which represent "closed" scopes.

public static array $closedScopes = [\T_CLASS => \T_CLASS, \T_ANON_CLASS => \T_ANON_CLASS, \T_INTERFACE => \T_INTERFACE, \T_TRAIT => \T_TRAIT, \T_FUNCTION => \T_FUNCTION, \T_CLOSURE => \T_CLOSURE]
I.e. anything declared within that scope - except for other closed scopes - is outside of the global namespace. This list doesn't contain `T_NAMESPACE` on purpose as variables declared within a namespace scope are still global and not limited to that namespace.

$controlStructureTokens

Control structure tokens.

public static array $controlStructureTokens = [\T_IF => \T_IF, \T_ELSEIF => \T_ELSEIF, \T_ELSE => \T_ELSE, \T_FOR => \T_FOR, \T_FOREACH => \T_FOREACH, \T_SWITCH => \T_SWITCH, \T_DO => \T_DO, \T_WHILE => \T_WHILE, \T_DECLARE => \T_DECLARE]

$listTokens

Tokens which are used to create lists.

public static array $listTokens = [\T_LIST => \T_LIST, \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY, \T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY]

$listTokensBC

Tokens which are used to create lists.

public static array $listTokensBC = [\T_LIST => \T_LIST, \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY, \T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY, \T_OPEN_SQUARE_BRACKET => \T_OPEN_SQUARE_BRACKET, \T_CLOSE_SQUARE_BRACKET => \T_CLOSE_SQUARE_BRACKET]
List which is backward-compatible with PHPCS < 3.3.0. Should only be used selectively.

$namespaceDeclarationClosers

List of tokens which can end a namespace declaration statement.

public static array $namespaceDeclarationClosers = [\T_SEMICOLON => \T_SEMICOLON, \T_OPEN_CURLY_BRACKET => \T_OPEN_CURLY_BRACKET, \T_CLOSE_TAG => \T_CLOSE_TAG]

$OOCanExtend

OO structures which can use the `extends` keyword.

public static array $OOCanExtend = [\T_CLASS => \T_CLASS, \T_ANON_CLASS => \T_ANON_CLASS, \T_INTERFACE => \T_INTERFACE]

$OOCanImplement

OO structures which can use the `implements` keyword.

public static array $OOCanImplement = [\T_CLASS => \T_CLASS, \T_ANON_CLASS => \T_ANON_CLASS]

$OOConstantScopes

OO scopes in which constants can be declared.

public static array $OOConstantScopes = [\T_CLASS => \T_CLASS, \T_ANON_CLASS => \T_ANON_CLASS, \T_INTERFACE => \T_INTERFACE]
Note: traits can not declare constants.

$OOPropertyScopes

OO scopes in which properties can be declared.

public static array $OOPropertyScopes = [\T_CLASS => \T_CLASS, \T_ANON_CLASS => \T_ANON_CLASS, \T_TRAIT => \T_TRAIT]
Note: interfaces can not declare properties.

$parameterTypeTokens

Token types which can be encountered in a parameter type declaration.

public static array $parameterTypeTokens = [ \T_ARRAY_HINT => \T_ARRAY_HINT, // PHPCS < 3.3.0. \T_CALLABLE => \T_CALLABLE, \T_SELF => \T_SELF, \T_PARENT => \T_PARENT, \T_STRING => \T_STRING, \T_NS_SEPARATOR => \T_NS_SEPARATOR, ]

$propertyModifierKeywords

Modifier keywords which can be used for a property declaration.

public static array $propertyModifierKeywords = [\T_PUBLIC => \T_PUBLIC, \T_PRIVATE => \T_PRIVATE, \T_PROTECTED => \T_PROTECTED, \T_STATIC => \T_STATIC, \T_VAR => \T_VAR]

$propertyTypeTokens

Token types which can be encountered in a property type declaration.

public static array $propertyTypeTokens = [ \T_ARRAY_HINT => \T_ARRAY_HINT, // PHPCS < 3.3.0. \T_CALLABLE => \T_CALLABLE, \T_SELF => \T_SELF, \T_PARENT => \T_PARENT, \T_STRING => \T_STRING, \T_NS_SEPARATOR => \T_NS_SEPARATOR, ]

$returnTypeTokens

Token types which can be encountered in a return type declaration.

public static array $returnTypeTokens = [ \T_STRING => \T_STRING, \T_CALLABLE => \T_CALLABLE, \T_SELF => \T_SELF, \T_PARENT => \T_PARENT, \T_NS_SEPARATOR => \T_NS_SEPARATOR, \T_RETURN_TYPE => \T_RETURN_TYPE, // PHPCS 2.4.0 < 3.3.0. \T_ARRAY_HINT => \T_ARRAY_HINT, // PHPCS < 2.8.0 / PHPCS < 3.5.3 for arrow functions. \T_ARRAY => \T_ARRAY, ]

$shortArrayTokens

Tokens which are used for short arrays.

public static array $shortArrayTokens = [\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY, \T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY]

$shortArrayTokensBC

Tokens which are used for short arrays.

public static array $shortArrayTokensBC = [\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY, \T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY, \T_OPEN_SQUARE_BRACKET => \T_OPEN_SQUARE_BRACKET, \T_CLOSE_SQUARE_BRACKET => \T_CLOSE_SQUARE_BRACKET]
List which is backward-compatible with PHPCS < 3.3.0. Should only be used selectively.

$shortListTokens

Tokens which are used for short lists.

public static array $shortListTokens = [\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY, \T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY]

$shortListTokensBC

Tokens which are used for short lists.

public static array $shortListTokensBC = [\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY, \T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY, \T_OPEN_SQUARE_BRACKET => \T_OPEN_SQUARE_BRACKET, \T_CLOSE_SQUARE_BRACKET => \T_CLOSE_SQUARE_BRACKET]
List which is backward-compatible with PHPCS < 3.3.0. Should only be used selectively.

$textStingStartTokens

Tokens which can start a - potentially multi-line - text string.

public static array $textStingStartTokens = [\T_START_HEREDOC => \T_START_HEREDOC, \T_START_NOWDOC => \T_START_NOWDOC, \T_CONSTANT_ENCAPSED_STRING => \T_CONSTANT_ENCAPSED_STRING, \T_DOUBLE_QUOTED_STRING => \T_DOUBLE_QUOTED_STRING]

Methods

arrowFunctionTokensBC()

Tokens which can represent the arrow function keyword.

public static arrowFunctionTokensBC( ) : array

Note: this is a method, not a property as the T_FN token may not exist.

Tags
since
Return values
array

<int|string> => <int|string>

Search results