diff --git a/PHPCSUtils/BackCompat/BCTokens.php b/PHPCSUtils/BackCompat/BCTokens.php index 4226c666..59516f90 100644 --- a/PHPCSUtils/BackCompat/BCTokens.php +++ b/PHPCSUtils/BackCompat/BCTokens.php @@ -121,25 +121,4 @@ public static function functionNameTokens() return $tokens; } - - /** - * Given a token, returns the name of the token. - * - * If passed an integer, the token name is sourced from PHP's token_name() - * function. If passed a string, it is assumed to be a PHPCS-supplied token - * that begins with PHPCS_T_, so the name is sourced from the token value itself. - * - * Changelog for the PHPCS native: - * - Introduced in PHPCS 3.0.0. - * - * @see \PHP_CodeSniffer\Util\Tokens::tokenName() Original function. - * - * @param int|string $token The token to get the name for. - * - * @return string - */ - public static function tokenName($token) - { - return Tokens::tokenName($token); - } } diff --git a/PHPCSUtils/Utils/Parentheses.php b/PHPCSUtils/Utils/Parentheses.php index 2c209e28..9a96521c 100644 --- a/PHPCSUtils/Utils/Parentheses.php +++ b/PHPCSUtils/Utils/Parentheses.php @@ -83,8 +83,7 @@ public static function getOwner(File $phpcsFile, $stackPtr) $stackPtr = $tokens[$stackPtr]['parenthesis_opener']; } - $skip = Tokens::$emptyTokens; - $prevNonEmpty = $phpcsFile->findPrevious($skip, ($stackPtr - 1), null, true); + $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($prevNonEmpty !== false && isset(self::$extraParenthesesOwners[$tokens[$prevNonEmpty]['code']]) === true ) { diff --git a/PHPCSUtils/Utils/PassedParameters.php b/PHPCSUtils/Utils/PassedParameters.php index 361e9acd..7f795463 100644 --- a/PHPCSUtils/Utils/PassedParameters.php +++ b/PHPCSUtils/Utils/PassedParameters.php @@ -305,8 +305,7 @@ public static function getParameters(File $phpcsFile, $stackPtr, $limit = 0, $is ); if ($tokens[$secondNonEmpty]['code'] === \T_COLON - && ($tokens[$firstNonEmpty]['type'] === 'T_PARAM_NAME' - || NamingConventions::isValidIdentifierName($tokens[$firstNonEmpty]['content']) === true) + && $tokens[$firstNonEmpty]['code'] === \T_PARAM_NAME ) { $parameters[$cnt]['name_start'] = $paramStart; $parameters[$cnt]['name_end'] = $secondNonEmpty; diff --git a/Tests/Utils/UseStatements/SplitImportUseStatementTest.inc b/Tests/Utils/UseStatements/SplitImportUseStatementTest.inc index ad23ddcf..e9daecf2 100644 --- a/Tests/Utils/UseStatements/SplitImportUseStatementTest.inc +++ b/Tests/Utils/UseStatements/SplitImportUseStatementTest.inc @@ -95,8 +95,6 @@ use Vendor\{ // Intentional parse error - use of reserved keyword as alias. use Vendor\YourNamespace\ClassName as const; -echo 'foo'; // Needed for consistent handling of the above test. - // Intentional parse error. This has to be the last test in the file. /* testParseError */ use MyNS\Level\{ diff --git a/Tests/BackCompat/BCTokens/TokenNameTest.php b/Tests/Xtra/Tokens/TokenNameTest.php similarity index 79% rename from Tests/BackCompat/BCTokens/TokenNameTest.php rename to Tests/Xtra/Tokens/TokenNameTest.php index 7aee78fb..69391dd8 100644 --- a/Tests/BackCompat/BCTokens/TokenNameTest.php +++ b/Tests/Xtra/Tokens/TokenNameTest.php @@ -8,17 +8,20 @@ * @link https://github.com/PHPCSStandards/PHPCSUtils */ -namespace PHPCSUtils\Tests\BackCompat\BCTokens; +namespace PHPCSUtils\Tests\Xtra\Tokens; -use PHPCSUtils\BackCompat\BCTokens; +use PHP_CodeSniffer\Util\Tokens; use PHPUnit\Framework\TestCase; /** - * Test class. + * Test the PHPCS native `Tokens::tokenName()` method. * - * @covers \PHPCSUtils\BackCompat\BCTokens::tokenName + * {@internal Note: this is testing PHPCS native functionality, but as PHPCS doesn't + * have any unit tests in place for this functionality, that's not a bad thing.} * - * @group tokens + * @coversNothing + * + * @group xtra * * @since 1.0.0 */ @@ -37,7 +40,7 @@ class TokenNameTest extends TestCase */ public function testTokenName($tokenCode, $expected) { - $this->assertSame($expected, BCTokens::tokenName($tokenCode)); + $this->assertSame($expected, Tokens::tokenName($tokenCode)); } /**