-
Notifications
You must be signed in to change notification settings - Fork 152
[TASK] Rename methods in RuleContainer
#1521
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
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,75 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Sabberworm\CSS\RuleSet; | ||
|
|
||
| use Sabberworm\CSS\Property\Declaration; | ||
|
|
||
| /** | ||
| * Provides a mapping of the deprecated methods in a `RuleContainer` to their renamed replacements. | ||
| */ | ||
| trait LegacyRuleContainerMethods | ||
| { | ||
| /** | ||
| * @deprecated in v9.2, will be removed in v10.0; use `addDeclaration()` instead. | ||
| */ | ||
| public function addRule(Declaration $declarationToAdd, ?Declaration $sibling = null): void | ||
| { | ||
| $this->addDeclaration($declarationToAdd, $sibling); | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated in v9.2, will be removed in v10.0; use `removeDeclaration()` instead. | ||
| */ | ||
| public function removeRule(Declaration $declarationToRemove): void | ||
| { | ||
| $this->removeDeclaration($declarationToRemove); | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated in v9.2, will be removed in v10.0; use `removeMatchingDeclarations()` instead. | ||
| */ | ||
| public function removeMatchingRules(string $searchPattern): void | ||
| { | ||
| $this->removeMatchingDeclarations($searchPattern); | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated in v9.2, will be removed in v10.0; use `removeAllDeclarations()` instead. | ||
| */ | ||
| public function removeAllRules(): void | ||
| { | ||
| $this->removeAllDeclarations(); | ||
| } | ||
|
|
||
| /** | ||
| * @param array<Declaration> $declarations | ||
| * | ||
| * @deprecated in v9.2, will be removed in v10.0; use `setDeclarations()` instead. | ||
| */ | ||
| public function setRules(array $declarations): void | ||
| { | ||
| $this->setDeclarations($declarations); | ||
| } | ||
|
|
||
| /** | ||
| * @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 $this->getDeclarations($searchPattern); | ||
| } | ||
|
|
||
| /** | ||
| * @return array<string, Declaration> | ||
| * | ||
| * @deprecated in v9.2, will be removed in v10.0; use `getDeclarationsAssociative()` instead. | ||
| */ | ||
| public function getRulesAssoc(?string $searchPattern = null): array | ||
| { | ||
| return $this->getDeclarationsAssociative($searchPattern); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
All these methods should get an
@deprecatedannotation stating since which version they are deprecated and in which version they will be removed (like inRuleContainer).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 wondered about this, as I had marked the trait as
@internal, but the methods are public and implemented in the classes using the trait, and this would be the only place to see the deprecation notice other than in the interface.I've added the deprecation notices into the trait.
Should the trait nonetheless be marked as
@internal?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, the trait should not be
@internal. The reason is that IDEs mark usages of@internalmethods and classes (so that the devs know that they should switch to something else), but probably not if only the trait it@internal.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 removed
@internaland also added a description for the trait.