33namespace Sabberworm \CSS \Value ;
44
55use Sabberworm \CSS \Parsing \ParserState ;
6+ use Sabberworm \CSS \Parsing \SourceException ;
7+ use Sabberworm \CSS \Parsing \UnexpectedEOFException ;
68use Sabberworm \CSS \Parsing \UnexpectedTokenException ;
79use Sabberworm \CSS \Renderable ;
810
911abstract class Value implements Renderable
1012{
13+ /**
14+ * @var int
15+ */
1116 protected $ iLineNo ;
1217
18+ /**
19+ * @param int $iLineNo
20+ */
1321 public function __construct ($ iLineNo = 0 )
1422 {
1523 $ this ->iLineNo = $ iLineNo ;
1624 }
1725
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+ */
1834 public static function parseValue (ParserState $ oParserState , array $ aListDelimiters = [])
1935 {
36+ /** @var array<int, RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string> $aStack */
2037 $ aStack = [];
2138 $ oParserState ->consumeWhiteSpace ();
2239 //Build a list of delimiters and parsed values
@@ -43,7 +60,7 @@ public static function parseValue(ParserState $oParserState, array $aListDelimit
4360 array_push ($ aStack , self ::parsePrimitiveValue ($ oParserState ));
4461 $ oParserState ->consumeWhiteSpace ();
4562 }
46- //Convert the list to list objects
63+ // Convert the list to list objects
4764 foreach ($ aListDelimiters as $ sDelimiter ) {
4865 if (count ($ aStack ) === 1 ) {
4966 return $ aStack [0 ];
@@ -74,6 +91,14 @@ public static function parseValue(ParserState $oParserState, array $aListDelimit
7491 return $ aStack [0 ];
7592 }
7693
94+ /**
95+ * @param bool $bIgnoreCase
96+ *
97+ * @return CSSFunction|string
98+ *
99+ * @throws UnexpectedEOFException
100+ * @throws UnexpectedTokenException
101+ */
77102 public static function parseIdentifierOrFunction (ParserState $ oParserState , $ bIgnoreCase = false )
78103 {
79104 $ sResult = $ oParserState ->parseIdentifier ($ bIgnoreCase );
@@ -88,6 +113,13 @@ public static function parseIdentifierOrFunction(ParserState $oParserState, $bIg
88113 return $ sResult ;
89114 }
90115
116+ /**
117+ * @return CSSFunction|CSSString|LineName|Size|URL|string
118+ *
119+ * @throws UnexpectedEOFException
120+ * @throws UnexpectedTokenException
121+ * @throws SourceException
122+ */
91123 public static function parsePrimitiveValue (ParserState $ oParserState )
92124 {
93125 $ oValue = null ;
@@ -123,13 +155,25 @@ public static function parsePrimitiveValue(ParserState $oParserState)
123155 return $ oValue ;
124156 }
125157
158+ /**
159+ * @return CSSFunction
160+ *
161+ * @throws UnexpectedEOFException
162+ * @throws UnexpectedTokenException
163+ */
126164 private static function parseMicrosoftFilter (ParserState $ oParserState )
127165 {
128166 $ sFunction = $ oParserState ->consumeUntil ('( ' , false , true );
129167 $ aArguments = Value::parseValue ($ oParserState , [', ' , '= ' ]);
130168 return new CSSFunction ($ sFunction , $ aArguments , ', ' , $ oParserState ->currentLine ());
131169 }
132170
171+ /**
172+ * @return string
173+ *
174+ * @throws UnexpectedEOFException
175+ * @throws UnexpectedTokenException
176+ */
133177 private static function parseUnicodeRangeValue (ParserState $ oParserState )
134178 {
135179 $ iCodepointMaxLenth = 6 ; // Code points outside BMP can use up to six digits
0 commit comments