Skip to content

Commit bf874f7

Browse files
committed
[TASK] Allow construction of 'empty' Selector
This was already allowed. This change merely clarifies the behaviour, and makes the constructor parameter optional. The `parse()` method is static, so it is more convenient if it can create an empty object, then set the value via setter methods.
1 parent b67aac0 commit bf874f7

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/Property/Selector.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Selector implements Renderable
5656
/**
5757
* @var string
5858
*/
59-
private $selector;
59+
private $selector = '';
6060

6161
/**
6262
* @internal since V8.8.0
@@ -72,9 +72,12 @@ public static function isValid(string $selector): bool
7272
/**
7373
* @throws \UnexpectedValueException if the selector is not valid
7474
*/
75-
final public function __construct(string $selector)
75+
final public function __construct(string $selector = '')
7676
{
77-
$this->setSelector($selector);
77+
// Allow construction of empty object for content to be set later via a setter method.
78+
if ($selector !== '') {
79+
$this->setSelector($selector);
80+
}
7881
}
7982

8083
/**

0 commit comments

Comments
 (0)