Skip to content

Commit 230d2ad

Browse files
author
Lars Roettig
committed
#26: Add Sniff for Gettersnot change state
1 parent 9b34291 commit 230d2ad

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Magento/Sniffs/Functions/GetterStateSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function process(File $phpcsFile, $stackPtr)
4545
{
4646
$methodName = $phpcsFile->getDeclarationName($stackPtr);
4747

48-
if ($methodName === null || strpos($methodName, 'get') === false) {
48+
if ($methodName === null || strpos($methodName, 'get') !== 0) {
4949
// Ignore closures and no getters
5050
return;
5151
}

Magento/Tests/Functions/GetterStateUnitTest.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ class Foo extends Bar
4040
return $this->property;
4141
}
4242

43+
public function TestigetFoo()
44+
{
45+
$this->property = 1223;
46+
return $this->property;
47+
}
48+
4349
/**
4450
* @return int
4551
*/

0 commit comments

Comments
 (0)