diff --git a/.github/workflows/basics.yml b/.github/workflows/basics.yml
index c619d6b4..3fa103ae 100644
--- a/.github/workflows/basics.yml
+++ b/.github/workflows/basics.yml
@@ -71,9 +71,7 @@ jobs:
# Check the code-style consistency of the XML file.
- name: Check XML code style
- run: |
- diff -B ./PHPCSUtils/ruleset.xml <(xmllint --format "./PHPCSUtils/ruleset.xml")
- diff -B ./PHPCS23Utils/ruleset.xml <(xmllint --format "./PHPCS23Utils/ruleset.xml")
+ run: diff -B ./PHPCSUtils/ruleset.xml <(xmllint --format "./PHPCSUtils/ruleset.xml")
# Check the code-style consistency of the PHP files.
- name: Check PHP code style
diff --git a/PHPCS23Utils/Sniffs/Load/LoadUtilsSniff.php b/PHPCS23Utils/Sniffs/Load/LoadUtilsSniff.php
deleted file mode 100644
index 3f8ea5ab..00000000
--- a/PHPCS23Utils/Sniffs/Load/LoadUtilsSniff.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
- Standard which makes the PHPCSUtils utility methods for external PHPCS standards available in PHPCS 2.x.
-
diff --git a/PHPCSUtils/Tokens/Collections.php b/PHPCSUtils/Tokens/Collections.php
index babc0f43..998576ca 100644
--- a/PHPCSUtils/Tokens/Collections.php
+++ b/PHPCSUtils/Tokens/Collections.php
@@ -26,51 +26,68 @@
* @since 1.0.0-alpha4 Direct property access is deprecated for forward-compatibility reasons.
* Use the methods of the same name as the property instead.
*
- * @method static array arrayOpenTokensBC() Tokens which can open an array (PHPCS cross-version compatible).
- * @method static array arrayTokens() Tokens which are used to create arrays.
- * @method static array arrayTokensBC() Tokens which are used to create arrays
- * (PHPCS cross-version compatible).
- * @method static array classModifierKeywords() Modifier keywords which can be used for a class declaration.
- * @method static array closedScopes() List of tokens which represent "closed" scopes.
- * @method static array constantModifierKeywords() Tokens which can be used as modifiers for a constant
- * declaration (in OO structures).
- * @method static array controlStructureTokens() Control structure tokens.
- * @method static array functionDeclarationTokens() Tokens which represent a keyword which starts
- * a function declaration.
- * @method static array incrementDecrementOperators() Increment/decrement operator tokens.
- * @method static array listOpenTokensBC() Tokens which can open a list (PHPCS cross-version compatible).
- * @method static array listTokens() Tokens which are used to create lists.
- * @method static array listTokensBC() Tokens which are used to create lists
- * (PHPCS cross-version compatible)
- * @method static array namespaceDeclarationClosers() List of tokens which can end a namespace declaration statement.
- * @method static array nameTokens() Tokens used for "names", be it namespace, OO, function
- * or constant names.
- * @method static array objectOperators() Object operator tokens.
- * @method static array phpOpenTags() Tokens which open PHP.
- * @method static array propertyModifierKeywords() Modifier keywords which can be used for a property declaration.
- * @method static array shortArrayListOpenTokensBC() Tokens which can open a short array or short list
- * (PHPCS cross-version compatible).
- * @method static array shortArrayTokens() Tokens which are used for short arrays.
- * @method static array shortArrayTokensBC() Tokens which are used for short arrays
- * (PHPCS cross-version compatible).
- * @method static array shortListTokens() Tokens which are used for short lists.
- * @method static array shortListTokensBC() Tokens which are used for short lists
- * (PHPCS cross-version compatible).
+ * @method static array alternativeControlStructureSyntaxes() Tokens for control structures which can use the
+ * alternative control structure syntax.
+ * @method static array alternativeControlStructureSyntaxClosers() Tokens representing alternative control structure
+ * syntax closer keywords.
+ * @method static array arrayOpenTokensBC() Tokens which can open an array
+ * (PHPCS cross-version compatible).
+ * @method static array arrayTokens() Tokens which are used to create arrays.
+ * @method static array arrayTokensBC() Tokens which are used to create arrays
+ * (PHPCS cross-version compatible).
+ * @method static array classModifierKeywords() Modifier keywords which can be used for a class
+ * declaration.
+ * @method static array closedScopes() List of tokens which represent "closed" scopes.
+ * @method static array constantModifierKeywords() Tokens which can be used as modifiers for a constant
+ * declaration (in OO structures).
+ * @method static array controlStructureTokens() Control structure tokens.
+ * @method static array functionDeclarationTokens() Tokens which represent a keyword which starts
+ * a function declaration.
+ * @method static array incrementDecrementOperators() Increment/decrement operator tokens.
+ * @method static array listOpenTokensBC() Tokens which can open a list
+ * (PHPCS cross-version compatible).
+ * @method static array listTokens() Tokens which are used to create lists.
+ * @method static array listTokensBC() Tokens which are used to create lists
+ * (PHPCS cross-version compatible)
+ * @method static array namespaceDeclarationClosers() List of tokens which can end a namespace
+ * declaration statement.
+ * @method static array nameTokens() Tokens used for "names", be it namespace, OO,
+ * function
+ * or constant names.
+ * @method static array objectOperators() Object operator tokens.
+ * @method static array ooCanExtend() OO structures which can use the "extends" keyword.
+ * @method static array ooCanImplement() OO structures which can use the "implements" keyword.
+ * @method static array ooConstantScopes() OO scopes in which constants can be declared.
+ * @method static array ooHierarchyKeywords() Tokens types used for "forwarding" calls within
+ * OO structures.
+ * @method static array ooPropertyScopes() OO scopes in which properties can be declared.
+ * @method static array phpOpenTags() Tokens which open PHP.
+ * @method static array propertyModifierKeywords() Modifier keywords which can be used for a property
+ * declaration.
+ * @method static array shortArrayListOpenTokensBC() Tokens which can open a short array or short list
+ * (PHPCS cross-version compatible).
+ * @method static array shortArrayTokens() Tokens which are used for short arrays.
+ * @method static array shortArrayTokensBC() Tokens which are used for short arrays
+ * (PHPCS cross-version compatible).
+ * @method static array shortListTokens() Tokens which are used for short lists.
+ * @method static array shortListTokensBC() Tokens which are used for short lists
+ * (PHPCS cross-version compatible).
+ * @method static array textStringStartTokens() Tokens which can start a - potentially multi-line -
+ * text string.
*/
final class Collections
{
/**
- * DEPRECATED: Tokens for control structures which can use the alternative control structure syntax.
+ * Tokens for control structures which can use the alternative control structure syntax.
*
* @since 1.0.0-alpha2
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::alternativeControlStructureSyntaxes()}
- * method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::alternativeControlStructureSyntaxes()} method for access.
*
* @var array =>
*/
- public static $alternativeControlStructureSyntaxTokens = [
+ private static $alternativeControlStructureSyntaxes = [
\T_IF => \T_IF,
\T_ELSEIF => \T_ELSEIF,
\T_ELSE => \T_ELSE,
@@ -82,16 +99,15 @@ final class Collections
];
/**
- * DEPRECATED: Tokens representing alternative control structure syntax closer keywords.
+ * Tokens representing alternative control structure syntax closer keywords.
*
* @since 1.0.0-alpha2
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::alternativeControlStructureSyntaxClosers()}
- * method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::alternativeControlStructureSyntaxClosers()} method for access.
*
* @var array =>
*/
- public static $alternativeControlStructureSyntaxCloserTokens = [
+ private static $alternativeControlStructureSyntaxClosers = [
\T_ENDIF => \T_ENDIF,
\T_ENDFOR => \T_ENDFOR,
\T_ENDFOREACH => \T_ENDFOREACH,
@@ -123,7 +139,7 @@ final class Collections
];
/**
- * DEPRECATED: Tokens which are used to create arrays.
+ * Tokens which are used to create arrays.
*
* @see \PHPCSUtils\Tokens\Collections::arrayOpenTokensBC() Related method to retrieve only the "open" tokens
* used for arrays (PHPCS cross-version compatible).
@@ -133,19 +149,19 @@ final class Collections
* for short arrays.
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::arrayTokens()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::arrayTokens()} method for access.
*
* @var array =>
*/
- public static $arrayTokens = [
+ private static $arrayTokens = [
\T_ARRAY => \T_ARRAY,
\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
\T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY,
];
/**
- * DEPRECATED: Tokens which are used to create arrays (PHPCS cross-version compatible).
+ * Tokens which are used to create arrays (PHPCS cross-version compatible).
*
* Includes `T_OPEN_SQUARE_BRACKET` and `T_CLOSE_SQUARE_BRACKET` to allow for handling
* intermittent tokenizer issues related to the retokenization to `T_OPEN_SHORT_ARRAY`.
@@ -157,12 +173,12 @@ final class Collections
* for short arrays (PHPCS cross-version compatible).
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::arrayTokensBC()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::arrayTokensBC()} method for access.
*
* @var array =>
*/
- public static $arrayTokensBC = [
+ private static $arrayTokensBC = [
\T_ARRAY => \T_ARRAY,
\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
\T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY,
@@ -171,23 +187,23 @@ final class Collections
];
/**
- * DEPRECATED: Modifier keywords which can be used for a class declaration.
+ * Modifier keywords which can be used for a class declaration.
*
* @since 1.0.0-alpha1
* @since 1.0.0-alpha4 Added the T_READONLY token for PHP 8.2 readonly classes.
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::classModifierKeywords()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::classModifierKeywords()} method for access.
*
* @var array =>
*/
- public static $classModifierKeywords = [
+ private static $classModifierKeywords = [
\T_FINAL => \T_FINAL,
\T_ABSTRACT => \T_ABSTRACT,
\T_READONLY => \T_READONLY,
];
/**
- * DEPRECATED: List of tokens which represent "closed" scopes.
+ * List of tokens which represent "closed" scopes.
*
* I.e. anything declared within that scope - except for other closed scopes - is
* outside of the global namespace.
@@ -197,12 +213,12 @@ final class Collections
*
* @since 1.0.0-alpha1
* @since 1.0.0-alpha4 Added the PHP 8.1 T_ENUM token.
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::closedScopes()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::closedScopes()} method for access.
*
* @var array =>
*/
- public static $closedScopes = [
+ private static $closedScopes = [
\T_CLASS => \T_CLASS,
\T_ANON_CLASS => \T_ANON_CLASS,
\T_INTERFACE => \T_INTERFACE,
@@ -230,16 +246,16 @@ final class Collections
];
/**
- * DEPRECATED: Control structure tokens.
+ * Control structure tokens.
*
* @since 1.0.0-alpha2
* @since 1.0.0-alpha4 Added the T_MATCH token for PHP 8.0 match expressions.
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::controlStructureTokens()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::controlStructureTokens()} method for access.
*
* @var array =>
*/
- public static $controlStructureTokens = [
+ private static $controlStructureTokens = [
\T_IF => \T_IF,
\T_ELSEIF => \T_ELSEIF,
\T_ELSE => \T_ELSE,
@@ -266,15 +282,15 @@ final class Collections
];
/**
- * DEPRECATED: Increment/decrement operator tokens.
+ * Increment/decrement operator tokens.
*
* @since 1.0.0-alpha3
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::incrementDecrementOperators()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::incrementDecrementOperators()} method for access.
*
* @var array =>
*/
- public static $incrementDecrementOperators = [
+ private static $incrementDecrementOperators = [
\T_DEC => \T_DEC,
\T_INC => \T_INC,
];
@@ -302,7 +318,7 @@ final class Collections
];
/**
- * DEPRECATED: Tokens which are used to create lists.
+ * Tokens which are used to create lists.
*
* @see \PHPCSUtils\Tokens\Collections::listTokensBC() Related method to retrieve tokens used
* for lists (PHPCS cross-version).
@@ -310,19 +326,19 @@ final class Collections
* for short lists.
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::listTokens()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::listTokens()} method for access.
*
* @var array =>
*/
- public static $listTokens = [
+ private static $listTokens = [
\T_LIST => \T_LIST,
\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
\T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY,
];
/**
- * DEPRECATED: Tokens which are used to create lists (PHPCS cross-version compatible).
+ * Tokens which are used to create lists (PHPCS cross-version compatible).
*
* Includes `T_OPEN_SQUARE_BRACKET` and `T_CLOSE_SQUARE_BRACKET` to allow for handling
* intermittent tokenizer issues related to the retokenization to `T_OPEN_SHORT_ARRAY`.
@@ -332,12 +348,12 @@ final class Collections
* for short lists (cross-version).
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::listTokensBC()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::listTokensBC()} method for access.
*
* @var array =>
*/
- public static $listTokensBC = [
+ private static $listTokensBC = [
\T_LIST => \T_LIST,
\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
\T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY,
@@ -346,36 +362,15 @@ final class Collections
];
/**
- * DEPRECATED: Tokens for the PHP magic constants.
- *
- * @since 1.0.0-alpha3
- *
- * @deprecated 1.0.0-alpha4 Use the {@see \PHP_CodeSniffer\Util\Tokens::$magicConstants} property
- * or the {@see \PHPCSUtils\BackCompat\BCTokens::magicConstants()} method instead.
- *
- * @var array =>
- */
- public static $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,
- ];
-
- /**
- * DEPRECATED: List of tokens which can end a namespace declaration statement.
+ * List of tokens which can end a namespace declaration statement.
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::namespaceDeclarationClosers()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::namespaceDeclarationClosers()} method for access.
*
* @var array =>
*/
- public static $namespaceDeclarationClosers = [
+ private static $namespaceDeclarationClosers = [
\T_SEMICOLON => \T_SEMICOLON,
\T_OPEN_CURLY_BRACKET => \T_OPEN_CURLY_BRACKET,
\T_CLOSE_TAG => \T_CLOSE_TAG,
@@ -404,66 +399,66 @@ final class Collections
];
/**
- * DEPRECATED: Object operator tokens.
+ * Object operator tokens.
*
* @since 1.0.0-alpha3
* @since 1.0.0-alpha4 Added the PHP 8.0 T_NULLSAFE_OBJECT_OPERATOR token.
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::objectOperators()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::objectOperators()} method for access.
*
* @var array =>
*/
- public static $objectOperators = [
+ private static $objectOperators = [
\T_DOUBLE_COLON => \T_DOUBLE_COLON,
\T_OBJECT_OPERATOR => \T_OBJECT_OPERATOR,
\T_NULLSAFE_OBJECT_OPERATOR => \T_NULLSAFE_OBJECT_OPERATOR,
];
/**
- * DEPRECATED: OO structures which can use the "extends" keyword.
+ * OO structures which can use the "extends" keyword.
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::ooCanExtend()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::ooCanExtend()} method for access.
*
* @var array =>
*/
- public static $OOCanExtend = [
+ private static $ooCanExtend = [
\T_CLASS => \T_CLASS,
\T_ANON_CLASS => \T_ANON_CLASS,
\T_INTERFACE => \T_INTERFACE,
];
/**
- * DEPRECATED: OO structures which can use the "implements" keyword.
+ * OO structures which can use the "implements" keyword.
*
* @since 1.0.0-alpha1
* @since 1.0.0-alpha4 Added the PHP 8.1 T_ENUM token.
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::ooCanImplement()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::ooCanImplement()} method for access.
*
* @var array =>
*/
- public static $OOCanImplement = [
+ private static $ooCanImplement = [
\T_CLASS => \T_CLASS,
\T_ANON_CLASS => \T_ANON_CLASS,
\T_ENUM => \T_ENUM,
];
/**
- * DEPRECATED: OO scopes in which constants can be declared.
+ * OO scopes in which constants can be declared.
*
* Note: traits can only declare constants since PHP 8.2.
*
* @since 1.0.0-alpha1
* @since 1.0.0-alpha4 Added the PHP 8.1 T_ENUM token.
* @since 1.0.0-alpha4 Added the T_TRAIT token for PHP 8.2 constants in traits.
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::ooConstantScopes()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::ooConstantScopes()} method for access.
*
* @var array =>
*/
- public static $OOConstantScopes = [
+ private static $ooConstantScopes = [
\T_CLASS => \T_CLASS,
\T_ANON_CLASS => \T_ANON_CLASS,
\T_INTERFACE => \T_INTERFACE,
@@ -472,75 +467,58 @@ final class Collections
];
/**
- * DEPRECATED: Tokens types used for "forwarding" calls within OO structures.
+ * Tokens types used for "forwarding" calls within OO structures.
*
* @link https://www.php.net/language.oop5.paamayim-nekudotayim PHP Manual on OO forwarding calls
*
* @since 1.0.0-alpha3
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::ooHierarchyKeywords()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::ooHierarchyKeywords()} method for access.
*
* @var array =>
*/
- public static $OOHierarchyKeywords = [
+ private static $ooHierarchyKeywords = [
\T_PARENT => \T_PARENT,
\T_SELF => \T_SELF,
\T_STATIC => \T_STATIC,
];
/**
- * DEPRECATED: Tokens types which can be encountered in the fully/partially qualified name of an OO structure.
- *
- * @since 1.0.0-alpha3
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::namespacedNameTokens()} method instead.
- *
- * @var array =>
- */
- public static $OONameTokens = [
- \T_NS_SEPARATOR => \T_NS_SEPARATOR,
- \T_STRING => \T_STRING,
- \T_NAMESPACE => \T_NAMESPACE,
- ];
-
- /**
- * DEPRECATED: OO scopes in which properties can be declared.
+ * OO scopes in which properties can be declared.
*
* Note: interfaces can not declare properties.
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::ooPropertyScopes()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::ooPropertyScopes()} method for access.
*
* @var array =>
*/
- public static $OOPropertyScopes = [
+ private static $ooPropertyScopes = [
\T_CLASS => \T_CLASS,
\T_ANON_CLASS => \T_ANON_CLASS,
\T_TRAIT => \T_TRAIT,
];
/**
- * DEPRECATED: Token types which can be encountered in a parameter type declaration.
+ * Token types which can be encountered in a parameter type declaration.
*
* @since 1.0.0-alpha1
* @since 1.0.0-alpha4 Added the T_TYPE_UNION, T_FALSE, T_NULL tokens for PHP 8.0 union type support.
* @since 1.0.0-alpha4 Added the T_TYPE_INTERSECTION token for PHP 8.1 intersection type support.
* @since 1.0.0-alpha4 Added the T_TRUE token for PHP 8.2 true type support.
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::parameterTypeTokens()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::parameterTypeTokens()} method for access.
*
* @var array =>
*/
- public static $parameterTypeTokens = [
+ private static $parameterTypeTokens = [
\T_CALLABLE => \T_CALLABLE,
\T_SELF => \T_SELF,
\T_PARENT => \T_PARENT,
\T_FALSE => \T_FALSE,
\T_TRUE => \T_TRUE,
\T_NULL => \T_NULL,
- \T_STRING => \T_STRING,
- \T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_TYPE_UNION => \T_TYPE_UNION,
\T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION,
];
@@ -558,16 +536,16 @@ final class Collections
];
/**
- * DEPRECATED: Modifier keywords which can be used for a property declaration.
+ * Modifier keywords which can be used for a property declaration.
*
* @since 1.0.0-alpha1
* @since 1.0.0-alpha4 Added the T_READONLY token for PHP 8.1 readonly properties.
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::propertyModifierKeywords()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::propertyModifierKeywords()} method for access.
*
* @var array =>
*/
- public static $propertyModifierKeywords = [
+ private static $propertyModifierKeywords = [
\T_PUBLIC => \T_PUBLIC,
\T_PRIVATE => \T_PRIVATE,
\T_PROTECTED => \T_PROTECTED,
@@ -577,52 +555,45 @@ final class Collections
];
/**
- * DEPRECATED: Token types which can be encountered in a property type declaration.
+ * Token types which can be encountered in a property type declaration.
*
* @since 1.0.0-alpha1
* @since 1.0.0-alpha4 Added the T_TYPE_UNION, T_FALSE, T_NULL tokens for PHP 8.0 union type support.
* @since 1.0.0-alpha4 Added the T_TYPE_INTERSECTION token for PHP 8.1 intersection type support.
* @since 1.0.0-alpha4 Added the T_TRUE token for PHP 8.2 true type support.
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::propertyTypeTokens()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::propertyTypeTokens()} method for access.
*
* @var array =>
*/
- public static $propertyTypeTokens = [
+ private static $propertyTypeTokens = [
\T_CALLABLE => \T_CALLABLE,
\T_SELF => \T_SELF,
\T_PARENT => \T_PARENT,
\T_FALSE => \T_FALSE,
\T_TRUE => \T_TRUE,
\T_NULL => \T_NULL,
- \T_STRING => \T_STRING,
- \T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_TYPE_UNION => \T_TYPE_UNION,
\T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION,
];
/**
- * DEPRECATED: Token types which can be encountered in a return type declaration.
+ * Token types which can be encountered in a return type declaration.
*
* @since 1.0.0-alpha1
* @since 1.0.0-alpha4 Added the T_TYPE_UNION, T_FALSE, T_NULL tokens for PHP 8.0 union type support.
* @since 1.0.0-alpha4 Added the T_TYPE_INTERSECTION token for PHP 8.1 intersection type support.
* @since 1.0.0-alpha4 Added the T_TRUE token for PHP 8.2 true type support.
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::returnTypeTokens()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::returnTypeTokens()} method for access.
*
* @var array =>
*/
- public static $returnTypeTokens = [
+ private static $returnTypeTokens = [
\T_CALLABLE => \T_CALLABLE,
- \T_SELF => \T_SELF,
- \T_PARENT => \T_PARENT,
- \T_STATIC => \T_STATIC,
\T_FALSE => \T_FALSE,
\T_TRUE => \T_TRUE,
\T_NULL => \T_NULL,
- \T_STRING => \T_STRING,
- \T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_TYPE_UNION => \T_TYPE_UNION,
\T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION,
];
@@ -644,23 +615,23 @@ final class Collections
];
/**
- * DEPRECATED: Tokens which are used for short arrays.
+ * Tokens which are used for short arrays.
*
* @see \PHPCSUtils\Tokens\Collections::arrayTokens() Related method to retrieve all tokens used for arrays.
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::shortArrayTokens()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::shortArrayTokens()} method for access.
*
* @var array =>
*/
- public static $shortArrayTokens = [
+ private static $shortArrayTokens = [
\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
\T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY,
];
/**
- * DEPRECATED: Tokens which are used for short arrays (PHPCS cross-version compatible).
+ * Tokens which are used for short arrays (PHPCS cross-version compatible).
*
* Includes `T_OPEN_SQUARE_BRACKET` and `T_CLOSE_SQUARE_BRACKET` to allow for handling
* intermittent tokenizer issues related to the retokenization to `T_OPEN_SHORT_ARRAY`.
@@ -670,12 +641,12 @@ final class Collections
* (cross-version).
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::shortArrayTokensBC()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::shortArrayTokensBC()} method for access.
*
* @var array =>
*/
- public static $shortArrayTokensBC = [
+ private static $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,
@@ -683,23 +654,23 @@ final class Collections
];
/**
- * DEPRECATED: Tokens which are used for short lists.
+ * Tokens which are used for short lists.
*
* @see \PHPCSUtils\Tokens\Collections::listTokens() Related method to retrieve all tokens used for lists.
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::shortListTokens()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::shortListTokens()} method for access.
*
* @var array =>
*/
- public static $shortListTokens = [
+ private static $shortListTokens = [
\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
\T_CLOSE_SHORT_ARRAY => \T_CLOSE_SHORT_ARRAY,
];
/**
- * DEPRECATED: Tokens which are used for short lists (PHPCS cross-version compatible).
+ * Tokens which are used for short lists (PHPCS cross-version compatible).
*
* Includes `T_OPEN_SQUARE_BRACKET` and `T_CLOSE_SQUARE_BRACKET` to allow for handling
* intermittent tokenizer issues related to the retokenization to `T_OPEN_SHORT_ARRAY`.
@@ -709,12 +680,12 @@ final class Collections
* (cross-version).
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::shortListTokensBC()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::shortListTokensBC()} method for access.
*
* @var array =>
*/
- public static $shortListTokensBC = [
+ private static $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,
@@ -722,15 +693,15 @@ final class Collections
];
/**
- * DEPRECATED: Tokens which can start a - potentially multi-line - text string.
+ * Tokens which can start a - potentially multi-line - text string.
*
* @since 1.0.0-alpha1
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::textStringStartTokens()} method instead.
+ * @since 1.0.0-rc1 This property is now private.
+ * Use the {@see Collections::textStringStartTokens()} method for access.
*
* @var array =>
*/
- public static $textStingStartTokens = [
+ private static $textStringStartTokens = [
\T_START_HEREDOC => \T_START_HEREDOC,
\T_START_NOWDOC => \T_START_NOWDOC,
\T_CONSTANT_ENCAPSED_STRING => \T_CONSTANT_ENCAPSED_STRING,
@@ -786,48 +757,6 @@ private static function triggerDeprecation($method, $version, $replacement)
);
}
- /**
- * Tokens for control structures which can use the alternative control structure syntax.
- *
- * @since 1.0.0-alpha4 This method replaces the {@see Collections::$alternativeControlStructureSyntaxTokens}
- * property.
- *
- * @return array =>
- */
- public static function alternativeControlStructureSyntaxes()
- {
- return self::$alternativeControlStructureSyntaxTokens;
- }
-
- /**
- * Tokens representing alternative control structure syntax closer keywords.
- *
- * @since 1.0.0-alpha4 This method replaces the {@see Collections::$alternativeControlStructureSyntaxCloserTokens}
- * property.
- *
- * @return array =>
- */
- public static function alternativeControlStructureSyntaxClosers()
- {
- return self::$alternativeControlStructureSyntaxCloserTokens;
- }
-
- /**
- * DEPRECATED: Tokens which can represent the arrow function keyword.
- *
- * @since 1.0.0-alpha2
- *
- * @deprecated 1.0.0-alpha4 Use the `T_FN` token constant instead.
- *
- * @return array =>
- */
- public static function arrowFunctionTokensBC()
- {
- self::triggerDeprecation(__FUNCTION__, '1.0.0-alpha4', 'the `T_FN` token');
-
- return [\T_FN => \T_FN];
- }
-
/**
* Tokens which can represent function calls and function-call-like language constructs.
*
@@ -845,31 +774,11 @@ public static function functionCallTokens()
// Class instantiation only.
$tokens[\T_ANON_CLASS] = \T_ANON_CLASS;
- $tokens += self::$OOHierarchyKeywords;
+ $tokens += self::$ooHierarchyKeywords;
return $tokens;
}
- /**
- * DEPRECATED: Tokens which represent a keyword which starts a function declaration.
- *
- * @since 1.0.0-alpha3
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::functionDeclarationTokens()} method instead.
- *
- * @return array =>
- */
- public static function functionDeclarationTokensBC()
- {
- self::triggerDeprecation(
- __FUNCTION__,
- '1.0.0-alpha4',
- \sprintf('the %s::functionDeclarationTokens() method', __CLASS__)
- );
-
- return self::$functionDeclarationTokens;
- }
-
/**
* Tokens types which can be encountered in a fully, partially or unqualified name.
*
@@ -894,75 +803,6 @@ public static function namespacedNameTokens()
return $tokens;
}
- /**
- * OO structures which can use the "extends" keyword.
- *
- * @since 1.0.0-alpha4 This method replaces the {@see Collections::$OOCanExtend} property.
- *
- * @return array =>
- */
- public static function ooCanExtend()
- {
- return self::$OOCanExtend;
- }
-
- /**
- * OO structures which can use the "implements" keyword.
- *
- * @since 1.0.0-alpha4 This method replaces the {@see Collections::$OOCanImplement} property.
- * @since 1.0.0-alpha4 Added the PHP 8.1 T_ENUM token.
- *
- * @return array =>
- */
- public static function ooCanImplement()
- {
- return self::$OOCanImplement;
- }
-
- /**
- * OO scopes in which constants can be declared.
- *
- * Note: traits can only declare constants since PHP 8.2.
- *
- * @since 1.0.0-alpha4 This method replaces the {@see Collections::$OOConstantScopes} property.
- * @since 1.0.0-alpha4 Added the PHP 8.1 T_ENUM token.
- * @since 1.0.0-alpha4 Added the T_TRAIT token for PHP 8.2 constants in traits.
- *
- * @return array =>
- */
- public static function ooConstantScopes()
- {
- return self::$OOConstantScopes;
- }
-
- /**
- * Tokens types used for "forwarding" calls within OO structures.
- *
- * @link https://www.php.net/language.oop5.paamayim-nekudotayim PHP Manual on OO forwarding calls
- *
- * @since 1.0.0-alpha4 This method replaces the {@see Collections::$OOHierarchyKeywords} property.
- *
- * @return array =>
- */
- public static function ooHierarchyKeywords()
- {
- return self::$OOHierarchyKeywords;
- }
-
- /**
- * OO scopes in which properties can be declared.
- *
- * Note: interfaces can not declare properties.
- *
- * @since 1.0.0-alpha4 This method replaces the {@see Collections::$OOPropertyScopes} property.
- *
- * @return array =>
- */
- public static function ooPropertyScopes()
- {
- return self::$OOPropertyScopes;
- }
-
/**
* Tokens which can be passed to the methods in the PassedParameter class.
*
@@ -1006,28 +846,6 @@ public static function parameterTypeTokens()
return $tokens;
}
- /**
- * DEPRECATED: Token types which can be encountered in a parameter type declaration (cross-version).
- *
- * @see \PHPCSUtils\Tokens\Collections::parameterTypeTokens() Related method (PHPCS 3.3.0+).
- *
- * @since 1.0.0-alpha3
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::parameterTypeTokens()} method instead.
- *
- * @return array =>
- */
- public static function parameterTypeTokensBC()
- {
- self::triggerDeprecation(
- __FUNCTION__,
- '1.0.0-alpha4',
- \sprintf('the %s::parameterTypeTokens() method', __CLASS__)
- );
-
- return self::parameterTypeTokens();
- }
-
/**
* Token types which can be encountered in a property type declaration.
*
@@ -1047,28 +865,6 @@ public static function propertyTypeTokens()
return $tokens;
}
- /**
- * DEPRECATED: Token types which can be encountered in a property type declaration (cross-version).
- *
- * @see \PHPCSUtils\Tokens\Collections::propertyTypeTokens() Related method (PHPCS 3.3.0+).
- *
- * @since 1.0.0-alpha3
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::propertyTypeTokens()} method instead.
- *
- * @return array =>
- */
- public static function propertyTypeTokensBC()
- {
- self::triggerDeprecation(
- __FUNCTION__,
- '1.0.0-alpha4',
- \sprintf('the %s::propertyTypeTokens() method', __CLASS__)
- );
-
- return self::propertyTypeTokens();
- }
-
/**
* Token types which can be encountered in a return type declaration.
*
@@ -1083,43 +879,9 @@ public static function propertyTypeTokensBC()
public static function returnTypeTokens()
{
$tokens = self::$returnTypeTokens;
- $tokens += self::$OOHierarchyKeywords;
+ $tokens += self::$ooHierarchyKeywords;
$tokens += self::namespacedNameTokens();
return $tokens;
}
-
- /**
- * DEPRECATED: Token types which can be encountered in a return type declaration (cross-version).
- *
- * @see \PHPCSUtils\Tokens\Collections::returnTypeTokens() Related method (PHPCS 3.3.0+).
- *
- * @since 1.0.0-alpha3
- *
- * @deprecated 1.0.0-alpha4 Use the {@see Collections::returnTypeTokens()} method instead.
- *
- * @return array =>
- */
- public static function returnTypeTokensBC()
- {
- self::triggerDeprecation(
- __FUNCTION__,
- '1.0.0-alpha4',
- \sprintf('the %s::returnTypeTokens() method', __CLASS__)
- );
-
- return self::returnTypeTokens();
- }
-
- /**
- * Tokens which can start a - potentially multi-line - text string.
- *
- * @since 1.0.0-alpha4 This method replaces the {@see Collections::$textStingStartTokens} property.
- *
- * @return array =>
- */
- public static function textStringStartTokens()
- {
- return self::$textStingStartTokens;
- }
}
diff --git a/PHPCSUtils/Utils/ControlStructures.php b/PHPCSUtils/Utils/ControlStructures.php
index da6ffd19..c9f7a903 100644
--- a/PHPCSUtils/Utils/ControlStructures.php
+++ b/PHPCSUtils/Utils/ControlStructures.php
@@ -193,66 +193,6 @@ public static function isElseIf(File $phpcsFile, $stackPtr)
return false;
}
- /**
- * Get the scope opener and closer for a DECLARE statement.
- *
- * A `declare` statement can be:
- * - applied to the rest of the file, like `declare(ticks=1);`
- * - applied to a limited scope using curly braces;
- * - applied to a limited scope using the alternative control structure syntax.
- *
- * In the first case, the statement - correctly - won't have a scope opener/closer.
- * In the second case, the statement will have the scope opener/closer indexes.
- * In the last case, due to a bug in the PHPCS Tokenizer, it won't have the scope opener/closer indexes,
- * while it really should. This bug was fixed in PHPCS 3.5.4.
- *
- * @link https://github.com/squizlabs/PHP_CodeSniffer/pull/2843 PHPCS PR #2843
- *
- * @since 1.0.0
- * @deprecated 1.0.0-alpha4 Check the scope_opener/scope_closer instead.
- *
- * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
- * @param int $stackPtr The position of the token we are checking.
- *
- * @return array|false An array with the token pointers; or `FALSE` if not a `DECLARE` token
- * or if the opener/closer could not be determined.
- * The format of the array return value is:
- * ```php
- * array(
- * 'opener' => integer, // Stack pointer to the scope opener.
- * 'closer' => integer, // Stack pointer to the scope closer.
- * )
- * ```
- */
- public static function getDeclareScopeOpenClose(File $phpcsFile, $stackPtr)
- {
- \trigger_error(
- \sprintf(
- 'The %s() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Check for the "scope_opener"/"scope_closer" keys instead.',
- __METHOD__
- ),
- \E_USER_DEPRECATED
- );
-
- $tokens = $phpcsFile->getTokens();
-
- if (isset($tokens[$stackPtr]) === false
- || $tokens[$stackPtr]['code'] !== \T_DECLARE
- ) {
- return false;
- }
-
- if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === true) {
- return [
- 'opener' => $tokens[$stackPtr]['scope_opener'],
- 'closer' => $tokens[$stackPtr]['scope_closer'],
- ];
- }
-
- return false;
- }
-
/**
* Retrieve the exception(s) being caught in a CATCH condition.
*
diff --git a/PHPCSUtils/Utils/FunctionDeclarations.php b/PHPCSUtils/Utils/FunctionDeclarations.php
index 74f87c4c..8371f1ff 100644
--- a/PHPCSUtils/Utils/FunctionDeclarations.php
+++ b/PHPCSUtils/Utils/FunctionDeclarations.php
@@ -621,108 +621,6 @@ public static function getParameters(File $phpcsFile, $stackPtr)
return $vars;
}
- /**
- * Check if an arbitrary token is the "fn" keyword for a PHP 7.4 arrow function.
- *
- * Helper function for cross-version compatibility with both PHP as well as PHPCS.
- * As of PHPCS 3.5.6, this function is no longer be needed.
- *
- * @see \PHPCSUtils\Utils\FunctionDeclarations::getArrowFunctionOpenClose() Related function.
- *
- * @since 1.0.0
- * @deprecated 1.0.0-alpha4 Use the T_FN token constant instead.
- *
- * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found.
- * @param int $stackPtr The token to check. Typically a T_FN or
- * T_STRING token as those are the only two
- * tokens which can be the arrow function keyword.
- *
- * @return bool `TRUE` if the token is the "fn" keyword for an arrow function. `FALSE` when it's not
- * or in case of live coding/parse error.
- */
- public static function isArrowFunction(File $phpcsFile, $stackPtr)
- {
- \trigger_error(
- \sprintf(
- 'The %s() function is deprecated since PHPCSUtils 1.0.0-alpha4. Use the `T_FN` token instead.',
- __METHOD__
- ),
- \E_USER_DEPRECATED
- );
-
- $tokens = $phpcsFile->getTokens();
- if (isset($tokens[$stackPtr]) === false) {
- return false;
- }
-
- if ($tokens[$stackPtr]['code'] === \T_FN
- && isset($tokens[$stackPtr]['scope_closer']) === true
- ) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Retrieve the parenthesis opener, parenthesis closer, the scope opener and the scope closer
- * for an arrow function.
- *
- * Helper function for cross-version compatibility with both PHP as well as PHPCS.
- * As of PHPCS 3.5.6, this function is no longer be needed.
- *
- * @see \PHPCSUtils\Utils\FunctionDeclarations::isArrowFunction() Related function.
- *
- * @since 1.0.0
- * @deprecated 1.0.0-alpha4 Use the T_FN token constant instead.
- *
- * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found.
- * @param int $stackPtr The token to retrieve the openers/closers for.
- * Typically a `T_FN` or `T_STRING` token as those are the
- * only two tokens which can be the arrow function keyword.
- *
- * @return array|false An array with the token pointers or `FALSE` if this is not an arrow function.
- * The format of the return value is:
- * ```php
- * array(
- * 'parenthesis_opener' => integer, // Stack pointer to the parenthesis opener.
- * 'parenthesis_closer' => integer, // Stack pointer to the parenthesis closer.
- * 'scope_opener' => integer, // Stack pointer to the scope opener (arrow).
- * 'scope_closer' => integer, // Stack pointer to the scope closer.
- * )
- * ```
- */
- public static function getArrowFunctionOpenClose(File $phpcsFile, $stackPtr)
- {
- \trigger_error(
- \sprintf(
- 'The %s() function is deprecated since PHPCSUtils 1.0.0-alpha4. Use the `T_FN` token instead.',
- __METHOD__
- ),
- \E_USER_DEPRECATED
- );
-
- $tokens = $phpcsFile->getTokens();
-
- if (isset($tokens[$stackPtr]) === false
- || $tokens[$stackPtr]['code'] !== \T_FN
- ) {
- return false;
- }
-
- if (isset($tokens[$stackPtr]['scope_closer']) === true) {
- // The keys will either all be set or none will be set, so no additional checks needed.
- return [
- 'parenthesis_opener' => $tokens[$stackPtr]['parenthesis_opener'],
- 'parenthesis_closer' => $tokens[$stackPtr]['parenthesis_closer'],
- 'scope_opener' => $tokens[$stackPtr]['scope_opener'],
- 'scope_closer' => $tokens[$stackPtr]['scope_closer'],
- ];
- }
-
- return [];
- }
-
/**
* Checks if a given function is a PHP magic function.
*
diff --git a/Tests/Tokens/Collections/AlternativeControlStructureSyntaxClosersTest.php b/Tests/Tokens/Collections/AlternativeControlStructureSyntaxClosersTest.php
deleted file mode 100644
index 6b6fec78..00000000
--- a/Tests/Tokens/Collections/AlternativeControlStructureSyntaxClosersTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-assertSame(
- Collections::$alternativeControlStructureSyntaxCloserTokens,
- Collections::alternativeControlStructureSyntaxClosers()
- );
- }
-}
diff --git a/Tests/Tokens/Collections/AlternativeControlStructureSyntaxesTest.php b/Tests/Tokens/Collections/AlternativeControlStructureSyntaxesTest.php
deleted file mode 100644
index af3b3707..00000000
--- a/Tests/Tokens/Collections/AlternativeControlStructureSyntaxesTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-assertSame(
- Collections::$alternativeControlStructureSyntaxTokens,
- Collections::alternativeControlStructureSyntaxes()
- );
- }
-}
diff --git a/Tests/Tokens/Collections/ArrowFunctionTokensBCTest.php b/Tests/Tokens/Collections/ArrowFunctionTokensBCTest.php
deleted file mode 100644
index f7b205ad..00000000
--- a/Tests/Tokens/Collections/ArrowFunctionTokensBCTest.php
+++ /dev/null
@@ -1,48 +0,0 @@
-expectDeprecation();
- $this->expectDeprecationMessage(
- 'Collections::arrowFunctionTokensBC() method is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the `T_FN` token instead.'
- );
-
- $expected = [
- \T_FN => \T_FN,
- ];
-
- $this->assertSame($expected, Collections::arrowFunctionTokensBC());
- }
-}
diff --git a/Tests/Tokens/Collections/FunctionDeclarationTokensBCTest.php b/Tests/Tokens/Collections/FunctionDeclarationTokensBCTest.php
deleted file mode 100644
index 067a2ac4..00000000
--- a/Tests/Tokens/Collections/FunctionDeclarationTokensBCTest.php
+++ /dev/null
@@ -1,50 +0,0 @@
-expectDeprecation();
- $this->expectDeprecationMessage(
- 'Collections::functionDeclarationTokensBC() method is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the PHPCSUtils\Tokens\Collections::functionDeclarationTokens() method instead.'
- );
-
- $expected = [
- \T_FUNCTION => \T_FUNCTION,
- \T_CLOSURE => \T_CLOSURE,
- \T_FN => \T_FN,
- ];
-
- $this->assertSame($expected, Collections::functionDeclarationTokensBC());
- }
-}
diff --git a/Tests/Tokens/Collections/OoCanExtendTest.php b/Tests/Tokens/Collections/OoCanExtendTest.php
deleted file mode 100644
index 17d8e842..00000000
--- a/Tests/Tokens/Collections/OoCanExtendTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-assertSame(Collections::$OOCanExtend, Collections::ooCanExtend());
- }
-}
diff --git a/Tests/Tokens/Collections/OoCanImplementTest.php b/Tests/Tokens/Collections/OoCanImplementTest.php
deleted file mode 100644
index cdbd7178..00000000
--- a/Tests/Tokens/Collections/OoCanImplementTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-assertSame(Collections::$OOCanImplement, Collections::ooCanImplement());
- }
-}
diff --git a/Tests/Tokens/Collections/OoConstantScopesTest.php b/Tests/Tokens/Collections/OoConstantScopesTest.php
deleted file mode 100644
index e0f7a605..00000000
--- a/Tests/Tokens/Collections/OoConstantScopesTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-assertSame(Collections::$OOConstantScopes, Collections::ooConstantScopes());
- }
-}
diff --git a/Tests/Tokens/Collections/OoHierarchyKeywordsTest.php b/Tests/Tokens/Collections/OoHierarchyKeywordsTest.php
deleted file mode 100644
index 52e3a689..00000000
--- a/Tests/Tokens/Collections/OoHierarchyKeywordsTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-assertSame(Collections::$OOHierarchyKeywords, Collections::ooHierarchyKeywords());
- }
-}
diff --git a/Tests/Tokens/Collections/OoPropertyScopesTest.php b/Tests/Tokens/Collections/OoPropertyScopesTest.php
deleted file mode 100644
index 957479fd..00000000
--- a/Tests/Tokens/Collections/OoPropertyScopesTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-assertSame(Collections::$OOPropertyScopes, Collections::ooPropertyScopes());
- }
-}
diff --git a/Tests/Tokens/Collections/ParameterTypeTokensBCTest.php b/Tests/Tokens/Collections/ParameterTypeTokensBCTest.php
deleted file mode 100644
index abab2b11..00000000
--- a/Tests/Tokens/Collections/ParameterTypeTokensBCTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
-expectDeprecation();
- $this->expectDeprecationMessage(
- 'Collections::parameterTypeTokensBC() method is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the PHPCSUtils\Tokens\Collections::parameterTypeTokens() method instead.'
- );
-
- $this->assertSame(Collections::parameterTypeTokens(), Collections::parameterTypeTokensBC());
- }
-}
diff --git a/Tests/Tokens/Collections/ParameterTypeTokensTest.php b/Tests/Tokens/Collections/ParameterTypeTokensTest.php
index bf62dbfe..417741cb 100644
--- a/Tests/Tokens/Collections/ParameterTypeTokensTest.php
+++ b/Tests/Tokens/Collections/ParameterTypeTokensTest.php
@@ -39,11 +39,11 @@ public function testParameterTypeTokens()
\T_FALSE => \T_FALSE,
\T_TRUE => \T_TRUE,
\T_NULL => \T_NULL,
- \T_STRING => \T_STRING,
- \T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_TYPE_UNION => \T_TYPE_UNION,
\T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION,
+ \T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_NAMESPACE => \T_NAMESPACE,
+ \T_STRING => \T_STRING,
\T_NAME_QUALIFIED => \T_NAME_QUALIFIED,
\T_NAME_FULLY_QUALIFIED => \T_NAME_FULLY_QUALIFIED,
\T_NAME_RELATIVE => \T_NAME_RELATIVE,
diff --git a/Tests/Tokens/Collections/PropertyBasedTokenArraysTest.php b/Tests/Tokens/Collections/PropertyBasedTokenArraysTest.php
index 4fb4069c..ba168124 100644
--- a/Tests/Tokens/Collections/PropertyBasedTokenArraysTest.php
+++ b/Tests/Tokens/Collections/PropertyBasedTokenArraysTest.php
@@ -37,11 +37,6 @@ final class PropertyBasedTokenArraysTest extends TestCase
*/
public function testPropertyBasedTokenArrays($name)
{
- /*
- * While most properties are still `public`, some aren't, so we may as well set
- * the test up to use reflection from the start, as the intention is to make
- * all relevant properties `private`.
- */
$reflProp = new ReflectionProperty('PHPCSUtils\Tokens\Collections', $name);
$reflProp->setAccessible(true);
$expected = $reflProp->getValue();
@@ -60,6 +55,8 @@ public function testPropertyBasedTokenArrays($name)
public function dataPropertyBasedTokenArrays()
{
$names = [
+ 'alternativeControlStructureSyntaxes',
+ 'alternativeControlStructureSyntaxClosers',
'arrayOpenTokensBC',
'arrayTokens',
'arrayTokensBC',
@@ -75,6 +72,11 @@ public function dataPropertyBasedTokenArrays()
'namespaceDeclarationClosers',
'nameTokens',
'objectOperators',
+ 'ooCanExtend',
+ 'ooCanImplement',
+ 'ooConstantScopes',
+ 'ooHierarchyKeywords',
+ 'ooPropertyScopes',
'phpOpenTags',
'propertyModifierKeywords',
'shortArrayListOpenTokensBC',
@@ -82,6 +84,7 @@ public function dataPropertyBasedTokenArrays()
'shortArrayTokensBC',
'shortListTokens',
'shortListTokensBC',
+ 'textStringStartTokens',
];
$data = [];
diff --git a/Tests/Tokens/Collections/PropertyTypeTokensBCTest.php b/Tests/Tokens/Collections/PropertyTypeTokensBCTest.php
deleted file mode 100644
index ff492c35..00000000
--- a/Tests/Tokens/Collections/PropertyTypeTokensBCTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
-expectDeprecation();
- $this->expectDeprecationMessage(
- 'Collections::propertyTypeTokensBC() method is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the PHPCSUtils\Tokens\Collections::propertyTypeTokens() method instead.'
- );
-
- $this->assertSame(Collections::propertyTypeTokens(), Collections::propertyTypeTokensBC());
- }
-}
diff --git a/Tests/Tokens/Collections/PropertyTypeTokensTest.php b/Tests/Tokens/Collections/PropertyTypeTokensTest.php
index 0f8e2b17..d2c3aeae 100644
--- a/Tests/Tokens/Collections/PropertyTypeTokensTest.php
+++ b/Tests/Tokens/Collections/PropertyTypeTokensTest.php
@@ -39,11 +39,11 @@ public function testPropertyTypeTokens()
\T_FALSE => \T_FALSE,
\T_TRUE => \T_TRUE,
\T_NULL => \T_NULL,
- \T_STRING => \T_STRING,
- \T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_TYPE_UNION => \T_TYPE_UNION,
\T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION,
+ \T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_NAMESPACE => \T_NAMESPACE,
+ \T_STRING => \T_STRING,
\T_NAME_QUALIFIED => \T_NAME_QUALIFIED,
\T_NAME_FULLY_QUALIFIED => \T_NAME_FULLY_QUALIFIED,
\T_NAME_RELATIVE => \T_NAME_RELATIVE,
diff --git a/Tests/Tokens/Collections/ReturnTypeTokensBCTest.php b/Tests/Tokens/Collections/ReturnTypeTokensBCTest.php
deleted file mode 100644
index a3b6b9d9..00000000
--- a/Tests/Tokens/Collections/ReturnTypeTokensBCTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
-expectDeprecation();
- $this->expectDeprecationMessage(
- 'Collections::returnTypeTokensBC() method is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the PHPCSUtils\Tokens\Collections::returnTypeTokens() method instead.'
- );
-
- $this->assertSame(Collections::returnTypeTokens(), Collections::returnTypeTokensBC());
- }
-}
diff --git a/Tests/Tokens/Collections/ReturnTypeTokensTest.php b/Tests/Tokens/Collections/ReturnTypeTokensTest.php
index 513a8f1d..085061c7 100644
--- a/Tests/Tokens/Collections/ReturnTypeTokensTest.php
+++ b/Tests/Tokens/Collections/ReturnTypeTokensTest.php
@@ -34,17 +34,17 @@ public function testReturnTypeTokens()
{
$expected = [
\T_CALLABLE => \T_CALLABLE,
- \T_SELF => \T_SELF,
- \T_PARENT => \T_PARENT,
- \T_STATIC => \T_STATIC,
\T_FALSE => \T_FALSE,
\T_TRUE => \T_TRUE,
\T_NULL => \T_NULL,
- \T_STRING => \T_STRING,
- \T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_TYPE_UNION => \T_TYPE_UNION,
\T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION,
+ \T_PARENT => \T_PARENT,
+ \T_SELF => \T_SELF,
+ \T_STATIC => \T_STATIC,
+ \T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_NAMESPACE => \T_NAMESPACE,
+ \T_STRING => \T_STRING,
\T_NAME_QUALIFIED => \T_NAME_QUALIFIED,
\T_NAME_FULLY_QUALIFIED => \T_NAME_FULLY_QUALIFIED,
\T_NAME_RELATIVE => \T_NAME_RELATIVE,
diff --git a/Tests/Tokens/Collections/TextStringStartTokensTest.php b/Tests/Tokens/Collections/TextStringStartTokensTest.php
deleted file mode 100644
index 89b89b9b..00000000
--- a/Tests/Tokens/Collections/TextStringStartTokensTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-assertSame(Collections::$textStingStartTokens, Collections::textStringStartTokens());
- }
-}
diff --git a/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError1Test.inc b/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError1Test.inc
deleted file mode 100644
index 2578c24a..00000000
--- a/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError1Test.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-expectDeprecation();
- $this->expectDeprecationMessage(
- 'ControlStructures::getDeclareScopeOpenClose() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Check for the "scope_opener"/"scope_closer" keys instead.'
- );
-
- $stackPtr = $this->getTargetToken('/* testNoCloseParenthesis */', \T_DECLARE);
- $result = ControlStructures::getDeclareScopeOpenClose(self::$phpcsFile, $stackPtr);
- $this->assertFalse($result);
- }
-}
diff --git a/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError2Test.inc b/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError2Test.inc
deleted file mode 100644
index 275a9989..00000000
--- a/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError2Test.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-expectDeprecation();
- $this->expectDeprecationMessage(
- 'ControlStructures::getDeclareScopeOpenClose() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Check for the "scope_opener"/"scope_closer" keys instead.'
- );
-
- $stackPtr = $this->getTargetToken('/* testNoScopeOpener */', \T_DECLARE);
- $result = ControlStructures::getDeclareScopeOpenClose(self::$phpcsFile, $stackPtr);
- $this->assertFalse($result);
- }
-}
diff --git a/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError3Test.inc b/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError3Test.inc
deleted file mode 100644
index 29348ff8..00000000
--- a/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError3Test.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-expectDeprecation();
- $this->expectDeprecationMessage(
- 'ControlStructures::getDeclareScopeOpenClose() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Check for the "scope_opener"/"scope_closer" keys instead.'
- );
-
- $stackPtr = $this->getTargetToken('/* testNoScopeCloser */', \T_DECLARE);
- $result = ControlStructures::getDeclareScopeOpenClose(self::$phpcsFile, $stackPtr);
- $this->assertFalse($result);
- }
-}
diff --git a/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError4Test.inc b/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError4Test.inc
deleted file mode 100644
index b05cccfa..00000000
--- a/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseParseError4Test.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-expectDeprecation();
- $this->expectDeprecationMessage(
- 'ControlStructures::getDeclareScopeOpenClose() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Check for the "scope_opener"/"scope_closer" keys instead.'
- );
-
- $stackPtr = $this->getTargetToken('/* testUnexpectedToken */', \T_DECLARE);
- $result = ControlStructures::getDeclareScopeOpenClose(self::$phpcsFile, $stackPtr);
- $this->assertFalse($result);
- }
-}
diff --git a/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseTest.inc b/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseTest.inc
deleted file mode 100644
index 057e07ba..00000000
--- a/Tests/Utils/ControlStructures/GetDeclareScopeOpenCloseTest.inc
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-expectDeprecation();
- $this->expectDeprecationMessage(
- 'ControlStructures::getDeclareScopeOpenClose() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Check for the "scope_opener"/"scope_closer" keys instead.'
- );
-
- $this->assertFalse(ControlStructures::getDeclareScopeOpenClose(self::$phpcsFile, 10000));
- }
-
- /**
- * Test that false is returned when a token other than `T_DECLARE` is passed.
- *
- * @return void
- */
- public function testNotDeclare()
- {
- $this->expectDeprecation();
- $this->expectDeprecationMessage(
- 'ControlStructures::getDeclareScopeOpenClose() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Check for the "scope_opener"/"scope_closer" keys instead.'
- );
-
- $target = $this->getTargetToken('/* testNotDeclare */', \T_ECHO);
- $this->assertFalse(ControlStructures::getDeclareScopeOpenClose(self::$phpcsFile, $target));
- }
-
- /**
- * Test retrieving the scope open/close tokens for a `declare` statement.
- *
- * @dataProvider dataGetDeclareScopeOpenClose
- *
- * @param string $testMarker The comment which prefaces the target token in the test file.
- * @param array|false $expected The expected return value.
- *
- * @return void
- */
- public function testGetDeclareScopeOpenClose($testMarker, $expected)
- {
- $this->expectDeprecation();
- $this->expectDeprecationMessage(
- 'ControlStructures::getDeclareScopeOpenClose() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Check for the "scope_opener"/"scope_closer" keys instead.'
- );
-
- $stackPtr = $this->getTargetToken($testMarker, \T_DECLARE);
-
- // Translate offsets to absolute token positions.
- if (isset($expected['opener'], $expected['closer']) === true) {
- $expected['opener'] += $stackPtr;
- $expected['closer'] += $stackPtr;
- }
-
- $result = ControlStructures::getDeclareScopeOpenClose(self::$phpcsFile, $stackPtr);
- $this->assertSame($expected, $result);
- }
-
- /**
- * Data provider.
- *
- * @see testGetDeclareScopeOpenClose() For the array format.
- *
- * @return array
- */
- public function dataGetDeclareScopeOpenClose()
- {
- return [
- 'file-scope' => [
- 'testMarker' => '/* testFileScope */',
- 'expected' => false,
- ],
-
- 'curlies' => [
- 'testMarker' => '/* testCurlies */',
- 'expected' => [
- 'opener' => 7,
- 'closer' => 11,
- ],
- ],
- 'nested-curlies-outside' => [
- 'testMarker' => '/* testNestedCurliesOutside */',
- 'expected' => [
- 'opener' => 7,
- 'closer' => 32,
- ],
- ],
- 'nested-curlies-inside' => [
- 'testMarker' => '/* testNestedCurliesInside */',
- 'expected' => [
- 'opener' => 12,
- 'closer' => 17,
- ],
- ],
-
- 'alternative-syntax' => [
- 'testMarker' => '/* testAlternativeSyntax */',
- 'expected' => [
- 'opener' => 7,
- 'closer' => 11,
- ],
- ],
- 'alternative-syntax-nested-level-1' => [
- 'testMarker' => '/* testAlternativeSyntaxNestedLevel1 */',
- 'expected' => [
- 'opener' => 7,
- 'closer' => 50,
- ],
- ],
- 'alternative-syntax-nested-level-2' => [
- 'testMarker' => '/* testAlternativeSyntaxNestedLevel2 */',
- 'expected' => [
- 'opener' => 12,
- 'closer' => 34,
- ],
- ],
- 'alternative-syntax-nested-level-3' => [
- 'testMarker' => '/* testAlternativeSyntaxNestedLevel3 */',
- 'expected' => [
- 'opener' => 7,
- 'closer' => 12,
- ],
- ],
-
- 'mixed-nested-level-1' => [
- 'testMarker' => '/* testMixedNestedLevel1 */',
- 'expected' => [
- 'opener' => 7,
- 'closer' => 61,
- ],
- ],
- 'mixed-nested-level-2' => [
- 'testMarker' => '/* testMixedNestedLevel2 */',
- 'expected' => [
- 'opener' => 12,
- 'closer' => 46,
- ],
- ],
- 'mixed-nested-level-3' => [
- 'testMarker' => '/* testMixedNestedLevel3 */',
- 'expected' => [
- 'opener' => 7,
- 'closer' => 24,
- ],
- ],
- 'mixed-nested-level-4' => [
- 'testMarker' => '/* testMixedNestedLevel4 */',
- 'expected' => false,
- ],
-
- 'multi-directive-file-scoped' => [
- 'testMarker' => '/* testMultiDirectiveFileScope */',
- 'expected' => false,
- ],
- 'multi-directive-brace-scoped' => [
- 'testMarker' => '/* testMultiDirectiveBraces */',
- 'expected' => [
- 'opener' => 12,
- 'closer' => 16,
- ],
- ],
- 'multi-directive-alt-syntax' => [
- 'testMarker' => '/* testMultiDirectiveAltSyntax */',
- 'expected' => [
- 'opener' => 11,
- 'closer' => 15,
- ],
- ],
-
- 'php-close-tag' => [
- 'testMarker' => '/* testPHPCloseTag */',
- 'expected' => false,
- ],
-
- 'live-coding' => [
- 'testMarker' => '/* testLiveCoding */',
- 'expected' => false,
- ],
- ];
- }
-}
diff --git a/Tests/Utils/FunctionDeclarations/IsArrowFunction2926Test.inc b/Tests/Utils/FunctionDeclarations/IsArrowFunction2926Test.inc
deleted file mode 100644
index 754a689f..00000000
--- a/Tests/Utils/FunctionDeclarations/IsArrowFunction2926Test.inc
+++ /dev/null
@@ -1,11 +0,0 @@
- << <<<'HTML'
-fn
-HTML;
diff --git a/Tests/Utils/FunctionDeclarations/IsArrowFunction2926Test.php b/Tests/Utils/FunctionDeclarations/IsArrowFunction2926Test.php
deleted file mode 100644
index 17ced8a2..00000000
--- a/Tests/Utils/FunctionDeclarations/IsArrowFunction2926Test.php
+++ /dev/null
@@ -1,205 +0,0 @@
- true,
- '3.5.4' => true,
- '3.5.5' => true,
- ];
-
- /**
- * Whether the test case file has been tokenized.
- *
- * Efficiency tweak as the tokenization is done in "before" not in "before class"
- * for this test.
- *
- * @var bool
- */
- private static $tokenized = false;
-
- /**
- * Do NOT Initialize PHPCS & tokenize the test case file.
- *
- * Skip tokenizing the test case file on "before class" as at that time, we can't skip the test
- * yet if the PHPCS version in incompatible and it would hang the Tokenizer (and therefore
- * the test) if it is.
- *
- * @beforeClass
- *
- * @return void
- */
- public static function setUpTestFile()
- {
- // Skip the tokenizing of the test case file at this time.
- }
-
- /**
- * Initialize PHPCS & tokenize the test case file on compatible PHPCS versions.
- *
- * Skip this test on PHPCS versions on which the Tokenizer will hang.
- *
- * @before
- *
- * @return void
- */
- public function setUpTestFileForReal()
- {
- $phpcsVersion = Helper::getVersion();
-
- if (isset($this->unsupportedPHPCSVersions[$phpcsVersion]) === true) {
- $this->markTestSkipped("Issue 2926 can not be tested on PHPCS $phpcsVersion as the Tokenizer will hang.");
- }
-
- if (self::$tokenized === false) {
- parent::setUpTestFile();
- self::$tokenized = true;
- }
- }
-
- /**
- * Reset static properties to their default value after the tests have finished.
- *
- * @afterClass
- *
- * @return void
- */
- public static function resetProperties()
- {
- self::$tokenized = false;
- }
-
- /**
- * Test correctly detecting arrow functions.
- *
- * @dataProvider dataArrowFunction
- *
- * @param string $testMarker The comment which prefaces the target token in the test file.
- * @param array $expected The expected return value for the respective functions.
- * @param array $targetContent The content for the target token to look for in case there could
- * be confusion.
- *
- * @return void
- */
- public function testIsArrowFunction($testMarker, $expected, $targetContent = null)
- {
- $this->expectDeprecation();
- $this->expectDeprecationMessage(
- 'FunctionDeclarations::isArrowFunction() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the `T_FN` token instead.'
- );
-
- $targets = [\T_FN, \T_STRING];
- $stackPtr = $this->getTargetToken($testMarker, $targets, $targetContent);
- $result = FunctionDeclarations::isArrowFunction(self::$phpcsFile, $stackPtr);
- $this->assertSame($expected['is'], $result);
- }
-
- /**
- * Test correctly detecting arrow functions.
- *
- * @dataProvider dataArrowFunction
- *
- * @param string $testMarker The comment which prefaces the target token in the test file.
- * @param array $expected The expected return value for the respective functions.
- * @param string $targetContent The content for the target token to look for in case there could
- * be confusion.
- *
- * @return void
- */
- public function testGetArrowFunctionOpenClose($testMarker, $expected, $targetContent = 'fn')
- {
- $this->expectDeprecation();
- $this->expectDeprecationMessage(
- 'FunctionDeclarations::getArrowFunctionOpenClose() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the `T_FN` token instead.'
- );
-
- $targets = [\T_FN, \T_STRING];
- $stackPtr = $this->getTargetToken($testMarker, $targets, $targetContent);
-
- // Change from offsets to absolute token positions.
- if ($expected['get'] !== false) {
- foreach ($expected['get'] as $key => $value) {
- $expected['get'][$key] += $stackPtr;
- }
- }
-
- $result = FunctionDeclarations::getArrowFunctionOpenClose(self::$phpcsFile, $stackPtr);
- $this->assertSame($expected['get'], $result);
- }
-
- /**
- * Data provider.
- *
- * @see testIsArrowFunction() For the array format.
- * @see testgetArrowFunctionOpenClose() For the array format.
- *
- * @return array
- */
- public function dataArrowFunction()
- {
- return [
- 'arrow-function-returning-heredoc' => [
- 'testMarker' => '/* testHeredoc */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 2,
- 'scope_opener' => 4,
- 'scope_closer' => 9,
- ],
- ],
- ],
- 'arrow-function-returning-nowdoc' => [
- 'testMarker' => '/* testNowdoc */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 2,
- 'scope_opener' => 4,
- 'scope_closer' => 9,
- ],
- ],
- ],
- ];
- }
-}
diff --git a/Tests/Utils/FunctionDeclarations/IsArrowFunctionTest.inc b/Tests/Utils/FunctionDeclarations/IsArrowFunctionTest.inc
deleted file mode 100644
index 733cb236..00000000
--- a/Tests/Utils/FunctionDeclarations/IsArrowFunctionTest.inc
+++ /dev/null
@@ -1,167 +0,0 @@
- $x + $y;
-
-/* testMixedCase */
-$fn1 = Fn($x) => $x + $y;
-
-/* testWhitespace */
-$fn1 = fn ($x) => $x + $y;
-
-/* testComment */
-$fn1 = fn /* comment here */ ($x) => $x + $y;
-
-/* testFunctionName */
-function &fn() {}
-
-/* testNestedOuter */
-$fn = fn($x) => /* testNestedInner */ fn($y) => $x * $y + $z;
-
-/* testFunctionCall */
-$extended = fn($c) => $callable($factory($c), $c);
-
-/* testChainedFunctionCall */
-$result = Collection::from([1, 2])
- ->map(fn($v) => $v * 2)
- ->reduce(/* testFunctionArgument */ fn($tmp, $v) => $tmp + $v, 0);
-
-/* testClosure */
-$extended = fn($c) => $callable(function() {
- for ($x = 1; $x < 10; $x++) {
- echo $x;
- }
-
- echo 'done';
-}, $c);
-
-$result = array_map(
- /* testReturnTypeNullableInt */
- static fn(int $number) : ?int => $number + 1,
- $numbers
-);
-
-/* testReference */
-fn&($x) => $x;
-
-/* testGrouped */
-(fn($x) => $x) + $y;
-
-/* testArrayValue */
-$a = [
- 'a' => fn() => return 1,
-];
-
-/* testYield */
-$a = fn($x) => yield 'k' => $x;
-
-/* testReturnTypeNamespacedClass */
-$fn = fn($x) : ?\My\NS\ClassName => $x;
-
-/* testReturnTypePartiallyQualifiedClass */
-$fn = fn($x) : ?NS\ClassName => $x;
-
-/* testReturnTypeNullableFQNClass */
-$a = fn(?\DateTime $x) : ?\DateTime => $x;
-
-/* testNamespaceOperatorInTypes */
-$fn = fn(namespace\Foo $a) : ?namespace\Foo => $a;
-
-/* testReturnTypeSelf */
-$fn = fn(self $a) : ?self => $a;
-
-/* testReturnTypeParent */
-$fn = fn(parent $a) : parent => $a;
-
-/* testReturnTypeCallable */
-$fn = fn(callable $a) : callable => $a;
-
-/* testReturnTypeArray */
-$fn = fn(array $a) : array => $a;
-
-/* testReturnTypeStatic */
-$fn = fn(array $a) : static => $a;
-
-/* testUnionParamType */
-$arrowWithUnionParam = fn(int|float $param) : SomeClass => new SomeClass($param);
-
-/* testUnionReturnType */
-$arrowWithUnionReturn = fn($param) : int|float => $param | 10;
-
-/* testReturnTypeArrayBug2773 */
-$fn = fn(): array => [a($a, $b)];
-
-array_map(
- /* testMoreArrayTypeDeclarations */
- static fn (array $value): array => array_filter($value),
- []
-);
-
-/* testTernary */
-$fn = fn($a) => $a ? /* testTernaryThen */ fn() : string => 'a' : /* testTernaryElse */ fn() : string => 'b';
-
-$foo = foo(
- /* testArrowFunctionAsArgument */
- fn() => bar()
-);
-
-$foo = foo(
- /* testArrowFunctionWithArrayAsArgument */
- fn() => [$row[0], $row[3]]
-);
-
-/* testConstantDeclaration */
-const FN = 'a';
-
-/* testConstantDeclarationLower */
-const fn = 'a';
-
-class Foo {
- /* testStaticMethodName */
- public static function fn($param) {
- /* testNestedInMethod */
- $fn = fn($c) => $callable($factory($c), $c);
- }
-
- public function foo() {
- /* testPropertyAssignment */
- $this->fn = 'a';
- }
-}
-
-$anon = new class() {
- /* testAnonClassMethodName */
- protected function fN($param) {
- }
-}
-
-/* testNonArrowStaticMethodCall */
-$a = Foo::fn($param);
-
-/* testNonArrowConstantAccess */
-$a = MyClass::FN;
-
-/* testNonArrowConstantAccessDeref */
-$a = MyClass::Fn[$a];
-
-/* testNonArrowObjectMethodCall */
-$a = $obj->fn($param);
-
-/* testNonArrowObjectMethodCallUpper */
-$a = $obj->FN($param);
-
-/* testNonArrowNamespacedFunctionCall */
-$a = MyNS\Sub\Fn($param);
-
-/* testNonArrowNamespaceOperatorFunctionCall */
-$a = namespace\fn($param);
-
-/* testNonArrowFunctionNameWithUnionTypes */
-function &fn(int|float $param) : string|null {}
-
-/* testLiveCoding */
-// Intentional parse error. This has to be the last test in the file.
-$fn = fn
diff --git a/Tests/Utils/FunctionDeclarations/IsArrowFunctionTest.php b/Tests/Utils/FunctionDeclarations/IsArrowFunctionTest.php
deleted file mode 100644
index 6c4cb85a..00000000
--- a/Tests/Utils/FunctionDeclarations/IsArrowFunctionTest.php
+++ /dev/null
@@ -1,715 +0,0 @@
-expectDeprecation();
- $this->expectDeprecationMessage(
- 'FunctionDeclarations::isArrowFunction() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the `T_FN` token instead.'
- );
-
- $result = FunctionDeclarations::isArrowFunction(self::$phpcsFile, 10000);
- $this->assertFalse($result, 'Failed isArrowFunction() test');
-
- $result = FunctionDeclarations::getArrowFunctionOpenClose(self::$phpcsFile, 10000);
- $this->assertFalse($result, 'Failed getArrowFunctionOpenClose() test');
- }
-
- /**
- * Test that the function returns false when passed a token which definitely is not an arrow function.
- *
- * @return void
- */
- public function testUnsupportedToken()
- {
- $this->expectDeprecation();
- $this->expectDeprecationMessage(
- 'FunctionDeclarations::isArrowFunction() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the `T_FN` token instead.'
- );
-
- $stackPtr = $this->getTargetToken('/* testConstantDeclaration */', \T_CONST);
-
- $result = FunctionDeclarations::isArrowFunction(self::$phpcsFile, $stackPtr);
- $this->assertFalse($result, 'Failed isArrowFunction() test');
-
- $result = FunctionDeclarations::getArrowFunctionOpenClose(self::$phpcsFile, $stackPtr);
- $this->assertFalse($result, 'Failed getArrowFunctionOpenClose() test');
- }
-
- /**
- * Test that the function returns false when passed a T_STRING token without `fn` as content.
- *
- * @return void
- */
- public function testTStringNotFn()
- {
- $this->expectDeprecation();
- $this->expectDeprecationMessage(
- 'FunctionDeclarations::isArrowFunction() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the `T_FN` token instead.'
- );
-
- $stackPtr = $this->getTargetToken('/* testNotTheRightContent */', \T_STRING);
-
- $result = FunctionDeclarations::isArrowFunction(self::$phpcsFile, $stackPtr);
- $this->assertFalse($result, 'Failed isArrowFunction() test');
-
- $result = FunctionDeclarations::getArrowFunctionOpenClose(self::$phpcsFile, $stackPtr);
- $this->assertFalse($result, 'Failed getArrowFunctionOpenClose() test');
- }
-
- /**
- * Test correctly detecting arrow functions.
- *
- * @dataProvider dataArrowFunction
- *
- * @param string $testMarker The comment which prefaces the target token in the test file.
- * @param array $expected The expected return value for the respective functions.
- * @param array $targetContent The content for the target token to look for in case there could
- * be confusion.
- * @param bool $skipOnPHP8 Optional. Whether the test should be skipped when the PHP 8 identifier
- * name tokenization is used (as the target token won't exist).
- * Defaults to `false`.
- *
- * @return void
- */
- public function testIsArrowFunction($testMarker, $expected, $targetContent = null, $skipOnPHP8 = false)
- {
- if ($skipOnPHP8 === true && parent::usesPhp8NameTokens() === true) {
- $this->markTestSkipped("PHP 8.0 identifier name tokenization used. Target token won't exist.");
- }
-
- $this->expectDeprecation();
- $this->expectDeprecationMessage(
- 'FunctionDeclarations::isArrowFunction() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the `T_FN` token instead.'
- );
-
- $targets = [\T_FN, \T_STRING];
- $stackPtr = $this->getTargetToken($testMarker, $targets, $targetContent);
- $result = FunctionDeclarations::isArrowFunction(self::$phpcsFile, $stackPtr);
- $this->assertSame($expected['is'], $result);
- }
-
- /**
- * Test correctly detecting arrow functions.
- *
- * @dataProvider dataArrowFunction
- *
- * @param string $testMarker The comment which prefaces the target token in the test file.
- * @param array $expected The expected return value for the respective functions.
- * @param string $targetContent The content for the target token to look for in case there could
- * be confusion.
- * @param bool $skipOnPHP8 Optional. Whether the test should be skipped when the PHP 8 identifier
- * name tokenization is used (as the target token won't exist).
- * Defaults to `false`.
- *
- * @return void
- */
- public function testGetArrowFunctionOpenClose($testMarker, $expected, $targetContent = 'fn', $skipOnPHP8 = false)
- {
- if ($skipOnPHP8 === true && parent::usesPhp8NameTokens() === true) {
- $this->markTestSkipped("PHP 8.0 identifier name tokenization used. Target token won't exist.");
- }
-
- $this->expectDeprecation();
- $this->expectDeprecationMessage(
- 'FunctionDeclarations::getArrowFunctionOpenClose() function is deprecated since PHPCSUtils 1.0.0-alpha4.'
- . ' Use the `T_FN` token instead.'
- );
-
- $targets = [\T_FN, \T_STRING];
- $stackPtr = $this->getTargetToken($testMarker, $targets, $targetContent);
-
- // Change from offsets to absolute token positions.
- if ($expected['get'] !== false) {
- foreach ($expected['get'] as $key => $value) {
- $expected['get'][$key] += $stackPtr;
- }
- }
-
- $result = FunctionDeclarations::getArrowFunctionOpenClose(self::$phpcsFile, $stackPtr);
- $this->assertSame($expected['get'], $result);
- }
-
- /**
- * Data provider.
- *
- * @see testIsArrowFunction() For the array format.
- * @see testgetArrowFunctionOpenClose() For the array format.
- *
- * @return array
- */
- public function dataArrowFunction()
- {
- $php8Names = parent::usesPhp8NameTokens();
-
- return [
- 'arrow-function-standard' => [
- 'testMarker' => '/* testStandard */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 5,
- 'scope_closer' => 12,
- ],
- ],
- ],
- 'arrow-function-mixed-case' => [
- 'testMarker' => '/* testMixedCase */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 5,
- 'scope_closer' => 12,
- ],
- ],
- 'targetContent' => 'Fn',
- ],
- 'arrow-function-with-whitespace' => [
- 'testMarker' => '/* testWhitespace */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 2,
- 'parenthesis_closer' => 4,
- 'scope_opener' => 6,
- 'scope_closer' => 13,
- ],
- ],
- ],
- 'arrow-function-with-comment' => [
- 'testMarker' => '/* testComment */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 4,
- 'parenthesis_closer' => 6,
- 'scope_opener' => 8,
- 'scope_closer' => 15,
- ],
- ],
- ],
- 'non-arrow-function-global-function-declaration' => [
- 'testMarker' => '/* testFunctionName */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- ],
- 'arrow-function-nested-outer' => [
- 'testMarker' => '/* testNestedOuter */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 5,
- 'scope_closer' => 25,
- ],
- ],
- ],
- 'arrow-function-nested-inner' => [
- 'testMarker' => '/* testNestedInner */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 5,
- 'scope_closer' => 16,
- ],
- ],
- ],
- 'arrow-function-function-call' => [
- 'testMarker' => '/* testFunctionCall */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 5,
- 'scope_closer' => 17,
- ],
- ],
- ],
- 'arrow-function-chained-function-call' => [
- 'testMarker' => '/* testChainedFunctionCall */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 5,
- 'scope_closer' => 12,
- ],
- ],
- 'targetContent' => 'fn',
- ],
- 'arrow-function-as-function-argument' => [
- 'testMarker' => '/* testFunctionArgument */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 6,
- 'scope_opener' => 8,
- 'scope_closer' => 15,
- ],
- ],
- ],
- 'arrow-function-nested-closure' => [
- 'testMarker' => '/* testClosure */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 5,
- 'scope_closer' => 60,
- ],
- ],
- ],
- 'arrow-function-with-return-type-nullable-int' => [
- 'testMarker' => '/* testReturnTypeNullableInt */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 5,
- 'scope_opener' => 12,
- 'scope_closer' => 19,
- ],
- ],
- ],
- 'arrow-function-with-reference' => [
- 'testMarker' => '/* testReference */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 2,
- 'parenthesis_closer' => 4,
- 'scope_opener' => 6,
- 'scope_closer' => 9,
- ],
- ],
- ],
- 'arrow-function-grouped-within-parenthesis' => [
- 'testMarker' => '/* testGrouped */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 5,
- 'scope_closer' => 8,
- ],
- ],
- ],
- 'arrow-function-as-array-value' => [
- 'testMarker' => '/* testArrayValue */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 2,
- 'scope_opener' => 4,
- 'scope_closer' => 9,
- ],
- ],
- ],
- 'arrow-function-with-yield-in-value' => [
- 'testMarker' => '/* testYield */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 5,
- 'scope_closer' => 14,
- ],
- ],
- ],
- 'arrow-function-with-return-type-nullable-namespaced-class' => [
- 'testMarker' => '/* testReturnTypeNamespacedClass */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => ($php8Names === true) ? 10 : 15,
- 'scope_closer' => ($php8Names === true) ? 13 : 18,
- ],
- ],
- ],
- 'arrow-function-with-return-type-nullable-partially-qualified-class' => [
- 'testMarker' => '/* testReturnTypePartiallyQualifiedClass */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => ($php8Names === true) ? 10 : 12,
- 'scope_closer' => ($php8Names === true) ? 13 : 15,
- ],
- ],
- ],
- 'arrow-function-with-fqn-class' => [
- 'testMarker' => '/* testReturnTypeNullableFQNClass */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => ($php8Names === true) ? 6 : 7,
- 'scope_opener' => ($php8Names === true) ? 13 : 15,
- 'scope_closer' => ($php8Names === true) ? 16 : 18,
- ],
- ],
- ],
- 'arrow-function-with-namespace-operator-in-types' => [
- 'testMarker' => '/* testNamespaceOperatorInTypes */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => ($php8Names === true) ? 5 : 7,
- 'scope_opener' => ($php8Names === true) ? 12 : 16,
- 'scope_closer' => ($php8Names === true) ? 15 : 19,
- ],
- ],
- ],
- 'arrow-function-with-return-type-nullable-self' => [
- 'testMarker' => '/* testReturnTypeSelf */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 5,
- 'scope_opener' => 12,
- 'scope_closer' => 15,
- ],
- ],
- ],
- 'arrow-function-with-return-type-parent' => [
- 'testMarker' => '/* testReturnTypeParent */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 5,
- 'scope_opener' => 11,
- 'scope_closer' => 14,
- ],
- ],
- ],
- 'arrow-function-with-return-type-callable' => [
- 'testMarker' => '/* testReturnTypeCallable */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 5,
- 'scope_opener' => 11,
- 'scope_closer' => 14,
- ],
- ],
- ],
- 'arrow-function-with-return-type-array' => [
- 'testMarker' => '/* testReturnTypeArray */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 5,
- 'scope_opener' => 11,
- 'scope_closer' => 14,
- ],
- ],
- ],
- 'arrow-function-with-return-type-static' => [
- 'testMarker' => '/* testReturnTypeStatic */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 5,
- 'scope_opener' => 11,
- 'scope_closer' => 14,
- ],
- ],
- ],
-
- 'arrow-function-with-union-param-type' => [
- 'testMarker' => '/* testUnionParamType */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 7,
- 'scope_opener' => 13,
- 'scope_closer' => 21,
- ],
- ],
- ],
- 'arrow-function-with-union-return-type' => [
- 'testMarker' => '/* testUnionReturnType */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 11,
- 'scope_closer' => 18,
- ],
- ],
- ],
- 'arrow-function-with-return-type-array-bug-2773' => [
- 'testMarker' => '/* testReturnTypeArrayBug2773 */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 2,
- 'scope_opener' => 7,
- 'scope_closer' => 18,
- ],
- ],
- ],
- 'arrow-function-with-array-param-and-return-type' => [
- 'testMarker' => '/* testMoreArrayTypeDeclarations */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 2,
- 'parenthesis_closer' => 6,
- 'scope_opener' => 11,
- 'scope_closer' => 17,
- ],
- ],
- ],
- 'arrow-function-with-ternary-content' => [
- 'testMarker' => '/* testTernary */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 5,
- 'scope_closer' => 40,
- ],
- ],
- ],
- 'arrow-function-with-ternary-content-after-then' => [
- 'testMarker' => '/* testTernaryThen */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 2,
- 'scope_opener' => 8,
- 'scope_closer' => 12,
- ],
- ],
- ],
- 'arrow-function-with-ternary-content-after-else' => [
- 'testMarker' => '/* testTernaryElse */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 2,
- 'scope_opener' => 8,
- 'scope_closer' => 11,
- ],
- ],
- ],
- 'arrow-function-as-function-call-argument' => [
- 'testMarker' => '/* testArrowFunctionAsArgument */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 2,
- 'scope_opener' => 4,
- 'scope_closer' => 8,
- ],
- ],
- ],
- 'arrow-function-as-function-call-argument-with-array-return' => [
- 'testMarker' => '/* testArrowFunctionWithArrayAsArgument */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 2,
- 'scope_opener' => 4,
- 'scope_closer' => 17,
- ],
- ],
- ],
- 'arrow-function-nested-in-method' => [
- 'testMarker' => '/* testNestedInMethod */',
- 'expected' => [
- 'is' => true,
- 'get' => [
- 'parenthesis_opener' => 1,
- 'parenthesis_closer' => 3,
- 'scope_opener' => 5,
- 'scope_closer' => 17,
- ],
- ],
- ],
-
- /*
- * Use of the "fn" keyword when not an arrow function.
- */
- 'non-arrow-function-const-declaration' => [
- 'testMarker' => '/* testConstantDeclaration */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- 'targetContent' => 'FN',
- ],
- 'non-arrow-function-const-declaration-lowercase' => [
- 'testMarker' => '/* testConstantDeclarationLower */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- ],
- 'non-arrow-function-static-method-declaration' => [
- 'testMarker' => '/* testStaticMethodName */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- ],
- 'non-arrow-function-assignment-to-property' => [
- 'testMarker' => '/* testPropertyAssignment */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- ],
- 'non-arrow-function-anon-class-method-declaration' => [
- 'testMarker' => '/* testAnonClassMethodName */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- 'targetContent' => 'fN',
- ],
- 'non-arrow-function-call-to-static-method' => [
- 'testMarker' => '/* testNonArrowStaticMethodCall */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- ],
- 'non-arrow-function-class-constant-access' => [
- 'testMarker' => '/* testNonArrowConstantAccess */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- 'targetContent' => 'FN',
- ],
- 'non-arrow-function-class-constant-access-with-deref' => [
- 'testMarker' => '/* testNonArrowConstantAccessDeref */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- 'targetContent' => 'Fn',
- ],
- 'non-arrow-function-call-to-object-method' => [
- 'testMarker' => '/* testNonArrowObjectMethodCall */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- ],
- 'non-arrow-function-call-to-object-method-uppercase' => [
- 'testMarker' => '/* testNonArrowObjectMethodCallUpper */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- 'targetContent' => 'FN',
- ],
- 'non-arrow-function-call-to-namespaced-function' => [
- 'testMarker' => '/* testNonArrowNamespacedFunctionCall */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- 'targetContent' => 'Fn',
- 'skipOnPHP8' => true,
- ],
- 'non-arrow-function-call-to-namespaced-function-using-namespace-operator' => [
- 'testMarker' => '/* testNonArrowNamespaceOperatorFunctionCall */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- 'targetContent' => 'fn',
- 'skipOnPHP8' => true,
- ],
- 'non-arrow-function-declaration-with-union-types' => [
- 'testMarker' => '/* testNonArrowFunctionNameWithUnionTypes */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- ],
-
- 'live-coding' => [
- 'testMarker' => '/* testLiveCoding */',
- 'expected' => [
- 'is' => false,
- 'get' => false,
- ],
- ],
- ];
- }
-}
diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php
index 8e660fb9..5666e772 100644
--- a/Tests/bootstrap.php
+++ b/Tests/bootstrap.php
@@ -97,9 +97,7 @@
}
/*
- * Alias the PHPCS 2.x classes to their PHPCS 3.x equivalent if necessary.
- *
- * Also alias the non-namespaced PHPUnit 4.x/5.x test case class to the
+ * Alias the non-namespaced PHPUnit 4.x/5.x test case class to the
* namespaced PHPUnit 6+ version.
*/
require_once \dirname(__DIR__) . '/phpcsutils-autoload.php';
diff --git a/phpcsutils-autoload.php b/phpcsutils-autoload.php
index 8135432b..0857fd10 100644
--- a/phpcsutils-autoload.php
+++ b/phpcsutils-autoload.php
@@ -8,12 +8,6 @@
* - If an external standard only supports PHPCS >= 3.1.0 and uses the PHPCS
* native unit test framework, this file does not need to be included.
*
- * - When PHPCS 2.x support is desired, include the `"PHPCS23Utils"` standard
- * in the ruleset of the external standard and this file will be included
- * automatically.
- * Including this file will allow PHPCSUtils to work in both PHPCS 2.x
- * as well as PHPCS 3.x.
- *
* - If an external standard uses its own unit test setup, this file should
* be included from the unit test bootstrap file.
*
@@ -52,52 +46,6 @@
define('PHPCSUTILS_AUTOLOAD', true);
}
-if (defined('PHPCSUTILS_PHPCS_ALIASES_SET') === false) {
- /*
- * Alias a number of PHPCS 2.x classes to their PHPCS 3.x equivalents.
- *
- * {@internal The PHPCS file have been reorganized in PHPCS 3.x, quite
- * a few "old" classes have been split and spread out over several "new"
- * classes. In other words, this will only work for a limited number
- * of classes.}}
- *
- * {@internal The `class_exists` wrappers are needed to play nice with other
- * external PHPCS standards creating cross-version compatibility in a
- * similar manner.}}
- */
- if (interface_exists('\PHP_CodeSniffer_Sniff') === true
- && interface_exists('\PHP_CodeSniffer\Sniffs\Sniff') === false
- ) {
- class_alias('\PHP_CodeSniffer_Sniff', '\PHP_CodeSniffer\Sniffs\Sniff');
- }
-
- if (class_exists('\PHP_CodeSniffer_File') === true
- && class_exists('\PHP_CodeSniffer\Files\File') === false
- ) {
- class_alias('\PHP_CodeSniffer_File', '\PHP_CodeSniffer\Files\File');
- }
-
- if (class_exists('\PHP_CodeSniffer_Tokens') === true
- && class_exists('\PHP_CodeSniffer\Util\Tokens') === false
- ) {
- class_alias('\PHP_CodeSniffer_Tokens', '\PHP_CodeSniffer\Util\Tokens');
- }
-
- if (class_exists('\PHP_CodeSniffer_Exception') === true
- && class_exists('\PHP_CodeSniffer\Exceptions\RuntimeException') === false
- ) {
- class_alias('\PHP_CodeSniffer_Exception', '\PHP_CodeSniffer\Exceptions\RuntimeException');
- }
-
- if (class_exists('\PHP_CodeSniffer_Exception') === true
- && class_exists('\PHP_CodeSniffer\Exceptions\TokenizerException') === false
- ) {
- class_alias('\PHP_CodeSniffer_Exception', '\PHP_CodeSniffer\Exceptions\TokenizerException');
- }
-
- define('PHPCSUTILS_PHPCS_ALIASES_SET', true);
-}
-
if (defined('PHPCSUTILS_PHPUNIT_ALIASES_SET') === false) {
/*
* Alias the PHPUnit 4/5 TestCase class to its PHPUnit 6+ name.