diff --git a/CHANGELOG.md b/CHANGELOG.md index b39384b6..6665202c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Please also have a look at our ### Deprecated +- Deprecate `__toString()` (#1006) - `OutputFormat` properties for space around list separators as an array (#880) ### Removed diff --git a/src/CSSList/AtRuleBlockList.php b/src/CSSList/AtRuleBlockList.php index 8ced1a97..892acfd4 100644 --- a/src/CSSList/AtRuleBlockList.php +++ b/src/CSSList/AtRuleBlockList.php @@ -42,6 +42,9 @@ public function atRuleArgs(): string return $this->arguments; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/CSSList/CSSList.php b/src/CSSList/CSSList.php index 1ec6cd7f..77831fd3 100644 --- a/src/CSSList/CSSList.php +++ b/src/CSSList/CSSList.php @@ -402,6 +402,9 @@ public function removeDeclarationBlockBySelector($selectors, $removeAll = false) } } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/CSSList/KeyFrame.php b/src/CSSList/KeyFrame.php index 1fce204b..3177ac19 100644 --- a/src/CSSList/KeyFrame.php +++ b/src/CSSList/KeyFrame.php @@ -51,6 +51,9 @@ public function getAnimationName() return $this->animationName; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/Comment/Comment.php b/src/Comment/Comment.php index 9d8b5ed3..761d6d82 100644 --- a/src/Comment/Comment.php +++ b/src/Comment/Comment.php @@ -50,6 +50,9 @@ public function setComment(string $commentText): void $this->commentText = $commentText; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/OutputFormatter.php b/src/OutputFormatter.php index 6fcfc2d8..1e39d210 100644 --- a/src/OutputFormatter.php +++ b/src/OutputFormatter.php @@ -159,7 +159,7 @@ public function safely(callable $callable): ?string } /** - * Clone of the `implode` function, but calls `render` with the current output format instead of `__toString()`. + * Clone of the `implode` function, but calls `render` with the current output format. * * @param array $values */ diff --git a/src/Property/CSSNamespace.php b/src/Property/CSSNamespace.php index 0d6750f0..7a4f64a9 100644 --- a/src/Property/CSSNamespace.php +++ b/src/Property/CSSNamespace.php @@ -54,6 +54,9 @@ public function getLineNo(): int return $this->lineNumber; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/Property/Charset.php b/src/Property/Charset.php index d0bb4276..dea13e16 100644 --- a/src/Property/Charset.php +++ b/src/Property/Charset.php @@ -71,6 +71,9 @@ public function getCharset() return $this->charset->getString(); } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/Property/Import.php b/src/Property/Import.php index 8240e28f..520e0120 100644 --- a/src/Property/Import.php +++ b/src/Property/Import.php @@ -72,6 +72,9 @@ public function getLocation() return $this->location; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/Property/Selector.php b/src/Property/Selector.php index c7226d3c..11e4fd8a 100644 --- a/src/Property/Selector.php +++ b/src/Property/Selector.php @@ -113,6 +113,9 @@ public function setSelector($selector): void $this->specificity = null; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->getSelector(); diff --git a/src/Renderable.php b/src/Renderable.php index 3a833f9a..ff96d66a 100644 --- a/src/Renderable.php +++ b/src/Renderable.php @@ -6,6 +6,9 @@ interface Renderable { + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string; public function render(OutputFormat $outputFormat): string; diff --git a/src/Rule/Rule.php b/src/Rule/Rule.php index 341f6dfb..4ac75724 100644 --- a/src/Rule/Rule.php +++ b/src/Rule/Rule.php @@ -260,6 +260,9 @@ public function getIsImportant() return $this->isImportant; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/RuleSet/AtRuleSet.php b/src/RuleSet/AtRuleSet.php index a1e2ddb7..9f7a1705 100644 --- a/src/RuleSet/AtRuleSet.php +++ b/src/RuleSet/AtRuleSet.php @@ -53,6 +53,9 @@ public function atRuleArgs() return $this->arguments; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/RuleSet/DeclarationBlock.php b/src/RuleSet/DeclarationBlock.php index 7db4d3af..7e0dfc1b 100644 --- a/src/RuleSet/DeclarationBlock.php +++ b/src/RuleSet/DeclarationBlock.php @@ -142,6 +142,8 @@ public function getSelectors() /** * @throws OutputException + * + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. */ public function __toString(): string { diff --git a/src/RuleSet/RuleSet.php b/src/RuleSet/RuleSet.php index 9f686223..5364e484 100644 --- a/src/RuleSet/RuleSet.php +++ b/src/RuleSet/RuleSet.php @@ -255,6 +255,9 @@ public function removeRule($mRule): void } } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/Value/CSSFunction.php b/src/Value/CSSFunction.php index fa435549..b32c9c2f 100644 --- a/src/Value/CSSFunction.php +++ b/src/Value/CSSFunction.php @@ -105,6 +105,9 @@ public function getArguments() return $this->aComponents; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/Value/CSSString.php b/src/Value/CSSString.php index 7ccdedaa..8f87c6e1 100644 --- a/src/Value/CSSString.php +++ b/src/Value/CSSString.php @@ -90,6 +90,9 @@ public function getString() return $this->string; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/Value/Color.php b/src/Value/Color.php index 76b81a04..81cd7554 100644 --- a/src/Value/Color.php +++ b/src/Value/Color.php @@ -224,6 +224,9 @@ public function getColorDescription() return $this->getName(); } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/Value/LineName.php b/src/Value/LineName.php index b134793f..9af9149e 100644 --- a/src/Value/LineName.php +++ b/src/Value/LineName.php @@ -49,6 +49,9 @@ public static function parse(ParserState $parserState): LineName return new LineName($aNames, $parserState->currentLine()); } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/Value/Size.php b/src/Value/Size.php index 748e2849..36a2ac6e 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -210,6 +210,9 @@ public function isRelative(): bool return false; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/Value/URL.php b/src/Value/URL.php index 5353f966..15eb52e0 100644 --- a/src/Value/URL.php +++ b/src/Value/URL.php @@ -76,6 +76,9 @@ public function getURL() return $this->oURL; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/src/Value/ValueList.php b/src/Value/ValueList.php index 28c30368..5c7b8f84 100644 --- a/src/Value/ValueList.php +++ b/src/Value/ValueList.php @@ -83,6 +83,9 @@ public function setListSeparator($sSeparator): void $this->sSeparator = $sSeparator; } + /** + * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead. + */ public function __toString(): string { return $this->render(new OutputFormat()); diff --git a/tests/Functional/Comment/CommentTest.php b/tests/Functional/Comment/CommentTest.php index 100d2531..bbfa06a7 100644 --- a/tests/Functional/Comment/CommentTest.php +++ b/tests/Functional/Comment/CommentTest.php @@ -13,19 +13,6 @@ */ final class CommentTest extends TestCase { - /** - * @test - */ - public function toStringRendersCommentEnclosedInCommentDelimiters(): void - { - $comment = 'There is no spoon.'; - $subject = new Comment(); - - $subject->setComment($comment); - - self::assertSame('/*' . $comment . '*/', (string) $subject); - } - /** * @test */ diff --git a/tests/FunctionalDeprecated/.gitkeep b/tests/FunctionalDeprecated/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/FunctionalDeprecated/Comment/CommentTest.php b/tests/FunctionalDeprecated/Comment/CommentTest.php new file mode 100644 index 00000000..8d9c1d31 --- /dev/null +++ b/tests/FunctionalDeprecated/Comment/CommentTest.php @@ -0,0 +1,27 @@ +setComment($comment); + + self::assertSame('/*' . $comment . '*/', (string) $subject); + } +}