Skip to content

Commit 411bd9e

Browse files
committed
[TASK] Add more native type declarations for Selector
The return type of `::isValid()` cannot use a native return type declaration yet as the method's return values currently are of a different type (#1043). Part of #811
1 parent 7ef82db commit 411bd9e

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Please also have a look at our
2828
- Make all non-private properties `@internal` (#886)
2929
- Use more native type declarations and strict mode
3030
(#641, #772, #774, #778, #804, #841, #873, #875, #891, #922, #923, #933, #958,
31-
#964, #967, #1000)
31+
#964, #967, #1000, #1044)
3232
- Add visibility to all class/interface constants (#469)
3333

3434
### Deprecated

src/Property/Selector.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,41 +75,32 @@ class Selector
7575
private $specificity;
7676

7777
/**
78-
* @param string $selector
79-
*
8078
* @return bool
8179
*
8280
* @internal since V8.8.0
8381
*/
84-
public static function isValid($selector)
82+
public static function isValid(string $selector)
8583
{
8684
return \preg_match(static::SELECTOR_VALIDATION_RX, $selector);
8785
}
8886

8987
/**
90-
* @param string $selector
9188
* @param bool $calculateSpecificity @deprecated since V8.8.0, will be removed in V9.0.0
9289
*/
93-
public function __construct($selector, $calculateSpecificity = false)
90+
public function __construct(string $selector, bool $calculateSpecificity = false)
9491
{
9592
$this->setSelector($selector);
9693
if ($calculateSpecificity) {
9794
$this->getSpecificity();
9895
}
9996
}
10097

101-
/**
102-
* @return string
103-
*/
104-
public function getSelector()
98+
public function getSelector(): string
10599
{
106100
return $this->selector;
107101
}
108102

109-
/**
110-
* @param string $selector
111-
*/
112-
public function setSelector($selector): void
103+
public function setSelector(string $selector): void
113104
{
114105
$this->selector = \trim($selector);
115106
$this->specificity = null;
@@ -124,9 +115,9 @@ public function __toString(): string
124115
}
125116

126117
/**
127-
* @return int
118+
* @return int<0, max>
128119
*/
129-
public function getSpecificity()
120+
public function getSpecificity(): int
130121
{
131122
if ($this->specificity === null) {
132123
$a = 0;

0 commit comments

Comments
 (0)