-
Notifications
You must be signed in to change notification settings - Fork 144
[CLEANUP] Avoid Hungarian notation in RuleSet
#1004
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
I'm not sure about the naming at all and would appreciate a critical eye (and suggestions). |
9cf23ca
to
51331a3
Compare
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 can only see one improvement on naming. W3C have changed the names of the abstract concepts over time, which has left us with some class names that no longer correspond.
51331a3
to
4a7d4cd
Compare
4a7d4cd
to
9dc285e
Compare
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 may have missed some changes in previous review. I've suggested a few more naming improvements.
src/RuleSet/RuleSet.php
Outdated
} | ||
/** @var array<int, Rule> $result */ | ||
$result = []; | ||
foreach ($this->aRules as $sName => $aRules) { | ||
foreach ($this->rules as $ruleName => $rule) { |
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.
Should we use $propertyName
here instead of $ruleName
?
src/RuleSet/RuleSet.php
Outdated
@@ -222,34 +223,34 @@ public function getRulesAssoc($mRule = null) | |||
* Note: this is different from pre-v.2.0 behaviour of PHP-CSS-Parser, where passing a Rule instance would | |||
* remove all rules with the same name. To get the old behaviour, use `removeRule($rule->getRule())`. | |||
* | |||
* @param Rule|string|null $mRule | |||
* @param Rule|string|null $removalPattern |
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 I would prefer $searchPattern
again here. The rules to be removed still have to be searched for.
src/RuleSet/RuleSet.php
Outdated
@@ -222,34 +223,34 @@ public function getRulesAssoc($mRule = null) | |||
* Note: this is different from pre-v.2.0 behaviour of PHP-CSS-Parser, where passing a Rule instance would | |||
* remove all rules with the same name. To get the old behaviour, use `removeRule($rule->getRule())`. | |||
* | |||
* @param Rule|string|null $mRule | |||
* @param Rule|string|null $removalPattern | |||
* pattern to remove. If $mRule is null, all rules are removed. If the pattern ends in a dash, |
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.
This mentions the parameter by name, and would also need updating. Though could perhaps be modified to avoid being self-referential.
src/RuleSet/RuleSet.php
Outdated
$sRule = $mRule->getRule(); | ||
if (!isset($this->aRules[$sRule])) { | ||
if ($removalPattern instanceof Rule) { | ||
$removalRule = $removalPattern->getRule(); |
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.
Maybe $propertyToRemove
instead of $removalRule
.
Updated and repushed. |
7d8c5a4
to
76753c6
Compare
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.
Might have been better to have this PR in more manageable chunks. But we are where we are, and we are nearly there.
I found one more variable that could be better-renamed.
29f1010
to
5fd54e3
Compare
3fb7d71
to
52846cb
Compare
Okay, I'll split this up. |
89d6e59
to
65c893a
Compare
baa7a5c
to
a9f99ca
Compare
src/RuleSet/RuleSet.php
Outdated
$sRule = $ruleToAdd->getRule(); | ||
if (!isset($this->rules[$sRule])) { | ||
$this->rules[$sRule] = []; | ||
$propertyOrRuleName = $ruleToAdd->getRule(); |
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.
Having looked into how this works and what it does, I now think just $propertyName
would be better - see #1051 (review).
e0e8d4a
to
163db73
Compare
163db73
to
d568127
Compare
All the split-off PRs now are merged, and this PR now is quite small and ready for a re-review. |
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.
Good rename to avoid a variable having two (slightly different) purposes.
Part of #756