Moodle PHP Documentation 4.4
Moodle 4.4.9+ (Build: 20250711) (4ea86454947)
Sabberworm\CSS\RuleSet\DeclarationBlock Class Reference
Inheritance diagram for Sabberworm\CSS\RuleSet\DeclarationBlock:
Sabberworm\CSS\RuleSet\RuleSet Sabberworm\CSS\Renderable Sabberworm\CSS\Comment\Commentable

Public Member Functions

 __toString ()
 
 addComments (array $aComments)
 
 addRule (Rule $oRule, Rule $oSibling=null)
 
 createBackgroundShorthand ()
 
 createBorderShorthand ()
 Combines border-color, border-style and border-width into border.
 
 createDimensionsShorthand ()
 Looks for long format CSS dimensional properties (margin, padding, border-color, border-style and border-width) and converts them into shorthand CSS properties.
 
 createFontShorthand ()
 Looks for long format CSS font properties (e.g.
 
 createListStyleShorthand ()
 
 createShorthandProperties (array $aProperties, $sShorthand)
 
 createShorthands ()
 Creates shorthand declarations (e.g.
 
 expandBackgroundShorthand ()
 Converts shorthand background declarations (e.g.
 
 expandBorderShorthand ()
 Splits shorthand border declarations (e.g.
 
 expandDimensionsShorthand ()
 Splits shorthand dimensional declarations (e.g.
 
 expandFontShorthand ()
 Converts shorthand font declarations (e.g.
 
 expandListStyleShorthand ()
 
 expandShorthands ()
 Splits shorthand declarations (e.g.
 
 getComments ()
 
 getLineNo ()
 
 getRules ($mRule=null)
 
 getRulesAssoc ($mRule=null)
 Returns all rules matching the given pattern and returns them in an associative array with the rule’s name as keys.
 
 getSelector ()
 
 getSelectors ()
 
 removeRule ($mRule)
 Removes a rule from this RuleSet.
 
 removeSelector ($mSelector)
 Remove one of the selectors of the block.
 
 render (OutputFormat $oOutputFormat)
 
 setComments (array $aComments)
 
 setRules (array $aRules)
 Overrides all the rules of this set.
 
 setSelector ($mSelector, $oList=null)
 
 setSelectors ($mSelector, $oList=null)
 

Static Public Member Functions

static parse (ParserState $oParserState, $oList=null)
 
static parseRuleSet (ParserState $oParserState, RuleSet $oRuleSet)
 

Public Attributes

$this aComments = []
 

Member Function Documentation

◆ __toString()

Sabberworm\CSS\RuleSet\DeclarationBlock::__toString ( )
Return values
string
Exceptions
OutputException

Reimplemented from Sabberworm\CSS\RuleSet\RuleSet.

◆ addComments()

Sabberworm\CSS\RuleSet\RuleSet::addComments ( array $aComments)
inherited
Parameters
array<string,Comment>$aComments
Return values
void

Implements Sabberworm\CSS\Comment\Commentable.

◆ addRule()

Sabberworm\CSS\RuleSet\RuleSet::addRule ( Rule $oRule,
Rule $oSibling = null )
inherited
Parameters
Rule | null$oSibling
Return values
void

◆ createBackgroundShorthand()

Sabberworm\CSS\RuleSet\DeclarationBlock::createBackgroundShorthand ( )
Return values
void

◆ createBorderShorthand()

Sabberworm\CSS\RuleSet\DeclarationBlock::createBorderShorthand ( )

Combines border-color, border-style and border-width into border.

Should be run after create_dimensions_shorthand!

Return values
void

◆ createDimensionsShorthand()

Sabberworm\CSS\RuleSet\DeclarationBlock::createDimensionsShorthand ( )

Looks for long format CSS dimensional properties (margin, padding, border-color, border-style and border-width) and converts them into shorthand CSS properties.

Return values
void

◆ createFontShorthand()

Sabberworm\CSS\RuleSet\DeclarationBlock::createFontShorthand ( )

Looks for long format CSS font properties (e.g.

font-weight) and tries to convert them into a shorthand CSS font property.

At least font-size AND font-family must be present in order to create a shorthand declaration.

Return values
void

◆ createListStyleShorthand()

Sabberworm\CSS\RuleSet\DeclarationBlock::createListStyleShorthand ( )
Return values
void

◆ createShorthandProperties()

Sabberworm\CSS\RuleSet\DeclarationBlock::createShorthandProperties ( array $aProperties,
$sShorthand )
Parameters
array<array-key,string>$aProperties
string$sShorthand
Return values
void

◆ createShorthands()

Sabberworm\CSS\RuleSet\DeclarationBlock::createShorthands ( )

Creates shorthand declarations (e.g.

margin or font) whenever possible.

Return values
void

◆ expandBackgroundShorthand()

Sabberworm\CSS\RuleSet\DeclarationBlock::expandBackgroundShorthand ( )

Converts shorthand background declarations (e.g.

background: url("chess.png") gray 50% repeat fixed;) into their constituent parts.

See also
http://www.w3.org/TR/21/colors.html#propdef-background
Return values
void

◆ expandBorderShorthand()

Sabberworm\CSS\RuleSet\DeclarationBlock::expandBorderShorthand ( )

Splits shorthand border declarations (e.g.

border: 1px red;).

Additional splitting happens in expandDimensionsShorthand.

Multiple borders are not yet supported as of 3.

Return values
void

◆ expandDimensionsShorthand()

Sabberworm\CSS\RuleSet\DeclarationBlock::expandDimensionsShorthand ( )

Splits shorthand dimensional declarations (e.g.

margin: 0px auto;) into their constituent parts.

Handles margin, padding, border-color, border-style and border-width.

Return values
void

◆ expandFontShorthand()

Sabberworm\CSS\RuleSet\DeclarationBlock::expandFontShorthand ( )

Converts shorthand font declarations (e.g.

font: 300 italic 11px/14px verdana, helvetica, sans-serif;) into their constituent parts.

Return values
void

◆ expandListStyleShorthand()

Sabberworm\CSS\RuleSet\DeclarationBlock::expandListStyleShorthand ( )
Return values
void

◆ expandShorthands()

Sabberworm\CSS\RuleSet\DeclarationBlock::expandShorthands ( )

Splits shorthand declarations (e.g.

margin or font) into their constituent parts.

Return values
void

◆ getComments()

Sabberworm\CSS\RuleSet\RuleSet::getComments ( )
inherited
Return values
array<string,Comment>

Implements Sabberworm\CSS\Comment\Commentable.

◆ getLineNo()

Sabberworm\CSS\RuleSet\RuleSet::getLineNo ( )
inherited
Return values
int

Implements Sabberworm\CSS\Renderable.

◆ getRulesAssoc()

Sabberworm\CSS\RuleSet\RuleSet::getRulesAssoc ( $mRule = null)
inherited

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.

Parameters
Rule | string | null$mRule$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 Rule behaves like calling getRules($mRule->getRule()).
Return values
array<string,Rule>

◆ getSelector()

Sabberworm\CSS\RuleSet\DeclarationBlock::getSelector ( )
Return values
array<int,Selector|string>
Deprecated
will be removed in version 9.0; use getSelectors() instead

◆ getSelectors()

Sabberworm\CSS\RuleSet\DeclarationBlock::getSelectors ( )
Return values
array<int,Selector|string>

◆ parse()

static Sabberworm\CSS\RuleSet\DeclarationBlock::parse ( ParserState $oParserState,
$oList = null )
static
Parameters
CSSList | null$oList
Return values
DeclarationBlock|false
Exceptions
UnexpectedTokenException
UnexpectedEOFException

◆ parseRuleSet()

static Sabberworm\CSS\RuleSet\RuleSet::parseRuleSet ( ParserState $oParserState,
RuleSet $oRuleSet )
staticinherited
Return values
void
Exceptions
UnexpectedTokenException
UnexpectedEOFException

◆ removeRule()

Sabberworm\CSS\RuleSet\RuleSet::removeRule ( $mRule)
inherited

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()).

Parameters
Rule | string | null$mRulepattern 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
void

◆ removeSelector()

Sabberworm\CSS\RuleSet\DeclarationBlock::removeSelector ( $mSelector)

Remove one of the selectors of the block.

Parameters
Selector | string$mSelector
Return values
bool

◆ render()

Sabberworm\CSS\RuleSet\DeclarationBlock::render ( OutputFormat $oOutputFormat)
Return values
string
Exceptions
OutputException

Reimplemented from Sabberworm\CSS\RuleSet\RuleSet.

◆ setComments()

Sabberworm\CSS\RuleSet\RuleSet::setComments ( array $aComments)
inherited
Parameters
array<string,Comment>$aComments
Return values
void

Implements Sabberworm\CSS\Comment\Commentable.

◆ setRules()

Sabberworm\CSS\RuleSet\RuleSet::setRules ( array $aRules)
inherited

Overrides all the rules of this set.

Parameters
array<array-key,Rule>$aRules The rules to override with.
Return values
void

◆ setSelector()

Sabberworm\CSS\RuleSet\DeclarationBlock::setSelector ( $mSelector,
$oList = null )
Parameters
Selector | string$mSelector
CSSList | null$oList
Return values
void
Deprecated
will be removed in version 9.0; use setSelectors() instead

◆ setSelectors()

Sabberworm\CSS\RuleSet\DeclarationBlock::setSelectors ( $mSelector,
$oList = null )
Parameters
array<int,Selector|string>|string$mSelector
CSSList | null$oList
Exceptions
UnexpectedTokenException

The documentation for this class was generated from the following file: