MediaWiki REL1_40
MediaWiki\Parser\MagicWordArray Class Reference

Class for handling an array of magic words. More...

Public Member Functions

 __construct ( $names=[], MagicWordFactory $factory=null)
 
 add ( $name)
 Add a magic word by name.
 
 addArray ( $names)
 Add a number of magic words by name.
 
 getBaseRegex (bool $capture=true, string $delimiter='/')
 Get the base regex.
 
 getHash ()
 Get a 2-d hashtable for this array.
 
 getNames ()
 
 getRegex ()
 Get an unanchored regex that does not match parameters.
 
 getRegexStart ()
 Get a regex anchored to the start of the string that does not match parameters.
 
 getVariableRegex ()
 Get a regex for matching variables with parameters.
 
 getVariableStartToEndRegex ()
 Get an anchored regex for matching variables with parameters.
 
 matchAndRemove (&$text)
 Returns an associative array, ID => param value, for all items that match Removes the matched items from the input string (passed by reference)
 
 matchStartAndRemove (&$text)
 Return the ID of the magic word at the start of $text, and remove the prefix from $text.
 
 matchStartToEnd ( $text)
 Match some text, without parameter capture Returns the magic word name, or false if there was no capture.
 
 matchVariableStartToEnd ( $text)
 Match some text, with parameter capture Returns an array with the magic word name in the first element and the parameter in the second element.
 
 parseMatch ( $m)
 Parse a match array from preg_match Returns array(magic word ID, parameter value) If there is no parameter value, that element will be false.
 

Public Attributes

string[] $names = []
 

Detailed Description

Class for handling an array of magic words.

Definition at line 36 of file MagicWordArray.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Parser\MagicWordArray::__construct ( $names = [],
MagicWordFactory $factory = null )
Parameters
string[]$names
MagicWordFactory | null$factory

Definition at line 56 of file MagicWordArray.php.

References MediaWiki\Parser\MagicWordArray\$names, and MediaWiki\MediaWikiServices\getInstance().

Member Function Documentation

◆ add()

MediaWiki\Parser\MagicWordArray::add ( $name)

Add a magic word by name.

Parameters
string$name

Definition at line 66 of file MagicWordArray.php.

◆ addArray()

MediaWiki\Parser\MagicWordArray::addArray ( $names)

Add a number of magic words by name.

Parameters
string[]$names

Definition at line 76 of file MagicWordArray.php.

References MediaWiki\Parser\MagicWordArray\$names.

◆ getBaseRegex()

MediaWiki\Parser\MagicWordArray::getBaseRegex ( bool $capture = true,
string $delimiter = '/' )

Get the base regex.

Parameters
bool$captureSet to false to suppress the capture groups, which can cause unexpected conflicts when this regexp is embedded in other regexps with similar constructs.
string$delimiterThe delimiter which will be used for the eventual regexp.
Returns
string[]
Access: internal

Definition at line 112 of file MagicWordArray.php.

◆ getHash()

MediaWiki\Parser\MagicWordArray::getHash ( )

Get a 2-d hashtable for this array.

Returns
array

Definition at line 85 of file MagicWordArray.php.

◆ getNames()

MediaWiki\Parser\MagicWordArray::getNames ( )
Since
1.20
Returns
string[]

Definition at line 226 of file MagicWordArray.php.

◆ getRegex()

MediaWiki\Parser\MagicWordArray::getRegex ( )

Get an unanchored regex that does not match parameters.

Returns
string[]
Access: internal

Definition at line 160 of file MagicWordArray.php.

References $base.

◆ getRegexStart()

MediaWiki\Parser\MagicWordArray::getRegexStart ( )

Get a regex anchored to the start of the string that does not match parameters.

Returns
string[]
Access: internal

Definition at line 192 of file MagicWordArray.php.

References $base.

◆ getVariableRegex()

MediaWiki\Parser\MagicWordArray::getVariableRegex ( )

Get a regex for matching variables with parameters.

Returns
string[]
Access: internal
Deprecated
since 1.36 Appears to have no uses.

Definition at line 181 of file MagicWordArray.php.

References wfDeprecated().

◆ getVariableStartToEndRegex()

MediaWiki\Parser\MagicWordArray::getVariableStartToEndRegex ( )

Get an anchored regex for matching variables with parameters.

Returns
string[]
Access: internal

Definition at line 210 of file MagicWordArray.php.

References $base.

◆ matchAndRemove()

MediaWiki\Parser\MagicWordArray::matchAndRemove ( & $text)

Returns an associative array, ID => param value, for all items that match Removes the matched items from the input string (passed by reference)

Parameters
string&$text
Returns
array

Definition at line 308 of file MagicWordArray.php.

References $matches, and $res.

◆ matchStartAndRemove()

MediaWiki\Parser\MagicWordArray::matchStartAndRemove ( & $text)

Return the ID of the magic word at the start of $text, and remove the prefix from $text.

Return false if no match found and $text is not modified. Does not match parameters.

Parameters
string&$text
Returns
int|bool False on failure

Definition at line 363 of file MagicWordArray.php.

◆ matchStartToEnd()

MediaWiki\Parser\MagicWordArray::matchStartToEnd ( $text)

Match some text, without parameter capture Returns the magic word name, or false if there was no capture.

Parameters
string$text
Returns
string|false False on failure

Definition at line 291 of file MagicWordArray.php.

◆ matchVariableStartToEnd()

MediaWiki\Parser\MagicWordArray::matchVariableStartToEnd ( $text)

Match some text, with parameter capture Returns an array with the magic word name in the first element and the parameter in the second element.

Both elements are false if there was no match.

Parameters
string$text
Returns
array

Definition at line 272 of file MagicWordArray.php.

◆ parseMatch()

MediaWiki\Parser\MagicWordArray::parseMatch ( $m)

Parse a match array from preg_match Returns array(magic word ID, parameter value) If there is no parameter value, that element will be false.

Parameters
array$m
Exceptions
MWException
Returns
array

Definition at line 240 of file MagicWordArray.php.

Member Data Documentation

◆ $names

string [] MediaWiki\Parser\MagicWordArray::$names = []

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