8
8
use Sabberworm \CSS \Parsing \ParserState ;
9
9
use Sabberworm \CSS \Parsing \UnexpectedEOFException ;
10
10
use Sabberworm \CSS \Parsing \UnexpectedTokenException ;
11
+ use Sabberworm \CSS \Position \Position ;
12
+ use Sabberworm \CSS \Position \Positionable ;
11
13
use Sabberworm \CSS \Renderable ;
12
14
use Sabberworm \CSS \Value \RuleValueList ;
13
15
use Sabberworm \CSS \Value \Value ;
17
19
*
18
20
* In CSS, `Rule`s are expressed as follows: “key: value[0][0] value[0][1], value[1][0] value[1][1];”
19
21
*/
20
- class Rule implements Renderable, Commentable
22
+ class Rule implements Commentable, Positionable, Renderable
21
23
{
24
+ use Position;
25
+
22
26
/**
23
27
* @var string
24
28
*/
@@ -39,18 +43,6 @@ class Rule implements Renderable, Commentable
39
43
*/
40
44
private $ aIeHack ;
41
45
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
-
54
46
/**
55
47
* @var array<array-key, Comment>
56
48
*
@@ -69,8 +61,7 @@ public function __construct($sRule, $iLineNo = 0, $iColNo = 0)
69
61
$ this ->mValue = null ;
70
62
$ this ->bIsImportant = false ;
71
63
$ this ->aIeHack = [];
72
- $ this ->iLineNo = $ iLineNo ;
73
- $ this ->iColNo = $ iColNo ;
64
+ $ this ->setPosition ($ iLineNo , $ iColNo );
74
65
$ this ->aComments = [];
75
66
}
76
67
@@ -142,34 +133,6 @@ private static function listDelimiterForRule($sRule)
142
133
}
143
134
}
144
135
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
-
173
136
/**
174
137
* @param string $sRule
175
138
*
@@ -295,7 +258,7 @@ public function addValue($mValue, $sType = ' ')
295
258
}
296
259
if (!$ this ->mValue instanceof RuleValueList || $ this ->mValue ->getListSeparator () !== $ sType ) {
297
260
$ mCurrentValue = $ this ->mValue ;
298
- $ this ->mValue = new RuleValueList ($ sType , $ this ->iLineNo );
261
+ $ this ->mValue = new RuleValueList ($ sType , $ this ->$ this -> getLineNumber () );
299
262
if ($ mCurrentValue ) {
300
263
$ this ->mValue ->addListComponent ($ mCurrentValue );
301
264
}
0 commit comments