RuleSet
in package
implements
CSSElement, Commentable, Positionable
Uses
Position
This class is a container for individual 'Rule's.
The most common form of a rule set is one constrained by a selector, i.e., a DeclarationBlock.
However, unknown AtRules (like @font-face) are rule sets as well.
If 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).
Interfaces, Classes and Traits
- CSSElement
- Represents any entity in the CSS that is encapsulated by a class.
- Commentable
- Positionable
- Represents a CSS item that may have a position in the source CSS document (line number and possibly column number).
Table of Contents
- $aRules : array<string, array<int<0, max>, Rule>>
- the rules in this rule set, using the property name as the key, with potentially multiple rules per property name.
- __construct() : mixed
- __toString() : string
- addComments() : void
- addRule() : void
- getComments() : array<string, Comment>
- getRules() : array<int, Rule>
- Returns all rules matching the given rule name
- getRulesAssoc() : array<string, 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.
- removeAllRules() : mixed
- removeMatchingRules() : mixed
- Removes rules by property name or search pattern.
- removeRule() : mixed
- Removes a `Rule` from this `RuleSet` by identity.
- setComments() : void
- setRules() : void
- Overrides all the rules of this set.
- renderRules() : string
Properties
$aRules
the rules in this rule set, using the property name as the key, with potentially multiple rules per property name.
private
array<string, array<int<0, max>, Rule>>
$aRules
Methods
__construct()
public
__construct(int $iLineNo) : mixed
Parameters
- $iLineNo : int
Return values
mixed —__toString()
public
__toString() : string
Tags
Return values
string —addComments()
public
addComments(array<string, Comment> $aComments) : void
Parameters
- $aComments : array<string, Comment>
Return values
void —addRule()
public
addRule(Rule $oRule[, Rule|null $oSibling = null ]) : void
Parameters
Return values
void —getComments()
public
getComments() : array<string, Comment>
Return values
array<string, Comment> —getRules()
Returns all rules matching the given rule name
public
getRules([Rule|string|null $mRule = null ]) : array<int, Rule>
Parameters
- $mRule : Rule|string|null = 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
Rulefor this parameter is deprecated in version 8.9.0, and will not work from v9.0. CallgetRules($rule->getRule())instead.
Tags
Return values
array<int, Rule> —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([Rule|string|null $mRule = null ]) : array<string, Rule>
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 getRules() would yield an indexed array containing both.
Parameters
- $mRule : Rule|string|null = null
-
$mRule 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
Rulefor this parameter is deprecated in version 8.9.0, and will not work from v9.0. CallgetRulesAssoc($rule->getRule())instead.
Return values
array<string, Rule> —removeAllRules()
public
removeAllRules() : mixed
Return values
mixed —removeMatchingRules()
Removes rules by property name or search pattern.
public
removeMatchingRules(string $searchPattern) : mixed
Parameters
- $searchPattern : string
-
pattern to remove. 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.
Return values
mixed —removeRule()
Removes a `Rule` from this `RuleSet` by identity.
public
removeRule(Rule|string|null $mRule) : mixed
Parameters
- $mRule : Rule|string|null
-
Ruleto remove. Passing astringornullis deprecated in version 8.9.0, and will no longer work from v9.0. UseremoveMatchingRules()orremoveAllRules()instead.
Return values
mixed —setComments()
public
setComments(array<string, Comment> $aComments) : void
Parameters
- $aComments : array<string, Comment>
Return values
void —setRules()
Overrides all the rules of this set.
public
setRules(array<array-key, Rule> $aRules) : void
Parameters
- $aRules : array<array-key, Rule>
-
The rules to override with.
Return values
void —renderRules()
protected
renderRules(OutputFormat $oOutputFormat) : string
Parameters
- $oOutputFormat : OutputFormat
