File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Inpsyde/Sniffs/CodeQuality Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 2525 */
2626final class NoAccessorsSniff implements Sniff
2727{
28- public $ allowSetUp = true ;
28+ const ALLOWED_NAMES = [
29+ 'getIterator ' ,
30+ 'getInnerIterator ' ,
31+ 'getChildren ' ,
32+ 'setUp ' ,
33+ ];
2934
3035 public $ skipForFunctions = true ;
3136
@@ -50,7 +55,7 @@ public function process(File $file, $position)
5055
5156 $ functionName = $ file ->getDeclarationName ($ position );
5257
53- if (!$ functionName || ($ functionName === ' setUp ' && $ this -> allowSetUp )) {
58+ if (!$ functionName || in_array ($ functionName, self :: ALLOWED_NAMES , true )) {
5459 return ;
5560 }
5661
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ function setTheThing($foo, $bar);
2121 function setting ();
2222}
2323
24- class WithAccessors {
24+ class WithAccessors implements \IteratorAggregate {
2525
2626 function thing () {
2727
@@ -44,4 +44,12 @@ function withThing() {
4444 function setTheThing ($ foo , $ bar ) {
4545
4646 }
47+
48+ /**
49+ * @inheritdoc
50+ */
51+ public function getIterator ()
52+ {
53+ return new \ArrayIterator ();
54+ }
4755}
You can’t perform that action at this time.
0 commit comments