Skip to content

Commit 9ae6d1a

Browse files
committed
Updated sniff to ignore attributes (ref #3283)
1 parent b626797 commit 9ae6d1a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ private function searchForConflict($phpcsFile, $start, $end, $tokens)
178178
continue;
179179
}
180180

181+
// Ignore attributes.
182+
if ($tokens[$i]['code'] === T_ATTRIBUTE
183+
&& isset($tokens[$i]['attribute_closer']) === true
184+
) {
185+
$i = $tokens[$i]['attribute_closer'];
186+
continue;
187+
}
188+
181189
// Detect and skip over symbols.
182190
if (isset($symbols[$tokens[$i]['code']]) === true
183191
&& isset($tokens[$i]['scope_closer']) === true

src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.1.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ if (!interface_exists('MyInterface')) {
6363
interface MyInterface {}
6464
}
6565

66+
#[\Attribute]
6667
namespace {
6768
class A {}
6869
}

0 commit comments

Comments
 (0)