File tree Expand file tree Collapse file tree 13 files changed +43
-31
lines changed Expand file tree Collapse file tree 13 files changed +43
-31
lines changed Original file line number Diff line number Diff line change @@ -49,13 +49,14 @@ public function __toString(): string
4949
5050 public function render (OutputFormat $ outputFormat ): string
5151 {
52- $ result = $ outputFormat ->comments ($ this );
52+ $ formatter = $ outputFormat ->getFormatter ();
53+ $ result = $ formatter ->comments ($ this );
5354 $ result .= $ outputFormat ->sBeforeAtRuleBlock ;
5455 $ arguments = $ this ->arguments ;
5556 if ($ arguments ) {
5657 $ arguments = ' ' . $ arguments ;
5758 }
58- $ result .= "@ {$ this ->type }$ arguments {$ outputFormat ->spaceBeforeOpeningBrace ()}{ " ;
59+ $ result .= "@ {$ this ->type }$ arguments {$ formatter ->spaceBeforeOpeningBrace ()}{ " ;
5960 $ result .= $ this ->renderListContents ($ outputFormat );
6061 $ result .= '} ' ;
6162 $ result .= $ outputFormat ->sAfterAtRuleBlock ;
Original file line number Diff line number Diff line change @@ -418,25 +418,27 @@ protected function renderListContents(OutputFormat $outputFormat)
418418 if (!$ this ->isRootList ()) {
419419 $ nextLevelFormat = $ outputFormat ->nextLevel ();
420420 }
421+ $ nextLevelFormatter = $ nextLevelFormat ->getFormatter ();
422+ $ formatter = $ outputFormat ->getFormatter ();
421423 foreach ($ this ->contents as $ listItem ) {
422- $ renderedCss = $ outputFormat ->safely (static function () use ($ nextLevelFormat , $ listItem ): string {
424+ $ renderedCss = $ formatter ->safely (static function () use ($ nextLevelFormat , $ listItem ): string {
423425 return $ listItem ->render ($ nextLevelFormat );
424426 });
425427 if ($ renderedCss === null ) {
426428 continue ;
427429 }
428430 if ($ isFirst ) {
429431 $ isFirst = false ;
430- $ result .= $ nextLevelFormat ->spaceBeforeBlocks ();
432+ $ result .= $ nextLevelFormatter ->spaceBeforeBlocks ();
431433 } else {
432- $ result .= $ nextLevelFormat ->spaceBetweenBlocks ();
434+ $ result .= $ nextLevelFormatter ->spaceBetweenBlocks ();
433435 }
434436 $ result .= $ renderedCss ;
435437 }
436438
437439 if (!$ isFirst ) {
438440 // Had some output
439- $ result .= $ outputFormat ->spaceAfterBlocks ();
441+ $ result .= $ formatter ->spaceAfterBlocks ();
440442 }
441443
442444 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 @@ -58,8 +58,9 @@ public function __toString(): string
5858
5959 public function render (OutputFormat $ outputFormat ): string
6060 {
61- $ result = $ outputFormat ->comments ($ this );
62- $ result .= "@ {$ this ->vendorKeyFrame } {$ this ->animationName }{$ outputFormat ->spaceBeforeOpeningBrace ()}{ " ;
61+ $ formatter = $ outputFormat ->getFormatter ();
62+ $ result = $ formatter ->comments ($ this );
63+ $ result .= "@ {$ this ->vendorKeyFrame } {$ this ->animationName }{$ formatter ->spaceBeforeOpeningBrace ()}{ " ;
6364 $ result .= $ this ->renderListContents ($ outputFormat );
6465 $ result .= '} ' ;
6566 return $ result ;
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ public function __toString(): string
7878
7979 public function render (OutputFormat $ outputFormat ): string
8080 {
81- return "{$ outputFormat ->comments ($ this )}@charset {$ this ->charset ->render ($ outputFormat )}; " ;
81+ return "{$ outputFormat ->getFormatter ()-> comments ($ this )}@charset {$ this ->charset ->render ($ outputFormat )}; " ;
8282 }
8383
8484 public function atRuleName (): string
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ public function __toString(): string
7979
8080 public function render (OutputFormat $ outputFormat ): string
8181 {
82- return $ outputFormat ->comments ($ this ) . '@import ' . $ this ->location ->render ($ outputFormat )
82+ return $ outputFormat ->getFormatter ()-> comments ($ this ) . '@import ' . $ this ->location ->render ($ outputFormat )
8383 . ($ this ->mediaQuery === null ? '' : ' ' . $ this ->mediaQuery ) . '; ' ;
8484 }
8585
Original file line number Diff line number Diff line change @@ -267,7 +267,8 @@ public function __toString(): string
267267
268268 public function render (OutputFormat $ outputFormat ): string
269269 {
270- $ result = "{$ outputFormat ->comments ($ this )}{$ this ->rule }: {$ outputFormat ->spaceAfterRuleName ()}" ;
270+ $ formatter = $ outputFormat ->getFormatter ();
271+ $ result = "{$ formatter ->comments ($ this )}{$ this ->rule }: {$ formatter ->spaceAfterRuleName ()}" ;
271272 if ($ this ->value instanceof Value) { // Can also be a ValueList
272273 $ result .= $ this ->value ->render ($ outputFormat );
273274 } else {
Original file line number Diff line number Diff line change @@ -60,12 +60,13 @@ public function __toString(): string
6060
6161 public function render (OutputFormat $ outputFormat ): string
6262 {
63- $ result = $ outputFormat ->comments ($ this );
63+ $ formatter = $ outputFormat ->getFormatter ();
64+ $ result = $ formatter ->comments ($ this );
6465 $ arguments = $ this ->arguments ;
6566 if ($ arguments ) {
6667 $ arguments = ' ' . $ arguments ;
6768 }
68- $ result .= "@ {$ this ->type }$ arguments {$ outputFormat ->spaceBeforeOpeningBrace ()}{ " ;
69+ $ result .= "@ {$ this ->type }$ arguments {$ formatter ->spaceBeforeOpeningBrace ()}{ " ;
6970 $ result .= $ this ->renderRules ($ outputFormat );
7071 $ result .= '} ' ;
7172 return $ result ;
Original file line number Diff line number Diff line change @@ -153,21 +153,23 @@ public function __toString(): string
153153 */
154154 public function render (OutputFormat $ outputFormat ): string
155155 {
156- $ result = $ outputFormat ->comments ($ this );
156+ $ formatter = $ outputFormat ->getFormatter ();
157+ $ result = $ formatter ->comments ($ this );
157158 if (\count ($ this ->selectors ) === 0 ) {
158159 // If all the selectors have been removed, this declaration block becomes invalid
159160 throw new OutputException ('Attempt to print declaration block with missing selector ' , $ this ->lineNumber );
160161 }
161162 $ result .= $ outputFormat ->sBeforeDeclarationBlock ;
162- $ result .= $ outputFormat ->implode (
163- $ outputFormat ->spaceBeforeSelectorSeparator () . ', ' . $ outputFormat ->spaceAfterSelectorSeparator (),
163+ $ result .= $ formatter ->implode (
164+ $ formatter ->spaceBeforeSelectorSeparator () . ', ' . $ formatter ->spaceAfterSelectorSeparator (),
164165 $ this ->selectors
165166 );
166167 $ result .= $ outputFormat ->sAfterDeclarationBlockSelectors ;
167- $ result .= $ outputFormat ->spaceBeforeOpeningBrace () . '{ ' ;
168+ $ result .= $ formatter ->spaceBeforeOpeningBrace () . '{ ' ;
168169 $ result .= $ this ->renderRules ($ outputFormat );
169170 $ result .= '} ' ;
170171 $ result .= $ outputFormat ->sAfterDeclarationBlock ;
172+
171173 return $ result ;
172174 }
173175}
Original file line number Diff line number Diff line change @@ -270,28 +270,29 @@ protected function renderRules(OutputFormat $outputFormat)
270270 $ oNextLevel = $ outputFormat ->nextLevel ();
271271 foreach ($ this ->aRules as $ aRules ) {
272272 foreach ($ aRules as $ rule ) {
273- $ sRendered = $ oNextLevel ->safely (static function () use ($ rule , $ oNextLevel ): string {
273+ $ sRendered = $ oNextLevel ->getFormatter ()-> safely (static function () use ($ rule , $ oNextLevel ): string {
274274 return $ rule ->render ($ oNextLevel );
275275 });
276276 if ($ sRendered === null ) {
277277 continue ;
278278 }
279279 if ($ bIsFirst ) {
280280 $ bIsFirst = false ;
281- $ result .= $ oNextLevel ->spaceBeforeRules ();
281+ $ result .= $ oNextLevel ->getFormatter ()-> spaceBeforeRules ();
282282 } else {
283- $ result .= $ oNextLevel ->spaceBetweenRules ();
283+ $ result .= $ oNextLevel ->getFormatter ()-> spaceBetweenRules ();
284284 }
285285 $ result .= $ sRendered ;
286286 }
287287 }
288288
289+ $ formatter = $ outputFormat ->getFormatter ();
289290 if (!$ bIsFirst ) {
290291 // Had some output
291- $ result .= $ outputFormat ->spaceAfterRules ();
292+ $ result .= $ formatter ->spaceAfterRules ();
292293 }
293294
294- return $ outputFormat ->removeLastSemicolon ($ result );
295+ return $ formatter ->removeLastSemicolon ($ result );
295296 }
296297
297298 /**
You can’t perform that action at this time.
0 commit comments