css-sanitizer
Classes to parse and sanitize CSS
Loading...
Searching...
No Matches
Wikimedia\CSS\Grammar\GrammarMatch Class Reference

Represent a match from a Matcher. More...

Public Member Functions

 __construct (ComponentValueList $list, $start, $length, $name=null, array $capturedMatches=[])
 
 getValues ()
 The matched values.
 
 getStart ()
 The starting position of this match within the original list of values.
 
 getLength ()
 The length of this match.
 
 getNext ()
 The position after this match, as in index into the original list of values.
 
 getName ()
 The name of this match.
 
 getCapturedMatches ()
 The captured submatches of this match.
 
 getUniqueID ()
 Return a key for this matcher's state.
 
 fixWhitespace (Token $old, Token $new)
 Replace whitespace in the matched values For use by Matcher only.
 
 __toString ()
 

Protected Attributes

 $start
 
 $length
 
 $values
 
 $name = null
 
 $capturedMatches = []
 

Detailed Description

Represent a match from a Matcher.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\CSS\Grammar\GrammarMatch::__construct ( ComponentValueList $list,
$start,
$length,
$name = null,
array $capturedMatches = [] )
Parameters
ComponentValueList$listList containing the match
int$startStarting index of the match.
int$lengthNumber of tokens in the match.
string | null$nameGive a name to this match.
GrammarMatch[]$capturedMatchesCaptured submatches of this match.

Member Function Documentation

◆ fixWhitespace()

Wikimedia\CSS\Grammar\GrammarMatch::fixWhitespace ( Token $old,
Token $new )

Replace whitespace in the matched values For use by Matcher only.

Parameters
Token$old
Token$new

◆ getCapturedMatches()

Wikimedia\CSS\Grammar\GrammarMatch::getCapturedMatches ( )

The captured submatches of this match.

This returns the matches from capturing submatchers (see Matcher::capture()) that matched during the matching of the top-level matcher that returned this match. If capturing submatchers were nested, the GrammarMatch objects returned here will themselves have captured sub- matches to return.

To borrow PCRE regular expression syntax, if the "pattern" described by the Matchers resembled www(?<A>xxx(?<B>yyy)xxx)(?<C>zzz)* then the top-level GrammarMatch's getCapturedMatches() would return a GrammarMatch named "A" (containing the "xxxyyyxxx" bit) and zero or more matches named "C" (for each "zzz"), and that "A" GrammarMatch's getCapturedMatches() would return a GrammarMatch named "B" (containing just the "yyy").

Note that the start and end positions reported by captured matches may be relative to a containing SimpleBlock or CSSFunction's value rather than to the ComponentValueList passed to the top-level Matcher.

Returns
GrammarMatch[]

◆ getLength()

Wikimedia\CSS\Grammar\GrammarMatch::getLength ( )

The length of this match.

Returns
int

◆ getName()

Wikimedia\CSS\Grammar\GrammarMatch::getName ( )

The name of this match.

Returns
string|null

◆ getNext()

Wikimedia\CSS\Grammar\GrammarMatch::getNext ( )

The position after this match, as in index into the original list of values.

Returns
int

◆ getStart()

Wikimedia\CSS\Grammar\GrammarMatch::getStart ( )

The starting position of this match within the original list of values.

Returns
int

◆ getUniqueID()

Wikimedia\CSS\Grammar\GrammarMatch::getUniqueID ( )

Return a key for this matcher's state.

Returns
string

◆ getValues()

Wikimedia\CSS\Grammar\GrammarMatch::getValues ( )

The matched values.

Returns
ComponentValue[]

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