Skip to content

Commit 97cadde

Browse files
committed
[TASK] Remove __toString()
Part of #998.
1 parent 86aeaa7 commit 97cadde

26 files changed

+13
-216
lines changed

src/CSSList/AtRuleBlockList.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ public function atRuleArgs(): string
4242
return $this->arguments;
4343
}
4444

45-
/**
46-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
47-
*/
48-
public function __toString(): string
49-
{
50-
return $this->render(new OutputFormat());
51-
}
52-
5345
public function render(OutputFormat $outputFormat): string
5446
{
5547
$result = $outputFormat->comments($this);

src/CSSList/CSSList.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -402,14 +402,6 @@ public function removeDeclarationBlockBySelector($selectors, $removeAll = false)
402402
}
403403
}
404404

405-
/**
406-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
407-
*/
408-
public function __toString(): string
409-
{
410-
return $this->render(new OutputFormat());
411-
}
412-
413405
/**
414406
* @return string
415407
*/

src/CSSList/KeyFrame.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ public function getAnimationName()
5151
return $this->animationName;
5252
}
5353

54-
/**
55-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
56-
*/
57-
public function __toString(): string
58-
{
59-
return $this->render(new OutputFormat());
60-
}
61-
6254
public function render(OutputFormat $outputFormat): string
6355
{
6456
$result = $outputFormat->comments($this);

src/Comment/Comment.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ public function setComment(string $commentText): void
5050
$this->commentText = $commentText;
5151
}
5252

53-
/**
54-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
55-
*/
56-
public function __toString(): string
57-
{
58-
return $this->render(new OutputFormat());
59-
}
60-
6153
public function render(OutputFormat $outputFormat): string
6254
{
6355
return '/*' . $this->commentText . '*/';

src/Property/CSSNamespace.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ public function getLineNo(): int
5454
return $this->lineNumber;
5555
}
5656

57-
/**
58-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
59-
*/
60-
public function __toString(): string
61-
{
62-
return $this->render(new OutputFormat());
63-
}
64-
6557
public function render(OutputFormat $outputFormat): string
6658
{
6759
return '@namespace ' . ($this->prefix === null ? '' : $this->prefix . ' ')

src/Property/Charset.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ public function getCharset()
7171
return $this->charset->getString();
7272
}
7373

74-
/**
75-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
76-
*/
77-
public function __toString(): string
78-
{
79-
return $this->render(new OutputFormat());
80-
}
81-
8274
public function render(OutputFormat $outputFormat): string
8375
{
8476
return "{$outputFormat->comments($this)}@charset {$this->charset->render($outputFormat)};";

src/Property/Import.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ public function getLocation()
7272
return $this->location;
7373
}
7474

75-
/**
76-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
77-
*/
78-
public function __toString(): string
79-
{
80-
return $this->render(new OutputFormat());
81-
}
82-
8375
public function render(OutputFormat $outputFormat): string
8476
{
8577
return $outputFormat->comments($this) . '@import ' . $this->location->render($outputFormat)

src/Property/Selector.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ public function setSelector(string $selector): void
6161
$this->selector = \trim($selector);
6262
}
6363

64-
/**
65-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
66-
*/
67-
public function __toString(): string
68-
{
69-
return $this->getSelector();
70-
}
71-
7264
/**
7365
* @return int<0, max>
7466
*/

src/Renderable.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,5 @@
66

77
interface Renderable
88
{
9-
/**
10-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
11-
*/
12-
public function __toString(): string;
13-
149
public function render(OutputFormat $outputFormat): string;
1510
}

src/Rule/Rule.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,6 @@ public function getIsImportant()
224224
return $this->isImportant;
225225
}
226226

227-
/**
228-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
229-
*/
230-
public function __toString(): string
231-
{
232-
return $this->render(new OutputFormat());
233-
}
234-
235227
public function render(OutputFormat $outputFormat): string
236228
{
237229
$result = "{$outputFormat->comments($this)}{$this->rule}:{$outputFormat->spaceAfterRuleName()}";

src/RuleSet/AtRuleSet.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@ public function atRuleArgs()
5353
return $this->arguments;
5454
}
5555

56-
/**
57-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
58-
*/
59-
public function __toString(): string
60-
{
61-
return $this->render(new OutputFormat());
62-
}
63-
6456
public function render(OutputFormat $outputFormat): string
6557
{
6658
$result = $outputFormat->comments($this);

src/RuleSet/DeclarationBlock.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,6 @@ public function getSelectors()
140140
return $this->selectors;
141141
}
142142

143-
/**
144-
* @throws OutputException
145-
*
146-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
147-
*/
148-
public function __toString(): string
149-
{
150-
return $this->render(new OutputFormat());
151-
}
152-
153143
/**
154144
* @throws OutputException
155145
*/

src/RuleSet/RuleSet.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,6 @@ public function removeRule($searchPattern): void
255255
}
256256
}
257257

258-
/**
259-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
260-
*/
261-
public function __toString(): string
262-
{
263-
return $this->render(new OutputFormat());
264-
}
265-
266258
/**
267259
* @return string
268260
*/

src/Value/CSSFunction.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,6 @@ public function getArguments()
105105
return $this->aComponents;
106106
}
107107

108-
/**
109-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
110-
*/
111-
public function __toString(): string
112-
{
113-
return $this->render(new OutputFormat());
114-
}
115-
116108
public function render(OutputFormat $outputFormat): string
117109
{
118110
$aArguments = parent::render($outputFormat);

src/Value/CSSString.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,6 @@ public function getString()
9090
return $this->string;
9191
}
9292

93-
/**
94-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
95-
*/
96-
public function __toString(): string
97-
{
98-
return $this->render(new OutputFormat());
99-
}
100-
10193
public function render(OutputFormat $outputFormat): string
10294
{
10395
$string = \addslashes($this->string);

src/Value/Color.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,6 @@ public function getColorDescription()
224224
return $this->getName();
225225
}
226226

227-
/**
228-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
229-
*/
230-
public function __toString(): string
231-
{
232-
return $this->render(new OutputFormat());
233-
}
234-
235227
public function render(OutputFormat $outputFormat): string
236228
{
237229
if ($this->shouldRenderAsHex($outputFormat)) {

src/Value/LineName.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ public static function parse(ParserState $parserState): LineName
4949
return new LineName($aNames, $parserState->currentLine());
5050
}
5151

52-
/**
53-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
54-
*/
55-
public function __toString(): string
56-
{
57-
return $this->render(new OutputFormat());
58-
}
59-
6052
public function render(OutputFormat $outputFormat): string
6153
{
6254
return '[' . parent::render(OutputFormat::createCompact()) . ']';

src/Value/Size.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,6 @@ public function isRelative(): bool
210210
return false;
211211
}
212212

213-
/**
214-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
215-
*/
216-
public function __toString(): string
217-
{
218-
return $this->render(new OutputFormat());
219-
}
220-
221213
public function render(OutputFormat $outputFormat): string
222214
{
223215
$l = \localeconv();

src/Value/URL.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,6 @@ public function getURL()
7676
return $this->oURL;
7777
}
7878

79-
/**
80-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
81-
*/
82-
public function __toString(): string
83-
{
84-
return $this->render(new OutputFormat());
85-
}
86-
8779
public function render(OutputFormat $outputFormat): string
8880
{
8981
return "url({$this->oURL->render($outputFormat)})";

src/Value/ValueList.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,6 @@ public function setListSeparator($sSeparator): void
8383
$this->sSeparator = $sSeparator;
8484
}
8585

86-
/**
87-
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
88-
*/
89-
public function __toString(): string
90-
{
91-
return $this->render(new OutputFormat());
92-
}
93-
9486
public function render(OutputFormat $outputFormat): string
9587
{
9688
return $outputFormat->implode(

tests/FunctionalDeprecated/.gitkeep

Whitespace-only changes.

tests/FunctionalDeprecated/Comment/CommentTest.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/FunctionalDeprecated/Property/SelectorTest.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/ParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function unicodeParsing(): void
193193
continue;
194194
}
195195
$contentRules = $ruleSet->getRules('content');
196-
$firstContentRuleAsString = $contentRules[0]->getValue()->__toString();
196+
$firstContentRuleAsString = $contentRules[0]->getValue()->render(OutputFormat::create());
197197
if ($selector === '.test-1') {
198198
self::assertSame('" "', $firstContentRuleAsString);
199199
}

tests/Unit/Value/ColorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Sabberworm\CSS\Tests\Unit\Value;
66

77
use PHPUnit\Framework\TestCase;
8+
use Sabberworm\CSS\OutputFormat;
89
use Sabberworm\CSS\Parsing\ParserState;
910
use Sabberworm\CSS\Parsing\SourceException;
1011
use Sabberworm\CSS\Settings;
@@ -346,7 +347,7 @@ public function parsesAndRendersValidColor(string $color, string $expectedRender
346347
{
347348
$subject = Color::parse(new ParserState($color, Settings::create()));
348349

349-
$renderedResult = (string) $subject;
350+
$renderedResult = $subject->render(OutputFormat::create());
350351

351352
self::assertSame($expectedRendering, $renderedResult);
352353
}

0 commit comments

Comments
 (0)