-
Notifications
You must be signed in to change notification settings - Fork 145
[TASK] Add native type declarations for CSSList
#1181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering of some of the array<int, Type> DocBlock types can actually be list - or is there some usage preventing that?
@@ -41,7 +41,7 @@ abstract class CSSList implements Renderable, Commentable | |||
protected $comments = []; | |||
|
|||
/** | |||
* @var array<int, RuleSet|CSSList|Import|Charset> | |||
* @var array<int<0, max>, RuleSet|CSSList|Import|Charset> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be a list
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not: In remove()
, we unset()
elements in the array, which creates gaps in the keys.
@@ -364,10 +363,10 @@ public function setContents(array $contents): void | |||
/** | |||
* Removes a declaration block from the CSS list if it matches all given selectors. | |||
* | |||
* @param DeclarationBlock|array<array-key, Selector>|string $selectors the selectors to match | |||
* @param DeclarationBlock|array<Selector>|string $selectors the selectors to match |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess array-key
is redundant so can be removed, but also wonder if the middle type could be a list
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could in theory. However, this being a list
is not required for the method to work correctly. As this method is public API, I'd prefer to keep it as broad as possible in order to reduce hassle for the developers who use it.
|
||
/** | ||
* Returns the stored items. | ||
* | ||
* @return array<int, RuleSet|Import|Charset|CSSList> | ||
* @return array<int<0, max>, RuleSet|Import|Charset|CSSList> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be a list
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, as $this->contents
may have gaps in the keys due to the unset()
in ::remove()
.
4e00c05
to
885b3d2
Compare
Part of #811