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 @@ -86,7 +86,7 @@ public function render(?OutputFormat $outputFormat = null): string
8686 if ($ outputFormat === null ) {
8787 $ outputFormat = new OutputFormat ();
8888 }
89- return $ outputFormat ->comments ($ this ) . $ this ->renderListContents ($ outputFormat );
89+ return $ outputFormat ->getFormatter ()-> comments ($ this ) . $ this ->renderListContents ($ outputFormat );
9090 }
9191
9292 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 @@ -234,7 +234,8 @@ public function __toString(): string
234234
235235 public function render (OutputFormat $ outputFormat ): string
236236 {
237- $ result = "{$ outputFormat ->comments ($ this )}{$ this ->rule }: {$ outputFormat ->spaceAfterRuleName ()}" ;
237+ $ formatter = $ outputFormat ->getFormatter ();
238+ $ result = "{$ formatter ->comments ($ this )}{$ this ->rule }: {$ formatter ->spaceAfterRuleName ()}" ;
238239 if ($ this ->value instanceof Value) { // Can also be a ValueList
239240 $ result .= $ this ->value ->render ($ outputFormat );
240241 } 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 @@ -278,28 +278,30 @@ protected function renderRules(OutputFormat $outputFormat)
278278 $ nextLevelFormat = $ outputFormat ->nextLevel ();
279279 foreach ($ this ->rules as $ rules ) {
280280 foreach ($ rules 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 }
296297
298+ $ formatter = $ outputFormat ->getFormatter ();
297299 if (!$ isFirst ) {
298300 // Had some output
299- $ result .= $ outputFormat ->spaceAfterRules ();
301+ $ result .= $ formatter ->spaceAfterRules ();
300302 }
301303
302- return $ outputFormat ->removeLastSemicolon ($ result );
304+ return $ formatter ->removeLastSemicolon ($ result );
303305 }
304306
305307 /**
You can’t perform that action at this time.
0 commit comments