diff --git a/Magento2/Sniffs/Legacy/DiConfigSniff.php b/Magento2/Sniffs/Legacy/DiConfigSniff.php new file mode 100644 index 00000000..954c32e0 --- /dev/null +++ b/Magento2/Sniffs/Legacy/DiConfigSniff.php @@ -0,0 +1,54 @@ + 'The node is obsolete. Instead, use the ', + ' 'The node is obsolete. Instead, use the ', + ' 'The node is obsolete. Instead, use the ', + ' node is obsolete. Instead, use the ', + ' 'The node is obsolete. Instead, provide the actual value as a text literal.' + ]; + + /** + * @inheritDoc + */ + public function register(): array + { + return [ + T_INLINE_HTML + ]; + } + + /** + * @inheritDoc + */ + public function process(File $phpcsFile, $stackPtr) + { + $lineContent = $phpcsFile->getTokensAsString($stackPtr, 1); + + foreach ($this->obsoleteDiNodes as $element => $message) { + if (strpos($lineContent, $element) !== false) { + $phpcsFile->addWarning( + $message, + $stackPtr, + self::WARNING_CODE + ); + } + } + } +} diff --git a/Magento2/Tests/Legacy/DiConfigUnitTest.php b/Magento2/Tests/Legacy/DiConfigUnitTest.php new file mode 100644 index 00000000..d5dad883 --- /dev/null +++ b/Magento2/Tests/Legacy/DiConfigUnitTest.php @@ -0,0 +1,33 @@ + 1, + 16 => 1, + 17 => 1, + 18 => 1, + 19 => 1 + ]; + } +} diff --git a/Magento2/Tests/Legacy/DiConfigUnitTest.xml b/Magento2/Tests/Legacy/DiConfigUnitTest.xml new file mode 100644 index 00000000..048e31b4 --- /dev/null +++ b/Magento2/Tests/Legacy/DiConfigUnitTest.xml @@ -0,0 +1,23 @@ + + + + + + + Magento\Catalog\Pricing\Price\RegularPrice + + + + + + + scalar5 + + + + diff --git a/Magento2/ruleset.xml b/Magento2/ruleset.xml index 204946d0..7b1e78f7 100644 --- a/Magento2/ruleset.xml +++ b/Magento2/ruleset.xml @@ -3,7 +3,7 @@ Magento Coding Standard - + @@ -223,6 +223,11 @@ 8 warning + + *\/di.xml$ + 8 + warning + @@ -258,6 +263,7 @@ warning + *\.xml$ 7 warning