22
33namespace Sabberworm \CSS \Rule ;
44
5+ use Sabberworm \CSS \Comment \Comment ;
56use Sabberworm \CSS \Comment \Commentable ;
67use Sabberworm \CSS \OutputFormat ;
78use Sabberworm \CSS \Parsing \ParserState ;
9+ use Sabberworm \CSS \Parsing \UnexpectedEOFException ;
10+ use Sabberworm \CSS \Parsing \UnexpectedTokenException ;
811use Sabberworm \CSS \Renderable ;
912use Sabberworm \CSS \Value \RuleValueList ;
1013use Sabberworm \CSS \Value \Value ;
1518 */
1619class Rule implements Renderable, Commentable
1720{
21+ /**
22+ * @var string
23+ */
1824 private $ sRule ;
1925
26+ /**
27+ * @var RuleValueList|null
28+ */
2029 private $ mValue ;
2130
31+ /**
32+ * @var bool
33+ */
2234 private $ bIsImportant ;
2335
36+ /**
37+ * @var array<int, int>
38+ */
2439 private $ aIeHack ;
2540
41+ /**
42+ * @var int
43+ */
2644 protected $ iLineNo ;
2745
46+ /**
47+ * @var int
48+ */
2849 protected $ iColNo ;
2950
51+ /**
52+ * @var array<array-key, Comment>
53+ */
3054 protected $ aComments ;
3155
56+ /**
57+ * @param string $sRule
58+ * @param int $iLineNo
59+ * @param int $iColNo
60+ */
3261 public function __construct ($ sRule , $ iLineNo = 0 , $ iColNo = 0 )
3362 {
3463 $ this ->sRule = $ sRule ;
@@ -40,6 +69,12 @@ public function __construct($sRule, $iLineNo = 0, $iColNo = 0)
4069 $ this ->aComments = [];
4170 }
4271
72+ /**
73+ * @return Rule
74+ *
75+ * @throws UnexpectedEOFException
76+ * @throws UnexpectedTokenException
77+ */
4378 public static function parse (ParserState $ oParserState )
4479 {
4580 $ aComments = $ oParserState ->consumeWhiteSpace ();
@@ -76,6 +111,11 @@ public static function parse(ParserState $oParserState)
76111 return $ oRule ;
77112 }
78113
114+ /**
115+ * @param string $sRule
116+ *
117+ * @return array<int, string>
118+ */
79119 private static function listDelimiterForRule ($ sRule )
80120 {
81121 if (preg_match ('/^font($|-)/ ' , $ sRule )) {
@@ -100,33 +140,59 @@ public function getColNo()
100140 return $ this ->iColNo ;
101141 }
102142
143+ /**
144+ * @param int $iLine
145+ * @param int $iColumn
146+ *
147+ * @return void
148+ */
103149 public function setPosition ($ iLine , $ iColumn )
104150 {
105151 $ this ->iColNo = $ iColumn ;
106152 $ this ->iLineNo = $ iLine ;
107153 }
108154
155+ /**
156+ * @param string $sRule
157+ *
158+ * @return void
159+ */
109160 public function setRule ($ sRule )
110161 {
111162 $ this ->sRule = $ sRule ;
112163 }
113164
165+ /**
166+ * @return string
167+ */
114168 public function getRule ()
115169 {
116170 return $ this ->sRule ;
117171 }
118172
173+ /**
174+ * @return RuleValueList|null
175+ */
119176 public function getValue ()
120177 {
121178 return $ this ->mValue ;
122179 }
123180
181+ /**
182+ * @param RuleValueList|null $mValue
183+ *
184+ * @return void
185+ */
124186 public function setValue ($ mValue )
125187 {
126188 $ this ->mValue = $ mValue ;
127189 }
128190
129191 /**
192+ * @param array<array-key, array<array-key, RuleValueList>>
193+ *
194+ * @return RuleValueList
195+ *
130196 * @deprecated Old-Style 2-dimensional array given. Retained for (some) backwards-compatibility.
131197 * Use `setValue()` instead and wrap the value inside a RuleValueList if necessary.
132198 */
@@ -164,6 +230,8 @@ public function setValues(array $aSpaceSeparatedValues)
164230 }
165231
166232 /**
233+ * @return array<int, array<int, RuleValueList>>
234+ *
167235 * @deprecated Old-Style 2-dimensional array returned. Retained for (some) backwards-compatibility.
168236 * Use `getValue()` instead and check for the existence of a (nested set of) ValueList object(s).
169237 */
@@ -192,8 +260,13 @@ public function getValues()
192260 }
193261
194262 /**
195- * Adds a value to the existing value. Value will be appended if a RuleValueList exists of the given type.
263+ * Adds a value to the existing value. Value will be appended if a ` RuleValueList` exists of the given type.
196264 * Otherwise, the existing value will be wrapped by one.
265+ *
266+ * @param RuleValueList|array<int, RuleValueList> $mValue
267+ * @param string $sType
268+ *
269+ * @return void
197270 */
198271 public function addValue ($ mValue , $ sType = ' ' )
199272 {
@@ -212,39 +285,61 @@ public function addValue($mValue, $sType = ' ')
212285 }
213286 }
214287
288+ /**
289+ * @param int $iModifier
290+ *
291+ * @return void
292+ */
215293 public function addIeHack ($ iModifier )
216294 {
217295 $ this ->aIeHack [] = $ iModifier ;
218296 }
219297
298+ /**
299+ * @param array<int, int> $aModifiers
300+ *
301+ * @return void
302+ */
220303 public function setIeHack (array $ aModifiers )
221304 {
222305 $ this ->aIeHack = $ aModifiers ;
223306 }
224307
308+ /**
309+ * @return array<int, int>
310+ */
225311 public function getIeHack ()
226312 {
227313 return $ this ->aIeHack ;
228314 }
229315
316+ /**
317+ * @param bool $bIsImportant
318+ *
319+ * @return void
320+ */
230321 public function setIsImportant ($ bIsImportant )
231322 {
232323 $ this ->bIsImportant = $ bIsImportant ;
233324 }
234325
326+ /**
327+ * @return bool
328+ */
235329 public function getIsImportant ()
236330 {
237331 return $ this ->bIsImportant ;
238332 }
239333
334+ /**
335+ * @return string
336+ */
240337 public function __toString ()
241338 {
242339 return $ this ->render (new OutputFormat ());
243340 }
244341
245342 /**
246- * @param OutputFormat $oOutputFormat
247- *
248343 * @return string
249344 */
250345 public function render (OutputFormat $ oOutputFormat )
@@ -266,23 +361,27 @@ public function render(OutputFormat $oOutputFormat)
266361 }
267362
268363 /**
269- * @param array $aComments Array of comments.
364+ * @param array<array-key, Comment> $aComments
365+ *
366+ * @return void
270367 */
271368 public function addComments (array $ aComments )
272369 {
273370 $ this ->aComments = array_merge ($ this ->aComments , $ aComments );
274371 }
275372
276373 /**
277- * @return array
374+ * @return array<array-key, Comment>
278375 */
279376 public function getComments ()
280377 {
281378 return $ this ->aComments ;
282379 }
283380
284381 /**
285- * @param array $aComments Array containing Comment objects.
382+ * @param array<array-key, Comment> $aComments
383+ *
384+ * @return void
286385 */
287386 public function setComments (array $ aComments )
288387 {
0 commit comments