66
77use Sabberworm \CSS \Comment \Comment ;
88use Sabberworm \CSS \OutputFormat ;
9+ use Sabberworm \CSS \Value \CSSString ;
10+ use Sabberworm \CSS \Value \URL ;
911
1012/**
1113 * `CSSNamespace` represents an `@namespace` rule.
1214 */
1315class CSSNamespace implements AtRule
1416{
1517 /**
16- * @var string
18+ * @var CSSString|URL
1719 */
1820 private $ url ;
1921
2022 /**
21- * @var string
23+ * @var string|null
2224 */
2325 private $ prefix ;
2426
@@ -35,11 +37,10 @@ class CSSNamespace implements AtRule
3537 protected $ comments = [];
3638
3739 /**
38- * @param string $url
39- * @param string|null $prefix
40+ * @param CSSString|URL $url
4041 * @param int<0, max> $lineNumber
4142 */
42- public function __construct ($ url , $ prefix = null , int $ lineNumber = 0 )
43+ public function __construct ($ url , ? string $ prefix = null , int $ lineNumber = 0 )
4344 {
4445 $ this ->url = $ url ;
4546 $ this ->prefix = $ prefix ;
@@ -61,33 +62,27 @@ public function render(OutputFormat $outputFormat): string
6162 }
6263
6364 /**
64- * @return string
65+ * @return CSSString|URL
6566 */
6667 public function getUrl ()
6768 {
6869 return $ this ->url ;
6970 }
7071
71- /**
72- * @return string|null
73- */
74- public function getPrefix ()
72+ public function getPrefix (): ?string
7573 {
7674 return $ this ->prefix ;
7775 }
7876
7977 /**
80- * @param string $url
78+ * @param CSSString|URL $url
8179 */
8280 public function setUrl ($ url ): void
8381 {
8482 $ this ->url = $ url ;
8583 }
8684
87- /**
88- * @param string $prefix
89- */
90- public function setPrefix ($ prefix ): void
85+ public function setPrefix (string $ prefix ): void
9186 {
9287 $ this ->prefix = $ prefix ;
9388 }
@@ -101,12 +96,12 @@ public function atRuleName(): string
10196 }
10297
10398 /**
104- * @return array<int, string>
99+ * @return array{0: CSSString|URL|non-empty- string, 1?: CSSString|URL}
105100 */
106101 public function atRuleArgs (): array
107102 {
108103 $ result = [$ this ->url ];
109- if ($ this ->prefix ) {
104+ if (\is_string ( $ this ->prefix ) && $ this -> prefix !== '' ) {
110105 \array_unshift ($ result , $ this ->prefix );
111106 }
112107 return $ result ;
0 commit comments