diff --git a/Magento2/Sniffs/Functions/FunctionsDeprecatedWithoutArgumentSniff.php b/Magento2/Sniffs/Functions/FunctionsDeprecatedWithoutArgumentSniff.php new file mode 100644 index 00000000..331e918e --- /dev/null +++ b/Magento2/Sniffs/Functions/FunctionsDeprecatedWithoutArgumentSniff.php @@ -0,0 +1,73 @@ +findNext(T_CLOSE_PARENTHESIS, $stackPtr); + $arguments = trim($phpcsFile->getTokensAsString($stackPtr + 1, $closeParenthesisPtr - $stackPtr - 1)); + + if ($arguments) { + return; + } + + $functionName = $phpcsFile->getTokensAsString($phpcsFile->findPrevious(T_STRING, $stackPtr), 1); + + if (in_array($functionName, self::FUNCTIONS_LIST)) { + $phpcsFile->addWarning(sprintf(self::WARNING_MESSAGE, $functionName), $stackPtr, self::WARNING_CODE); + } + } +} diff --git a/Magento2/Tests/Functions/FunctionsDeprecatedWithoutArgumentUnitTest.inc b/Magento2/Tests/Functions/FunctionsDeprecatedWithoutArgumentUnitTest.inc new file mode 100644 index 00000000..63b449b9 --- /dev/null +++ b/Magento2/Tests/Functions/FunctionsDeprecatedWithoutArgumentUnitTest.inc @@ -0,0 +1,33 @@ + 1, + 25 => 1, + 27 => 1, + 29 => 1 + ]; + } +} diff --git a/Magento2/ruleset.xml b/Magento2/ruleset.xml index 5ea68ff3..12114bdb 100644 --- a/Magento2/ruleset.xml +++ b/Magento2/ruleset.xml @@ -251,6 +251,11 @@ *Test.php */tests/* + + 7 + warning + *\.xml$ + 8 warning