33 * Copyright © Magento. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6+
67namespace Magento \Sniffs \Templates ;
78
89use PHP_CodeSniffer \Sniffs \Sniff ;
@@ -34,15 +35,6 @@ class ThisInTemplateSniff implements Sniff
3435 */
3536 protected $ warningCode = 'FoundThis ' ;
3637
37- /**
38- * List of methods, allowed to called via $this.
39- *
40- * @var array
41- */
42- protected $ allowedMethods = [
43- 'helper ' ,
44- ];
45-
4638 /**
4739 * @inheritdoc
4840 */
@@ -58,15 +50,7 @@ public function process(File $phpcsFile, $stackPtr)
5850 {
5951 $ tokens = $ phpcsFile ->getTokens ();
6052 if ($ tokens [$ stackPtr ]['content ' ] === '$this ' ) {
61- $ endOfStatementPtr = $ phpcsFile ->findEndOfStatement ($ stackPtr );
62- $ functionPtr = $ phpcsFile ->findNext (T_STRING , $ stackPtr , $ endOfStatementPtr );
63- if ($ functionPtr !== false ) {
64- if (!in_array ($ tokens [$ functionPtr ]['content ' ], $ this ->allowedMethods )) {
65- $ phpcsFile ->addWarning ($ this ->warningMessage , $ stackPtr , $ this ->warningCode , [], $ this ->severity );
66- }
67- } else {
68- $ phpcsFile ->addWarning ($ this ->warningMessage , $ stackPtr , $ this ->warningCode , [], $ this ->severity );
69- }
53+ $ phpcsFile ->addWarning ($ this ->warningMessage , $ stackPtr , $ this ->warningCode , [], $ this ->severity );
7054 }
7155 }
7256}
0 commit comments