Skip to content

Commit c6383f6

Browse files
committed
#558: Content Types Output Style Attribute Removal
- Code Review Feedback/Amends (Thanks, @BarnyShergold)
1 parent 4527f1e commit c6383f6

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

app/code/Magento/PageBuilder/Setup/Converters/PageBuilderStripStyles.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(DOMDocument $domDocument)
4242
*/
4343
private function generateDataAttribute(): string
4444
{
45-
return strtoupper(uniqid());
45+
return \strtoupper(\uniqid());
4646
}
4747

4848
/**
@@ -68,11 +68,11 @@ private function generateInternalStyles(array $styleMap): string
6868
*/
6969
public function convert($value): string
7070
{
71-
libxml_use_internal_errors(true);
71+
\libxml_use_internal_errors(true);
7272
$document = new DOMDocument();
7373
$document->loadHTML($value);
7474
$xpath = new DOMXPath($document);
75-
libxml_clear_errors();
75+
\libxml_clear_errors();
7676

7777
$body = $document->documentElement->lastChild;
7878
$nodes = $xpath->query(self::XPATH_SELECTOR); // Query for Inline Styles
@@ -98,7 +98,7 @@ public function convert($value): string
9898
$body->appendChild($style);
9999

100100
// @todo: Refactor
101-
preg_match(
101+
\preg_match(
102102
'/<html><body>(.+)<\/body><\/html>$/si',
103103
$document->saveHTML(),
104104
$matches

dev/tests/integration/testsuite/Magento/PageBuilder/Setup/Converters/PageBuilderStripStylesTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testConvert(string $htmlString, int $expectedStyleTags)
4040
$convertPageBuilderStripStyles = $this->objectManager->create(PageBuilderStripStyles::class);
4141
$result = $convertPageBuilderStripStyles->convert($htmlString);
4242

43-
libxml_use_internal_errors(true);
43+
\libxml_use_internal_errors(true);
4444

4545
$docBefore = new DOMDocument();
4646
$docBefore->loadHTML($htmlString);
@@ -50,7 +50,7 @@ public function testConvert(string $htmlString, int $expectedStyleTags)
5050
$docAfter->loadHTML($result);
5151
$xpathAfter = new DOMXPath($docAfter);
5252

53-
libxml_clear_errors();
53+
\libxml_clear_errors();
5454

5555
$getInternalStyles = false;
5656
$nodesBefore = $xpathBefore->query(PageBuilderStripStyles::XPATH_SELECTOR);
@@ -67,10 +67,10 @@ public function testConvert(string $htmlString, int $expectedStyleTags)
6767
}
6868

6969
// Assert Inline Styles Were Removed
70-
$this->assertEquals(0, count($xpathAfter->query(PageBuilderStripStyles::XPATH_SELECTOR)));
70+
$this->assertEquals(0, \count($xpathAfter->query(PageBuilderStripStyles::XPATH_SELECTOR)));
7171

7272
// Assert Expected Internal Styles
73-
$this->assertEquals($expectedStyleTags, count($xpathAfter->query('//style')));
73+
$this->assertEquals($expectedStyleTags, \count($xpathAfter->query('//style')));
7474

7575
// Assert Converted Styles
7676
if ($getInternalStyles) {
@@ -170,6 +170,7 @@ public function conversionData(): array
170170
];
171171
// phpcs:enable Generic.Files.LineLength.TooLong
172172
}
173+
173174
/**
174175
* @return array
175176
*/

0 commit comments

Comments
 (0)