From bb81761834e60297ef136ff1330b89c48a2fc0d9 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Wed, 12 Mar 2025 16:58:11 +0100 Subject: [PATCH] [CLEANUP] Avoid magic method forwarding in `AtRuleSet` Part of #1147 --- config/phpstan-baseline.neon | 12 ------------ src/RuleSet/AtRuleSet.php | 5 +++-- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/config/phpstan-baseline.neon b/config/phpstan-baseline.neon index 435a4cd3b..8af861d56 100644 --- a/config/phpstan-baseline.neon +++ b/config/phpstan-baseline.neon @@ -150,18 +150,6 @@ parameters: count: 1 path: ../src/Rule/Rule.php - - - message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:comments\(\)\.$#' - identifier: method.notFound - count: 1 - path: ../src/RuleSet/AtRuleSet.php - - - - message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:spaceBeforeOpeningBrace\(\)\.$#' - identifier: method.notFound - count: 1 - path: ../src/RuleSet/AtRuleSet.php - - message: '#^Only booleans are allowed in an if condition, string given\.$#' identifier: if.condNotBoolean diff --git a/src/RuleSet/AtRuleSet.php b/src/RuleSet/AtRuleSet.php index c8fb79e33..a896246b9 100644 --- a/src/RuleSet/AtRuleSet.php +++ b/src/RuleSet/AtRuleSet.php @@ -63,12 +63,13 @@ public function __toString(): string public function render(OutputFormat $outputFormat): string { - $result = $outputFormat->comments($this); + $formatter = $outputFormat->getFormatter(); + $result = $formatter->comments($this); $arguments = $this->arguments; if ($arguments) { $arguments = ' ' . $arguments; } - $result .= "@{$this->type}$arguments{$outputFormat->spaceBeforeOpeningBrace()}{"; + $result .= "@{$this->type}$arguments{$formatter->spaceBeforeOpeningBrace()}{"; $result .= $this->renderRules($outputFormat); $result .= '}'; return $result;