Documentation

DeclarationBlock extends RuleSet
in package

Declaration blocks are the parts of a css file which denote the rules belonging to a selector.

Declaration blocks usually appear directly inside a Document or another CSSList (mostly a MediaQuery).

Table of Contents

$aComments  : mixed
$iLineNo  : mixed
$aRules  : mixed
$aSelectors  : mixed
__construct()  : mixed
__toString()  : mixed
addComments()  : mixed
addRule()  : mixed
createBackgroundShorthand()  : mixed
createBorderShorthand()  : mixed
Combine border-color, border-style and border-width into border Should be run after create_dimensions_shorthand!
createDimensionsShorthand()  : mixed
createFontShorthand()  : mixed
Looks for long format CSS font properties (e.g. <tt>font-weight</tt>) and tries to convert them into a shorthand CSS <tt>font</tt> property.
createListStyleShorthand()  : mixed
createShorthandProperties()  : mixed
createShorthands()  : mixed
Create shorthand declarations (e.g. +margin+ or +font+) whenever possible.
expandBackgroundShorthand()  : mixed
expandBorderShorthand()  : mixed
Split shorthand border declarations (e.g. <tt>border: 1px red;</tt>) Additional splitting happens in expandDimensionsShorthand Multiple borders are not yet supported as of 3
expandDimensionsShorthand()  : mixed
Split shorthand dimensional declarations (e.g. <tt>margin: 0px auto;</tt>) into their constituent parts.
expandFontShorthand()  : mixed
Convert shorthand font declarations (e.g. <tt>font: 300 italic 11px/14px verdana, helvetica, sans-serif;</tt>) into their constituent parts.
expandListStyleShorthand()  : mixed
expandShorthands()  : mixed
Split shorthand declarations (e.g. +margin+ or +font+) into their constituent parts.
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.
getSelector()  : mixed
getSelectors()  : array<string|int, Selector>
Get selectors.
parse()  : mixed
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()).
removeSelector()  : mixed
render()  : mixed
setComments()  : mixed
setRules()  : mixed
Override all the rules of this set.
setSelector()  : mixed
setSelectors()  : mixed

Properties

$aComments

protected mixed $aComments

Methods

__construct()

public __construct(mixed $iLineNo) : mixed
Parameters
$iLineNo : 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

createBackgroundShorthand()

public createBackgroundShorthand() : mixed
Return values
mixed

createBorderShorthand()

Combine border-color, border-style and border-width into border Should be run after create_dimensions_shorthand!

public createBorderShorthand() : mixed
Return values
mixed

createDimensionsShorthand()

public createDimensionsShorthand() : mixed
Return values
mixed

createFontShorthand()

Looks for long format CSS font properties (e.g. <tt>font-weight</tt>) and tries to convert them into a shorthand CSS <tt>font</tt> property.

public createFontShorthand() : mixed

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

Return values
mixed

createListStyleShorthand()

public createListStyleShorthand() : mixed
Return values
mixed

createShorthandProperties()

public createShorthandProperties(array<string|int, mixed> $aProperties, mixed $sShorthand) : mixed
Parameters
$aProperties : array<string|int, mixed>
$sShorthand : mixed
Return values
mixed

createShorthands()

Create shorthand declarations (e.g. +margin+ or +font+) whenever possible.

public createShorthands() : mixed
Return values
mixed

expandBackgroundShorthand()

public expandBackgroundShorthand() : mixed
Return values
mixed

expandBorderShorthand()

Split shorthand border declarations (e.g. <tt>border: 1px red;</tt>) Additional splitting happens in expandDimensionsShorthand Multiple borders are not yet supported as of 3

public expandBorderShorthand() : mixed
Return values
mixed

expandDimensionsShorthand()

Split shorthand dimensional declarations (e.g. <tt>margin: 0px auto;</tt>) into their constituent parts.

public expandDimensionsShorthand() : mixed

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

Return values
mixed

expandFontShorthand()

Convert shorthand font declarations (e.g. <tt>font: 300 italic 11px/14px verdana, helvetica, sans-serif;</tt>) into their constituent parts.

public expandFontShorthand() : mixed
Return values
mixed

expandListStyleShorthand()

public expandListStyleShorthand() : mixed
Return values
mixed

expandShorthands()

Split shorthand declarations (e.g. +margin+ or +font+) into their constituent parts.

public expandShorthands() : mixed
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.

getSelector()

public getSelector() : mixed
Tags
deprecated

use getSelectors()

Return values
mixed

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

removeSelector()

public removeSelector(mixed $mSelector) : mixed
Parameters
$mSelector : mixed
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

setSelector()

public setSelector(mixed $mSelector) : mixed
Parameters
$mSelector : mixed
Tags
deprecated

use setSelectors()

Return values
mixed

setSelectors()

public setSelectors(mixed $mSelector) : mixed
Parameters
$mSelector : mixed
Return values
mixed

Search results