Skip to content

Commit 782bf7d

Browse files
committed
PSR12.Traits.UseDeclaration: fix typo in error code
The `processUseStatement()` method checking single-line trait `use` statements checks the spacing after the `use` keyword, but the error did not have the correct error code.
1 parent 4aafcb3 commit 782bf7d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ The file documents changes to the PHP_CodeSniffer project.
164164
- Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
165165
- Fixed bug #3854 : Fatal error when using Gitblame report in combination with `--basepath` and running from project subdirectory
166166
- Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
167+
- Fixed bug #3856 : PSR12.Traits.UseDeclaration was using the wrong error code - SpacingAfterAs - for spacing issues after the use keyword
168+
- These will now be reported using the SpacingAfterUse error code.
169+
- Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
167170
- Fixed bug #3867 : Tokenizer/PHP: union type and intersection type operators were not correctly tokenized for static properties without explicit visibility
168171
- Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
169172
- Fixed bug #3877 : Filter names can be case-sensitive. The -h help text will now display the correct case for the available filters

src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ protected function processUseStatement(File $phpcsFile, $stackPtr)
655655
$error = 'Expected 1 space after USE in trait import statement; %s found';
656656
if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
657657
$data = ['0'];
658-
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterAs', $data);
658+
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterUse', $data);
659659
if ($fix === true) {
660660
$phpcsFile->fixer->addContent($stackPtr, ' ');
661661
}
@@ -668,7 +668,7 @@ protected function processUseStatement(File $phpcsFile, $stackPtr)
668668
}
669669

670670
$data = [$found];
671-
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterAs', $data);
671+
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterUse', $data);
672672
if ($fix === true) {
673673
if ($found === 'newline') {
674674
$phpcsFile->fixer->beginChangeset();

0 commit comments

Comments
 (0)