Skip to content

Commit 50045f7

Browse files
authored
[TASK] Add more native type declarations for Selector (#1044)
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 b6d0b70 commit 50045f7

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
@@ -29,7 +29,7 @@ Please also have a look at our
2929
- Make all non-private properties `@internal` (#886)
3030
- Use more native type declarations and strict mode
3131
(#641, #772, #774, #778, #804, #841, #873, #875, #891, #922, #923, #933, #958,
32-
#964, #967, #1000)
32+
#964, #967, #1000, #1044)
3333
- Add visibility to all class/interface constants (#469)
3434

3535
### Deprecated

src/Property/Selector.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,41 +78,32 @@ class Selector implements Renderable
7878
private $specificity;
7979

8080
/**
81-
* @param string $selector
82-
*
8381
* @return bool
8482
*
8583
* @internal since V8.8.0
8684
*/
87-
public static function isValid($selector)
85+
public static function isValid(string $selector)
8886
{
8987
return \preg_match(static::SELECTOR_VALIDATION_RX, $selector);
9088
}
9189

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

104-
/**
105-
* @return string
106-
*/
107-
public function getSelector()
101+
public function getSelector(): string
108102
{
109103
return $this->selector;
110104
}
111105

112-
/**
113-
* @param string $selector
114-
*/
115-
public function setSelector($selector): void
106+
public function setSelector(string $selector): void
116107
{
117108
$this->selector = \trim($selector);
118109
$this->specificity = null;
@@ -127,9 +118,9 @@ public function __toString(): string
127118
}
128119

129120
/**
130-
* @return int
121+
* @return int<0, max>
131122
*/
132-
public function getSpecificity()
123+
public function getSpecificity(): int
133124
{
134125
if ($this->specificity === null) {
135126
$a = 0;

0 commit comments

Comments
 (0)