Skip to content

Commit 3e40682

Browse files
committed
[TASK] Add native type declarations for Import
Part of #811
1 parent b561b72 commit 3e40682

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Please also have a look at our
3434
- Use more native type declarations and strict mode
3535
(#641, #772, #774, #778, #804, #841, #873, #875, #891, #922, #923, #933, #958,
3636
#964, #967, #1000, #1044, #1134, #1136, #1137, #1139, #1140, #1141, #1145,
37-
#1162, #1163, #1166)
37+
#1162, #1163, #1166, #1172)
3838
- Add visibility to all class/interface constants (#469)
3939

4040
### Deprecated

config/phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ parameters:
7272
count: 1
7373
path: ../src/Property/Charset.php
7474

75-
-
76-
message: '#^Only booleans are allowed in an if condition, string given\.$#'
77-
identifier: if.condNotBoolean
78-
count: 1
79-
path: ../src/Property/Import.php
80-
8175
-
8276
message: '#^Only booleans are allowed in an if condition, Sabberworm\\CSS\\Value\\RuleValueList\|string\|null given\.$#'
8377
identifier: if.condNotBoolean

src/Property/Import.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Import implements AtRule
1919
private $location;
2020

2121
/**
22-
* @var string
22+
* @var string|null
2323
*/
2424
private $mediaQuery;
2525

@@ -38,10 +38,9 @@ class Import implements AtRule
3838
protected $comments = [];
3939

4040
/**
41-
* @param string $mediaQuery
4241
* @param int<0, max> $lineNumber
4342
*/
44-
public function __construct(URL $location, $mediaQuery, int $lineNumber = 0)
43+
public function __construct(URL $location, ?string $mediaQuery, int $lineNumber = 0)
4544
{
4645
$this->location = $location;
4746
$this->mediaQuery = $mediaQuery;
@@ -56,18 +55,12 @@ public function getLineNo(): int
5655
return $this->lineNumber;
5756
}
5857

59-
/**
60-
* @param URL $location
61-
*/
62-
public function setLocation($location): void
58+
public function setLocation(URL $location): void
6359
{
6460
$this->location = $location;
6561
}
6662

67-
/**
68-
* @return URL
69-
*/
70-
public function getLocation()
63+
public function getLocation(): URL
7164
{
7265
return $this->location;
7366
}
@@ -95,14 +88,15 @@ public function atRuleName(): string
9588
}
9689

9790
/**
98-
* @return array<int, URL|string>
91+
* @return array{0: URL, 1?: non-empty-string}
9992
*/
10093
public function atRuleArgs(): array
10194
{
10295
$result = [$this->location];
103-
if ($this->mediaQuery) {
104-
\array_push($result, $this->mediaQuery);
96+
if (\is_string($this->mediaQuery) && $this->mediaQuery !== '') {
97+
$result[] = $this->mediaQuery;
10598
}
99+
106100
return $result;
107101
}
108102

@@ -130,10 +124,7 @@ public function setComments(array $comments): void
130124
$this->comments = $comments;
131125
}
132126

133-
/**
134-
* @return string
135-
*/
136-
public function getMediaQuery()
127+
public function getMediaQuery(): ?string
137128
{
138129
return $this->mediaQuery;
139130
}

0 commit comments

Comments
 (0)