Automattic\WooCommerce\Vendor\Sabberworm\CSS\RuleSet
DeclarationBlock::parse
Method of the class: DeclarationBlock{}
No Hooks.
Returns
DeclarationBlock|false.
Usage
$result = DeclarationBlock::parse( $oParserState, $oList );
- $oParserState(ParserState) (required)
- .
- $oList(CSSList|null)
- .
Default:null
DeclarationBlock::parse() DeclarationBlock::parse code WC 10.5.0
public static function parse(ParserState $oParserState, $oList = null)
{
$aComments = [];
$oResult = new DeclarationBlock($oParserState->currentLine());
try {
$aSelectorParts = [];
$sStringWrapperChar = false;
do {
$aSelectorParts[] = $oParserState->consume(1)
. $oParserState->consumeUntil(['{', '}', '\'', '"'], false, false, $aComments);
if (in_array($oParserState->peek(), ['\'', '"']) && substr(end($aSelectorParts), -1) != "\\") {
if ($sStringWrapperChar === false) {
$sStringWrapperChar = $oParserState->peek();
} elseif ($sStringWrapperChar == $oParserState->peek()) {
$sStringWrapperChar = false;
}
}
} while (!in_array($oParserState->peek(), ['{', '}']) || $sStringWrapperChar !== false);
$oResult->setSelectors(implode('', $aSelectorParts), $oList);
if ($oParserState->comes('{')) {
$oParserState->consume(1);
}
} catch (UnexpectedTokenException $e) {
if ($oParserState->getSettings()->bLenientParsing) {
if (!$oParserState->comes('}')) {
$oParserState->consumeUntil('}', false, true);
}
return false;
} else {
throw $e;
}
}
$oResult->setComments($aComments);
RuleSet::parseRuleSet($oParserState, $oResult);
return $oResult;
}