Skip to content

Commit 3dcd027

Browse files
committed
[CLEANUP] Avoid magic method forwarding in RuleSet
Part of #1147
1 parent b0238f0 commit 3dcd027

File tree

2 files changed

+9
-37
lines changed

2 files changed

+9
-37
lines changed

config/phpstan-baseline.neon

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -168,36 +168,6 @@ parameters:
168168
count: 1
169169
path: ../src/RuleSet/DeclarationBlock.php
170170

171-
-
172-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:removeLastSemicolon\(\)\.$#'
173-
identifier: method.notFound
174-
count: 1
175-
path: ../src/RuleSet/RuleSet.php
176-
177-
-
178-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:safely\(\)\.$#'
179-
identifier: method.notFound
180-
count: 1
181-
path: ../src/RuleSet/RuleSet.php
182-
183-
-
184-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:spaceAfterRules\(\)\.$#'
185-
identifier: method.notFound
186-
count: 1
187-
path: ../src/RuleSet/RuleSet.php
188-
189-
-
190-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:spaceBeforeRules\(\)\.$#'
191-
identifier: method.notFound
192-
count: 1
193-
path: ../src/RuleSet/RuleSet.php
194-
195-
-
196-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:spaceBetweenRules\(\)\.$#'
197-
identifier: method.notFound
198-
count: 1
199-
path: ../src/RuleSet/RuleSet.php
200-
201171
-
202172
message: '#^Only booleans are allowed in a negated boolean, string\|null given\.$#'
203173
identifier: booleanNot.exprNotBoolean

src/RuleSet/RuleSet.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,27 +278,29 @@ protected function renderRules(OutputFormat $outputFormat)
278278
$isFirst = true;
279279
$nextLevelFormat = $outputFormat->nextLevel();
280280
foreach ($this->getRules() as $rule) {
281-
$renderedRule = $nextLevelFormat->safely(static function () use ($rule, $nextLevelFormat): string {
282-
return $rule->render($nextLevelFormat);
283-
});
281+
$renderedRule = $nextLevelFormat->getFormatter()
282+
->safely(static function () use ($rule, $nextLevelFormat): string {
283+
return $rule->render($nextLevelFormat);
284+
});
284285
if ($renderedRule === null) {
285286
continue;
286287
}
287288
if ($isFirst) {
288289
$isFirst = false;
289-
$result .= $nextLevelFormat->spaceBeforeRules();
290+
$result .= $nextLevelFormat->getFormatter()->spaceBeforeRules();
290291
} else {
291-
$result .= $nextLevelFormat->spaceBetweenRules();
292+
$result .= $nextLevelFormat->getFormatter()->spaceBetweenRules();
292293
}
293294
$result .= $renderedRule;
294295
}
295296

297+
$formatter = $outputFormat->getFormatter();
296298
if (!$isFirst) {
297299
// Had some output
298-
$result .= $outputFormat->spaceAfterRules();
300+
$result .= $formatter->spaceAfterRules();
299301
}
300302

301-
return $outputFormat->removeLastSemicolon($result);
303+
return $formatter->removeLastSemicolon($result);
302304
}
303305

304306
/**

0 commit comments

Comments
 (0)