diff --git a/src/Value/Value.php b/src/Value/Value.php index 8de17d7d..63577db9 100644 --- a/src/Value/Value.php +++ b/src/Value/Value.php @@ -3,20 +3,37 @@ namespace Sabberworm\CSS\Value; use Sabberworm\CSS\Parsing\ParserState; +use Sabberworm\CSS\Parsing\SourceException; +use Sabberworm\CSS\Parsing\UnexpectedEOFException; use Sabberworm\CSS\Parsing\UnexpectedTokenException; use Sabberworm\CSS\Renderable; abstract class Value implements Renderable { + /** + * @var int + */ protected $iLineNo; + /** + * @param int $iLineNo + */ public function __construct($iLineNo = 0) { $this->iLineNo = $iLineNo; } + /** + * @param array $aListDelimiters + * + * @return RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string + * + * @throws UnexpectedTokenException + * @throws UnexpectedEOFException + */ public static function parseValue(ParserState $oParserState, array $aListDelimiters = []) { + /** @var array $aStack */ $aStack = []; $oParserState->consumeWhiteSpace(); //Build a list of delimiters and parsed values @@ -43,7 +60,7 @@ public static function parseValue(ParserState $oParserState, array $aListDelimit array_push($aStack, self::parsePrimitiveValue($oParserState)); $oParserState->consumeWhiteSpace(); } - //Convert the list to list objects + // Convert the list to list objects foreach ($aListDelimiters as $sDelimiter) { if (count($aStack) === 1) { return $aStack[0]; @@ -74,6 +91,14 @@ public static function parseValue(ParserState $oParserState, array $aListDelimit return $aStack[0]; } + /** + * @param bool $bIgnoreCase + * + * @return CSSFunction|string + * + * @throws UnexpectedEOFException + * @throws UnexpectedTokenException + */ public static function parseIdentifierOrFunction(ParserState $oParserState, $bIgnoreCase = false) { $sResult = $oParserState->parseIdentifier($bIgnoreCase); @@ -88,6 +113,13 @@ public static function parseIdentifierOrFunction(ParserState $oParserState, $bIg return $sResult; } + /** + * @return CSSFunction|CSSString|LineName|Size|URL|string + * + * @throws UnexpectedEOFException + * @throws UnexpectedTokenException + * @throws SourceException + */ public static function parsePrimitiveValue(ParserState $oParserState) { $oValue = null; @@ -123,6 +155,12 @@ public static function parsePrimitiveValue(ParserState $oParserState) return $oValue; } + /** + * @return CSSFunction + * + * @throws UnexpectedEOFException + * @throws UnexpectedTokenException + */ private static function parseMicrosoftFilter(ParserState $oParserState) { $sFunction = $oParserState->consumeUntil('(', false, true); @@ -130,6 +168,12 @@ private static function parseMicrosoftFilter(ParserState $oParserState) return new CSSFunction($sFunction, $aArguments, ',', $oParserState->currentLine()); } + /** + * @return string + * + * @throws UnexpectedEOFException + * @throws UnexpectedTokenException + */ private static function parseUnicodeRangeValue(ParserState $oParserState) { $iCodepointMaxLenth = 6; // Code points outside BMP can use up to six digits