Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions config/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ parameters:
count: 1
path: ../src/Rule/Rule.php

-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
identifier: notEqual.notAllowed
count: 1
path: ../src/RuleSet/DeclarationBlock.php

-
message: '#^Parameters should have "string" types as the only types passed to this method$#'
identifier: typePerfect.narrowPublicClassMethodParamType
Expand Down
22 changes: 15 additions & 7 deletions src/RuleSet/DeclarationBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,25 @@ public static function parse(ParserState $parserState, ?CSSList $list = null): ?
$result = new DeclarationBlock($parserState->currentLine());
try {
$selectorParts = [];
$stringWrapperCharacter = null;
do {
$selectorParts[] = $parserState->consume(1)
. $parserState->consumeUntil(['{', '}', '\'', '"'], false, false, $comments);
if (\in_array($parserState->peek(), ['\'', '"'], true) && \substr(\end($selectorParts), -1) != '\\') {
if (!isset($stringWrapperCharacter)) {
$stringWrapperCharacter = $parserState->peek();
} elseif ($stringWrapperCharacter === $parserState->peek()) {
unset($stringWrapperCharacter);
}
$nextCharacter = $parserState->peek();
switch ($nextCharacter) {
case '\'':
// The fallthrough is intentional.
case '"':
if (!\is_string($stringWrapperCharacter)) {
$stringWrapperCharacter = $nextCharacter;
} elseif ($stringWrapperCharacter === $nextCharacter) {
if (\substr(\end($selectorParts), -1) !== '\\') {
$stringWrapperCharacter = null;
}
}
break;
}
} while (!\in_array($parserState->peek(), ['{', '}'], true) || isset($stringWrapperCharacter));
} while (!\in_array($nextCharacter, ['{', '}'], true) || \is_string($stringWrapperCharacter));
$result->setSelectors(\implode('', $selectorParts), $list);
if ($parserState->comes('{')) {
$parserState->consume(1);
Expand Down