3
3
namespace Sabberworm \CSS \Value ;
4
4
5
5
use Sabberworm \CSS \Parsing \ParserState ;
6
+ use Sabberworm \CSS \Parsing \SourceException ;
7
+ use Sabberworm \CSS \Parsing \UnexpectedEOFException ;
6
8
use Sabberworm \CSS \Parsing \UnexpectedTokenException ;
7
9
use Sabberworm \CSS \Renderable ;
8
10
9
11
abstract class Value implements Renderable
10
12
{
13
+ /**
14
+ * @var int
15
+ */
11
16
protected $ iLineNo ;
12
17
18
+ /**
19
+ * @param int $iLineNo
20
+ */
13
21
public function __construct ($ iLineNo = 0 )
14
22
{
15
23
$ this ->iLineNo = $ iLineNo ;
16
24
}
17
25
26
+ /**
27
+ * @param array<array-key, string> $aListDelimiters
28
+ *
29
+ * @return RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string
30
+ *
31
+ * @throws UnexpectedTokenException
32
+ * @throws UnexpectedEOFException
33
+ */
18
34
public static function parseValue (ParserState $ oParserState , array $ aListDelimiters = [])
19
35
{
36
+ /** @var array<int, RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string> $aStack */
20
37
$ aStack = [];
21
38
$ oParserState ->consumeWhiteSpace ();
22
39
//Build a list of delimiters and parsed values
@@ -43,7 +60,7 @@ public static function parseValue(ParserState $oParserState, array $aListDelimit
43
60
array_push ($ aStack , self ::parsePrimitiveValue ($ oParserState ));
44
61
$ oParserState ->consumeWhiteSpace ();
45
62
}
46
- //Convert the list to list objects
63
+ // Convert the list to list objects
47
64
foreach ($ aListDelimiters as $ sDelimiter ) {
48
65
if (count ($ aStack ) === 1 ) {
49
66
return $ aStack [0 ];
@@ -74,6 +91,14 @@ public static function parseValue(ParserState $oParserState, array $aListDelimit
74
91
return $ aStack [0 ];
75
92
}
76
93
94
+ /**
95
+ * @param bool $bIgnoreCase
96
+ *
97
+ * @return CSSFunction|string
98
+ *
99
+ * @throws UnexpectedEOFException
100
+ * @throws UnexpectedTokenException
101
+ */
77
102
public static function parseIdentifierOrFunction (ParserState $ oParserState , $ bIgnoreCase = false )
78
103
{
79
104
$ sResult = $ oParserState ->parseIdentifier ($ bIgnoreCase );
@@ -88,6 +113,13 @@ public static function parseIdentifierOrFunction(ParserState $oParserState, $bIg
88
113
return $ sResult ;
89
114
}
90
115
116
+ /**
117
+ * @return CSSFunction|CSSString|LineName|Size|URL|string
118
+ *
119
+ * @throws UnexpectedEOFException
120
+ * @throws UnexpectedTokenException
121
+ * @throws SourceException
122
+ */
91
123
public static function parsePrimitiveValue (ParserState $ oParserState )
92
124
{
93
125
$ oValue = null ;
@@ -123,13 +155,25 @@ public static function parsePrimitiveValue(ParserState $oParserState)
123
155
return $ oValue ;
124
156
}
125
157
158
+ /**
159
+ * @return CSSFunction
160
+ *
161
+ * @throws UnexpectedEOFException
162
+ * @throws UnexpectedTokenException
163
+ */
126
164
private static function parseMicrosoftFilter (ParserState $ oParserState )
127
165
{
128
166
$ sFunction = $ oParserState ->consumeUntil ('( ' , false , true );
129
167
$ aArguments = Value::parseValue ($ oParserState , [', ' , '= ' ]);
130
168
return new CSSFunction ($ sFunction , $ aArguments , ', ' , $ oParserState ->currentLine ());
131
169
}
132
170
171
+ /**
172
+ * @return string
173
+ *
174
+ * @throws UnexpectedEOFException
175
+ * @throws UnexpectedTokenException
176
+ */
133
177
private static function parseUnicodeRangeValue (ParserState $ oParserState )
134
178
{
135
179
$ iCodepointMaxLenth = 6 ; // Code points outside BMP can use up to six digits
0 commit comments