Skip to content

Commit b2b38ed

Browse files
committed
PHP 8.1: PSR2/UseDeclaration - Added support for enums
1 parent 10d5cce commit b2b38ed

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ private function shouldIgnoreUse($phpcsFile, $stackPtr)
285285
}
286286

287287
// Ignore USE keywords for traits.
288-
if ($phpcsFile->hasCondition($stackPtr, [T_CLASS, T_TRAIT]) === true) {
288+
if ($phpcsFile->hasCondition($stackPtr, [T_CLASS, T_TRAIT, T_ENUM]) === true) {
289289
return true;
290290
}
291291

src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.1.inc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ trait HelloWorld
3030
use Hello, World;
3131
}
3232

33+
enum SomeEnum
34+
{
35+
use Hello, World;
36+
}
37+
3338
$x = $foo ? function ($foo) use /* comment */ ($bar): int {
3439
return 1;
3540
} : $bar;
3641

3742
// Testcase must be on last line in the file.
38-
use
43+
use

0 commit comments

Comments
 (0)