Skip to content

Commit 27e8bcc

Browse files
Vrtak-CZondrejmirtes
authored andcommitted
False positive test for unused uses if class in inside annotation
1 parent 9b5f363 commit 27e8bcc

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

tests/Sniffs/Namespaces/UnusedUsesSniffTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ public function testReturnTypehint()
8585
$this->assertNoSniffErrorInFile($this->checkFile(__DIR__ . '/data/php7/unusedUses.php'));
8686
}
8787

88+
public function testUsedUseInsideAnnotation()
89+
{
90+
$report = $this->checkFile(__DIR__ . '/data/unusedUses.php', [
91+
'searchAnnotations' => true,
92+
]);
93+
$this->assertNoSniffError($report, 16);
94+
}
95+
8896
public function testFindCaseInsensitiveUse()
8997
{
9098
$report = $this->checkFile(__DIR__ . '/data/caseInsensitiveUse.php');

tests/Sniffs/Namespaces/data/unusedUses.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
use function LoremIpsum\UsedFunction;
1414
use const FooBar\UNUSED_CONSTANT;
1515
use const LoremIpsum\USED_CONSTANT;
16+
use X;
1617

1718
class TestClass
1819
{
1920

21+
/**
22+
* @Assert\NotBlank(groups={X::SOME_CONSTANT}
23+
*/
2024
public function test(S $s)
2125
{
2226
new \Test\Foo\Bar();

0 commit comments

Comments
 (0)