Skip to content

Commit bbded9b

Browse files
committed
PSR12/ImportStatement: fix sniff to work with the PHP 8 identifier tokens
The existing unit tests already contain tests covering this change.
1 parent bb933e9 commit bbded9b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ public function process(File $phpcsFile, $stackPtr)
6060
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true);
6161
}
6262

63-
if ($tokens[$next]['code'] !== T_NS_SEPARATOR) {
63+
if ($tokens[$next]['code'] !== T_NAME_FULLY_QUALIFIED) {
6464
return;
6565
}
6666

6767
$error = 'Import statements must not begin with a leading backslash';
6868
$fix = $phpcsFile->addFixableError($error, $next, 'LeadingSlash');
6969

7070
if ($fix === true) {
71-
$phpcsFile->fixer->replaceToken($next, '');
71+
$phpcsFile->fixer->replaceToken($next, ltrim($tokens[$next]['content'], '\\'));
7272
}
7373

7474
}//end process()

0 commit comments

Comments
 (0)