NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist · #165 most downloaded on Packagist
Parser for CSS Files written in PHP
Last release 17 days ago
20 Sep 2026
Ships fairly regularly
a new release about every 4 months
Most releases are documented
notes for 40 of 54 stable releases
Nothing withdrawn
no release was ever pulled
14 years old
54 releases · first in 2012
Remove the thecodingmachine/safe dependency
thecodingmachine/safe dependency (#1622)@layer statements (and other statement at-rules){ (#1624)Full Changelog: v9.4.0...v9.5.0
One column per quarter.
Deprecate support for PHP 7.2 and 7.3
LineName components (#1590)Full Changelog: v9.3.0...v9.4.0
Add support for modern CSS at-rules: @layer , @scope , and @starting-style
@layer, @scope, and @starting-style (#1549)Full Changelog: v9.2.0...v9.3.0
RuleSet\RuleContainer is deprecated; use RuleSet\DeclarationList instead
OutputFormat::setSpaceAroundSelectorCombinator() (#1504)RuleSet\RuleContainer is renamed to RuleSet\DeclarationList (#1530, #1539)setRule() in RuleSet and DeclarationBlock have been renamedsetDeclaration(), etc. (#1521)Rule\Rule class is renamed to Property\DeclarationRule::setRule() and getRule() are replaced with setPropertyName() andgetPropertyName() (#1506)Selector is now represented as a sequence of Selector\Component objectsgetComponents(), manipulated individually, or setsetComponents() (#1478, #1486, #1487, #1488, #1494, #1496, #1536, #1537)Selector::setSelector() and Selector constructor will now throw exceptionDeclarationBlock::setSelectors() are no longerRuleSet\RuleContainer is deprecated; use RuleSet\DeclarationList insteadsetRule() in RuleSet and DeclarationBlock are deprecated;setDeclaration() (#1521)Rule\Rule class is deprecated; Property\Declaration is a directRule::setRule() and getRule() are deprecated and replaced withsetPropertyName() and getPropertyName() (#1506, #1519)} is encountered (#1425, #1426)DeclarationBlock::setSelectors() (#1419)removeDeclarationBlockBySelector() to be order-insensitve (#1406)calc expressions when a newline immediately precedes or+ or - operator (#1399)Full Changelog: v9.1.0...v9.2.0
Improve performance of selector validation (avoiding silent PCRE catastrophic failure)
Add an API and deprecation policy
RuleContainer for RuleSet Rule manipulation methods (#1256)DeclarationBlock no longer extends RuleSet and instead has a RuleSet asgetRuleSet() to access it directly (#1194)null (not zero) (#1288)setPosition() (in Rule and other classes) now has fluent interface,RuleSet::removeRule() now only allows Rule as the parameterAtRuleSet and DeclarationBlock);removeMatchingRules() or removeAllRules() for other functions (#1255)RuleSet::getRules() and getRulesAssoc() now only allow string or nullAtRuleSet and DeclarationBlock)KeyFrame properties to sensible defaults (#1146)OutputFormat final (#1128)Selector a Renderable (#1017)string for some OutputFormat properties (#885)getLineNo() from these classes (use getLineNumber() instead):Comment, CSSList, SourceException, Charset, CSSNamespace, Import,Rule, DeclarationBlock, RuleSet, CSSFunction, Value (#1258)Rule::getColNo() (use getColumnNumber() instead) (#1287)getAllValues() is no longergetAllValues() is no longer__toString() (#1046)OutputFormat (#898)atRuleArgs() from the AtRule interface (#1141)OutputFormat::get() and ::set() (#1108, #1110)Rule (#995)getLineNo() from the Renderable interface (#1038)OutputFormat::level() (#874)Parser::setCharset/getCharset (#808)Rule::getValues() (#582)Rule::setValues() (#562)Document::getAllSelectors() (#561)DeclarationBlock::getSelector() (#559)DeclarationBlock::setSelector() (#560)OutputFormat (#1345):not) with comma-separated arguments (#1292):not(html, body)) (#1293)Rule before sibling even with different property nameRuleSet::addRule()) (#1270)RuleSet::addRule() sets non-negative column number when siblingrgb colors with percentage values using hex notation (#803)@ziegenberg is a new contributor to this release and did a lot of the heavy
lifting. Thanks! ❤️
Support for PHP < 7.2 is deprecated; version 9.0 will require PHP 7.2 or later
RuleSet::removeMatchingRules() methodAtRuleSet and DeclarationBlock) (#1249)RuleSet::removeAllRules() methodAtRuleSet and DeclarationBlock) (#1249)CSSElement (#1231)getLineNumber and getColumnNumber which return a nullable intComment, CSSList, SourceException, Charset, CSSNamespace, Import,Rule, DeclarationBlock, RuleSet, CSSFunction, Value (#1225, #1263)Positionable interface for CSS items that may have a positiongetAllValues() are deconflated, so it now takes three (all$element and $ruleSearchPattern to be specifiedPositionable in the following CSS item classes:Comment, CSSList, SourceException, Charset, CSSNamespace, Import,Rule, DeclarationBlock, RuleSet, CSSFunction, Value (#1225)string or null to RuleSet::removeRule() is deprecatedAtRuleSet and DeclarationBlock);removeMatchingRules() or removeAllRules() instead (#1249)Rule to RuleSet::getRules() or getRulesAssoc() is deprecated,AtRuleSet and DeclarationBlockgetRules($rule->getRule()) instead) (#1248)getAllValues() is deprecated;getAllValues() is deprecated;getLineNo() is deprecated in these classes (use getLineNumber() instead):Comment, CSSList, SourceException, Charset, CSSNamespace, Import,Rule, DeclarationBlock, RuleSet, CSSFunction, Value (#1225, #1233)Rule::getColNo() is deprecated (use getColumnNumber() instead)Rule::setPosition() isnull instead if there is no line number) (#1225, #1233)Deprecate extending OutputFormat
OutputFormat properties for space around specific list separators (#880)OutputFormat constructor as @internal (#1131)OutputFormatter as @internal (#896)Selector::isValid() as @internal (#1037)@internal (#908)OutputFormat::nextLevel() as @internal (#901)@internal (#886)OutputFormat (#1131)OutputFormat::get() and ::set() (#1107)-webkit-calc and -moz-calc (#1086)OutputFormat to OutputFormatter__toString() (#1006)Rule (#993, #1003)OutputFormat properties for space around list separators as an array (#880)OutputFormat::level() (#870)Deprecate the expansion of shorthand properties
@internal (#674)Parser::setCharset() and Parser::getCharset() (#688)Support arithmetic operators in CSS function arguments
Mark all class constants as @internal
@internal (#472)CalcFunction::parse() (#593)Fix PHP notice caused by parsing invalid color values having less than 6 characters
Add a method to get an import's media queries
turns unit with turn (#350)ParserState::strsplit() (#344)No longer use eval for the comparison in getSelectorsBySpecificity, in case it gets passed untrusted input (CVE-2020-13756). Also fixed in 8.3.1, 8.2.…
calc()vminCSSList#replace%@importeval for the comparison in getSelectorsBySpecificity, in
case it gets passed untrusted input (CVE-2020-13756). Also fixed in 8.3.1,
8.2.1, 8.1.1, 8.0.1, 7.0.4, 6.0.2, 5.2.1, 5.1.3, 5.0.9, 4.0.1, 3.0.1, 2.0.1,
1.0.1.vmNothing published for this version
Refactor parsing logic to mostly reside in the class files whose data structure is to be parsed (this should eventually allow us to unit-test specific
calc expessions when the first operand is a negative
number, thanks to @raxbg.Nothing published for this version
Support parsing calc(), thanks to @raxbg.
calc(), thanks to @raxbg.progid:) in lenient mode, thanks to
@FMCorzNothing published for this version
Comments are no longer silently ignored but stored with the object with which they appear (no render support, though). Thanks to @FMCorz.
\0 and \9 can now be parsed (and rendered) in lenient
mode. Thanks (again) to @FMCorz.Nothing published for this version
Store source CSS line numbers in tokens and parsing exceptions.
Sabberworm\CSS\Parsing\SourceException instead of \Exception.Nothing published for this version
Fixed parsing empty CSS when multibyte is off
150 time performance boost thanks to @ossinkine
*No backwards-incompatible changes*
E_NOTICECompatibility with PHP 7. Well timed, eh?
Sabberworm\CSS\Value\String class has been renamed to
Sabberworm\CSS\Value\CSSString.Nothing published for this version
Remove some declarations in interfaces incompatible with PHP 5.3 (< 5.3.9)
Format output using Sabberworm\CSS\OutputFormat
Nothing published for this version
Support removing a selector from a declaration block using $oBlock->removeSelector($mSelector)
Support removing a selector from a declaration block using
$oBlock->removeSelector($mSelector)
Introduce a specialized exception (Sabberworm\CSS\Parsing\OuputException) for exceptions during output rendering
No deprecations
{…} into the CSS document.Nothing published for this version
Remove the use of consumeUntil in comment parsing. This makes it possible to parse comments such as / Perfectly valid /
/** Perfectly valid **/Updated CHANGELOG.md to reflect changes since 5.0.4
Performance enhancements by Michael M Slusarz
Nothing published for this version
Make default settings’ multibyte parsing option dependent on whether or not the mbstring extension is actually installed.
Fix broken decimal point output optimization
*No backwards-incompatible changes*
Initial support for lenient parsing (setting this parser option will catch some exceptions internally and recover the parser’s state as neatly as poss
Don’t output floats with locale-aware separator chars
*No backwards-incompatible changes*
CHANGELOG.md file added to distribution
*No backwards-incompatible changes*
Correctly parse all known CSS 3 units (including Hz and kHz).
Sabberworm\CSS\Value\Color’s __toString method overrides CSSList’s to
maybe return something other than type(value, …) (see above).Nothing published for this version
Generic interface Sabberworm\CSS\Property\AtRule, implemented by all @-rule classes
Sabberworm\CSS\Property\AtRule, implemented by all @-rule
classesSabberworm\CSS\RuleSet\AtRule renamed to Sabberworm\CSS\RuleSet\AtRuleSetSabberworm\CSS\CSSList\MediaQuery renamed to
Sabberworm\CSS\RuleSet\CSSList\AtRuleBlockList with differing semantics and
API (which also works for other block-list-based @-rules like @supports).Nothing published for this version
Support for lenient parsing (on by default)
mb_-functions, which default
charset to use and – new – whether or not to be forgiving when parsing) are
now encapsulated in an instance of Sabberworm\CSS\Settings which can be
passed as the second argument to Sabberworm\CSS\Parser->__construct().Sabberworm\CSS\Parser->__construct() is no longer supported. Use
Sabberworm\CSS\Settings::create()->withDefaultCharset('some-charset')
instead.Sabberworm\CSS\Parser->bUseMbFunctions has no effect. Use
Sabberworm\CSS\Settings::create()->withMultibyteSupport(true/false) instead.Sabberworm\CSS\Parser->parse() may throw a
Sabberworm\CSS\Parsing\UnexpectedTokenException when in strict parsing mode.Nothing published for this version
Allow multiple rules of the same type per rule set
Sabberworm\CSS\RuleSet->getRules() returns an index-based array instead of
an associative array. Use Sabberworm\CSS\RuleSet->getRulesAssoc() (which
eliminates duplicate rules and lets the later rule of the same name win).Sabberworm\CSS\RuleSet->removeRule() works as it did before except when
passed an instance of Sabberworm\CSS\Rule\Rule, in which case it would only
remove the exact rule given instead of all the rules of the same type. To get
the old behaviour, use Sabberworm\CSS\RuleSet->removeRule($oRule->getRule();Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →