diff --git a/Magento2/Sniffs/Namespaces/UseDeclarationSniff.php b/Magento2/Sniffs/Namespaces/UseDeclarationSniff.php new file mode 100644 index 00000000..b7b52b8b --- /dev/null +++ b/Magento2/Sniffs/Namespaces/UseDeclarationSniff.php @@ -0,0 +1,51 @@ +findNext([T_COMMA, T_SEMICOLON, T_OPEN_USE_GROUP, T_CLOSE_TAG], ($stackPtr + 1)); + $getTokenAsContent = $phpcsFile->getTokensAsString($stackPtr, ($next - $stackPtr)); + if (strpos($getTokenAsContent, $this->_prohibitNamespace) !== false) { + $phpcsFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode); + } + } +} diff --git a/Magento2/Tests/Namespaces/UseDeclarationUnitTest.inc b/Magento2/Tests/Namespaces/UseDeclarationUnitTest.inc new file mode 100644 index 00000000..553f55ec --- /dev/null +++ b/Magento2/Tests/Namespaces/UseDeclarationUnitTest.inc @@ -0,0 +1,4 @@ + 1]; + } +} diff --git a/Magento2/ruleset.xml b/Magento2/ruleset.xml index 9d65e166..8f6f495f 100644 --- a/Magento2/ruleset.xml +++ b/Magento2/ruleset.xml @@ -189,6 +189,10 @@ *Test.php */tests/* + + 8 + warning + 8 warning