[TASK] Allow construction of 'empty' Selector#1500
Closed
JakeQZ wants to merge 2 commits into
Closed
Conversation
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.
oliverklee
requested changes
Feb 7, 2026
| * @throws \UnexpectedValueException if the selector is not valid | ||
| */ | ||
| final public function __construct(string $selector) | ||
| final public function __construct(string $selector = '') |
Collaborator
There was a problem hiding this comment.
We should cover creating a selector (and thus having an empty string for a selector) without passing the $selector with a test.
Collaborator
There was a problem hiding this comment.
I don't see a test that uses new Selector() in #1498 - but I'm still at my first coffee. Am I missing something?
Collaborator
Author
There was a problem hiding this comment.
Test method added was canConstructObjectWithEmptyState():
Collaborator
Author
There was a problem hiding this comment.
I've added an additional test for construction without a parameter.
b61bd50 to
2c62814
Compare
Collaborator
Author
|
As per #1496 (comment), this isn't needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.