Skip to content

Commit 04b5cc5

Browse files
committed
[CLEANUP] Avoid magic method forwarding in CSSList
Part of #1147
1 parent 898d5cd commit 04b5cc5

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

config/phpstan-baseline.neon

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,6 @@ parameters:
1818
count: 1
1919
path: ../src/CSSList/CSSBlockList.php
2020

21-
-
22-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:safely\(\)\.$#'
23-
identifier: method.notFound
24-
count: 1
25-
path: ../src/CSSList/CSSList.php
26-
27-
-
28-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:spaceAfterBlocks\(\)\.$#'
29-
identifier: method.notFound
30-
count: 1
31-
path: ../src/CSSList/CSSList.php
32-
33-
-
34-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:spaceBeforeBlocks\(\)\.$#'
35-
identifier: method.notFound
36-
count: 1
37-
path: ../src/CSSList/CSSList.php
38-
39-
-
40-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:spaceBetweenBlocks\(\)\.$#'
41-
identifier: method.notFound
42-
count: 1
43-
path: ../src/CSSList/CSSList.php
44-
4521
-
4622
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
4723
identifier: notEqual.notAllowed

src/CSSList/CSSList.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,25 +419,27 @@ protected function renderListContents(OutputFormat $outputFormat)
419419
if (!$this->isRootList()) {
420420
$nextLevelFormat = $outputFormat->nextLevel();
421421
}
422+
$nextLevelFormatter = $nextLevelFormat->getFormatter();
423+
$formatter = $outputFormat->getFormatter();
422424
foreach ($this->contents as $listItem) {
423-
$renderedCss = $outputFormat->safely(static function () use ($nextLevelFormat, $listItem): string {
425+
$renderedCss = $formatter->safely(static function () use ($nextLevelFormat, $listItem): string {
424426
return $listItem->render($nextLevelFormat);
425427
});
426428
if ($renderedCss === null) {
427429
continue;
428430
}
429431
if ($isFirst) {
430432
$isFirst = false;
431-
$result .= $nextLevelFormat->spaceBeforeBlocks();
433+
$result .= $nextLevelFormatter->spaceBeforeBlocks();
432434
} else {
433-
$result .= $nextLevelFormat->spaceBetweenBlocks();
435+
$result .= $nextLevelFormatter->spaceBetweenBlocks();
434436
}
435437
$result .= $renderedCss;
436438
}
437439

438440
if (!$isFirst) {
439441
// Had some output
440-
$result .= $outputFormat->spaceAfterBlocks();
442+
$result .= $formatter->spaceAfterBlocks();
441443
}
442444

443445
return $result;

0 commit comments

Comments
 (0)