Skip to content

[BUGFIX] Allow at-rules to be parsed in strict mode #456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 13, 2024

Conversation

JakeQZ
Copy link
Collaborator

@JakeQZ JakeQZ commented Feb 10, 2024

The reverts the change to CSSList in
134f4e6 and adds a comment that null is an expected return value when the end of the list (or block) is reached.

Fixes #352

@JakeQZ JakeQZ added the bug label Feb 10, 2024
@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 10, 2024

The reverts the change to CSSList

Or at least it should. I found it impossible to copy and paste the previous version of the code from the GitHub diff, so went hunting for a specific version that should have contained the code to restore. Only it didn't. So it was a bit painstaking to actually revert that change. Any tips to speed up the process would be greatly appreciated.

@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 10, 2024

Could not open input file: .\.phive\phpcs.phar

Can't fix this without knowing what the problems are. And, of course, the PHIVE set-up is a total PITA locally on Windows.

@JakeQZ JakeQZ force-pushed the bugfix/strict-at-rule-parsing branch from 2637ac2 to 97a4e27 Compare February 10, 2024 03:46
@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 10, 2024

Could not open input file: .\.phive\phpcs.phar

Can't fix this without knowing what the problems are. And, of course, the PHIVE set-up is a total PITA.

OK, fixed, using info from logs (was an else if instead of elseif).

The reverts the change to `CSSList` in
134f4e6
and adds a comment that `null` is an expected return value when the end of
the list (or block) is reached.

It also adds a convention, for now, that a test filename beginning with `=`
should mean that it is initially tested with strict parsing enabled.

Fixes #352
@JakeQZ JakeQZ force-pushed the bugfix/strict-at-rule-parsing branch from 97a4e27 to bbc2d73 Compare February 10, 2024 04:11
$oParser = new Parser(file_get_contents($sDirectory . '/' . $sFileName));
$oParser = new Parser(
\file_get_contents($sDirectory . '/' . $sFileName),
Settings::create()->withLenientParsing($sFileName[0] !== '=')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of having separate sets of fixtures with "magic" prefixes, I'd prefer to communicate this more clearly to the reader, e.g., with a separate testcase that uses the CSS in the test code instead of reading from files. (After all, one of the purposes of tests is to communicate the intended behavior to the reader).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've moved the new tests to the specific test class responsible. When working within an IDE, having the test content as separate files is no probem, and helps avoid test class files with literally millions of lines to scroll through, which, even if it doesn't cause the computer to break down, is a bit of a PITA.

@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 11, 2024

Can't figure out how to remove the files I added that are no longer wanted.

@JakeQZ JakeQZ marked this pull request as draft February 11, 2024 02:39
@JakeQZ JakeQZ force-pushed the bugfix/strict-at-rule-parsing branch from 5581cb7 to be48242 Compare February 11, 2024 03:01
@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 11, 2024

Can't figure out how to remove the files I added that are no longer wanted.

Non-alphanumeric characters in filenames cause problems in OSs developed in the 1970s, that are still prevelant now. So must be avoided.

@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 11, 2024

I want to convert this from draft to live. But can't find whatever I need to do to do so. Nothing hapens when I click the 'Draft' button.

@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 11, 2024

Change the status to “Ready for review” near the bottom of your pull request to remove the draft state

Nope. Don't see it.

@JakeQZ JakeQZ marked this pull request as ready for review February 11, 2024 03:22
@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 11, 2024

Change the status to “Ready for review” near the bottom of your pull request to remove the draft state

Nope. Don't see it.

Finally found it. What an awful UI. Thank you Microsoft.

JakeQZ and others added 7 commits February 13, 2024 17:36
Co-authored-by: Oliver Klee <github@oliverklee.de>
Co-authored-by: Oliver Klee <github@oliverklee.de>
Co-authored-by: Oliver Klee <github@oliverklee.de>
Co-authored-by: Oliver Klee <github@oliverklee.de>
Co-authored-by: Oliver Klee <github@oliverklee.de>
Co-authored-by: Oliver Klee <github@oliverklee.de>
@JakeQZ JakeQZ self-assigned this Feb 13, 2024
@JakeQZ JakeQZ requested a review from oliverklee February 13, 2024 17:49
Copy link
Collaborator

@oliverklee oliverklee left a comment

Choose a reason for hiding this comment

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

LGTM. 🙏

@oliverklee oliverklee merged commit 3dd89b5 into main Feb 13, 2024
@oliverklee oliverklee deleted the bugfix/strict-at-rule-parsing branch February 13, 2024 17:57
@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 13, 2024

Wondering it we should release an 8.5.1 with this fix, since it was a regression in 8.4.

@oliverklee
Copy link
Collaborator

Yeah, I think backporting it to 8.5.x makes sense. We probably need to change the native type declarations to PHPDoc annotations.

Would you be willing to create the backport PR?

And should we release 8.5.1 directly after merging it, or should we first collect some more fixes?

@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 13, 2024

Yeah, I think backporting it to 8.5.x makes sense. We probably need to change the native type declarations to PHPDoc annotations.

Ah, yes, the 8.x branch supports older PHP versions which don't support native type declerations.

Would you be willing to create the backport PR?

I should hopefully be able to merge the commit to main to a PR branch off the 8.x. Then revert the type hint changes.

And should we release 8.5.1 directly after merging it, or should we first collect some more fixes?

The other outstanding PRs awaiting review mostly don't look straightforward, and may require post-review changes, so may take some time to complete.

I was keen to resolve this issue as a priority since it was a regression. The others aren't, AFAIAA, so it would be on a case-by-case basis whether they can be easily backported once completed on main. So I'd suggest an 8.5.1 with this fix, and some time later when the outstanding PRs have been resolved one way or another, (probably) an 8.5.2 with a rollup of fixes from those.

JakeQZ added a commit that referenced this pull request Feb 13, 2024
The reverts the change to `CSSList` in
134f4e6
and adds a comment that `null` is an expected return value when the end of
the list (or block) is reached.

Fixes #352
oliverklee pushed a commit that referenced this pull request Feb 14, 2024
The reverts the change to `CSSList` in
134f4e6
and adds a comment that `null` is an expected return value when the end of
the list (or block) is reached.

Fixes #352
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@media block gives syntax error
3 participants