From bf874f79fa44bb18931f0b2fc9536bdab1bfac81 Mon Sep 17 00:00:00 2001 From: Jake Hotson Date: Sat, 7 Feb 2026 00:11:19 +0000 Subject: [PATCH 1/2] [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. --- src/Property/Selector.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Property/Selector.php b/src/Property/Selector.php index 01db122e..f95b4c48 100644 --- a/src/Property/Selector.php +++ b/src/Property/Selector.php @@ -56,7 +56,7 @@ class Selector implements Renderable /** * @var string */ - private $selector; + private $selector = ''; /** * @internal since V8.8.0 @@ -72,9 +72,12 @@ public static function isValid(string $selector): bool /** * @throws \UnexpectedValueException if the selector is not valid */ - final public function __construct(string $selector) + final public function __construct(string $selector = '') { - $this->setSelector($selector); + // Allow construction of empty object for content to be set later via a setter method. + if ($selector !== '') { + $this->setSelector($selector); + } } /** From 2c62814e5f7431923b4c1b3966094686c4b9adf4 Mon Sep 17 00:00:00 2001 From: Jake Hotson Date: Sun, 8 Feb 2026 06:01:49 +0000 Subject: [PATCH 2/2] Add test for construction with empty string --- tests/Unit/Property/SelectorTest.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/Unit/Property/SelectorTest.php b/tests/Unit/Property/SelectorTest.php index 1e537951..86116c55 100644 --- a/tests/Unit/Property/SelectorTest.php +++ b/tests/Unit/Property/SelectorTest.php @@ -318,7 +318,17 @@ public function parseExtractsTwoCommentsFromSelector(): void /** * @test */ - public function canConstructObjectWithEmptyState(): void + public function constructsObjectWithEmptyStateWithNoArgumetProvided(): void + { + $subject = new Selector(); + + self::assertSame('', $subject->getSelector()); + } + + /** + * @test + */ + public function constructsObjectWithEmptyStateWithEmptyStringProvided(): void { $subject = new Selector('');