{"id":13623748,"url":"https://github.com/MyIntervals/PHP-CSS-Parser","last_synced_at":"2025-04-15T20:32:14.107Z","repository":{"id":1030539,"uuid":"858754","full_name":"MyIntervals/PHP-CSS-Parser","owner":"MyIntervals","description":"A Parser for CSS Files written in PHP. Allows extraction of CSS files into a data structure, manipulation of said structure and output as (optimized) CSS","archived":false,"fork":false,"pushed_at":"2025-04-09T16:40:16.000Z","size":2906,"stargazers_count":1786,"open_issues_count":150,"forks_count":144,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-04-09T17:37:41.656Z","etag":null,"topics":["composer-package","css","hacktoberfest","parser"],"latest_commit_sha":null,"homepage":"http://www.sabberworm.com/blog/2010/6/10/php-css-parser","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MyIntervals.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-08-24T09:39:55.000Z","updated_at":"2025-04-09T16:40:18.000Z","dependencies_parsed_at":"2023-02-18T03:01:28.788Z","dependency_job_id":"e56156cd-6ab9-4f40-9e89-3bfd2576ebe8","html_url":"https://github.com/MyIntervals/PHP-CSS-Parser","commit_stats":{"total_commits":768,"total_committers":45,"mean_commits":"17.066666666666666","dds":0.6796875,"last_synced_commit":"3d8e6b68c73a4de6991800ddf9565700eeb1b2f8"},"previous_names":["sabberworm/php-css-parser"],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyIntervals%2FPHP-CSS-Parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyIntervals%2FPHP-CSS-Parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyIntervals%2FPHP-CSS-Parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyIntervals%2FPHP-CSS-Parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MyIntervals","download_url":"https://codeload.github.com/MyIntervals/PHP-CSS-Parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248361892,"owners_count":21091007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer-package","css","hacktoberfest","parser"],"created_at":"2024-08-01T21:01:35.223Z","updated_at":"2025-04-15T20:32:14.077Z","avatar_url":"https://github.com/MyIntervals.png","language":"PHP","readme":"# PHP CSS Parser\n\n[![Build Status](https://github.com/MyIntervals/PHP-CSS-Parser/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/MyIntervals/PHP-CSS-Parser/actions/)\n[![Coverage Status](https://coveralls.io/repos/github/MyIntervals/PHP-CSS-Parser/badge.svg?branch=main)](https://coveralls.io/github/MyIntervals/PHP-CSS-Parser?branch=main)\n\nA Parser for CSS Files written in PHP. Allows extraction of CSS files into a data structure, manipulation of said structure and output as (optimized) CSS.\n\n## Usage\n\n### Installation using Composer\n\n```bash\ncomposer require sabberworm/php-css-parser\n```\n\n### Extraction\n\nTo use the CSS Parser, create a new instance. The constructor takes the following form:\n\n```php\nnew \\Sabberworm\\CSS\\Parser($css);\n```\n\nTo read a file, for example, you’d do the following:\n\n```php\n$parser = new \\Sabberworm\\CSS\\Parser(file_get_contents('somefile.css'));\n$cssDocument = $parser-\u003eparse();\n```\n\nThe resulting CSS document structure can be manipulated prior to being output.\n\n### Options\n\n#### Charset\n\nThe charset option will only be used if the CSS file does not contain an `@charset` declaration. UTF-8 is the default, so you won’t have to create a settings object at all if you don’t intend to change that.\n\n```php\n$settings = \\Sabberworm\\CSS\\Settings::create()\n    -\u003ewithDefaultCharset('windows-1252');\n$parser = new \\Sabberworm\\CSS\\Parser($css, $settings);\n```\n\n#### Strict parsing\n\nTo have the parser throw an exception when encountering invalid/unknown constructs (as opposed to trying to ignore them and carry on parsing), supply a thusly configured `\\Sabberworm\\CSS\\Settings` object:\n\n```php\n$parser = new \\Sabberworm\\CSS\\Parser(\n    file_get_contents('somefile.css'),\n    \\Sabberworm\\CSS\\Settings::create()-\u003ebeStrict()\n);\n```\n\nNote that this will also disable a workaround for parsing the unquoted variant of the legacy IE-specific `filter` rule.\n\n#### Disable multibyte functions\n\nTo achieve faster parsing, you can choose to have PHP-CSS-Parser use regular string functions instead of `mb_*` functions. This should work fine in most cases, even for UTF-8 files, as all the multibyte characters are in string literals. Still it’s not recommended using this with input you have no control over as it’s not thoroughly covered by test cases.\n\n```php\n$settings = \\Sabberworm\\CSS\\Settings::create()-\u003ewithMultibyteSupport(false);\n$parser = new \\Sabberworm\\CSS\\Parser($css, $settings);\n```\n\n### Manipulation\n\nThe resulting data structure consists mainly of five basic types: `CSSList`, `RuleSet`, `Rule`, `Selector` and `Value`. There are two additional types used: `Import` and `Charset`, which you won’t use often.\n\n#### CSSList\n\n`CSSList` represents a generic CSS container, most likely containing declaration blocks (rule sets with a selector), but it may also contain at-rules, charset declarations, etc.\n\nTo access the items stored in a `CSSList` – like the document you got back when calling `$parser-\u003eparse()` –, use `getContents()`, then iterate over that collection and use `instanceof` to check whether you’re dealing with another `CSSList`, a `RuleSet`, a `Import` or a `Charset`.\n\nTo append a new item (selector, media query, etc.) to an existing `CSSList`, construct it using the constructor for this class and use the `append($oItem)` method.\n\n#### RuleSet\n\n`RuleSet` is a container for individual rules. The most common form of a rule set is one constrained by a selector. The following concrete subtypes exist:\n\n* `AtRuleSet` – for generic at-rules for generic at-rules which are not covered by specific classes, i.e., not `@import`, `@charset` or `@media`. A common example for this is `@font-face`.\n* `DeclarationBlock` – a `RuleSet` constrained by a `Selector`; contains an array of selector objects (comma-separated in the CSS) as well as the rules to be applied to the matching elements.\n\nNote: A `CSSList` can contain other `CSSList`s (and `Import`s as well as a `Charset`), while a `RuleSet` can only contain `Rule`s.\n\nIf you want to manipulate a `RuleSet`, use the methods `addRule(Rule $rule)`, `getRules()` and `removeRule($rule)` (which accepts either a `Rule` or a rule name; optionally suffixed by a dash to remove all related rules).\n\n#### Rule\n\n`Rule`s just have a string key (the rule) and a `Value`.\n\n#### Value\n\n`Value` is an abstract class that only defines the `render` method. The concrete subclasses for atomic value types are:\n\n* `Size` – consists of a numeric `size` value and a unit.\n* `Color` – colors can be input in the form #rrggbb, #rgb or schema(val1, val2, …) but are always stored as an array of ('s' =\u003e val1, 'c' =\u003e val2, 'h' =\u003e val3, …) and output in the second form.\n* `CSSString` – this is just a wrapper for quoted strings to distinguish them from keywords; always output with double quotes.\n* `URL` – URLs in CSS; always output in `URL(\"\")` notation.\n\nThere is another abstract subclass of `Value`, `ValueList`: A `ValueList` represents a lists of `Value`s, separated by some separation character (mostly `,`, whitespace, or `/`).\n\nThere are two types of `ValueList`s:\n\n* `RuleValueList` – The default type, used to represent all multivalued rules like `font: bold 12px/3 Helvetica, Verdana, sans-serif;` (where the value would be a whitespace-separated list of the primitive value `bold`, a slash-separated list and a comma-separated list).\n* `CSSFunction` – A special kind of value that also contains a function name and where the values are the function’s arguments. Also handles equals-sign-separated argument lists like `filter: alpha(opacity=90);`.\n\n#### Convenience methods\n\nThere are a few convenience methods on `Document` to ease finding, manipulating and deleting rules:\n\n* `getAllDeclarationBlocks()` – does what it says; no matter how deeply nested the selectors are. Aliased as `getAllSelectors()`.\n* `getAllRuleSets()` – does what it says; no matter how deeply nested the rule sets are.\n* `getAllValues()` – finds all `Value` objects inside `Rule`s.\n\n## To-Do\n\n* More convenience methods (like `selectorsWithElement($sId/Class/TagName)`, `attributesOfType($type)`, `removeAttributesOfType($type)`)\n* Real multibyte support. Currently, only multibyte charsets whose first 255 code points take up only one byte and are identical with ASCII are supported (yes, UTF-8 fits this description).\n* Named color support (using `Color` instead of an anonymous string literal)\n\n## Use cases\n\n### Use `Parser` to prepend an ID to all selectors\n\n```php\n$myId = \"#my_id\";\n$parser = new \\Sabberworm\\CSS\\Parser($css);\n$cssDocument = $parser-\u003eparse();\nforeach ($cssDocument-\u003egetAllDeclarationBlocks() as $block) {\n    foreach ($block-\u003egetSelectors() as $selector) {\n        // Loop over all selector parts (the comma-separated strings in a\n        // selector) and prepend the ID.\n        $selector-\u003esetSelector($myId.' '.$selector-\u003egetSelector());\n    }\n}\n```\n\n### Shrink all absolute sizes to half\n\n```php\n$parser = new \\Sabberworm\\CSS\\Parser($css);\n$cssDocument = $parser-\u003eparse();\nforeach ($cssDocument-\u003egetAllValues() as $value) {\n    if ($value instanceof CSSSize \u0026\u0026 !$value-\u003eisRelative()) {\n        $value-\u003esetSize($value-\u003egetSize() / 2);\n    }\n}\n```\n\n### Remove unwanted rules\n\n```php\n$parser = new \\Sabberworm\\CSS\\Parser($css);\n$cssDocument = $parser-\u003eparse();\nforeach($cssDocument-\u003egetAllRuleSets() as $oRuleSet) {\n    // Note that the added dash will make this remove all rules starting with\n    // `font-` (like `font-size`, `font-weight`, etc.) as well as a potential\n    // `font` rule.\n    $oRuleSet-\u003eremoveRule('font-');\n    $oRuleSet-\u003eremoveRule('cursor');\n}\n```\n\n### Output\n\nTo output the entire CSS document into a variable, just use `-\u003erender()`:\n\n```php\n$parser = new \\Sabberworm\\CSS\\Parser(file_get_contents('somefile.css'));\n$cssDocument = $parser-\u003eparse();\nprint $cssDocument-\u003erender();\n```\n\nIf you want to format the output, pass an instance of type `\\Sabberworm\\CSS\\OutputFormat`:\n\n```php\n$format = \\Sabberworm\\CSS\\OutputFormat::create()\n    -\u003eindentWithSpaces(4)-\u003esetSpaceBetweenRules(\"\\n\");\nprint $cssDocument-\u003erender($format);\n```\n\nOr use one of the predefined formats:\n\n```php\nprint $cssDocument-\u003erender(Sabberworm\\CSS\\OutputFormat::createPretty());\nprint $cssDocument-\u003erender(Sabberworm\\CSS\\OutputFormat::createCompact());\n```\n\nTo see what you can do with output formatting, look at the tests in `tests/OutputFormatTest.php`.\n\n## Examples\n\n### Example 1 (At-Rules)\n\n#### Input\n\n```css\n@charset \"utf-8\";\n\n@font-face {\n  font-family: \"CrassRoots\";\n  src: url(\"../media/cr.ttf\");\n}\n\nhtml, body {\n    font-size: 1.6em;\n}\n\n@keyframes mymove {\n    from { top: 0px; }\n    to { top: 200px; }\n}\n\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eStructure (\u003ccode\u003evar_dump()\u003c/code\u003e)\u003c/b\u003e\u003c/summary\u003e\n\n```php\nclass Sabberworm\\CSS\\CSSList\\Document#4 (2) {\n  protected $contents =\u003e\n  array(4) {\n    [0] =\u003e\n    class Sabberworm\\CSS\\Property\\Charset#6 (2) {\n      private $charset =\u003e\n      class Sabberworm\\CSS\\Value\\CSSString#5 (2) {\n        private $string =\u003e\n        string(5) \"utf-8\"\n        protected $lineNumber =\u003e\n        int(1)\n      }\n      protected $lineNumber =\u003e\n      int(1)\n    }\n    [1] =\u003e\n    class Sabberworm\\CSS\\RuleSet\\AtRuleSet#7 (4) {\n      private $type =\u003e\n      string(9) \"font-face\"\n      private $arguments =\u003e\n      string(0) \"\"\n      private $rules =\u003e\n      array(2) {\n        'font-family' =\u003e\n        array(1) {\n          [0] =\u003e\n          class Sabberworm\\CSS\\Rule\\Rule#8 (4) {\n            private $rule =\u003e\n            string(11) \"font-family\"\n            private $value =\u003e\n            class Sabberworm\\CSS\\Value\\CSSString#9 (2) {\n              private $string =\u003e\n              string(10) \"CrassRoots\"\n              protected $lineNumber =\u003e\n              int(4)\n            }\n            private $isImportant =\u003e\n            bool(false)\n            protected $lineNumber =\u003e\n            int(4)\n          }\n        }\n        'src' =\u003e\n        array(1) {\n          [0] =\u003e\n          class Sabberworm\\CSS\\Rule\\Rule#10 (4) {\n            private $rule =\u003e\n            string(3) \"src\"\n            private $value =\u003e\n            class Sabberworm\\CSS\\Value\\URL#11 (2) {\n              private $url =\u003e\n              class Sabberworm\\CSS\\Value\\CSSString#12 (2) {\n                private $string =\u003e\n                string(15) \"../media/cr.ttf\"\n                protected $lineNumber =\u003e\n                int(5)\n              }\n              protected $lineNumber =\u003e\n              int(5)\n            }\n            private $isImportant =\u003e\n            bool(false)\n            protected $lineNumber =\u003e\n            int(5)\n          }\n        }\n      }\n      protected $lineNumber =\u003e\n      int(3)\n    }\n    [2] =\u003e\n    class Sabberworm\\CSS\\RuleSet\\DeclarationBlock#13 (3) {\n      private $selectors =\u003e\n      array(2) {\n        [0] =\u003e\n        class Sabberworm\\CSS\\Property\\Selector#14 (2) {\n          private $selector =\u003e\n          string(4) \"html\"\n          private $specificity =\u003e\n          NULL\n        }\n        [1] =\u003e\n        class Sabberworm\\CSS\\Property\\Selector#15 (2) {\n          private $selector =\u003e\n          string(4) \"body\"\n          private $specificity =\u003e\n          NULL\n        }\n      }\n      private $rules =\u003e\n      array(1) {\n        'font-size' =\u003e\n        array(1) {\n          [0] =\u003e\n          class Sabberworm\\CSS\\Rule\\Rule#16 (4) {\n            private $rule =\u003e\n            string(9) \"font-size\"\n            private $value =\u003e\n            class Sabberworm\\CSS\\Value\\Size#17 (4) {\n              private $size =\u003e\n              double(1.6)\n              private $unit =\u003e\n              string(2) \"em\"\n              private $isColorComponent =\u003e\n              bool(false)\n              protected $lineNumber =\u003e\n              int(9)\n            }\n            private $isImportant =\u003e\n            bool(false)\n            protected $lineNumber =\u003e\n            int(9)\n          }\n        }\n      }\n      protected $lineNumber =\u003e\n      int(8)\n    }\n    [3] =\u003e\n    class Sabberworm\\CSS\\CSSList\\KeyFrame#18 (4) {\n      private $vendorKeyFrame =\u003e\n      string(9) \"keyframes\"\n      private $animationName =\u003e\n      string(6) \"mymove\"\n      protected $contents =\u003e\n      array(2) {\n        [0] =\u003e\n        class Sabberworm\\CSS\\RuleSet\\DeclarationBlock#19 (3) {\n          private $selectors =\u003e\n          array(1) {\n            [0] =\u003e\n            class Sabberworm\\CSS\\Property\\Selector#20 (2) {\n              private $selector =\u003e\n              string(4) \"from\"\n              private $specificity =\u003e\n              NULL\n            }\n          }\n          private $rules =\u003e\n          array(1) {\n            'top' =\u003e\n            array(1) {\n              [0] =\u003e\n              class Sabberworm\\CSS\\Rule\\Rule#21 (4) {\n                private $rule =\u003e\n                string(3) \"top\"\n                private $value =\u003e\n                class Sabberworm\\CSS\\Value\\Size#22 (4) {\n                  private $size =\u003e\n                  double(0)\n                  private $unit =\u003e\n                  string(2) \"px\"\n                  private $isColorComponent =\u003e\n                  bool(false)\n                  protected $lineNumber =\u003e\n                  int(13)\n                }\n                private $isImportant =\u003e\n                bool(false)\n                protected $lineNumber =\u003e\n                int(13)\n              }\n            }\n          }\n          protected $lineNumber =\u003e\n          int(13)\n        }\n        [1] =\u003e\n        class Sabberworm\\CSS\\RuleSet\\DeclarationBlock#23 (3) {\n          private $selectors =\u003e\n          array(1) {\n            [0] =\u003e\n            class Sabberworm\\CSS\\Property\\Selector#24 (2) {\n              private $selector =\u003e\n              string(2) \"to\"\n              private $specificity =\u003e\n              NULL\n            }\n          }\n          private $rules =\u003e\n          array(1) {\n            'top' =\u003e\n            array(1) {\n              [0] =\u003e\n              class Sabberworm\\CSS\\Rule\\Rule#25 (4) {\n                private $rule =\u003e\n                string(3) \"top\"\n                private $value =\u003e\n                class Sabberworm\\CSS\\Value\\Size#26 (4) {\n                  private $size =\u003e\n                  double(200)\n                  private $unit =\u003e\n                  string(2) \"px\"\n                  private $isColorComponent =\u003e\n                  bool(false)\n                  protected $lineNumber =\u003e\n                  int(14)\n                }\n                private $isImportant =\u003e\n                bool(false)\n                protected $lineNumber =\u003e\n                int(14)\n              }\n            }\n          }\n          protected $lineNumber =\u003e\n          int(14)\n        }\n      }\n      protected $lineNumber =\u003e\n      int(12)\n    }\n  }\n  protected $lineNumber =\u003e\n  int(1)\n}\n\n```\n\u003c/details\u003e\n\n#### Output (`render()`)\n\n```css\n@charset \"utf-8\";\n@font-face {font-family: \"CrassRoots\";src: url(\"../media/cr.ttf\");}\nhtml, body {font-size: 1.6em;}\n@keyframes mymove {from {top: 0px;} to {top: 200px;}}\n```\n\n### Example 2 (Values)\n\n#### Input\n\n```css\n#header {\n    margin: 10px 2em 1cm 2%;\n    font-family: Verdana, Helvetica, \"Gill Sans\", sans-serif;\n    color: red !important;\n}\n\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eStructure (\u003ccode\u003evar_dump()\u003c/code\u003e)\u003c/b\u003e\u003c/summary\u003e\n\n```php\nclass Sabberworm\\CSS\\CSSList\\Document#4 (2) {\n  protected $contents =\u003e\n  array(1) {\n    [0] =\u003e\n    class Sabberworm\\CSS\\RuleSet\\DeclarationBlock#5 (3) {\n      private $selectors =\u003e\n      array(1) {\n        [0] =\u003e\n        class Sabberworm\\CSS\\Property\\Selector#6 (2) {\n          private $selector =\u003e\n          string(7) \"#header\"\n          private $specificity =\u003e\n          NULL\n        }\n      }\n      private $rules =\u003e\n      array(3) {\n        'margin' =\u003e\n        array(1) {\n          [0] =\u003e\n          class Sabberworm\\CSS\\Rule\\Rule#7 (4) {\n            private $rule =\u003e\n            string(6) \"margin\"\n            private $value =\u003e\n            class Sabberworm\\CSS\\Value\\RuleValueList#12 (3) {\n              protected $components =\u003e\n              array(4) {\n                [0] =\u003e\n                class Sabberworm\\CSS\\Value\\Size#8 (4) {\n                  private $size =\u003e\n                  double(10)\n                  private $unit =\u003e\n                  string(2) \"px\"\n                  private $isColorComponent =\u003e\n                  bool(false)\n                  protected $lineNumber =\u003e\n                  int(2)\n                }\n                [1] =\u003e\n                class Sabberworm\\CSS\\Value\\Size#9 (4) {\n                  private $size =\u003e\n                  double(2)\n                  private $unit =\u003e\n                  string(2) \"em\"\n                  private $isColorComponent =\u003e\n                  bool(false)\n                  protected $lineNumber =\u003e\n                  int(2)\n                }\n                [2] =\u003e\n                class Sabberworm\\CSS\\Value\\Size#10 (4) {\n                  private $size =\u003e\n                  double(1)\n                  private $unit =\u003e\n                  string(2) \"cm\"\n                  private $isColorComponent =\u003e\n                  bool(false)\n                  protected $lineNumber =\u003e\n                  int(2)\n                }\n                [3] =\u003e\n                class Sabberworm\\CSS\\Value\\Size#11 (4) {\n                  private $size =\u003e\n                  double(2)\n                  private $unit =\u003e\n                  string(1) \"%\"\n                  private $isColorComponent =\u003e\n                  bool(false)\n                  protected $lineNumber =\u003e\n                  int(2)\n                }\n              }\n              protected $separator =\u003e\n              string(1) \" \"\n              protected $lineNumber =\u003e\n              int(2)\n            }\n            private $isImportant =\u003e\n            bool(false)\n            protected $lineNumber =\u003e\n            int(2)\n          }\n        }\n        'font-family' =\u003e\n        array(1) {\n          [0] =\u003e\n          class Sabberworm\\CSS\\Rule\\Rule#13 (4) {\n            private $rule =\u003e\n            string(11) \"font-family\"\n            private $value =\u003e\n            class Sabberworm\\CSS\\Value\\RuleValueList#15 (3) {\n              protected $components =\u003e\n              array(4) {\n                [0] =\u003e\n                string(7) \"Verdana\"\n                [1] =\u003e\n                string(9) \"Helvetica\"\n                [2] =\u003e\n                class Sabberworm\\CSS\\Value\\CSSString#14 (2) {\n                  private $string =\u003e\n                  string(9) \"Gill Sans\"\n                  protected $lineNumber =\u003e\n                  int(3)\n                }\n                [3] =\u003e\n                string(10) \"sans-serif\"\n              }\n              protected $sSeparator =\u003e\n              string(1) \",\"\n              protected $lineNumber =\u003e\n              int(3)\n            }\n            private $isImportant =\u003e\n            bool(false)\n            protected $lineNumber =\u003e\n            int(3)\n          }\n        }\n        'color' =\u003e\n        array(1) {\n          [0] =\u003e\n          class Sabberworm\\CSS\\Rule\\Rule#16 (4) {\n            private $rule =\u003e\n            string(5) \"color\"\n            private $value =\u003e\n            string(3) \"red\"\n            private $isImportant =\u003e\n            bool(true)\n            protected $lineNumber =\u003e\n            int(4)\n          }\n        }\n      }\n      protected $lineNumber =\u003e\n      int(1)\n    }\n  }\n  protected $lineNumber =\u003e\n  int(1)\n}\n\n```\n\u003c/details\u003e\n\n#### Output (`render()`)\n\n```css\n#header {margin: 10px 2em 1cm 2%;font-family: Verdana,Helvetica,\"Gill Sans\",sans-serif;color: red !important;}\n```\n\n## Class diagram\n\n```mermaid\nclassDiagram\n    direction LR\n\n    %% Start of the part originally generated from the PHP code using tasuku43/mermaid-class-diagram\n\n    class CSSElement {\n        \u003c\u003cinterface\u003e\u003e\n    }\n    class Renderable {\n        \u003c\u003cinterface\u003e\u003e\n    }\n    class Positionable {\n        \u003c\u003cinterface\u003e\u003e\n    }\n    class CSSListItem {\n        \u003c\u003cinterface\u003e\u003e\n    }\n    class DeclarationBlock {\n    }\n    class RuleSet {\n        \u003c\u003cabstract\u003e\u003e\n    }\n    class AtRuleSet {\n    }\n    class KeyframeSelector {\n    }\n    class AtRule {\n        \u003c\u003cinterface\u003e\u003e\n    }\n    class Charset {\n    }\n    class Import {\n    }\n    class Selector {\n    }\n    class CSSNamespace {\n    }\n    class Settings {\n    }\n    class Rule {\n    }\n    class Parser {\n    }\n    class OutputFormatter {\n    }\n    class OutputFormat {\n    }\n    class OutputException {\n    }\n    class UnexpectedEOFException {\n    }\n    class SourceException {\n    }\n    class UnexpectedTokenException {\n    }\n    class ParserState {\n    }\n    class Anchor {\n    }\n    class CSSBlockList {\n        \u003c\u003cabstract\u003e\u003e\n    }\n    class Document {\n    }\n    class CSSList {\n        \u003c\u003cabstract\u003e\u003e\n    }\n    class KeyFrame {\n    }\n    class AtRuleBlockList {\n    }\n    class Color {\n    }\n    class URL {\n    }\n    class CalcRuleValueList {\n    }\n    class ValueList {\n        \u003c\u003cabstract\u003e\u003e\n    }\n    class CalcFunction {\n    }\n    class LineName {\n    }\n    class Value {\n        \u003c\u003cabstract\u003e\u003e\n    }\n    class Size {\n    }\n    class CSSString {\n    }\n    class PrimitiveValue {\n        \u003c\u003cabstract\u003e\u003e\n    }\n    class CSSFunction {\n    }\n    class RuleValueList {\n    }\n    class Commentable {\n        \u003c\u003cinterface\u003e\u003e\n    }\n    class Comment {\n    }\n\n    RuleSet \u003c|-- DeclarationBlock: inheritance\n    Renderable \u003c|-- CSSElement: inheritance\n    Renderable \u003c|-- CSSListItem: inheritance\n    Commentable \u003c|-- CSSListItem: inheritance\n    Positionable \u003c|.. RuleSet: realization\n    CSSElement \u003c|.. RuleSet: realization\n    CSSListItem \u003c|.. RuleSet: realization\n    RuleSet \u003c|-- AtRuleSet: inheritance\n    AtRule \u003c|.. AtRuleSet: realization\n    Renderable \u003c|.. Selector: realization\n    Selector \u003c|-- KeyframeSelector: inheritance\n    CSSListItem \u003c|-- AtRule: inheritance\n    Positionable \u003c|.. Charset: realization\n    AtRule \u003c|.. Charset: realization\n    Positionable \u003c|.. Import: realization\n    AtRule \u003c|.. Import: realization\n    Positionable \u003c|.. CSSNamespace: realization\n    AtRule \u003c|.. CSSNamespace: realization\n    CSSElement \u003c|.. Rule: realization\n    Positionable \u003c|.. Rule: realization\n    Commentable \u003c|.. Rule: realization\n    SourceException \u003c|-- OutputException: inheritance\n    UnexpectedTokenException \u003c|-- UnexpectedEOFException: inheritance\n    Exception \u003c|-- SourceException: inheritance\n    Positionable \u003c|.. SourceException: realization\n    SourceException \u003c|-- UnexpectedTokenException: inheritance\n    CSSList \u003c|-- CSSBlockList: inheritance\n    CSSBlockList \u003c|-- Document: inheritance\n    CSSElement \u003c|.. CSSList: realization\n    Positionable \u003c|.. CSSList: realization\n    CSSListItem \u003c|.. CSSList: realization\n    CSSList \u003c|-- KeyFrame: inheritance\n    AtRule \u003c|.. KeyFrame: realization\n    CSSBlockList \u003c|-- AtRuleBlockList: inheritance\n    AtRule \u003c|.. AtRuleBlockList: realization\n    CSSFunction \u003c|-- Color: inheritance\n    PrimitiveValue \u003c|-- URL: inheritance\n    RuleValueList \u003c|-- CalcRuleValueList: inheritance\n    Value \u003c|-- ValueList: inheritance\n    CSSFunction \u003c|-- CalcFunction: inheritance\n    ValueList \u003c|-- LineName: inheritance\n    CSSElement \u003c|.. Value: realization\n    Positionable \u003c|.. Value: realization\n    PrimitiveValue \u003c|-- Size: inheritance\n    PrimitiveValue \u003c|-- CSSString: inheritance\n    Value \u003c|-- PrimitiveValue: inheritance\n    ValueList \u003c|-- CSSFunction: inheritance\n    ValueList \u003c|-- RuleValueList: inheritance\n    Renderable \u003c|.. Comment: realization\n    Positionable \u003c|.. Comment: realization\n\n    %% end of the generated part\n\n\n    Anchor --\u003e \"1\" ParserState : parserState\n    CSSList --\u003e \"*\" CSSList : contents\n    CSSList --\u003e \"*\" Charset : contents\n    CSSList --\u003e \"*\" Comment : comments\n    CSSList --\u003e \"*\" Import : contents\n    CSSList --\u003e \"*\" RuleSet : contents\n    CSSNamespace --\u003e \"*\" Comment : comments\n    Charset --\u003e \"*\" Comment : comments\n    Charset --\u003e \"1\" CSSString : charset\n    DeclarationBlock --\u003e \"*\" Selector : selectors\n    Import --\u003e \"*\" Comment : comments\n    OutputFormat --\u003e \"1\" OutputFormat : nextLevelFormat\n    OutputFormat --\u003e \"1\" OutputFormatter : outputFormatter\n    OutputFormatter --\u003e \"1\" OutputFormat : outputFormat\n    Parser --\u003e \"1\" ParserState : parserState\n    ParserState --\u003e \"1\" Settings : parserSettings\n    Rule --\u003e \"*\" Comment : comments\n    Rule --\u003e \"1\" RuleValueList : value\n    RuleSet --\u003e \"*\" Comment : comments\n    RuleSet --\u003e \"*\" Rule : rules\n    URL --\u003e \"1\" CSSString : url\n    ValueList --\u003e \"*\" Value : components\n```\n\n## API and deprecation policy\n\nPlease have a look at our\n[API and deprecation policy](docs/API-and-deprecation-policy.md).\n\n## Contributing\n\nContributions in the form of bug reports, feature requests, or pull requests are\nmore than welcome. :pray: Please have a look at our\n[contribution guidelines](CONTRIBUTING.md) to learn more about how to\ncontribute to PHP-CSS-Parser.\n\n## Contributors/Thanks to\n\n* [oliverklee](https://github.com/oliverklee) for lots of refactorings, code modernizations and CI integrations\n* [raxbg](https://github.com/raxbg) for contributions to parse `calc`, grid lines, and various bugfixes.\n* [westonruter](https://github.com/westonruter) for bugfixes and improvements.\n* [FMCorz](https://github.com/FMCorz) for many patches and suggestions, for being able to parse comments and IE hacks (in lenient mode).\n* [Lullabot](https://github.com/Lullabot) for a patch that allows to know the line number for each parsed token.\n* [ju1ius](https://github.com/ju1ius) for the specificity parsing code and the ability to expand/compact shorthand properties.\n* [ossinkine](https://github.com/ossinkine) for a 150 time performance boost.\n* [GaryJones](https://github.com/GaryJones) for lots of input and [https://css-specificity.info/](https://css-specificity.info/).\n* [docteurklein](https://github.com/docteurklein) for output formatting and `CSSList-\u003eremove()` inspiration.\n* [nicolopignatelli](https://github.com/nicolopignatelli) for PSR-0 compatibility.\n* [diegoembarcadero](https://github.com/diegoembarcadero) for keyframe at-rule parsing.\n* [goetas](https://github.com/goetas) for `@namespace` at-rule support.\n* [ziegenberg](https://github.com/ziegenberg) for general housekeeping and cleanup.\n* [View full list](https://github.com/sabberworm/PHP-CSS-Parser/contributors)\n\n## Misc\n\n### Legacy Support\n\nThe latest pre-PSR-0 version of this project can be checked with the `0.9.0` tag.\n","funding_links":[],"categories":["Table of Contents"],"sub_categories":["Markup and CSS"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMyIntervals%2FPHP-CSS-Parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMyIntervals%2FPHP-CSS-Parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMyIntervals%2FPHP-CSS-Parser/lists"}