Skip to content

Commit

Permalink
Merge pull request #154 from magento-commerce/imported-sivaschenko-ma…
Browse files Browse the repository at this point in the history
…gento-coding-standard-370

[Imported] Removed obsolete layout check
  • Loading branch information
sivaschenko authored Feb 11, 2022
2 parents 61c28ba + df01d64 commit 9b40157
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
33 changes: 1 addition & 32 deletions Magento2/Sniffs/Legacy/LayoutSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -378,7 +347,7 @@ private function testListText(SimpleXMLElement $layout, File $phpcsFile): void
dom_import_simplexml($elements[0])->getLineNo()-1,
self::ERROR_CODE_OBSOLETE_CLASS
);
};
}
}

/**
Expand Down
1 change: 0 additions & 1 deletion Magento2/Tests/Legacy/LayoutUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public function getErrorList($testFile = '')
return [
13 => 1,
22 => 1,
23 => 1,
145 => 1,
148 => 1,
];
Expand Down

0 comments on commit 9b40157

Please sign in to comment.