diff --git a/CHANGELOG.md b/CHANGELOG.md index e39699b8..65250de3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,8 @@ Please also have a look at our - Use more native type declarations and strict mode (#641, #772, #774, #778, #804, #841, #873, #875, #891, #922, #923, #933, #958, #964, #967, #1000, #1044, #1134, #1136, #1137, #1139, #1140, #1141, #1145, - #1162, #1163, #1166, #1172, #1174, #1178, #1179, #1181, #1183, #1184, #1186) + #1162, #1163, #1166, #1172, #1174, #1178, #1179, #1181, #1183, #1184, #1186, + #1187) - Add visibility to all class/interface constants (#469) ### Deprecated diff --git a/config/phpstan-baseline.neon b/config/phpstan-baseline.neon index 889cc859..722454ba 100644 --- a/config/phpstan-baseline.neon +++ b/config/phpstan-baseline.neon @@ -30,18 +30,6 @@ parameters: count: 1 path: ../src/CSSList/Document.php - - - message: '#^Cannot call method render\(\) on string\.$#' - identifier: method.nonObject - count: 1 - path: ../src/Property/CSSNamespace.php - - - - message: '#^Only booleans are allowed in an if condition, string given\.$#' - identifier: if.condNotBoolean - count: 1 - path: ../src/Property/CSSNamespace.php - - message: '#^Only booleans are allowed in an if condition, Sabberworm\\CSS\\Value\\RuleValueList\|string\|null given\.$#' identifier: if.condNotBoolean diff --git a/src/Property/CSSNamespace.php b/src/Property/CSSNamespace.php index 75336249..5b174861 100644 --- a/src/Property/CSSNamespace.php +++ b/src/Property/CSSNamespace.php @@ -6,6 +6,8 @@ use Sabberworm\CSS\Comment\Comment; use Sabberworm\CSS\OutputFormat; +use Sabberworm\CSS\Value\CSSString; +use Sabberworm\CSS\Value\URL; /** * `CSSNamespace` represents an `@namespace` rule. @@ -13,12 +15,12 @@ class CSSNamespace implements AtRule { /** - * @var string + * @var CSSString|URL */ private $url; /** - * @var string + * @var string|null */ private $prefix; @@ -35,11 +37,10 @@ class CSSNamespace implements AtRule protected $comments = []; /** - * @param string $url - * @param string|null $prefix + * @param CSSString|URL $url * @param int<0, max> $lineNumber */ - public function __construct($url, $prefix = null, int $lineNumber = 0) + public function __construct($url, ?string $prefix = null, int $lineNumber = 0) { $this->url = $url; $this->prefix = $prefix; @@ -61,33 +62,27 @@ public function render(OutputFormat $outputFormat): string } /** - * @return string + * @return CSSString|URL */ public function getUrl() { return $this->url; } - /** - * @return string|null - */ - public function getPrefix() + public function getPrefix(): ?string { return $this->prefix; } /** - * @param string $url + * @param CSSString|URL $url */ public function setUrl($url): void { $this->url = $url; } - /** - * @param string $prefix - */ - public function setPrefix($prefix): void + public function setPrefix(string $prefix): void { $this->prefix = $prefix; } @@ -101,12 +96,12 @@ public function atRuleName(): string } /** - * @return array + * @return array{0: CSSString|URL|non-empty-string, 1?: CSSString|URL} */ public function atRuleArgs(): array { $result = [$this->url]; - if ($this->prefix) { + if (\is_string($this->prefix) && $this->prefix !== '') { \array_unshift($result, $this->prefix); } return $result;