Skip to content

Commit aa68a3d

Browse files
committed
Fix bug in NoAccessorsSniff
1 parent 9805691 commit aa68a3d

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## Not released
4+
- Fix bug in `NoAccessorsSniff`
5+
36
## 0.7.2
47
- Fix bug in `ReturnTypeDeclarationSniff` which caused wrong return type detection.
58

Inpsyde/Sniffs/CodeQuality/NoAccessorsSniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function process(File $file, $position)
5454
return;
5555
}
5656

57-
preg_match('/^(set|get)[a-zA-Z0-9_\x7f-\xff]+/', $functionName, $matches);
57+
preg_match('/^(set|get)[_A-Z0-9]+/', $functionName, $matches);
5858
if (!$matches) {
5959
return;
6060
}
@@ -67,6 +67,8 @@ public function process(File $file, $position)
6767
$position,
6868
'NoSetter'
6969
);
70+
71+
return;
7072
}
7173

7274
$file->addWarning(

tests/fixtures/no-accessors.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@
22

33
// @phpcsSniff CodeQuality.NoAccessors
44

5+
function getting() {
6+
7+
}
8+
9+
function setting() {
10+
11+
}
12+
513
interface WithAccessorsInterface {
614

715
// @phpcsWarningCodeOnNextLine NoGetter
816
function getTheThing();
917

1018
// @phpcsWarningCodeOnNextLine NoSetter
1119
function setTheThing($foo, $bar);
20+
21+
function setting();
1222
}
1323

1424
class WithAccessors {
@@ -17,6 +27,10 @@ function thing() {
1727

1828
}
1929

30+
function setting() {
31+
32+
}
33+
2034
// @phpcsWarningCodeOnNextLine NoGetter
2135
function getTheThing() {
2236

0 commit comments

Comments
 (0)