## Collections

Collections.php : 26

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.

##### Tags

see
  Tokens

  PHPCS native token groups.

see
  BCTokens

  Backward compatible version of the PHPCS native token groups.

since
  1.0.0

### Table of Contents

$alternativeControlStructureSyntaxCloserTokens : array
  Alternative control structure syntax closer keyword tokens.
$alternativeControlStructureSyntaxTokens : array
  Control structures which can use the alternative control structure syntax.
$arrayTokens : array
  Tokens which are used to create arrays.
$arrayTokensBC : array
  Tokens which are used to create arrays.
$classModifierKeywords : array
  Modifier keywords which can be used for a class declaration.
$closedScopes : array
  List of tokens which represent "closed" scopes.
$controlStructureTokens : array
  Control structure tokens.
$incrementDecrementOperators : array
  Increment/decrement operator tokens.
$listTokens : array
  Tokens which are used to create lists.
$listTokensBC : array
  Tokens which are used to create lists.
$magicConstants : array
  Tokens for the PHP magic constants.
$namespaceDeclarationClosers : array
  List of tokens which can end a namespace declaration statement.
$objectOperators : array
  Object operators.
$OOCanExtend : array
  OO structures which can use the "extends" keyword.
$OOCanImplement : array
  OO structures which can use the "implements" keyword.
$OOConstantScopes : array
  OO scopes in which constants can be declared.
$OOHierarchyKeywords : array
  Tokens types used for "forwarding" calls within OO structures.
$OONameTokens : array
  Tokens types which can be encountered in the fully/partially qualified name of an OO structure.
$OOPropertyScopes : array
  OO scopes in which properties can be declared.
$parameterTypeTokens : array
  Token types which can be encountered in a parameter type declaration.
$propertyModifierKeywords : array
  Modifier keywords which can be used for a property declaration.
$propertyTypeTokens : array
  Token types which can be encountered in a property type declaration.
$returnTypeTokens : array
  Token types which can be encountered in a return type declaration.
$shortArrayTokens : array
  Tokens which are used for short arrays.
$shortArrayTokensBC : array
  Tokens which are used for short arrays.
$shortListTokens : array
  Tokens which are used for short lists.
$shortListTokensBC : array
  Tokens which are used for short lists.
$textStingStartTokens : array
  Tokens which can start a - potentially multi-line - text string.
arrowFunctionTokensBC() : array
  Tokens which can represent the arrow function keyword.
functionDeclarationTokens() : array
  Tokens which can represent a keyword which starts a function declaration.
functionDeclarationTokensBC() : array
  Tokens which can represent a keyword which starts a function declaration.
parameterTypeTokensBC() : array
  Token types which can be encountered in a parameter type declaration (cross-version).
propertyTypeTokensBC() : array
  Token types which can be encountered in a property type declaration (cross-version).
returnTypeTokensBC() : array
  Token types which can be encountered in a return type declaration (cross-version).

### Properties

#### $alternativeControlStructureSyntaxCloserTokens

Collections.php : 54

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]`

##### Tags

since
  1.0.0-alpha2

#### $alternativeControlStructureSyntaxTokens

Collections.php : 36

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]`

##### Tags

since
  1.0.0-alpha2

#### $arrayTokens

Collections.php : 73

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]`

##### Tags

see
  Collections::$shortArrayTokens

  Related property containing only tokens used for short arrays.

since
  1.0.0

#### $arrayTokensBC

Collections.php : 92

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.

##### Tags

see
  Collections::$shortArrayTokensBC

  Related property containing only tokens used for short arrays (cross-version).

since
  1.0.0

#### $classModifierKeywords

Collections.php : 107

Modifier keywords which can be used for a class declaration.

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

##### Tags

since
  1.0.0

#### $closedScopes

Collections.php : 125

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 the `T_NAMESPACE` token on purpose as variables declared within a namespace scope are still global and not limited to that namespace.

##### Tags

since
  1.0.0

#### $controlStructureTokens

Collections.php : 141

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]`

##### Tags

since
  1.0.0-alpha2

#### $incrementDecrementOperators

Collections.php : 160

Increment/decrement operator tokens.

`public static array $incrementDecrementOperators = [T_DEC => T_DEC, T_INC => T_INC]`

##### Tags

since
  1.0.0-alpha3

#### $listTokens

Collections.php : 175

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]`

##### Tags

see
  Collections::$shortListTokens

  Related property containing only tokens used for short lists.

since
  1.0.0

#### $listTokensBC

Collections.php : 194

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.

##### Tags

see
  Collections::$shortListTokensBC

  Related property containing only tokens used for short lists (cross-version).

since
  1.0.0

#### $magicConstants

Collections.php : 211

Tokens for the PHP magic constants.

`public static array $magicConstants = [T_CLASS_C => T_CLASS_C, T_DIR => T_DIR, T_FILE => T_FILE, T_FUNC_C => T_FUNC_C, T_LINE => T_LINE, T_METHOD_C => T_METHOD_C, T_NS_C => T_NS_C, T_TRAIT_C => T_TRAIT_C]`

##### Tags

link
  https://www.php.net/language.constants.predefined

  PHP Manual on magic constants

since
  1.0.0-alpha3

#### $namespaceDeclarationClosers

Collections.php : 229

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]`

##### Tags

since
  1.0.0

#### $objectOperators

Collections.php : 242

Object operators.

`public static array $objectOperators = [T_OBJECT_OPERATOR => T_OBJECT_OPERATOR, T_DOUBLE_COLON => T_DOUBLE_COLON]`

##### Tags

since
  1.0.0-alpha3

#### $OOCanExtend

Collections.php : 254

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]`

##### Tags

since
  1.0.0

#### $OOCanImplement

Collections.php : 267

OO structures which can use the "implements" keyword.

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

##### Tags

since
  1.0.0

#### $OOConstantScopes

Collections.php : 281

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.

##### Tags

since
  1.0.0

#### $OOHierarchyKeywords

Collections.php : 296

Tokens types used for "forwarding" calls within OO structures.

`public static array $OOHierarchyKeywords = [T_PARENT => T_PARENT, T_SELF => T_SELF, T_STATIC => T_STATIC]`

##### Tags

link
  https://www.php.net/language.oop5.paamayim-nekudotayim

  PHP Manual on OO forwarding calls

since
  1.0.0-alpha3

#### $OONameTokens

Collections.php : 314

Tokens types which can be encountered in the fully/partially qualified name of an OO structure.

`public static array $OONameTokens = [T_NS_SEPARATOR => T_NS_SEPARATOR, T_STRING => T_STRING, T_NAMESPACE => T_NAMESPACE]`

Example:

    echo namespace\Sub\ClassName::method();

##### Tags

since
  1.0.0-alpha3

#### $OOPropertyScopes

Collections.php : 329

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.

##### Tags

since
  1.0.0

#### $parameterTypeTokens

Collections.php : 355

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

`public static array $parameterTypeTokens = [T_CALLABLE => T_CALLABLE, T_SELF => T_SELF, T_PARENT => T_PARENT, T_STRING => T_STRING, T_NS_SEPARATOR => T_NS_SEPARATOR]`

Sister-property to the \PHPCSUtils\Tokens\Collections::parameterTypeTokensBC() method. The property supports PHPCS 3.3.0 and up. The method supports PHPCS 2.6.0 and up.

Notable difference:

- The method will include the `T_ARRAY_HINT` token when used with PHPCS 2.x and 3.x. This token constant will no longer exist in PHPCS 4.x.

It is recommended to use the property instead of the method if a standard supports does not need to support PHPCS < 3.3.0.

##### Tags

see
  Collections::parameterTypeTokensBC()

  Related method (cross-version).

since
  1.0.0

#### $propertyModifierKeywords

Collections.php : 370

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]`

##### Tags

since
  1.0.0

#### $propertyTypeTokens

Collections.php : 398

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

`public static array $propertyTypeTokens = [T_CALLABLE => T_CALLABLE, T_SELF => T_SELF, T_PARENT => T_PARENT, T_STRING => T_STRING, T_NS_SEPARATOR => T_NS_SEPARATOR]`

Sister-property to the \PHPCSUtils\Tokens\Collections::propertyTypeTokensBC() method. The property supports PHPCS 3.3.0 and up. The method supports PHPCS 2.6.0 and up.

Notable difference:

- The method will include the `T_ARRAY_HINT` token when used with PHPCS 2.x and 3.x. This token constant will no longer exist in PHPCS 4.x.

It is recommended to use the property instead of the method if a standard supports does not need to support PHPCS < 3.3.0.

##### Tags

see
  Collections::propertyTypeTokensBC()

  Related method (cross-version).

since
  1.0.0

#### $returnTypeTokens

Collections.php : 427

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_STATIC => T_STATIC, T_NS_SEPARATOR => T_NS_SEPARATOR]`

Sister-property to the \PHPCSUtils\Tokens\Collections::returnTypeTokensBC() method. The property supports PHPCS 3.5.4 and up. The method supports PHPCS 2.6.0 and up.

Notable differences:

- The method will include the `T_ARRAY_HINT` and the `T_RETURN_TYPE` tokens when used with PHPCS 2.x and 3.x. These token constants will no longer exist in PHPCS 4.x.
- The method will include the `T_ARRAY` token which is needed for select arrow functions in PHPCS < 3.5.4.

It is recommended to use the property instead of the method if a standard supports does not need to support PHPCS < 3.5.4.

##### Tags

see
  Collections::returnTypeTokensBC()

  Related method (cross-version).

since
  1.0.0

#### $shortArrayTokens

Collections.php : 445

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]`

##### Tags

see
  Collections::$arrayTokens

  Related property containing all tokens used for arrays.

since
  1.0.0

#### $shortArrayTokensBC

Collections.php : 463

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.

##### Tags

see
  Collections::$arrayTokensBC

  Related property containing all tokens used for arrays (cross-version).

since
  1.0.0

#### $shortListTokens

Collections.php : 479

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]`

##### Tags

see
  Collections::$listTokens

  Related property containing all tokens used for lists.

since
  1.0.0

#### $shortListTokensBC

Collections.php : 497

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.

##### Tags

see
  Collections::$listTokensBC

  Related property containing all tokens used for lists (cross-version).

since
  1.0.0

#### $textStingStartTokens

Collections.php : 511

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]`

##### Tags

since
  1.0.0

### Methods

#### arrowFunctionTokensBC()

Collections.php : 527

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 for arrow functions may not exist.

##### Tags

since
  1.0.0-alpha2

##### Return values

array —

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

#### functionDeclarationTokens()

Collections.php : 556

Tokens which can represent a keyword which starts a function declaration.

`public static functionDeclarationTokens() : array`

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

Sister-method to the \PHPCSUtils\Tokens\Collections::functionDeclarationTokensBC() method. This method supports PHPCS 3.5.3 and up. The \PHPCSUtils\Tokens\Collections::functionDeclarationTokensBC() method supports PHPCS 2.6.0 and up.

##### Tags

see
  Collections::functionDeclarationTokensBC()

  Related method (PHPCS 2.6.0+).

since
  1.0.0-alpha3

##### Return values

array —

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

#### functionDeclarationTokensBC()

Collections.php : 597

Tokens which can represent a keyword which starts a function declaration.

`public static functionDeclarationTokensBC() : array`

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

Sister-method to the \PHPCSUtils\Tokens\Collections::functionDeclarationTokens() method. The \PHPCSUtils\Tokens\Collections::functionDeclarationTokens() method supports PHPCS 3.5.3 and up. This method supports PHPCS 2.6.0 and up.

Notable difference:

- This method accounts for when the `T_FN` token doesn't exist.

Note: if this method is used, the \PHPCSUtils\Utils\FunctionDeclarations::isArrowFunction() method needs to be used on arrow function tokens to verify whether it really is an arrow function declaration or not.

It is recommended to use the \PHPCSUtils\Tokens\Collections::functionDeclarationTokens() method instead of this method if a standard supports does not need to support PHPCS < 3.5.3.

##### Tags

see
  Collections::functionDeclarationTokens()

  Related method (PHPCS 3.5.3+).

see
  FunctionDeclarations::isArrowFunction()

  Arrow function verification.

since
  1.0.0-alpha3

##### Return values

array —

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

#### parameterTypeTokensBC()

Collections.php : 629

Token types which can be encountered in a parameter type declaration (cross-version).

`public static parameterTypeTokensBC() : array`

Sister-method to the \PHPCSUtils\Tokens\Collections::$parameterTypeTokens property. The property supports PHPCS 3.3.0 and up. The method supports PHPCS 2.6.0 and up.

Notable difference:

- The method will include the `T_ARRAY_HINT` token when used with PHPCS 2.x and 3.x. This token constant will no longer exist in PHPCS 4.x.

It is recommended to use the property instead of the method if a standard supports does not need to support PHPCS < 3.3.0.

##### Tags

see
  Collections::$parameterTypeTokens

  Related property (PHPCS 3.3.0+).

since
  1.0.0-alpha3

##### Return values

array —

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

#### propertyTypeTokensBC()

Collections.php : 661

Token types which can be encountered in a property type declaration (cross-version).

`public static propertyTypeTokensBC() : array`

Sister-method to the \PHPCSUtils\Tokens\Collections::$propertyTypeTokens property. The property supports PHPCS 3.3.0 and up. The method supports PHPCS 2.6.0 and up.

Notable difference:

- The method will include the `T_ARRAY_HINT` token when used with PHPCS 2.x and 3.x. This token constant will no longer exist in PHPCS 4.x.

It is recommended to use the property instead of the method if a standard supports does not need to support PHPCS < 3.3.0.

##### Tags

see
  Collections::$propertyTypeTokens

  Related property (PHPCS 3.3.0+).

since
  1.0.0-alpha3

##### Return values

array —

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

#### returnTypeTokensBC()

Collections.php : 687

Token types which can be encountered in a return type declaration (cross-version).

`public static returnTypeTokensBC() : array`

Sister-property to the \PHPCSUtils\Tokens\Collections::returnTypeTokensBC() method. The property supports PHPCS 3.5.4 and up. The method supports PHPCS 2.6.0 and up.

Notable differences:

- The method will include the `T_ARRAY_HINT` and the `T_RETURN_TYPE` tokens when used with PHPCS 2.x and 3.x. These token constants will no longer exist in PHPCS 4.x.
- The method will include the `T_ARRAY` token which is needed for select arrow functions in PHPCS < 3.5.4.

It is recommended to use the property instead of the method if a standard supports does not need to support PHPCS < 3.5.4.

##### Tags

see
  Collections::$returnTypeTokens

  Related property (PHPCS 3.5.4+).

since
  1.0.0-alpha3

##### Return values

array —

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

## Search results