diff --git a/Magento2/Sniffs/Legacy/LayoutSniff.php b/Magento2/Sniffs/Legacy/LayoutSniff.php index 78b67b21..4b2fe240 100644 --- a/Magento2/Sniffs/Legacy/LayoutSniff.php +++ b/Magento2/Sniffs/Legacy/LayoutSniff.php @@ -18,7 +18,6 @@ class LayoutSniff implements Sniff { private const ERROR_CODE_XML = 'WrongXML'; - private const ERROR_CODE_NOT_ALLOWED = 'NotAllowed'; private const ERROR_CODE_OBSOLETE_BLOCK = 'ObsoleteBlock'; private const ERROR_CODE_OBSOLETE_CLASS = 'ObsoleteClass'; private const ERROR_CODE_OBSOLETE_TOHTML_ATTRIBUTE = 'ObsoleteToHtmlAttribute'; @@ -230,7 +229,6 @@ public function process(File $phpcsFile, $stackPtr) } $this->testObsoleteReferences($layout, $phpcsFile); - $this->testHeadBlocks($layout, $phpcsFile); $this->testOutputAttribute($layout, $phpcsFile); $this->testHelperAttribute($layout, $phpcsFile); $this->testListText($layout, $phpcsFile); @@ -276,35 +274,6 @@ private function getFormattedXML(File $phpcsFile) return $doc->saveXML(); } - /** - * Check that CSS, Link and Script blocks are inside a head block - * - * @param SimpleXMLElement $layout - * @param File $phpcsFile - */ - private function testHeadBlocks(SimpleXMLElement $layout, File $phpcsFile): void - { - $selectorHeadBlock = '(name()="block" or name()="referenceBlock") and ' . - '(@name="head" or @name="convert_root_head" or @name="vde_head")'; - $elements = $layout->xpath( - '//block[@class="Magento\Theme\Block\Html\Head\Css" ' . - 'or @class="Magento\Theme\Block\Html\Head\Link" ' . - 'or @class="Magento\Theme\Block\Html\Head\Script"]' . - '/parent::*[not(' . - $selectorHeadBlock . - ')]' - ); - if (!empty($elements)) { - $phpcsFile->addError( - 'Blocks \Magento\Theme\Block\Html\Head\{Css,Link,Script} ' . - 'are allowed within the "head" block only. ' . - 'Verify integrity of the nodes nesting.', - dom_import_simplexml($elements[0])->getLineNo(), - self::ERROR_CODE_NOT_ALLOWED - ); - }; - } - /** * Check that the output attribute has the right value * @@ -378,7 +347,7 @@ private function testListText(SimpleXMLElement $layout, File $phpcsFile): void dom_import_simplexml($elements[0])->getLineNo()-1, self::ERROR_CODE_OBSOLETE_CLASS ); - }; + } } /** diff --git a/Magento2/Tests/Legacy/LayoutUnitTest.php b/Magento2/Tests/Legacy/LayoutUnitTest.php index 8e7a6551..b793159e 100644 --- a/Magento2/Tests/Legacy/LayoutUnitTest.php +++ b/Magento2/Tests/Legacy/LayoutUnitTest.php @@ -18,7 +18,6 @@ public function getErrorList($testFile = '') return [ 13 => 1, 22 => 1, - 23 => 1, 145 => 1, 148 => 1, ];