diff --git a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php index 04f31d67e4..6db1156652 100644 --- a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php +++ b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php @@ -28,8 +28,8 @@ final class UndoNamespacedNameSingleTokenTest extends AbstractMethodUnitTest /** * Test that identifier names are tokenized the same across PHP versions, based on the PHP 5/7 tokenization. * - * @param string $testMarker The comment prefacing the test. - * @param array $expectedTokens The tokenization expected. + * @param string $testMarker The comment prefacing the test. + * @param array> $expectedTokens The tokenization expected. * * @dataProvider dataIdentifierTokenization * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize @@ -57,14 +57,14 @@ public function testIdentifierTokenization($testMarker, $expectedTokens) * * @see testIdentifierTokenization() * - * @return array + * @return array>>> */ public static function dataIdentifierTokenization() { return [ - [ - '/* testNamespaceDeclaration */', - [ + 'namespace declaration' => [ + 'testMarker' => '/* testNamespaceDeclaration */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Package', @@ -75,9 +75,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testNamespaceDeclarationWithLevels */', - [ + 'namespace declaration, multi-level' => [ + 'testMarker' => '/* testNamespaceDeclarationWithLevels */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Vendor', @@ -104,9 +104,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testUseStatement */', - [ + 'import use statement, class' => [ + 'testMarker' => '/* testUseStatement */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'ClassName', @@ -117,9 +117,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testUseStatementWithLevels */', - [ + 'import use statement, class, multi-level' => [ + 'testMarker' => '/* testUseStatementWithLevels */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Vendor', @@ -146,9 +146,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionUseStatement */', - [ + 'import use statement, function' => [ + 'testMarker' => '/* testFunctionUseStatement */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'function', @@ -167,9 +167,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionUseStatementWithLevels */', - [ + 'import use statement, function, multi-level' => [ + 'testMarker' => '/* testFunctionUseStatementWithLevels */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'function', @@ -204,9 +204,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testConstantUseStatement */', - [ + 'import use statement, constant' => [ + 'testMarker' => '/* testConstantUseStatement */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'const', @@ -225,9 +225,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testConstantUseStatementWithLevels */', - [ + 'import use statement, constant, multi-level' => [ + 'testMarker' => '/* testConstantUseStatementWithLevels */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'const', @@ -262,9 +262,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testMultiUseUnqualified */', - [ + 'import use statement, multi-statement, unqualified class' => [ + 'testMarker' => '/* testMultiUseUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'UnqualifiedClassName', @@ -275,9 +275,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testMultiUsePartiallyQualified */', - [ + 'import use statement, multi-statement, partially qualified class' => [ + 'testMarker' => '/* testMultiUsePartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Sublevel', @@ -296,9 +296,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testGroupUseStatement */', - [ + 'group use statement, multi-level prefix, mix inside group' => [ + 'testMarker' => '/* testGroupUseStatement */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Vendor', @@ -492,9 +492,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testClassName */', - [ + 'class declaration' => [ + 'testMarker' => '/* testClassName */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'MyClass', @@ -506,9 +506,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testExtendedFQN */', - [ + 'class declaration, extends fully qualified name' => [ + 'testMarker' => '/* testExtendedFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -540,9 +540,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testImplementsRelative */', - [ + 'class declaration, implements namespace relative name' => [ + 'testMarker' => '/* testImplementsRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -561,9 +561,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testImplementsFQN */', - [ + 'class declaration, implements fully qualified name' => [ + 'testMarker' => '/* testImplementsFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -586,9 +586,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testImplementsUnqualified */', - [ + 'class declaration, implements unqualified name' => [ + 'testMarker' => '/* testImplementsUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Unqualified', @@ -599,9 +599,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testImplementsPartiallyQualified */', - [ + 'class declaration, implements partially qualified name' => [ + 'testMarker' => '/* testImplementsPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Sub', @@ -629,9 +629,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionName */', - [ + 'method declaration' => [ + 'testMarker' => '/* testFunctionName */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'function_name', @@ -642,9 +642,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testTypeDeclarationRelative */', - [ + 'param type declaration, namespace relative name' => [ + 'testMarker' => '/* testTypeDeclarationRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -667,9 +667,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testTypeDeclarationFQN */', - [ + 'param type declaration, fully qualified name' => [ + 'testMarker' => '/* testTypeDeclarationFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -700,9 +700,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testTypeDeclarationUnqualified */', - [ + 'param type declaration, unqualified name' => [ + 'testMarker' => '/* testTypeDeclarationUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Unqualified', @@ -717,9 +717,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testTypeDeclarationPartiallyQualified */', - [ + 'param type declaration, partially qualified name' => [ + 'testMarker' => '/* testTypeDeclarationPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_NULLABLE', 'content' => '?', @@ -742,9 +742,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testReturnTypeFQN */', - [ + 'return type declaration, fully qualified name' => [ + 'testMarker' => '/* testReturnTypeFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NULLABLE', 'content' => '?', @@ -763,9 +763,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionCallRelative */', - [ + 'function call, namespace relative name' => [ + 'testMarker' => '/* testFunctionCallRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'NameSpace', @@ -784,9 +784,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionCallFQN */', - [ + 'function call, fully qualified name' => [ + 'testMarker' => '/* testFunctionCallFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -817,9 +817,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionCallUnqualified */', - [ + 'function call, unqualified name' => [ + 'testMarker' => '/* testFunctionCallUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'function_name', @@ -830,9 +830,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionCallPartiallyQualified */', - [ + 'function call, partially qualified name' => [ + 'testMarker' => '/* testFunctionCallPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Level', @@ -851,9 +851,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testCatchRelative */', - [ + 'catch, namespace relative name' => [ + 'testMarker' => '/* testCatchRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -880,9 +880,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testCatchFQN */', - [ + 'catch, fully qualified name' => [ + 'testMarker' => '/* testCatchFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -897,9 +897,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testCatchUnqualified */', - [ + 'catch, unqualified name' => [ + 'testMarker' => '/* testCatchUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Exception', @@ -910,9 +910,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testCatchPartiallyQualified */', - [ + 'catch, partially qualified name' => [ + 'testMarker' => '/* testCatchPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Level', @@ -931,9 +931,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testNewRelative */', - [ + 'class instantiation, namespace relative name' => [ + 'testMarker' => '/* testNewRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -952,9 +952,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testNewFQN */', - [ + 'class instantiation, fully qualified name' => [ + 'testMarker' => '/* testNewFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -977,9 +977,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testNewUnqualified */', - [ + 'class instantiation, unqualified name' => [ + 'testMarker' => '/* testNewUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'ClassName', @@ -990,9 +990,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testNewPartiallyQualified */', - [ + 'class instantiation, partially qualified name' => [ + 'testMarker' => '/* testNewPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Level', @@ -1011,9 +1011,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testDoubleColonRelative */', - [ + 'double colon class access, namespace relative name' => [ + 'testMarker' => '/* testDoubleColonRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -1032,9 +1032,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testDoubleColonFQN */', - [ + 'double colon class access, fully qualified name' => [ + 'testMarker' => '/* testDoubleColonFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -1049,9 +1049,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testDoubleColonUnqualified */', - [ + 'double colon class access, unqualified name' => [ + 'testMarker' => '/* testDoubleColonUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'ClassName', @@ -1062,9 +1062,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testDoubleColonPartiallyQualified */', - [ + 'double colon class access, partially qualified name' => [ + 'testMarker' => '/* testDoubleColonPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Level', @@ -1083,9 +1083,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInstanceOfRelative */', - [ + 'instanceof, namespace relative name' => [ + 'testMarker' => '/* testInstanceOfRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -1104,9 +1104,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInstanceOfFQN */', - [ + 'instanceof, fully qualified name' => [ + 'testMarker' => '/* testInstanceOfFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -1129,9 +1129,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInstanceOfUnqualified */', - [ + 'instanceof, unqualified name' => [ + 'testMarker' => '/* testInstanceOfUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'ClassName', @@ -1142,9 +1142,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInstanceOfPartiallyQualified */', - [ + 'instanceof, partially qualified name' => [ + 'testMarker' => '/* testInstanceOfPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Partially', @@ -1163,9 +1163,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInvalidInPHP8Whitespace */', - [ + 'function call, namespace relative, with whitespace (invalid in PHP 8)' => [ + 'testMarker' => '/* testInvalidInPHP8Whitespace */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -1213,9 +1213,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInvalidInPHP8Comments */', - [ + 'double colon class access, fully qualified, with whitespace and comments (invalid in PHP 8)' => [ + 'testMarker' => '/* testInvalidInPHP8Comments */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\',