Skip to content

Commit 902b134

Browse files
committed
#187: Added sniff for deprecated model methods
- minor fixes
1 parent b7fd1ed commit 902b134

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Magento2/Sniffs/Methods/DeprecatedModelMethodSniff.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use PHP_CodeSniffer\Sniffs\Sniff;
99
use PHP_CodeSniffer\Files\File;
10-
use PHP_CodeSniffer\Util\Tokens;
1110

1211
/**
1312
* Detects possible use of deprecated model methods.
@@ -21,8 +20,7 @@ class DeprecatedModelMethodSniff implements Sniff
2120
*
2221
* @var string
2322
*/
24-
protected $warningMessage = "Possible use of the deprecated model method 'getResource()'" .
25-
" to '%s' the data detected.";
23+
protected $warningMessage = "The use of the deprecated method 'getResource()' to '%s' the data detected.";
2624

2725
/**
2826
* Warning violation code.
@@ -69,7 +67,7 @@ public function process(File $phpcsFile, $stackPtr)
6967
);
7068
if ($resourcePosition !== false) {
7169
$methodPosition = $phpcsFile->findNext([T_STRING, T_VARIABLE], $resourcePosition + 1, $endOfStatement);
72-
if ($methodPosition !== false && in_array($tokens[$methodPosition]['content'], $this->methods)) {
70+
if ($methodPosition !== false && in_array($tokens[$methodPosition]['content'], $this->methods, true)) {
7371
$phpcsFile->addWarning(
7472
sprintf($this->warningMessage, $tokens[$methodPosition]['content']),
7573
$stackPtr,

0 commit comments

Comments
 (0)