88use Sabberworm \CSS \Parsing \ParserState ;
99use Sabberworm \CSS \Parsing \UnexpectedEOFException ;
1010use Sabberworm \CSS \Parsing \UnexpectedTokenException ;
11+ use Sabberworm \CSS \Position \Position ;
12+ use Sabberworm \CSS \Position \Positionable ;
1113use Sabberworm \CSS \Renderable ;
1214use Sabberworm \CSS \Value \RuleValueList ;
1315use Sabberworm \CSS \Value \Value ;
1719 *
1820 * In CSS, `Rule`s are expressed as follows: “key: value[0][0] value[0][1], value[1][0] value[1][1];”
1921 */
20- class Rule implements Renderable, Commentable
22+ class Rule implements Commentable, Positionable, Renderable
2123{
24+ use Position;
25+
2226 /**
2327 * @var string
2428 */
@@ -39,18 +43,6 @@ class Rule implements Renderable, Commentable
3943 */
4044 private $ aIeHack ;
4145
42- /**
43- * @var int
44- */
45- protected $ iLineNo ;
46-
47- /**
48- * @var int
49- *
50- * @internal since 8.8.0
51- */
52- protected $ iColNo ;
53-
5446 /**
5547 * @var array<array-key, Comment>
5648 *
@@ -69,8 +61,7 @@ public function __construct($sRule, $iLineNo = 0, $iColNo = 0)
6961 $ this ->mValue = null ;
7062 $ this ->bIsImportant = false ;
7163 $ this ->aIeHack = [];
72- $ this ->iLineNo = $ iLineNo ;
73- $ this ->iColNo = $ iColNo ;
64+ $ this ->setPosition ($ iLineNo , $ iColNo );
7465 $ this ->aComments = [];
7566 }
7667
@@ -142,34 +133,6 @@ private static function listDelimiterForRule($sRule)
142133 }
143134 }
144135
145- /**
146- * @return int
147- */
148- public function getLineNo ()
149- {
150- return $ this ->iLineNo ;
151- }
152-
153- /**
154- * @return int
155- */
156- public function getColNo ()
157- {
158- return $ this ->iColNo ;
159- }
160-
161- /**
162- * @param int $iLine
163- * @param int $iColumn
164- *
165- * @return void
166- */
167- public function setPosition ($ iLine , $ iColumn )
168- {
169- $ this ->iColNo = $ iColumn ;
170- $ this ->iLineNo = $ iLine ;
171- }
172-
173136 /**
174137 * @param string $sRule
175138 *
@@ -295,7 +258,7 @@ public function addValue($mValue, $sType = ' ')
295258 }
296259 if (!$ this ->mValue instanceof RuleValueList || $ this ->mValue ->getListSeparator () !== $ sType ) {
297260 $ mCurrentValue = $ this ->mValue ;
298- $ this ->mValue = new RuleValueList ($ sType , $ this ->iLineNo );
261+ $ this ->mValue = new RuleValueList ($ sType , $ this ->getLineNumber () );
299262 if ($ mCurrentValue ) {
300263 $ this ->mValue ->addListComponent ($ mCurrentValue );
301264 }
0 commit comments