diff --git a/src/CSSList/CSSList.php b/src/CSSList/CSSList.php index e6cb900f..a92d57d7 100644 --- a/src/CSSList/CSSList.php +++ b/src/CSSList/CSSList.php @@ -4,8 +4,7 @@ namespace Sabberworm\CSS\CSSList; -use Sabberworm\CSS\Comment\Comment; -use Sabberworm\CSS\Comment\Commentable; +use Sabberworm\CSS\Comment\CommentContainer; use Sabberworm\CSS\OutputFormat; use Sabberworm\CSS\Parsing\ParserState; use Sabberworm\CSS\Parsing\SourceException; @@ -36,12 +35,7 @@ */ abstract class CSSList implements CSSListItem { - /** - * @var list - * - * @internal since 8.8.0 - */ - protected $comments = []; + use CommentContainer; /** * @var array, CSSListItem> @@ -444,28 +438,4 @@ public function getContents(): array { return $this->contents; } - - /** - * @param list $comments - */ - public function addComments(array $comments): void - { - $this->comments = \array_merge($this->comments, $comments); - } - - /** - * @return list - */ - public function getComments(): array - { - return $this->comments; - } - - /** - * @param list $comments - */ - public function setComments(array $comments): void - { - $this->comments = $comments; - } } diff --git a/src/Property/CSSNamespace.php b/src/Property/CSSNamespace.php index d2274d18..eef1fcf7 100644 --- a/src/Property/CSSNamespace.php +++ b/src/Property/CSSNamespace.php @@ -4,7 +4,7 @@ namespace Sabberworm\CSS\Property; -use Sabberworm\CSS\Comment\Comment; +use Sabberworm\CSS\Comment\CommentContainer; use Sabberworm\CSS\OutputFormat; use Sabberworm\CSS\Value\CSSString; use Sabberworm\CSS\Value\URL; @@ -14,6 +14,8 @@ */ class CSSNamespace implements AtRule { + use CommentContainer; + /** * @var CSSString|URL */ @@ -29,13 +31,6 @@ class CSSNamespace implements AtRule */ private $lineNumber; - /** - * @var list - * - * @internal since 8.8.0 - */ - protected $comments = []; - /** * @param CSSString|URL $url * @param int<0, max> $lineNumber @@ -109,28 +104,4 @@ public function atRuleArgs(): array } return $result; } - - /** - * @param list $comments - */ - public function addComments(array $comments): void - { - $this->comments = \array_merge($this->comments, $comments); - } - - /** - * @return list - */ - public function getComments(): array - { - return $this->comments; - } - - /** - * @param list $comments - */ - public function setComments(array $comments): void - { - $this->comments = $comments; - } } diff --git a/src/Property/Charset.php b/src/Property/Charset.php index 6e81cd4e..51b43e13 100644 --- a/src/Property/Charset.php +++ b/src/Property/Charset.php @@ -4,7 +4,7 @@ namespace Sabberworm\CSS\Property; -use Sabberworm\CSS\Comment\Comment; +use Sabberworm\CSS\Comment\CommentContainer; use Sabberworm\CSS\OutputFormat; use Sabberworm\CSS\Value\CSSString; @@ -18,6 +18,8 @@ */ class Charset implements AtRule { + use CommentContainer; + /** * @var CSSString */ @@ -30,13 +32,6 @@ class Charset implements AtRule */ protected $lineNumber; - /** - * @var list - * - * @internal since 8.8.0 - */ - protected $comments = []; - /** * @param int<0, max> $lineNumber */ @@ -88,28 +83,4 @@ public function atRuleArgs(): CSSString { return $this->charset; } - - /** - * @param list $comments - */ - public function addComments(array $comments): void - { - $this->comments = \array_merge($this->comments, $comments); - } - - /** - * @return list - */ - public function getComments(): array - { - return $this->comments; - } - - /** - * @param list $comments - */ - public function setComments(array $comments): void - { - $this->comments = $comments; - } } diff --git a/src/Property/Import.php b/src/Property/Import.php index e2c2f41f..31feaf55 100644 --- a/src/Property/Import.php +++ b/src/Property/Import.php @@ -4,7 +4,7 @@ namespace Sabberworm\CSS\Property; -use Sabberworm\CSS\Comment\Comment; +use Sabberworm\CSS\Comment\CommentContainer; use Sabberworm\CSS\OutputFormat; use Sabberworm\CSS\Value\URL; @@ -13,6 +13,8 @@ */ class Import implements AtRule { + use CommentContainer; + /** * @var URL */ @@ -30,13 +32,6 @@ class Import implements AtRule */ protected $lineNumber; - /** - * @var list - * - * @internal since 8.8.0 - */ - protected $comments = []; - /** * @param int<0, max> $lineNumber */ @@ -95,30 +90,6 @@ public function atRuleArgs(): array return $result; } - /** - * @param list $comments - */ - public function addComments(array $comments): void - { - $this->comments = \array_merge($this->comments, $comments); - } - - /** - * @return list - */ - public function getComments(): array - { - return $this->comments; - } - - /** - * @param list $comments - */ - public function setComments(array $comments): void - { - $this->comments = $comments; - } - public function getMediaQuery(): ?string { return $this->mediaQuery; diff --git a/src/Rule/Rule.php b/src/Rule/Rule.php index fbd1646f..4eb7decd 100644 --- a/src/Rule/Rule.php +++ b/src/Rule/Rule.php @@ -6,6 +6,7 @@ use Sabberworm\CSS\Comment\Comment; use Sabberworm\CSS\Comment\Commentable; +use Sabberworm\CSS\Comment\CommentContainer; use Sabberworm\CSS\OutputFormat; use Sabberworm\CSS\Parsing\ParserState; use Sabberworm\CSS\Parsing\UnexpectedEOFException; @@ -21,6 +22,8 @@ */ class Rule implements Renderable, Commentable { + use CommentContainer; + /** * @var non-empty-string */ @@ -48,13 +51,6 @@ class Rule implements Renderable, Commentable */ protected $columnNumber; - /** - * @var list - * - * @internal since 8.8.0 - */ - protected $comments = []; - /** * @param non-empty-string $rule * @param int<0, max> $lineNumber @@ -235,28 +231,4 @@ public function render(OutputFormat $outputFormat): string $result .= ';'; return $result; } - - /** - * @param list $comments - */ - public function addComments(array $comments): void - { - $this->comments = \array_merge($this->comments, $comments); - } - - /** - * @return list - */ - public function getComments(): array - { - return $this->comments; - } - - /** - * @param list $comments - */ - public function setComments(array $comments): void - { - $this->comments = $comments; - } } diff --git a/src/RuleSet/RuleSet.php b/src/RuleSet/RuleSet.php index 871aa757..fc597ea0 100644 --- a/src/RuleSet/RuleSet.php +++ b/src/RuleSet/RuleSet.php @@ -4,8 +4,7 @@ namespace Sabberworm\CSS\RuleSet; -use Sabberworm\CSS\Comment\Comment; -use Sabberworm\CSS\Comment\Commentable; +use Sabberworm\CSS\Comment\CommentContainer; use Sabberworm\CSS\CSSList\CSSListItem; use Sabberworm\CSS\OutputFormat; use Sabberworm\CSS\Parsing\ParserState; @@ -28,6 +27,8 @@ */ abstract class RuleSet implements CSSListItem { + use CommentContainer; + /** * the rules in this rule set, using the property name as the key, * with potentially multiple rules per property name. @@ -43,13 +44,6 @@ abstract class RuleSet implements CSSListItem */ protected $lineNumber; - /** - * @var list - * - * @internal since 8.8.0 - */ - protected $comments = []; - /** * @param int<0, max> $lineNumber */ @@ -299,28 +293,4 @@ protected function renderRules(OutputFormat $outputFormat): string return $formatter->removeLastSemicolon($result); } - - /** - * @param list $comments - */ - public function addComments(array $comments): void - { - $this->comments = \array_merge($this->comments, $comments); - } - - /** - * @return list - */ - public function getComments(): array - { - return $this->comments; - } - - /** - * @param list $comments - */ - public function setComments(array $comments): void - { - $this->comments = $comments; - } }