Skip to content

Commit fdd1a65

Browse files
authored
[CLEANUP] Avoid magic method forwarding in RuleSet (#1159)
Part of #1147
1 parent 831f3d9 commit fdd1a65

File tree

2 files changed

+7
-35
lines changed

2 files changed

+7
-35
lines changed

config/phpstan-baseline.neon

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -156,36 +156,6 @@ parameters:
156156
count: 1
157157
path: ../src/RuleSet/DeclarationBlock.php
158158

159-
-
160-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:removeLastSemicolon\(\)\.$#'
161-
identifier: method.notFound
162-
count: 1
163-
path: ../src/RuleSet/RuleSet.php
164-
165-
-
166-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:safely\(\)\.$#'
167-
identifier: method.notFound
168-
count: 1
169-
path: ../src/RuleSet/RuleSet.php
170-
171-
-
172-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:spaceAfterRules\(\)\.$#'
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\:\:spaceBeforeRules\(\)\.$#'
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\:\:spaceBetweenRules\(\)\.$#'
185-
identifier: method.notFound
186-
count: 1
187-
path: ../src/RuleSet/RuleSet.php
188-
189159
-
190160
message: '#^Only booleans are allowed in a negated boolean, string\|null given\.$#'
191161
identifier: booleanNot.exprNotBoolean

src/RuleSet/RuleSet.php

Lines changed: 7 additions & 5 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 {
281+
$nextLevelFormatter = $nextLevelFormat->getFormatter();
282+
$renderedRule = $nextLevelFormatter->safely(static function () use ($rule, $nextLevelFormat): string {
282283
return $rule->render($nextLevelFormat);
283284
});
284285
if ($renderedRule === null) {
285286
continue;
286287
}
287288
if ($isFirst) {
288289
$isFirst = false;
289-
$result .= $nextLevelFormat->spaceBeforeRules();
290+
$result .= $nextLevelFormatter->spaceBeforeRules();
290291
} else {
291-
$result .= $nextLevelFormat->spaceBetweenRules();
292+
$result .= $nextLevelFormatter->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)