All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
Please also have a look at our API and deprecation policy.
- Add Interface
CSSElement
(#1231) - Methods
getLineNumber
andgetColumnNumber
which return a nullableint
for the following classes:Comment
,CSSList
,SourceException
,Charset
,CSSNamespace
,Import
,Rule
,DeclarationBlock
,RuleSet
,CSSFunction
,Value
(#1225) Positionable
interface for CSS items that may have a position (line and perhaps column number) in the parsed CSS (#1221)- Partial support for CSS Color Module Level 4:
rgb
andrgba
, andhsl
andhsla
are now aliases (#797}- Parse color functions that use the "modern" syntax (#800)
- Render RGB functions with "modern" syntax when required (#840)
- Support
none
as color function component value (#859)
- Add a class diagram to the README (#482)
- Add more tests (#449)
- Parameters for
getAllValues()
are deconflated, so it now takes three (all optional), allowing$element
and$ruleSearchPattern
to be specified separately (#1241) - Implement
Positionable
in the following CSS item classes:Comment
,CSSList
,SourceException
,Charset
,CSSNamespace
,Import
,Rule
,DeclarationBlock
,RuleSet
,CSSFunction
,Value
(#1225) - Initialize
KeyFrame
properties to sensible defaults (#1146) - Make
OutputFormat
final
(#1128) - Make
Selector
aRenderable
(#1017) - Only allow
string
for someOutputFormat
properties (#885) - Use more native type declarations and strict mode (#641, #772, #774, #778, #804, #841, #873, #875, #891, #922, #923, #933, #958, #964, #967, #1000, #1044, #1134, #1136, #1137, #1139, #1140, #1141, #1145, #1162, #1163, #1166, #1172, #1174, #1178, #1179, #1181, #1183, #1184, #1186, #1187, #1190, #1192, #1193, #1203)
- Add visibility to all class/interface constants (#469)
- Passing a string as the first argument to
getAllValues()
is deprecated; the search pattern should now be passed as the second argument (#1241) - Passing a Boolean as the second argument to
getAllValues()
is deprecated; the flag for searching in function arguments should now be passed as the third argument (#1241) getLineNo()
is deprecated in these classes (usegetLineNumber()
instead):Comment
,CSSList
,SourceException
,Charset
,CSSNamespace
,Import
,Rule
,DeclarationBlock
,RuleSet
,CSSFunction
,Value
(#1225, #1233)Rule::getColNo()
is deprecated (usegetColumnNumber()
instead) (#1225, #1233)- Providing zero as the line number argument to
Rule::setPosition()
is deprecated (passnull
instead if there is no line number) (#1225, #1233)
- Passing a string as the first argument to
getAllValues()
is no longer supported and will not work; the search pattern should now be passed as the second argument (#1243) - Passing a Boolean as the second argument to
getAllValues()
is no longer supported and will not work; the flag for searching in function arguments should now be passed as the third argument (#1243) - Remove
__toString()
(#1046) - Drop magic method forwarding in
OutputFormat
(#898) - Drop
atRuleArgs()
from theAtRule
interface (#1141) - Remove
OutputFormat::get()
and::set()
(#1108, #1110) - Drop special support for vendor prefixes (#1083)
- Remove the IE hack in
Rule
(#995) - Drop
getLineNo()
from theRenderable
interface (#1038) - Remove
OutputFormat::level()
(#874) - Remove expansion of shorthand properties (#838)
- Remove
Parser::setCharset/getCharset
(#808) - Remove
Rule::getValues()
(#582) - Remove
Rule::setValues()
(#562) - Remove
Document::getAllSelectors()
(#561) - Remove
DeclarationBlock::getSelector()
(#559) - Remove
DeclarationBlock::setSelector()
(#560) - Drop support for PHP < 7.2 (#420)
- Don't render
rgb
colors with percentage values using hex notation (#803)
- Add an API and deprecation policy (#720)
@ziegenberg is a new contributor to this release and did a lot of the heavy lifting. Thanks! ❤️
OutputFormat
properties for space around specific list separators (#880)
- Mark the
OutputFormat
constructor as@internal
(#1131) - Mark
OutputFormatter
as@internal
(#896) - Mark
Selector::isValid()
as@internal
(#1037) - Mark parsing-related methods of most CSS elements as
@internal
(#908) - Mark
OutputFormat::nextLevel()
as@internal
(#901) - Make all non-private properties
@internal
(#886)
- Deprecate extending
OutputFormat
(#1131) - Deprecate
OutputFormat::get()
and::set()
(#1107) - Deprecate support for
-webkit-calc
and-moz-calc
(#1086) - Deprecate magic method forwarding from
OutputFormat
toOutputFormatter
(#894) - Deprecate
__toString()
(#1006) - Deprecate greedy calculation of selector specificity (#1018)
- Deprecate the IE hack in
Rule
(#993, #1003) OutputFormat
properties for space around list separators as an array (#880)- Deprecate
OutputFormat::level()
(#870)
- Include comments for all rules in declaration block (#1169)
- Render rules in line and column number order (#1059)
- Create
Size
with correct types inexpandBackgroundShorthand
(#814) - Parse
@font-face
src
property as comma-delimited list (#794)
- Add support for PHP 8.4 (#643, #657)
- Mark parsing-internal classes and methods as
@internal
(#674) - Block installations on unsupported higher PHP versions (#691)
- Deprecate the expansion of shorthand properties (#578, #580, #579, #577, #576, #575, #574, #573, #572, #571, #570, #569, #566, #567, #558, #714)
- Deprecate
Parser::setCharset()
andParser::getCharset()
(#688)
- Fix type errors in PHP strict mode (#664)
- Support arithmetic operators in CSS function arguments (#607)
- Add support for inserting an item in a CSS list (#545)
- Add support for the
dvh
,lvh
andsvh
length units (#415)
- Improve performance of
Value::parseValue
with many delimiters by refactoring to removearray_search()
(#413)
- Mark all class constants as
@internal
(#472)
- Fix undefined local variable in
CalcFunction::parse()
(#593)
- Fix PHP notice caused by parsing invalid color values having less than 6 characters (#485)
- Fix (regression) failure to parse at-rules with strict parsing (#456)
- Add a method to get an import's media queries (#384)
- Add more unit tests (#381, #382)
- Retain CSSList and Rule comments when rendering CSS (#351)
- Replace invalid
turns
unit withturn
(#350) - Also allow string values for rules (#348)
- Fix invalid calc parsing (#169)
- Handle scientific notation when parsing sizes (#179)
- Fix PHP 8.1 compatibility in
ParserState::strsplit()
(#344)
- Support for PHP 8.x
- PHPDoc annotations
- Allow usage of CSS variables inside color functions (by parsing them as regular functions)
- Use PSR-12 code style
- No deprecations
- Improved handling of whitespace in
calc()
- Fix parsing units whose prefix is also a valid unit, like
vmin
- Allow passing an object to
CSSList#replace
- Fix PHP 7.3 warnings
- Correctly parse keyframes with
%
- Don’t convert large numbers to scientific notation
- Allow a file to end after an
@import
- Preserve case of CSS variables as specced
- Allow identifiers to use escapes the same way as strings
- No longer use
eval
for the comparison ingetSelectorsBySpecificity
, 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. - Prevent an infinite loop when parsing invalid grid line names
- Remove invalid unit
vm
- Retain rule order after expanding shorthands
- PHP ≥ 5.6 is now required
- HHVM compatibility target dropped
- 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 parts of the parsing logic individually).
- Fix error in parsing
calc
expessions when the first operand is a negative number, thanks to @raxbg. - Support parsing CSS4 colors in hex notation with alpha values, thanks to @raxbg.
- Swallow more errors in lenient mode, thanks to @raxbg.
- Allow specifying arbitrary strings to output before and after declaration blocks, thanks to @westonruter.
- No backwards-incompatible changes
- No deprecations
- Support parsing
calc()
, thanks to @raxbg. - Support parsing grid-lines, again thanks to @raxbg.
- Support parsing legacy IE filters (
progid:
) in lenient mode, thanks to @FMCorz - Performance improvements parsing large files, again thanks to @FMCorz
- No backwards-incompatible changes
- No deprecations
- Comments are no longer silently ignored but stored with the object with which they appear (no render support, though). Thanks to @FMCorz.
- The IE hacks using
\0
and\9
can now be parsed (and rendered) in lenient mode. Thanks (again) to @FMCorz. - Media queries with or without spaces before the query are parsed. Still no real parsing support, though. Sorry…
- PHPUnit is now listed as a dev-dependency in composer.json.
- No backwards-incompatible changes
- No deprecations
- Store source CSS line numbers in tokens and parsing exceptions.
- No deprecations
- Unrecoverable parser errors throw an exception of type
Sabberworm\CSS\Parsing\SourceException
instead of\Exception
.
- Fixed parsing empty CSS when multibyte is off
- No backwards-incompatible changes
- No deprecations
- 150 time performance boost thanks to @ossinkine
- No backwards-incompatible changes
- No deprecations
- No more suppressed
E_NOTICE
- No backwards-incompatible changes
- No deprecations
- Compatibility with PHP 7. Well timed, eh?
- No deprecations
- The
Sabberworm\CSS\Value\String
class has been renamed toSabberworm\CSS\Value\CSSString
.
- Remove some declarations in interfaces incompatible with PHP 5.3 (< 5.3.9)
- No deprecations
- Format output using Sabberworm\CSS\OutputFormat
- No backwards-incompatible changes
- The parse() method replaces __toString with an optional argument (instance of the OutputFormat class)
-
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
- Outputting a declaration block that has no selectors throws an OuputException
instead of outputting an invalid
{…}
into the CSS document.
- Remove the use of consumeUntil in comment parsing. This makes it possible to
parse comments such as
/** Perfectly valid **/
- Add fr relative size unit
- Fix some issues with HHVM
- No backwards-incompatible changes
- No deprecations
- Updated CHANGELOG.md to reflect changes since 5.0.4
- No backwards-incompatible changes
- No deprecations
- Performance enhancements by Michael M Slusarz
- More rescue entry points for lenient parsing (unexpected tokens between declaration blocks and unclosed comments)
- No backwards-incompatible changes
- No deprecations
- Make default settings’ multibyte parsing option dependent on whether or not the mbstring extension is actually installed.
- No backwards-incompatible changes
- No deprecations
- Fix broken decimal point output optimization
- No backwards-incompatible changes
- No deprecations
- Fix broken unit test
- No backwards-incompatible changes
- No deprecations
- Initial support for lenient parsing (setting this parser option will catch some exceptions internally and recover the parser’s state as neatly as possible).
- No backwards-incompatible changes
- No deprecations
- Don’t output floats with locale-aware separator chars
- No backwards-incompatible changes
- No deprecations
- More size units recognized
- No backwards-incompatible changes
- No deprecations
- CHANGELOG.md file added to distribution
- No backwards-incompatible changes
- No deprecations
- Internal cleanup
- No backwards-incompatible changes
- No deprecations
- Correctly parse all known CSS 3 units (including Hz and kHz).
- Output RGB colors in short (#aaa or #ababab) notation
- Be case-insensitive when parsing identifiers.
- No deprecations
Sabberworm\CSS\Value\Color
’s__toString
method overridesCSSList
’s to maybe return something other thantype(value, …)
(see above).
- Support for more @-rules
- Generic interface
Sabberworm\CSS\Property\AtRule
, implemented by all @-rule classes - No deprecations
Sabberworm\CSS\RuleSet\AtRule
renamed toSabberworm\CSS\RuleSet\AtRuleSet
Sabberworm\CSS\CSSList\MediaQuery
renamed toSabberworm\CSS\RuleSet\CSSList\AtRuleBlockList
with differing semantics and API (which also works for other block-list-based @-rules like@supports
).
- Support for lenient parsing (on by default)
- No deprecations
- All properties (like whether or not to use
mb_
-functions, which default charset to use and – new – whether or not to be forgiving when parsing) are now encapsulated in an instance ofSabberworm\CSS\Settings
which can be passed as the second argument toSabberworm\CSS\Parser->__construct()
. - Specifying a charset as the second argument to
Sabberworm\CSS\Parser->__construct()
is no longer supported. UseSabberworm\CSS\Settings::create()->withDefaultCharset('some-charset')
instead. - Setting
Sabberworm\CSS\Parser->bUseMbFunctions
has no effect. UseSabberworm\CSS\Settings::create()->withMultibyteSupport(true/false)
instead. Sabberworm\CSS\Parser->parse()
may throw aSabberworm\CSS\Parsing\UnexpectedTokenException
when in strict parsing mode.
- Allow multiple rules of the same type per rule set
Sabberworm\CSS\RuleSet->getRules()
returns an index-based array instead of an associative array. UseSabberworm\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 ofSabberworm\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, useSabberworm\CSS\RuleSet->removeRule($oRule->getRule()
;
Initial release of a stable public API.
Last version not to use PSR-0 project organization semantics.