function UseDeclarationSniff::processUseStatement
Processes a single use statement.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
int $stackPtr The position of the current token in the: stack passed in $tokens.
Return value
void
1 call to UseDeclarationSniff::processUseStatement()
- UseDeclarationSniff::process in vendor/
squizlabs/ php_codesniffer/ src/ Standards/ PSR12/ Sniffs/ Traits/ UseDeclarationSniff.php - Processes this test, when one of its tokens is encountered.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ PSR12/ Sniffs/ Traits/ UseDeclarationSniff.php, line 683
Class
Namespace
PHP_CodeSniffer\Standards\PSR12\Sniffs\TraitsCode
protected function processUseStatement(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
$next = $phpcsFile->findNext([
T_COMMA,
T_SEMICOLON,
], $stackPtr + 1);
if ($next !== false && $tokens[$next]['code'] === T_COMMA) {
$error = 'Each imported trait must have its own "use" import statement';
$fix = $phpcsFile->addFixableError($error, $next, 'MultipleImport');
if ($fix === true) {
$padding = str_repeat(' ', $tokens[$stackPtr]['column'] - 1);
$phpcsFile->fixer
->replaceToken($next, ';' . $phpcsFile->eolChar . $padding . 'use ');
}
}
}