Skip to content

Commit 34ebb96

Browse files
authored
[CLEANUP] Avoid magic method forwarding in DeclarationBlock (#1161)
Part of #1147
1 parent 8d66357 commit 34ebb96

File tree

2 files changed

+6
-34
lines changed

2 files changed

+6
-34
lines changed

config/phpstan-baseline.neon

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -102,36 +102,6 @@ parameters:
102102
count: 1
103103
path: ../src/RuleSet/AtRuleSet.php
104104

105-
-
106-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:comments\(\)\.$#'
107-
identifier: method.notFound
108-
count: 1
109-
path: ../src/RuleSet/DeclarationBlock.php
110-
111-
-
112-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:implode\(\)\.$#'
113-
identifier: method.notFound
114-
count: 1
115-
path: ../src/RuleSet/DeclarationBlock.php
116-
117-
-
118-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:spaceAfterSelectorSeparator\(\)\.$#'
119-
identifier: method.notFound
120-
count: 1
121-
path: ../src/RuleSet/DeclarationBlock.php
122-
123-
-
124-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:spaceBeforeOpeningBrace\(\)\.$#'
125-
identifier: method.notFound
126-
count: 1
127-
path: ../src/RuleSet/DeclarationBlock.php
128-
129-
-
130-
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:spaceBeforeSelectorSeparator\(\)\.$#'
131-
identifier: method.notFound
132-
count: 1
133-
path: ../src/RuleSet/DeclarationBlock.php
134-
135105
-
136106
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
137107
identifier: notEqual.notAllowed

src/RuleSet/DeclarationBlock.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,23 @@ public function __toString(): string
155155
*/
156156
public function render(OutputFormat $outputFormat): string
157157
{
158-
$result = $outputFormat->comments($this);
158+
$formatter = $outputFormat->getFormatter();
159+
$result = $formatter->comments($this);
159160
if (\count($this->selectors) === 0) {
160161
// If all the selectors have been removed, this declaration block becomes invalid
161162
throw new OutputException('Attempt to print declaration block with missing selector', $this->lineNumber);
162163
}
163164
$result .= $outputFormat->getContentBeforeDeclarationBlock();
164-
$result .= $outputFormat->implode(
165-
$outputFormat->spaceBeforeSelectorSeparator() . ',' . $outputFormat->spaceAfterSelectorSeparator(),
165+
$result .= $formatter->implode(
166+
$formatter->spaceBeforeSelectorSeparator() . ',' . $formatter->spaceAfterSelectorSeparator(),
166167
$this->selectors
167168
);
168169
$result .= $outputFormat->getContentAfterDeclarationBlockSelectors();
169-
$result .= $outputFormat->spaceBeforeOpeningBrace() . '{';
170+
$result .= $formatter->spaceBeforeOpeningBrace() . '{';
170171
$result .= $this->renderRules($outputFormat);
171172
$result .= '}';
172173
$result .= $outputFormat->getContentAfterDeclarationBlock();
174+
173175
return $result;
174176
}
175177
}

0 commit comments

Comments
 (0)