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
[BUGFIX] Revert broken support for multiple comments
This reverts e4c66f6 (#672), which broke comment parsing in
strict mode.

We'll need to re-implement support for multiple comments later
in a way that does not break the existing comment parsing.

This is the v8.x backport of #740.
  • Loading branch information
oliverklee committed Oct 24, 2024
commit 09635e6e5f1c01e7549bac322cec572a477f9b58
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ This project adheres to [Semantic Versioning](https://semver.org/).
### Fixed

- Fix type errors in PHP strict mode (#695)
- Fix comment parsing to support multiple comments (#671)

## 8.6.0

Expand Down
6 changes: 1 addition & 5 deletions src/Rule/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ public static function parse(ParserState $oParserState)
$oParserState->consume(';');
}

// NOTE: This is a backport to fix comment parsing to support multiple
// comments. This will be rectified in version 9.0.0.
while (preg_match('/\\s/isSu', $oParserState->peek()) === 1) {
$oParserState->consume(1);
}
$oParserState->consumeWhiteSpace();

return $oRule;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1172,11 +1172,14 @@ public function flatCommentExtractingOneComment()
self::assertCount(1, $comments);
self::assertSame("Find Me!", $comments[0]->getComment());
}

/**
* @test
*/
public function flatCommentExtractingTwoComments()
{
self::markTestSkipped('This is currently broken.');

$parser = new Parser('div {/*Find Me!*/left:10px; /*Find Me Too!*/text-align:left;}');
$doc = $parser->parse();
$contents = $doc->getContents();
Expand Down
2 changes: 0 additions & 2 deletions tests/RuleSet/DeclarationBlockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,6 @@ public function canRemoveCommentsFromRulesUsingStrictParsing(
$cssWithComments,
$cssWithoutComments
) {
self::markTestSkipped('This currently crashes, and we need to fix it.');

$parserSettings = ParserSettings::create()->withLenientParsing(false);
$document = (new Parser($cssWithComments, $parserSettings))->parse();

Expand Down