Skip to content

Removed obsolete layout check #370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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