Skip to content

Update PHP-CSS-Parser to v9 - #8213

Open
swissspidy wants to merge 1 commit into
developfrom
try/update-php-css-parser
Open

Update PHP-CSS-Parser to v9#8213
swissspidy wants to merge 1 commit into
developfrom
try/update-php-css-parser

Conversation

@swissspidy

@swissspidy swissspidy commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #

Checklist

  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@swissspidy
swissspidy force-pushed the try/update-php-css-parser branch from ddadc34 to a8d3909 Compare July 17, 2026 13:24
@swissspidy
swissspidy force-pushed the try/update-php-css-parser branch from a8d3909 to f288689 Compare July 17, 2026 14:01
@swissspidy
swissspidy marked this pull request as ready for review July 17, 2026 14:12
Copilot AI review requested due to automatic review settings July 17, 2026 14:12

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

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-parser from 8.5.1 to 9.4.0 (and update lockfile accordingly).
  • Update AMP_Style_Sanitizer integration 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.

Comment thread phpunit.xml.dist
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 thread composer.json
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants