Automattic\WooCommerce\Vendor\Sabberworm\CSS\RuleSet

RuleSet::parseRuleSetpublic staticWC 1.0

Method of the class: RuleSet{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = RuleSet::parseRuleSet( $oParserState, $oRuleSet );
$oParserState(ParserState) (required)
.
$oRuleSet(RuleSet) (required)
.

RuleSet::parseRuleSet() code WC 10.8.1

public static function parseRuleSet(ParserState $oParserState, RuleSet $oRuleSet)
{
    while ($oParserState->comes(';')) {
        $oParserState->consume(';');
    }
    while (true) {
        $commentsBeforeRule = $oParserState->consumeWhiteSpace();
        if ($oParserState->comes('}')) {
            break;
        }
        $oRule = null;
        if ($oParserState->getSettings()->bLenientParsing) {
            try {
                $oRule = Rule::parse($oParserState, $commentsBeforeRule);
            } catch (UnexpectedTokenException $e) {
                try {
                    $sConsume = $oParserState->consumeUntil(["\n", ";", '}'], true);
                    // We need to “unfind” the matches to the end of the ruleSet as this will be matched later
                    if ($oParserState->streql(substr($sConsume, -1), '}')) {
                        $oParserState->backtrack(1);
                    } else {
                        while ($oParserState->comes(';')) {
                            $oParserState->consume(';');
                        }
                    }
                } catch (UnexpectedTokenException $e) {
                    // We’ve reached the end of the document. Just close the RuleSet.
                    return;
                }
            }
        } else {
            $oRule = Rule::parse($oParserState, $commentsBeforeRule);
        }
        if ($oRule) {
            $oRuleSet->addRule($oRule);
        }
    }
    $oParserState->consume('}');
}