File tree Expand file tree Collapse file tree 13 files changed +46
-33
lines changed Expand file tree Collapse file tree 13 files changed +46
-33
lines changed Original file line number Diff line number Diff line change @@ -52,13 +52,14 @@ public function __toString(): string
5252
5353 public function render (OutputFormat $ outputFormat ): string
5454 {
55- $ result = $ outputFormat ->comments ($ this );
55+ $ formatter = $ outputFormat ->getFormatter ();
56+ $ result = $ formatter ->comments ($ this );
5657 $ result .= $ outputFormat ->getBeforeAtRuleBlock ();
5758 $ arguments = $ this ->arguments ;
5859 if ($ arguments ) {
5960 $ arguments = ' ' . $ arguments ;
6061 }
61- $ result .= "@ {$ this ->type }$ arguments {$ outputFormat ->spaceBeforeOpeningBrace ()}{ " ;
62+ $ result .= "@ {$ this ->type }$ arguments {$ formatter ->spaceBeforeOpeningBrace ()}{ " ;
6263 $ result .= $ this ->renderListContents ($ outputFormat );
6364 $ result .= '} ' ;
6465 $ result .= $ outputFormat ->getAfterAtRuleBlock ();
Original file line number Diff line number Diff line change @@ -421,25 +421,27 @@ protected function renderListContents(OutputFormat $outputFormat)
421421 if (!$ this ->isRootList ()) {
422422 $ nextLevelFormat = $ outputFormat ->nextLevel ();
423423 }
424+ $ nextLevelFormatter = $ nextLevelFormat ->getFormatter ();
425+ $ formatter = $ outputFormat ->getFormatter ();
424426 foreach ($ this ->contents as $ listItem ) {
425- $ renderedCss = $ outputFormat ->safely (static function () use ($ nextLevelFormat , $ listItem ): string {
427+ $ renderedCss = $ formatter ->safely (static function () use ($ nextLevelFormat , $ listItem ): string {
426428 return $ listItem ->render ($ nextLevelFormat );
427429 });
428430 if ($ renderedCss === null ) {
429431 continue ;
430432 }
431433 if ($ isFirst ) {
432434 $ isFirst = false ;
433- $ result .= $ nextLevelFormat ->spaceBeforeBlocks ();
435+ $ result .= $ nextLevelFormatter ->spaceBeforeBlocks ();
434436 } else {
435- $ result .= $ nextLevelFormat ->spaceBetweenBlocks ();
437+ $ result .= $ nextLevelFormatter ->spaceBetweenBlocks ();
436438 }
437439 $ result .= $ renderedCss ;
438440 }
439441
440442 if (!$ isFirst ) {
441443 // Had some output
442- $ result .= $ outputFormat ->spaceAfterBlocks ();
444+ $ result .= $ formatter ->spaceAfterBlocks ();
443445 }
444446
445447 return $ result ;
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ public function render(?OutputFormat $outputFormat = null): string
9898 if ($ outputFormat === null ) {
9999 $ outputFormat = new OutputFormat ();
100100 }
101- return $ outputFormat ->comments ($ this ) . $ this ->renderListContents ($ outputFormat );
101+ return $ outputFormat ->getFormatter ()-> comments ($ this ) . $ this ->renderListContents ($ outputFormat );
102102 }
103103
104104 public function isRootList (): bool
Original file line number Diff line number Diff line change @@ -61,8 +61,9 @@ public function __toString(): string
6161
6262 public function render (OutputFormat $ outputFormat ): string
6363 {
64- $ result = $ outputFormat ->comments ($ this );
65- $ result .= "@ {$ this ->vendorKeyFrame } {$ this ->animationName }{$ outputFormat ->spaceBeforeOpeningBrace ()}{ " ;
64+ $ formatter = $ outputFormat ->getFormatter ();
65+ $ result = $ formatter ->comments ($ this );
66+ $ result .= "@ {$ this ->vendorKeyFrame } {$ this ->animationName }{$ formatter ->spaceBeforeOpeningBrace ()}{ " ;
6667 $ result .= $ this ->renderListContents ($ outputFormat );
6768 $ result .= '} ' ;
6869 return $ result ;
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ public function __toString(): string
8181
8282 public function render (OutputFormat $ outputFormat ): string
8383 {
84- return "{$ outputFormat ->comments ($ this )}@charset {$ this ->charset ->render ($ outputFormat )}; " ;
84+ return "{$ outputFormat ->getFormatter ()-> comments ($ this )}@charset {$ this ->charset ->render ($ outputFormat )}; " ;
8585 }
8686
8787 public function atRuleName (): string
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ public function __toString(): string
8282
8383 public function render (OutputFormat $ outputFormat ): string
8484 {
85- return $ outputFormat ->comments ($ this ) . '@import ' . $ this ->location ->render ($ outputFormat )
85+ return $ outputFormat ->getFormatter ()-> comments ($ this ) . '@import ' . $ this ->location ->render ($ outputFormat )
8686 . ($ this ->mediaQuery === null ? '' : ' ' . $ this ->mediaQuery ) . '; ' ;
8787 }
8888
Original file line number Diff line number Diff line change @@ -270,7 +270,8 @@ public function __toString(): string
270270
271271 public function render (OutputFormat $ outputFormat ): string
272272 {
273- $ result = "{$ outputFormat ->comments ($ this )}{$ this ->rule }: {$ outputFormat ->spaceAfterRuleName ()}" ;
273+ $ formatter = $ outputFormat ->getFormatter ();
274+ $ result = "{$ formatter ->comments ($ this )}{$ this ->rule }: {$ formatter ->spaceAfterRuleName ()}" ;
274275 if ($ this ->value instanceof Value) { // Can also be a ValueList
275276 $ result .= $ this ->value ->render ($ outputFormat );
276277 } else {
Original file line number Diff line number Diff line change @@ -63,12 +63,13 @@ public function __toString(): string
6363
6464 public function render (OutputFormat $ outputFormat ): string
6565 {
66- $ result = $ outputFormat ->comments ($ this );
66+ $ formatter = $ outputFormat ->getFormatter ();
67+ $ result = $ formatter ->comments ($ this );
6768 $ arguments = $ this ->arguments ;
6869 if ($ arguments ) {
6970 $ arguments = ' ' . $ arguments ;
7071 }
71- $ result .= "@ {$ this ->type }$ arguments {$ outputFormat ->spaceBeforeOpeningBrace ()}{ " ;
72+ $ result .= "@ {$ this ->type }$ arguments {$ formatter ->spaceBeforeOpeningBrace ()}{ " ;
7273 $ result .= $ this ->renderRules ($ outputFormat );
7374 $ result .= '} ' ;
7475 return $ result ;
Original file line number Diff line number Diff 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 ->getBeforeDeclarationBlock ();
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 ->getAfterDeclarationBlockSelectors ();
169- $ result .= $ outputFormat ->spaceBeforeOpeningBrace () . '{ ' ;
170+ $ result .= $ formatter ->spaceBeforeOpeningBrace () . '{ ' ;
170171 $ result .= $ this ->renderRules ($ outputFormat );
171172 $ result .= '} ' ;
172173 $ result .= $ outputFormat ->getAfterDeclarationBlock ();
174+
173175 return $ result ;
174176 }
175177}
Original file line number Diff line number Diff line change @@ -273,28 +273,30 @@ protected function renderRules(OutputFormat $outputFormat)
273273 $ nextLevelFormat = $ outputFormat ->nextLevel ();
274274 foreach ($ this ->rules as $ rules ) {
275275 foreach ($ rules as $ rule ) {
276- $ renderedRule = $ nextLevelFormat ->safely (static function () use ($ rule , $ nextLevelFormat ): string {
277- return $ rule ->render ($ nextLevelFormat );
278- });
276+ $ renderedRule = $ nextLevelFormat ->getFormatter ()
277+ ->safely (static function () use ($ rule , $ nextLevelFormat ): string {
278+ return $ rule ->render ($ nextLevelFormat );
279+ });
279280 if ($ renderedRule === null ) {
280281 continue ;
281282 }
282283 if ($ isFirst ) {
283284 $ isFirst = false ;
284- $ result .= $ nextLevelFormat ->spaceBeforeRules ();
285+ $ result .= $ nextLevelFormat ->getFormatter ()-> spaceBeforeRules ();
285286 } else {
286- $ result .= $ nextLevelFormat ->spaceBetweenRules ();
287+ $ result .= $ nextLevelFormat ->getFormatter ()-> spaceBetweenRules ();
287288 }
288289 $ result .= $ renderedRule ;
289290 }
290291 }
291292
293+ $ formatter = $ outputFormat ->getFormatter ();
292294 if (!$ isFirst ) {
293295 // Had some output
294- $ result .= $ outputFormat ->spaceAfterRules ();
296+ $ result .= $ formatter ->spaceAfterRules ();
295297 }
296298
297- return $ outputFormat ->removeLastSemicolon ($ result );
299+ return $ formatter ->removeLastSemicolon ($ result );
298300 }
299301
300302 /**
You can’t perform that action at this time.
0 commit comments