Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403]

(no description)

File Size: 326 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

RuleSet:: (13 methods):
  __construct()
  parseRuleSet()
  getLineNo()
  addRule()
  getRules()
  setRules()
  getRulesAssoc()
  removeRule()
  __toString()
  render()
  addComments()
  getComments()
  setComments()


Class: RuleSet  - X-Ref

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.

__construct($iLineNo = 0)   X-Ref

param: int $iLineNo

parseRuleSet(ParserState $oParserState, RuleSet $oRuleSet)   X-Ref

return: void

getLineNo()   X-Ref

return: int

addRule(Rule $oRule, Rule $oSibling = null)   X-Ref

param: Rule|null $oSibling
return: void

getRules($mRule = null)   X-Ref
Returns all rules matching the given rule name

param: Rule|string|null $mRule
return: array<int, Rule>

setRules(array $aRules)   X-Ref
Overrides all the rules of this set.

param: array<array-key, Rule> $aRules The rules to override with.
return: void

getRulesAssoc($mRule = null)   X-Ref
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.

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.

param: Rule|string|null $mRule $mRule
return: array<string, Rule>

removeRule($mRule)   X-Ref
Removes a rule from this RuleSet. This accepts all the possible values that `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 behaviour, use `removeRule($oRule->getRule())`.

param: Rule|string|null $mRule
return: void

__toString()   X-Ref

return: string

render(OutputFormat $oOutputFormat)   X-Ref

return: string

addComments(array $aComments)   X-Ref

param: array<string, Comment> $aComments
return: void

getComments()   X-Ref

return: array<string, Comment>

setComments(array $aComments)   X-Ref

param: array<string, Comment> $aComments
return: void