Documentation

RuleSet
in package
implements Renderable, Commentable

RuleSet is a generic superclass denoting rules. The typical example for rule sets are declaration block.

However, unknown At-Rules (like @font-face) are also rule sets.

Interfaces, Classes and Traits

Renderable
Commentable

Table of Contents

$aComments  : mixed
$iLineNo  : mixed
$aRules  : mixed
__construct()  : mixed
__toString()  : mixed
addComments()  : mixed
addRule()  : mixed
getComments()  : array<string|int, mixed>
getLineNo()  : int
getRules()  : array<string|int, Rule>
Returns all rules matching the given rule name
getRulesAssoc()  : array<string|int, Rule>
Returns all rules matching the given pattern and returns them in an associative array with the rule’s name as keys. This method exists mainly for backwards-compatibility and is really only partially useful.
parseRuleSet()  : mixed
removeRule()  : mixed
Remove a rule from this RuleSet. This accepts all the possible values that @link{getRules()} accepts. If given a Rule, it will only remove this particular rule (by identity). If given a name, it will remove all rules by that name. Note: this is different from pre-v.2.0 behaviour of PHP-CSS-Parser, where passing a Rule instance would remove all rules with the same name. To get the old behvaiour, use removeRule($oRule->getRule()).
render()  : mixed
setComments()  : mixed
setRules()  : mixed
Override all the rules of this set.

Properties

$aComments

protected mixed $aComments

Methods

__construct()

public __construct(mixed $iLineNo) : mixed
Parameters
$iLineNo : mixed
Return values
mixed

__toString()

public __toString() : mixed
Return values
mixed

addComments()

public addComments(array<string|int, mixed> $aComments) : mixed
Parameters
$aComments : array<string|int, mixed>

Array of comments.

Return values
mixed

addRule()

public addRule(Rule $oRule[, Rule $oSibling = null ]) : mixed
Parameters
$oRule : Rule
$oSibling : Rule = null
Return values
mixed

getComments()

public getComments() : array<string|int, mixed>
Return values
array<string|int, mixed>

getLineNo()

public getLineNo() : int
Return values
int

getRules()

Returns all rules matching the given rule name

public getRules([(null|string|\Sabberworm\CSS\Rule\Rule) $mRule = null ]) : array<string|int, Rule>
Parameters
$mRule : (null|string|\Sabberworm\CSS\Rule\Rule) = null

pattern to search for. If null, returns all rules. if the pattern ends with a dash, all rules starting with the pattern are returned as well as one matching the pattern with the dash excluded. passing a Rule behaves like calling getRules($mRule->getRule()).

Tags
example

$oRuleSet->getRules('font-') //returns an array of all rules either beginning with font- or matching font.

example

$oRuleSet->getRules('font') //returns array(0 => $oRule, …) or array().

Return values
array<string|int, Rule>

Rules.

getRulesAssoc()

Returns all rules matching the given pattern and returns them in an associative array with the rule’s name as keys. This method exists mainly for backwards-compatibility and is really only partially useful.

public getRulesAssoc([(string) $mRule = null ]) : array<string|int, Rule>
Parameters
$mRule : (string) = null

pattern to search for. If null, returns all rules. if the pattern ends with a dash, all rules starting with the pattern are returned as well as one matching the pattern with the dash excluded. passing a Rule behaves like calling getRules($mRule->getRule()). Note: This method loses some information: Calling this (with an argument of 'background-') on a declaration block like { background-color: green; background-color; rgba(0, 127, 0, 0.7); } will only yield an associative array containing the rgba-valued rule while @link{getRules()} would yield an indexed array containing both.

Return values
array<string|int, Rule>

Rules.

removeRule()

Remove a rule from this RuleSet. This accepts all the possible values that @link{getRules()} accepts. If given a Rule, it will only remove this particular rule (by identity). If given a name, it will remove all rules by that name. Note: this is different from pre-v.2.0 behaviour of PHP-CSS-Parser, where passing a Rule instance would remove all rules with the same name. To get the old behvaiour, use removeRule($oRule->getRule()).

public removeRule((null|string|\Sabberworm\CSS\Rule\Rule) $mRule) : mixed
Parameters
$mRule : (null|string|\Sabberworm\CSS\Rule\Rule)

pattern to remove. If $mRule is null, all rules are removed. If the pattern ends in a dash, all rules starting with the pattern are removed as well as one matching the pattern with the dash excluded. Passing a Rule behaves matches by identity.

Return values
mixed

setComments()

public setComments(array<string|int, mixed> $aComments) : mixed
Parameters
$aComments : array<string|int, mixed>

Array containing Comment objects.

Return values
mixed

setRules()

Override all the rules of this set.

public setRules(array<string|int, Rule$aRules) : mixed
Parameters
$aRules : array<string|int, Rule>

The rules to override with.

Return values
mixed

Search results