2020use function Safe \preg_match ;
2121
2222/**
23- * `Rule`s just have a string key (the rule ) and a 'Value'.
23+ * `Rule`s just have a string key (the property name ) and a 'Value'.
2424 *
2525 * In CSS, `Rule`s are expressed as follows: “key: value[0][0] value[0][1], value[1][0] value[1][1];”
2626 */
@@ -32,7 +32,7 @@ class Rule implements Commentable, CSSElement, Positionable
3232 /**
3333 * @var non-empty-string
3434 */
35- private $ rule ;
35+ private $ propertyName ;
3636
3737 /**
3838 * @var RuleValueList|string|null
@@ -45,13 +45,13 @@ class Rule implements Commentable, CSSElement, Positionable
4545 private $ isImportant = false ;
4646
4747 /**
48- * @param non-empty-string $rule
48+ * @param non-empty-string $propertyName
4949 * @param int<1, max>|null $lineNumber
5050 * @param int<0, max>|null $columnNumber
5151 */
52- public function __construct (string $ rule , ?int $ lineNumber = null , ?int $ columnNumber = null )
52+ public function __construct (string $ propertyName , ?int $ lineNumber = null , ?int $ columnNumber = null )
5353 {
54- $ this ->rule = $ rule ;
54+ $ this ->propertyName = $ propertyName ;
5555 $ this ->setPosition ($ lineNumber , $ columnNumber );
5656 }
5757
@@ -97,17 +97,17 @@ public static function parse(ParserState $parserState, array $commentsBeforeRule
9797 * The first item is the innermost separator (or, put another way, the highest-precedence operator).
9898 * The sequence continues to the outermost separator (or lowest-precedence operator).
9999 *
100- * @param non-empty-string $rule
100+ * @param non-empty-string $propertyName
101101 *
102102 * @return list<non-empty-string>
103103 */
104- private static function listDelimiterForRule (string $ rule ): array
104+ private static function listDelimiterForRule (string $ propertyName ): array
105105 {
106- if (preg_match ('/^font($|-)/ ' , $ rule ) === 1 ) {
106+ if (preg_match ('/^font($|-)/ ' , $ propertyName ) === 1 ) {
107107 return [', ' , '/ ' , ' ' ];
108108 }
109109
110- switch ($ rule ) {
110+ switch ($ propertyName ) {
111111 case 'src ' :
112112 return [' ' , ', ' ];
113113 default :
@@ -116,19 +116,39 @@ private static function listDelimiterForRule(string $rule): array
116116 }
117117
118118 /**
119- * @param non-empty-string $rule
119+ * @param non-empty-string $propertyName
120120 */
121- public function setRule (string $ rule ): void
121+ public function setPropertyName (string $ propertyName ): void
122122 {
123- $ this ->rule = $ rule ;
123+ $ this ->propertyName = $ propertyName ;
124124 }
125125
126126 /**
127127 * @return non-empty-string
128128 */
129+ public function getPropertyName (): string
130+ {
131+ return $ this ->propertyName ;
132+ }
133+
134+ /**
135+ * @param non-empty-string $propertyName
136+ *
137+ * @deprecated in v9.2, will be removed in v10.0; use `setPropertyName()` instead.
138+ */
139+ public function setRule (string $ propertyName ): void
140+ {
141+ $ this ->propertyName = $ propertyName ;
142+ }
143+
144+ /**
145+ * @return non-empty-string
146+ *
147+ * @deprecated in v9.2, will be removed in v10.0; use `getPropertyName()` instead.
148+ */
129149 public function getRule (): string
130150 {
131- return $ this ->rule ;
151+ return $ this ->propertyName ;
132152 }
133153
134154 /**
@@ -186,7 +206,7 @@ public function getIsImportant(): bool
186206 public function render (OutputFormat $ outputFormat ): string
187207 {
188208 $ formatter = $ outputFormat ->getFormatter ();
189- $ result = "{$ formatter ->comments ($ this )}{$ this ->rule }: {$ formatter ->spaceAfterRuleName ()}" ;
209+ $ result = "{$ formatter ->comments ($ this )}{$ this ->propertyName }: {$ formatter ->spaceAfterRuleName ()}" ;
190210 if ($ this ->value instanceof Value) { // Can also be a ValueList
191211 $ result .= $ this ->value ->render ($ outputFormat );
192212 } else {
0 commit comments