Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions PHPCSUtils/BackCompat/BCTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
3 changes: 1 addition & 2 deletions PHPCSUtils/Utils/Parentheses.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
3 changes: 1 addition & 2 deletions PHPCSUtils/Utils/PassedParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions Tests/Utils/UseStatements/SplitImportUseStatementTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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\{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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));
}

/**
Expand Down