22
33namespace Sabberworm \CSS \CSSList ;
44
5+ use Sabberworm \CSS \Comment \Comment ;
56use Sabberworm \CSS \Comment \Commentable ;
67use Sabberworm \CSS \OutputFormat ;
78use Sabberworm \CSS \Parsing \ParserState ;
89use Sabberworm \CSS \Parsing \SourceException ;
10+ use Sabberworm \CSS \Parsing \UnexpectedEOFException ;
911use Sabberworm \CSS \Parsing \UnexpectedTokenException ;
1012use Sabberworm \CSS \Property \AtRule ;
1113use Sabberworm \CSS \Property \Charset ;
2224use Sabberworm \CSS \Value \Value ;
2325
2426/**
25- * A CSSList is the most generic container available. Its contents include RuleSet as well as other CSSList objects.
26- * Also, it may contain Import and Charset objects stemming from at-rules.
27+ * A `CSSList` is the most generic container available. Its contents include `RuleSet` as well as other `CSSList`
28+ * objects.
29+ *
30+ * Also, it may contain `Import` and `Charset` objects stemming from at-rules.
2731 */
2832abstract class CSSList implements Renderable, Commentable
2933{
3034 /**
31- * @var array
35+ * @var array<array-key, Comment> $aComments
3236 */
3337 protected $ aComments ;
3438
3539 /**
36- * @var array<int, RuleSet|Import|Charset|CSSList >
40+ * @var array<int, RuleSet|CSSList| Import|Charset>
3741 */
3842 protected $ aContents ;
3943
@@ -52,6 +56,12 @@ public function __construct($iLineNo = 0)
5256 $ this ->iLineNo = $ iLineNo ;
5357 }
5458
59+ /**
60+ * @throws SourceException
61+ * @throws UnexpectedTokenException
62+ *
63+ * @return void
64+ */
5565 public static function parseList (ParserState $ oParserState , CSSList $ oList )
5666 {
5767 $ bIsRoot = $ oList instanceof Document;
@@ -86,6 +96,13 @@ public static function parseList(ParserState $oParserState, CSSList $oList)
8696 }
8797 }
8898
99+ /**
100+ * @return AtRuleBlockList|KeyFrame|Charset|CSSNamespace|Import|AtRuleSet|DeclarationBlock|null|false
101+ *
102+ * @throws SourceException
103+ * @throws UnexpectedEOFException
104+ * @throws UnexpectedTokenException
105+ */
89106 private static function parseListItem (ParserState $ oParserState , CSSList $ oList )
90107 {
91108 $ bIsRoot = $ oList instanceof Document;
@@ -130,6 +147,15 @@ private static function parseListItem(ParserState $oParserState, CSSList $oList)
130147 }
131148 }
132149
150+ /**
151+ * @param ParserState $oParserState
152+ *
153+ * @return AtRuleBlockList|KeyFrame|Charset|CSSNamespace|Import|AtRuleSet|null
154+ *
155+ * @throws SourceException
156+ * @throws UnexpectedTokenException
157+ * @throws UnexpectedEOFException
158+ */
133159 private static function parseAtRule (ParserState $ oParserState )
134160 {
135161 $ oParserState ->consume ('@ ' );
@@ -213,6 +239,11 @@ private static function parseAtRule(ParserState $oParserState)
213239 /**
214240 * Tests an identifier for a given value. Since identifiers are all keywords, they can be vendor-prefixed.
215241 * We need to check for these versions too.
242+ *
243+ * @param string $sIdentifier
244+ * @param string $sMatch
245+ *
246+ * @return bool
216247 */
217248 private static function identifierIs ($ sIdentifier , $ sMatch )
218249 {
@@ -229,31 +260,37 @@ public function getLineNo()
229260 }
230261
231262 /**
232- * Prepend item to list of contents.
263+ * Prepends an item to the list of contents.
264+ *
265+ * @param RuleSet|CSSList|Import|Charset $oItem
233266 *
234- * @param RuleSet|Import|Charset|CSSList $oItem Item.
267+ * @return void
235268 */
236269 public function prepend ($ oItem )
237270 {
238271 array_unshift ($ this ->aContents , $ oItem );
239272 }
240273
241274 /**
242- * Append item to list of contents.
275+ * Appends an item to tje list of contents.
276+ *
277+ * @param RuleSet|CSSList|Import|Charset $oItem
243278 *
244- * @param RuleSet|Import|Charset|CSSList $oItem Item.
279+ * @return void
245280 */
246281 public function append ($ oItem )
247282 {
248283 $ this ->aContents [] = $ oItem ;
249284 }
250285
251286 /**
252- * Splice the list of contents.
287+ * Splices the list of contents.
253288 *
254- * @param int $iOffset Offset.
255- * @param int $iLength Length. Optional.
256- * @param RuleSet[] $mReplacement Replacement. Optional.
289+ * @param int $iOffset
290+ * @param int $iLength
291+ * @param array<int, RuleSet|CSSList|Import|Charset> $mReplacement
292+ *
293+ * @return void
257294 */
258295 public function splice ($ iOffset , $ iLength = null , $ mReplacement = null )
259296 {
@@ -267,7 +304,7 @@ public function splice($iOffset, $iLength = null, $mReplacement = null)
267304 * May be a RuleSet (most likely a DeclarationBlock), a Import,
268305 * a Charset or another CSSList (most likely a MediaQuery)
269306 *
270- * @return bool Whether the item was removed.
307+ * @return bool whether the item was removed
271308 */
272309 public function remove ($ oItemToRemove )
273310 {
@@ -283,8 +320,10 @@ public function remove($oItemToRemove)
283320 * Replaces an item from the CSS list.
284321 *
285322 * @param RuleSet|Import|Charset|CSSList $oOldItem
286- * May be a RuleSet (most likely a DeclarationBlock), a Import, a Charset
287- * or another CSSList (most likely a MediaQuery)
323+ * May be a `RuleSet` (most likely a `DeclarationBlock`), an `Import`, a `Charset`
324+ * or another `CSSList` (most likely a `MediaQuery`)
325+ *
326+ * @return bool
288327 */
289328 public function replace ($ oOldItem , $ mNewItem )
290329 {
@@ -301,9 +340,7 @@ public function replace($oOldItem, $mNewItem)
301340 }
302341
303342 /**
304- * Set the contents.
305- *
306- * @param array<int, RuleSet|Import|Charset|CSSList> $aContents Objects to set as content.
343+ * @param array<int, RuleSet|Import|Charset|CSSList> $aContents
307344 */
308345 public function setContents (array $ aContents )
309346 {
@@ -316,8 +353,10 @@ public function setContents(array $aContents)
316353 /**
317354 * Removes a declaration block from the CSS list if it matches all given selectors.
318355 *
319- * @param array|string $mSelector The selectors to match.
320- * @param boolean $bRemoveAll Whether to stop at the first declaration block found or remove all blocks
356+ * @param DeclarationBlock|array<array-key, Selector>|string $mSelector the selectors to match
357+ * @param bool $bRemoveAll whether to stop at the first declaration block found or remove all blocks
358+ *
359+ * @return void
321360 */
322361 public function removeDeclarationBlockBySelector ($ mSelector , $ bRemoveAll = false )
323362 {
@@ -352,6 +391,9 @@ public function removeDeclarationBlockBySelector($mSelector, $bRemoveAll = false
352391 }
353392 }
354393
394+ /**
395+ * @return string
396+ */
355397 public function __toString ()
356398 {
357399 return $ this ->render (new OutputFormat ());
@@ -394,6 +436,8 @@ public function render(OutputFormat $oOutputFormat)
394436
395437 /**
396438 * Return true if the list can not be further outdented. Only important when rendering.
439+ *
440+ * @return bool
397441 */
398442 abstract public function isRootList ();
399443
@@ -406,23 +450,23 @@ public function getContents()
406450 }
407451
408452 /**
409- * @param array $aComments Array of comments.
453+ * @param array<array-key, Comment> $aComments
410454 */
411455 public function addComments (array $ aComments )
412456 {
413457 $ this ->aComments = array_merge ($ this ->aComments , $ aComments );
414458 }
415459
416460 /**
417- * @return array
461+ * @return array<array-key, Comment>
418462 */
419463 public function getComments ()
420464 {
421465 return $ this ->aComments ;
422466 }
423467
424468 /**
425- * @param array $aComments Array containing Comment objects.
469+ * @param array<array-key, Comment> $aComments
426470 */
427471 public function setComments (array $ aComments )
428472 {
0 commit comments