Update PHP-CSS-Parser to v9 - #8213
Open
swissspidy wants to merge 1 commit into
Open
Conversation
swissspidy
force-pushed
the
try/update-php-css-parser
branch
from
July 17, 2026 13:24
ddadc34 to
a8d3909
Compare
swissspidy
force-pushed
the
try/update-php-css-parser
branch
from
July 17, 2026 14:01
a8d3909 to
f288689
Compare
swissspidy
marked this pull request as ready for review
July 17, 2026 14:12
There was a problem hiding this comment.
Pull request overview
Updates the AMP plugin’s CSS sanitization stack to work with sabberworm/php-css-parser v9.x by upgrading the dependency and adapting sanitizer/test expectations to the parser’s updated APIs and rendering behavior.
Changes:
- Bump
sabberworm/php-css-parserfrom 8.5.1 to 9.4.0 (and update lockfile accordingly). - Update
AMP_Style_Sanitizerintegration for PHP-CSS-Parser v9 APIs (OutputFormat setters, declaration removal/addition, value rendering). - Update PHPUnit config and CSS sanitizer tests to match new rendered CSS output.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
composer.json |
Bumps PHP-CSS-Parser requirement to 9.4.0 and updates the patch source. |
composer.lock |
Locks updated PHP-CSS-Parser version and its new dependency set. |
includes/sanitizers/class-amp-style-sanitizer.php |
Migrates sanitizer logic to PHP-CSS-Parser v9 APIs and adds helper for value-to-string rendering. |
tests/php/test-amp-style-sanitizer.php |
Updates expected minified CSS outputs to align with v9 rendering differences. |
phpunit.xml.dist |
Changes PHPUnit deprecation handling behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| backupGlobals="false" | ||
| colors="true" | ||
| convertDeprecationsToExceptions="true" | ||
| convertDeprecationsToExceptions="false" |
Comment on lines
320
to
324
| '<style>@media (max-width: 450px) { .sidebar { padding: 0; }; } .sidebar { margin: 0 auto; }</style><div class="sidebar"></div>', | ||
| '<div class="sidebar"></div>', | ||
| [ | ||
| '@media (max-width: 450px){.sidebar{padding:0}}.sidebar{margin:0 auto}', | ||
| '@media (max-width: 450px){.sidebar{padding:0}.sidebar{margin:0 auto}}', | ||
| ], |
Comment on lines
82
to
86
| "patches": { | ||
| "sabberworm/php-css-parser": { | ||
| "1. Validate name-start code points for identifier <https://github.com/westonruter/PHP-CSS-Parser/pull/2>": "https://github.com/sabberworm/PHP-CSS-Parser/compare/cc791ad...westonruter:PHP-CSS-Parser:fix/malformed-identifier-without-tests.diff", | ||
| "2. Fix parsing CSS selectors which contain commas <https://github.com/westonruter/PHP-CSS-Parser/pull/1>": "https://github.com/sabberworm/PHP-CSS-Parser/compare/cc791ad...westonruter:PHP-CSS-Parser:fix/selector-comma-parsing-without-tests.diff", | ||
| "3. Parse simple expressions <https://github.com/sabberworm/PHP-CSS-Parser/pull/389>": "https://github.com/sabberworm/PHP-CSS-Parser/compare/cc791ad...westonruter:PHP-CSS-Parser:fix/expression-parsing-without-tests.diff" | ||
| "Port custom patches (strict validation, deep clone, expression parser)": "https://github.com/swissspidy/PHP-CSS-Parser/pull/1.patch" | ||
| } | ||
| } |
Comment on lines
+3811
to
+3816
| private function get_css_value_string( $value ) { | ||
| if ( $value instanceof Renderable ) { | ||
| return $value->render( OutputFormat::createCompact() ); | ||
| } | ||
| return (string) $value; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #
Checklist