5
5
use Sabberworm \CSS \OutputFormat ;
6
6
use Sabberworm \CSS \Parsing \ParserState ;
7
7
use Sabberworm \CSS \Parsing \SourceException ;
8
- use Sabberworm \CSS \Value \CSSString ;
8
+ use Sabberworm \CSS \Property \Selector ;
9
+ use Sabberworm \CSS \RuleSet \DeclarationBlock ;
10
+ use Sabberworm \CSS \RuleSet \RuleSet ;
9
11
use Sabberworm \CSS \Value \Value ;
10
12
11
13
/**
12
- * The root CSSList of a parsed file. Contains all top-level css contents, mostly declaration blocks,
14
+ * The root ` CSSList` of a parsed file. Contains all top-level CSS contents, mostly declaration blocks,
13
15
* but also any at-rules encountered.
14
16
*/
15
17
class Document extends CSSBlockList
16
18
{
17
19
/**
18
- * Document constructor.
19
- *
20
20
* @param int $iLineNo
21
21
*/
22
22
public function __construct ($ iLineNo = 0 )
@@ -25,8 +25,6 @@ public function __construct($iLineNo = 0)
25
25
}
26
26
27
27
/**
28
- * @param ParserState $oParserState
29
- *
30
28
* @return Document
31
29
*
32
30
* @throws SourceException
@@ -39,16 +37,23 @@ public static function parse(ParserState $oParserState)
39
37
}
40
38
41
39
/**
42
- * Gets all DeclarationBlock objects recursively.
40
+ * Gets all `DeclarationBlock` objects recursively.
41
+ *
42
+ * @return array<int, DeclarationBlock>
43
43
*/
44
44
public function getAllDeclarationBlocks ()
45
45
{
46
+ /** @var array<int, DeclarationBlock> $aResult */
46
47
$ aResult = [];
47
48
$ this ->allDeclarationBlocks ($ aResult );
48
49
return $ aResult ;
49
50
}
50
51
51
52
/**
53
+ * Gets all `DeclarationBlock` objects recursively.
54
+ *
55
+ * @return array<int, DeclarationBlock>
56
+ *
52
57
* @deprecated will be removed in version 9.0; use `getAllDeclarationBlocks()` instead
53
58
*/
54
59
public function getAllSelectors ()
@@ -57,23 +62,28 @@ public function getAllSelectors()
57
62
}
58
63
59
64
/**
60
- * Returns all RuleSet objects found recursively in the tree.
65
+ * Returns all `RuleSet` objects found recursively in the tree.
66
+ *
67
+ * @return array<int, RuleSet>
61
68
*/
62
69
public function getAllRuleSets ()
63
70
{
71
+ /** @var array<int, RuleSet> $aResult */
64
72
$ aResult = [];
65
73
$ this ->allRuleSets ($ aResult );
66
74
return $ aResult ;
67
75
}
68
76
69
77
/**
70
- * Returns all Value objects found recursively in the tree.
78
+ * Returns all ` Value` objects found recursively in the tree.
71
79
*
72
- * @param object |string $mElement
73
- * the CSSList or RuleSet to start the search from (defaults to the whole document).
80
+ * @param CSSList|RuleSet |string $mElement
81
+ * the ` CSSList` or ` RuleSet` to start the search from (defaults to the whole document).
74
82
* If a string is given, it is used as rule name filter.
75
83
* @param bool $bSearchInFunctionArguments whether to also return Value objects used as Function arguments.
76
84
*
85
+ * @return array<int, Value>
86
+ *
77
87
* @see RuleSet->getRules()
78
88
*/
79
89
public function getAllValues ($ mElement = null , $ bSearchInFunctionArguments = false )
@@ -85,32 +95,38 @@ public function getAllValues($mElement = null, $bSearchInFunctionArguments = fal
85
95
$ sSearchString = $ mElement ;
86
96
$ mElement = $ this ;
87
97
}
88
- /** @var array<int, Value|CSSString > $aResult */
98
+ /** @var array<int, Value> $aResult */
89
99
$ aResult = [];
90
100
$ this ->allValues ($ mElement , $ aResult , $ sSearchString , $ bSearchInFunctionArguments );
91
101
return $ aResult ;
92
102
}
93
103
94
104
/**
95
- * Returns all Selector objects found recursively in the tree.
96
- * Note that this does not yield the full DeclarationBlock that the selector belongs to
105
+ * Returns all `Selector` objects found recursively in the tree.
106
+ *
107
+ * Note that this does not yield the full `DeclarationBlock` that the selector belongs to
97
108
* (and, currently, there is no way to get to that).
98
109
*
99
- * @param string $sSpecificitySearch
110
+ * @param string|null $sSpecificitySearch
100
111
* An optional filter by specificity.
101
112
* May contain a comparison operator and a number or just a number (defaults to "==").
102
113
*
103
- * @example getSelectorsBySpecificity('>= 100')
114
+ * @return array<int, Selector>
115
+ * @example `getSelectorsBySpecificity('>= 100')`
116
+ *
104
117
*/
105
118
public function getSelectorsBySpecificity ($ sSpecificitySearch = null )
106
119
{
120
+ /** @var array<int, Selector> $aResult */
107
121
$ aResult = [];
108
122
$ this ->allSelectors ($ aResult , $ sSpecificitySearch );
109
123
return $ aResult ;
110
124
}
111
125
112
126
/**
113
- * Expands all shorthand properties to their long value
127
+ * Expands all shorthand properties to their long value.
128
+ *
129
+ * @return void
114
130
*/
115
131
public function expandShorthands ()
116
132
{
@@ -120,7 +136,9 @@ public function expandShorthands()
120
136
}
121
137
122
138
/**
123
- * Create shorthands properties whenever possible
139
+ * Create shorthands properties whenever possible.
140
+ *
141
+ * @return void
124
142
*/
125
143
public function createShorthands ()
126
144
{
@@ -130,7 +148,7 @@ public function createShorthands()
130
148
}
131
149
132
150
/**
133
- * Override `render()` to make format argument optional
151
+ * Overrides `render()` to make format argument optional.
134
152
*
135
153
* @param OutputFormat|null $oOutputFormat
136
154
*
@@ -144,6 +162,9 @@ public function render(OutputFormat $oOutputFormat = null)
144
162
return parent ::render ($ oOutputFormat );
145
163
}
146
164
165
+ /**
166
+ * @return bool
167
+ */
147
168
public function isRootList ()
148
169
{
149
170
return true ;
0 commit comments