-
Notifications
You must be signed in to change notification settings - Fork 152
[TASK] Rename RuleContainer to DeclarationList
#1530
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Sabberworm\CSS\RuleSet; | ||
|
|
||
| use Sabberworm\CSS\Property\Declaration; | ||
|
|
||
| /** | ||
| * Represents a CSS item that contains `Declaration`s, defining the methods to manipulate them. | ||
| */ | ||
| interface DeclarationList | ||
| { | ||
| public function addDeclaration(Declaration $declarationToAdd, ?Declaration $sibling = null): void; | ||
|
|
||
| public function removeDeclaration(Declaration $declarationToRemove): void; | ||
|
|
||
| public function removeMatchingDeclarations(string $searchPattern): void; | ||
|
|
||
| public function removeAllDeclarations(): void; | ||
|
|
||
| /** | ||
| * @param array<Declaration> $declarations | ||
| */ | ||
| public function setDeclarations(array $declarations): void; | ||
|
|
||
| /** | ||
| * @return array<int<0, max>, Declaration> | ||
| */ | ||
| public function getDeclarations(?string $searchPattern = null): array; | ||
|
|
||
| /** | ||
| * @return array<string, Declaration> | ||
| */ | ||
| public function getDeclarationsAssociative(?string $searchPattern = null): array; | ||
|
|
||
| /** | ||
| * @deprecated in v9.2, will be removed in v10.0; use `addDeclaration()` instead. | ||
| */ | ||
| public function addRule(Declaration $declarationToAdd, ?Declaration $sibling = null): void; | ||
|
|
||
| /** | ||
| * @deprecated in v9.2, will be removed in v10.0; use `removeDeclaration()` instead. | ||
| */ | ||
| public function removeRule(Declaration $declarationToRemove): void; | ||
|
|
||
| /** | ||
| * @deprecated in v9.2, will be removed in v10.0; use `removeMatchingDeclarations()` instead. | ||
| */ | ||
| public function removeMatchingRules(string $searchPattern): void; | ||
|
|
||
| /** | ||
| * @deprecated in v9.2, will be removed in v10.0; use `removeAllDeclarations()` instead. | ||
| */ | ||
| public function removeAllRules(): void; | ||
|
|
||
| /** | ||
| * @param array<Declaration> $declarations | ||
| * | ||
| * @deprecated in v9.2, will be removed in v10.0; use `setDeclarations()` instead. | ||
| */ | ||
| public function setRules(array $declarations): void; | ||
|
|
||
| /** | ||
| * @return array<int<0, max>, Declaration> | ||
| * | ||
| * @deprecated in v9.2, will be removed in v10.0; use `getDeclarations()` instead. | ||
| */ | ||
| public function getRules(?string $searchPattern = null): array; | ||
|
|
||
| /** | ||
| * @return array<string, Declaration> | ||
| * | ||
| * @deprecated in v9.2, will be removed in v10.0; use `getDeclarationsAssociative()` instead. | ||
| */ | ||
| public function getRulesAssoc(?string $searchPattern = null): array; | ||
| } |
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
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.
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.
We'll need to replace these additional bootstrap file as soon as possible (in a dedicated PR) with something that also works for consumers of our library. At the moment, PHPStan fails to find these aliases within Emogrifier, and other consumers will run into the same problem.
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.
Oh. I don't know of a way of doing that.
The aliases allow us to make a minor release using the new class names, with the old class names deprecated. Then they will be dropped in the next major release.
I expected Stan to find the alias files; when I found it didn't, I discoved this means of telling it.
Is there a way of providing some PHPStan config for consumers? Or maybe a 'dev' Composer autoload setting could work?
Uh oh!
There was an error while loading. Please reload this page.
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 think we can try these approaches (in this order until one solves the problem):
autoloading/class-aliases.php(or something similar), move all class aliases there, and add it toautoload.filesincomposer.json.Uh oh!
There was an error while loading. Please reload this page.
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 see there is a branch in Emogrifier that uses the
devbranch of PHP-CSS-Parser, but not sure how to experimentally hack Composer'svendordirectory. Though maybe if there is a way via Composer to avoid the PHPStan bootstrap settings within PHP-CSS-Parser itself, that may solve the problem for consumers.Uh oh!
There was an error while loading. Please reload this page.
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.
We can create a PR (or a branch) here in PHP-CSS-Parser and then create a branch in Emogrifier that uses that branch (similar to the PR that uses PHP-CSS-Parser main) and then either run the tests locally or on CI for a PR.
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've just entered #1532 for this and will give it a try.
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.
@JakeQZ This is how I tested this in Emogrifier without having to push to GitHub first: MyIntervals/emogrifier#1570