Skip to content

[TASK] Remove __toString() #1046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Please also have a look at our

### Removed

- Remove `__toString()` (#1046)
- Drop magic method forwarding in `OutputFormat` (#898)
- Drop `atRuleArgs()` from the `AtRule` interface (#1141)
- Remove `OutputFormat::get()` and `::set()` (#1108, #1110)
Expand Down
8 changes: 0 additions & 8 deletions src/CSSList/AtRuleBlockList.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ 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());
}

public function render(OutputFormat $outputFormat): string
{
$formatter = $outputFormat->getFormatter();
Expand Down
8 changes: 0 additions & 8 deletions src/CSSList/CSSList.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,6 @@ 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());
}

protected function renderListContents(OutputFormat $outputFormat): string
{
$result = '';
Expand Down
8 changes: 0 additions & 8 deletions src/CSSList/KeyFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ public function getAnimationName(): string
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());
}

public function render(OutputFormat $outputFormat): string
{
$formatter = $outputFormat->getFormatter();
Expand Down
8 changes: 0 additions & 8 deletions src/Comment/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ 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());
}

public function render(OutputFormat $outputFormat): string
{
return '/*' . $this->commentText . '*/';
Expand Down
8 changes: 0 additions & 8 deletions src/Property/CSSNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ 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());
}

public function render(OutputFormat $outputFormat): string
{
return '@namespace ' . ($this->prefix === null ? '' : $this->prefix . ' ')
Expand Down
8 changes: 0 additions & 8 deletions src/Property/Charset.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ public function getCharset(): string
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());
}

public function render(OutputFormat $outputFormat): string
{
return "{$outputFormat->getFormatter()->comments($this)}@charset {$this->charset->render($outputFormat)};";
Expand Down
8 changes: 0 additions & 8 deletions src/Property/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ public function getLocation(): URL
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());
}

public function render(OutputFormat $outputFormat): string
{
return $outputFormat->getFormatter()->comments($this) . '@import ' . $this->location->render($outputFormat)
Expand Down
8 changes: 0 additions & 8 deletions src/Property/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ public function setSelector(string $selector): void
$this->selector = \trim($selector);
}

/**
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
*/
public function __toString(): string
{
return $this->getSelector();
}

/**
* @return int<0, max>
*/
Expand Down
5 changes: 0 additions & 5 deletions src/Renderable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,5 @@

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;
}
8 changes: 0 additions & 8 deletions src/Rule/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,6 @@ 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());
}

public function render(OutputFormat $outputFormat): string
{
$formatter = $outputFormat->getFormatter();
Expand Down
8 changes: 0 additions & 8 deletions src/RuleSet/AtRuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ 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());
}

public function render(OutputFormat $outputFormat): string
{
$formatter = $outputFormat->getFormatter();
Expand Down
10 changes: 0 additions & 10 deletions src/RuleSet/DeclarationBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,6 @@ public function getSelectors()
return $this->selectors;
}

/**
* @throws OutputException
*
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
*/
public function __toString(): string
{
return $this->render(new OutputFormat());
}

/**
* @throws OutputException
*/
Expand Down
8 changes: 0 additions & 8 deletions src/RuleSet/RuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,6 @@ public function removeRule($searchPattern): 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());
}

protected function renderRules(OutputFormat $outputFormat): string
{
$result = '';
Expand Down
8 changes: 0 additions & 8 deletions src/Value/CSSFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@ public function getArguments()
return $this->components;
}

/**
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
*/
public function __toString(): string
{
return $this->render(new OutputFormat());
}

public function render(OutputFormat $outputFormat): string
{
$arguments = parent::render($outputFormat);
Expand Down
8 changes: 0 additions & 8 deletions src/Value/CSSString.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ public function getString(): string
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());
}

public function render(OutputFormat $outputFormat): string
{
$string = \addslashes($this->string);
Expand Down
8 changes: 0 additions & 8 deletions src/Value/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,6 @@ 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());
}

public function render(OutputFormat $outputFormat): string
{
if ($this->shouldRenderAsHex($outputFormat)) {
Expand Down
8 changes: 0 additions & 8 deletions src/Value/LineName.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ public static function parse(ParserState $parserState): LineName
return new LineName($names, $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());
}

public function render(OutputFormat $outputFormat): string
{
return '[' . parent::render(OutputFormat::createCompact()) . ']';
Expand Down
8 changes: 0 additions & 8 deletions src/Value/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,6 @@ 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());
}

public function render(OutputFormat $outputFormat): string
{
$locale = \localeconv();
Expand Down
8 changes: 0 additions & 8 deletions src/Value/URL.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ public function getURL(): CSSString
return $this->url;
}

/**
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
*/
public function __toString(): string
{
return $this->render(new OutputFormat());
}

public function render(OutputFormat $outputFormat): string
{
return "url({$this->url->render($outputFormat)})";
Expand Down
8 changes: 0 additions & 8 deletions src/Value/ValueList.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ public function setListSeparator($separator): void
$this->separator = $separator;
}

/**
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
*/
public function __toString(): string
{
return $this->render(new OutputFormat());
}

public function render(OutputFormat $outputFormat): string
{
$formatter = $outputFormat->getFormatter();
Expand Down
Empty file.
27 changes: 0 additions & 27 deletions tests/FunctionalDeprecated/Comment/CommentTest.php

This file was deleted.

25 changes: 0 additions & 25 deletions tests/FunctionalDeprecated/Property/SelectorTest.php

This file was deleted.