Skip to content

Add support for layer declarations ending with semicolon - #1624

Merged
JakeQZ merged 3 commits into
MyIntervals:mainfrom
samuil-banti-wpenigne:add-support-for-layer-declaration-ending-with-semicolon
Aug 28, 2026
Merged

Add support for layer declarations ending with semicolon#1624
JakeQZ merged 3 commits into
MyIntervals:mainfrom
samuil-banti-wpenigne:add-support-for-layer-declaration-ending-with-semicolon

Conversation

@samuil-banti-wpenigne

@samuil-banti-wpenigne samuil-banti-wpenigne commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Semicolon-terminated @layer is valid CSS but was parsed as a block, so later rules were swallowed.

@layer has two forms (CSS Cascade 5):

@layer reset;
@layer base, components;
@layer theme { .button { color: blue; } }

Generic at-rule parsing always searched for {. For @layer reset;, that meant consuming through the next { (e.g. @property), so the rest of the stylesheet was treated as nested contents of a fake layer block.

Fix: stop at { or ;. A ; becomes AtRuleStatement; a { still becomes AtRuleBlockList or AtRuleSet. layer stays in BLOCK_RULES, so @layer theme { … } is unchanged.

@samuil-banti-wpenigne
samuil-banti-wpenigne marked this pull request as draft August 27, 2026 07:30
@coveralls

coveralls commented Aug 27, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 75.842% (+0.4%) from 75.487% — samuil-banti-wpenigne:add-support-for-layer-declaration-ending-with-semicolon into MyIntervals:main

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for semicolon-terminated at-rules without consuming subsequent CSS rules.

Changes:

  • Adds AtRuleStatement parsing and rendering.
  • Preserves block-form @layer behavior.
  • Adds unit and parser regression tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/CSSList/CSSList.php Distinguishes statement and block at-rules.
src/Property/AtRuleStatement.php Represents semicolon-terminated at-rules.
tests/CSSList/AtRuleStatementTest.php Tests parsing and rule boundaries.
tests/Unit/Property/AtRuleStatementTest.php Tests the new representation.
CHANGELOG.md Documents the fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/CSSList/CSSList.php
// Unknown other at rule (font-face or such)
$arguments = \trim($parserState->consumeUntil('{', false, true));
// Unknown other at rule (font-face, @layer, or such)
$arguments = \trim($parserState->consumeUntil(['{', ';'], false, false));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same with {. Fixing it is beyond the scope of this PR. #1625 added.

@JakeQZ JakeQZ left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. Excellent contribution @samuil-banti-wpenigne. Hard to pick any holes in that.

The functional tests for the new class should be in a different location (and namespace), and I don't think we need a changelog entry that tests have been added.

Otherwise, looks perfect. Thank you so much, particularly for taking the time to understand the codebase.

@oliverklee, do you have any other nitpicks?

Comment thread tests/CSSList/AtRuleStatementTest.php Outdated
Comment thread CHANGELOG.md Outdated
@JakeQZ JakeQZ added the bug label Aug 28, 2026

@JakeQZ JakeQZ left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now. One of the best PR submissions we've ever had. Thank you.

@oliverklee, anything else to pick up on?

phar.io server is currently down, causing failing checks...

@oliverklee

Copy link
Copy Markdown
Collaborator

@JakeQZ I most probably won't have time to look at this today or tomorrow, and I don't want to block this. So feel free to merge in the meantime.

@JakeQZ

JakeQZ commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

@JakeQZ I most probably won't have time to look at this today or tomorrow, and I don't want to block this. So feel free to merge in the meantime.

OK. Happy to do so so that people can pick up the -dev branch. The code change looks solid, the new class located with its siblings (which may all be relocated at some point), and the tests good.

The only thing I can think of that might be falling short is whether the tests cover every eventuality and format of at-rules. But they never will - there's always an edge case that has been missed. AI was surprisingly smart at picking up the pre-existing lack of string parsing, which has been logged as #1625. Any other issues found can be resolved as a follow-up.

Thanks again @samuil-banti-wpenigne for your excellent contribution.

@JakeQZ
JakeQZ merged commit 5556bcd into MyIntervals:main Aug 28, 2026
42 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants