MediaWiki REL1_34
|
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 () | |
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 = [] |
Private Attributes | |
$baseRegex | |
MagicWordFactory | $factory |
array | $hash |
$regex | |
Class for handling an array of magic words.
Definition at line 32 of file MagicWordArray.php.
MagicWordArray::__construct | ( | $names = [] , |
|
MagicWordFactory | $factory = null |
||
) |
string[] | $names | |
MagicWordFactory | null | $factory |
Definition at line 50 of file MagicWordArray.php.
MagicWordArray::add | ( | $name | ) |
MagicWordArray::addArray | ( | $names | ) |
Add a number of magic words by name.
string[] | $names |
Definition at line 70 of file MagicWordArray.php.
References $names.
MagicWordArray::getBaseRegex | ( | ) |
Get the base regex.
Definition at line 100 of file MagicWordArray.php.
References $baseRegex.
Referenced by getRegex(), getRegexStart(), and getVariableStartToEndRegex().
MagicWordArray::getHash | ( | ) |
Get a 2-d hashtable for this array.
Definition at line 79 of file MagicWordArray.php.
References $hash.
Referenced by matchStartToEnd().
MagicWordArray::getNames | ( | ) |
MagicWordArray::getRegex | ( | ) |
Get an unanchored regex that does not match parameters.
Definition at line 134 of file MagicWordArray.php.
References $base, $regex, and getBaseRegex().
Referenced by getVariableRegex(), and matchAndRemove().
MagicWordArray::getRegexStart | ( | ) |
Get a regex anchored to the start of the string that does not match parameters.
Definition at line 162 of file MagicWordArray.php.
References $base, and getBaseRegex().
Referenced by matchStartAndRemove().
MagicWordArray::getVariableRegex | ( | ) |
Get a regex for matching variables with parameters.
Definition at line 153 of file MagicWordArray.php.
References getRegex().
MagicWordArray::getVariableStartToEndRegex | ( | ) |
Get an anchored regex for matching variables with parameters.
Definition at line 179 of file MagicWordArray.php.
References $base, and getBaseRegex().
Referenced by matchVariableStartToEnd().
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)
string | &$text |
Definition at line 279 of file MagicWordArray.php.
References $matches, $regex, $res, getRegex(), and parseMatch().
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.
string | &$text |
Definition at line 323 of file MagicWordArray.php.
References $regex, getRegexStart(), and parseMatch().
MagicWordArray::matchStartToEnd | ( | $text | ) |
Match some text, without parameter capture Returns the magic word name, or false if there was no capture.
string | $text |
Definition at line 262 of file MagicWordArray.php.
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.
string | $text |
Definition at line 241 of file MagicWordArray.php.
References $regex, getVariableStartToEndRegex(), and parseMatch().
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.
array | $m |
MWException |
Definition at line 209 of file MagicWordArray.php.
Referenced by matchAndRemove(), matchStartAndRemove(), and matchVariableStartToEnd().
|
private |
Definition at line 42 of file MagicWordArray.php.
Referenced by getBaseRegex().
|
private |
Definition at line 37 of file MagicWordArray.php.
Referenced by __construct().
|
private |
Definition at line 40 of file MagicWordArray.php.
Referenced by getHash(), and matchStartToEnd().
string [] MagicWordArray::$names = [] |
Definition at line 34 of file MagicWordArray.php.
Referenced by __construct(), addArray(), and getNames().
|
private |
Definition at line 44 of file MagicWordArray.php.
Referenced by getRegex(), matchAndRemove(), matchStartAndRemove(), and matchVariableStartToEnd().