Skip to content

Commit 216540f

Browse files
Replace multiple string concatenation by joining array of strings
1 parent d271281 commit 216540f

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public function load($area)
4242
public static function getFilePath($area)
4343
{
4444
$diPath = DirectoryList::getDefaultConfig()[DirectoryList::GENERATED_METADATA][DirectoryList::PATH];
45-
return BP . '/' . $diPath . '/' . $area . '.php';
45+
return join('', [BP, '/', $diPath, '/', $area, '.php']);
4646
}
4747
}

lib/internal/Magento/Framework/View/Element/AbstractBlock.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,14 @@ public function getChildHtml($alias = '', $useCache = true)
517517
$out = $layout->renderElement($childName, $useCache);
518518
}
519519
} else {
520+
$outParts = [];
520521
foreach ($layout->getChildNames($name) as $child) {
521-
$out .= $layout->renderElement($child, $useCache);
522+
$elementHtml = $layout->renderElement($child, $useCache);
523+
if (!empty($elementHtml)) {
524+
$outParts[] = $elementHtml;
525+
}
522526
}
527+
$out = join('', $outParts);
523528
}
524529

525530
return $out;
@@ -548,9 +553,14 @@ public function getChildChildHtml($alias, $childChildAlias = '', $useCache = tru
548553
$childChildName = $layout->getChildName($childName, $childChildAlias);
549554
$out = $layout->renderElement($childChildName, $useCache);
550555
} else {
556+
$outParts = [];
551557
foreach ($layout->getChildNames($childName) as $childChild) {
552-
$out .= $layout->renderElement($childChild, $useCache);
558+
$elementHtml = $layout->renderElement($childChild, $useCache);
559+
if (!empty($elementHtml)) {
560+
$outParts[] = $elementHtml;
561+
}
553562
}
563+
$out = join('', $outParts);
554564
}
555565
return $out;
556566
}

lib/internal/Magento/Framework/View/Layout.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,16 @@ protected function _renderUiComponent($name)
586586
*/
587587
protected function _renderContainer($name, $useCache = true)
588588
{
589-
$html = '';
589+
$htmlParts = [];
590590
$children = $this->getChildNames($name);
591591
foreach ($children as $child) {
592-
$html .= $this->renderElement($child, $useCache);
592+
$childHtml = $this->renderElement($child, $useCache);
593+
if (!empty($childHtml)) {
594+
$htmlParts[] = $childHtml;
595+
}
593596
}
594-
if ($html == '' || !$this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_TAG)) {
595-
return $html;
597+
if (empty($htmlParts) || !$this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_TAG)) {
598+
return join('', $htmlParts);
596599
}
597600

598601
$htmlId = $this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_ID);
@@ -606,8 +609,7 @@ protected function _renderContainer($name, $useCache = true)
606609
}
607610

608611
$htmlTag = $this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_TAG);
609-
610-
$html = sprintf('<%1$s%2$s%3$s>%4$s</%1$s>', $htmlTag, $htmlId, $htmlClass, $html);
612+
$html = sprintf('<%1$s%2$s%3$s>%4$s</%1$s>', $htmlTag, $htmlId, $htmlClass, join('', $htmlParts));
611613

612614
return $html;
613615
}

0 commit comments

Comments
 (0)