You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param (null|string|Rule) $mRule pattern to search for. If null, returns all rules. if the pattern ends with a dash, all rules starting with the pattern are returned as well as one matching the pattern with the dash excluded. passing a Rule behaves like calling getRules($mRule->getRule()).
53
-
* @example $oRuleSet->getRules('font-') //returns an array of all rules either beginning with font- or matching font.
54
-
* @example $oRuleSet->getRules('font') //returns array(0 => $oRule, …) or array().
55
-
*/
51
+
/**
52
+
* Returns all rules matching the given rule name
53
+
*
54
+
* @param (null|string|Rule) $mRule pattern to search for.
55
+
* If null, returns all rules. if the pattern ends with a dash, all rules starting with the pattern are
56
+
* returned as well as one matching the pattern with the dash excluded.
57
+
* Passing a Rule behaves like calling getRules($mRule->getRule()).
58
+
*
59
+
* @example $oRuleSet->getRules('font-') //returns an array of all rules either beginning with font- or matching
60
+
* font.
61
+
* @example $oRuleSet->getRules('font') //returns array(0 => $oRule, …) or array().
62
+
*
63
+
* @return array
64
+
*/
56
65
publicfunctiongetRules($mRule = null) {
57
66
if ($mRuleinstanceof Rule) {
58
67
$mRule = $mRule->getRule();
@@ -78,11 +87,21 @@ public function setRules(array $aRules) {
78
87
}
79
88
}
80
89
81
-
/**
82
-
* Returns all rules matching the given pattern and returns them in an associative array with the rule’s name as keys. This method exists mainly for backwards-compatibility and is really only partially useful.
83
-
* @param (string) $mRule pattern to search for. If null, returns all rules. if the pattern ends with a dash, all rules starting with the pattern are returned as well as one matching the pattern with the dash excluded. passing a Rule behaves like calling getRules($mRule->getRule()).
84
-
* Note: This method loses some information: Calling this (with an argument of 'background-') on a declaration block like { background-color: green; background-color; rgba(0, 127, 0, 0.7); } will only yield an associative array containing the rgba-valued rule while @link{getRules()} would yield an indexed array containing both.
85
-
*/
90
+
/**
91
+
* Returns all rules matching the given pattern and returns them in an associative array with the rule’s name as
92
+
* keys. This method exists mainly for backwards-compatibility and is really only partially useful.
93
+
*
94
+
* @param (string) $mRule pattern to search for.
95
+
* If null, returns all rules. if the pattern ends with a dash, all rules starting with the pattern are
96
+
* returned as well as one matching the pattern with the dash excluded.
97
+
* Passing a Rule behaves like calling getRules($mRule->getRule()).
98
+
* Note: This method loses some information: Calling this (with an argument of 'background-')
99
+
* on a declaration block like { background-color: green; background-color; rgba(0, 127, 0, 0.7); }
100
+
* will only yield an associative array containing the rgba-valued rule while @link{getRules()}
101
+
* would yield an indexed array containing both.
102
+
*
103
+
* @return array
104
+
*/
86
105
publicfunctiongetRulesAssoc($mRule = null) {
87
106
$aResult = array();
88
107
foreach($this->getRules($mRule) as$oRule) {
@@ -92,9 +111,19 @@ public function getRulesAssoc($mRule = null) {
92
111
}
93
112
94
113
/**
95
-
* Remove a rule from this RuleSet. This accepts all the possible values that @link{getRules()} accepts. If given a Rule, it will only remove this particular rule (by identity). If given a name, it will remove all rules by that name. 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 behvaiour, use removeRule($oRule->getRule()).
96
-
* @param (null|string|Rule) $mRule pattern to remove. If $mRule is null, all rules are removed. If the pattern ends in a dash, all rules starting with the pattern are removed as well as one matching the pattern with the dash excluded. Passing a Rule behaves matches by identity.
97
-
*/
114
+
* Remove a rule from this RuleSet.
115
+
*
116
+
* This accepts all the possible values that @link{getRules()} accepts.
117
+
* If given a Rule, it will only remove this particular rule (by identity).
118
+
* If given a name, it will remove all rules by that name.
119
+
* Note: this is different from pre-v.2.0 behaviour of PHP-CSS-Parser, where passing a Rule instance would
120
+
* remove all rules with the same name. To get the old behvaiour, use removeRule($oRule->getRule()).
121
+
*
122
+
* @param (null|string|Rule) $mRule pattern to remove.
123
+
* If $mRule is null, all rules are removed. If the pattern ends in a dash, all rules starting with the pattern
124
+
* are removed as well as one matching the pattern with the dash excluded.
125
+
* Passing a Rule behaves matches by identity.
126
+
*/
98
127
publicfunctionremoveRule($mRule) {
99
128
if($mRuleinstanceof Rule) {
100
129
$sRule = $mRule->getRule();
@@ -140,7 +169,7 @@ public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat) {
140
169
$sResult .= $sRendered;
141
170
}
142
171
}
143
-
172
+
144
173
if(!$bIsFirst) {
145
174
// Had some output
146
175
$sResult .= $oOutputFormat->spaceAfterRules();
@@ -170,4 +199,21 @@ public function setComments(array $aComments) {
170
199
$this->aComments = $aComments;
171
200
}
172
201
202
+
/**
203
+
* Returns all comments that were declared before this Rule
0 commit comments