From 9185a9f89eeb53bf9919757fa0e1d80c312e9cbc Mon Sep 17 00:00:00 2001 From: Shankar Konar Date: Sun, 13 Oct 2019 18:36:53 +0530 Subject: [PATCH] import static test ruleset --- .../Sniffs/Namespaces/UseDeclarationSniff.php | 51 +++++++++++++++++++ .../Namespaces/UseDeclarationUnitTest.inc | 4 ++ .../Namespaces/UseDeclarationUnitTest.php | 30 +++++++++++ Magento2/ruleset.xml | 4 ++ 4 files changed, 89 insertions(+) create mode 100644 Magento2/Sniffs/Namespaces/UseDeclarationSniff.php create mode 100644 Magento2/Tests/Namespaces/UseDeclarationUnitTest.inc create mode 100644 Magento2/Tests/Namespaces/UseDeclarationUnitTest.php 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