MediaWiki  1.23.8
MagicWordArray Class Reference

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

Public Member Functions

 __construct ( $names=array())
 
 add ( $name)
 Add a magic word by name. More...
 
 addArray ( $names)
 Add a number of magic words by name. More...
 
 getBaseRegex ()
 Get the base regex. More...
 
 getHash ()
 Get a 2-d hashtable for this array. More...
 
 getNames ()
 
 getRegex ()
 Get an unanchored regex that does not match parameters. More...
 
 getRegexStart ()
 Get a regex anchored to the start of the string that does not match parameters. More...
 
 getVariableRegex ()
 Get a regex for matching variables with parameters. More...
 
 getVariableStartToEndRegex ()
 Get an anchored regex for matching variables with parameters. More...
 
 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) More...
 
 matchStartAndRemove (&$text)
 Return the ID of the magic word at the start of $text, and remove the prefix from $text. More...
 
 matchStartToEnd ( $text)
 Match some text, without parameter capture Returns the magic word name, or false if there was no capture. More...
 
 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. More...
 
 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. More...
 

Public Attributes

 $baseRegex
 
 $hash
 
 $matches
 
 $names = array()
 
 $regex
 

Detailed Description

Class for handling an array of magic words.

Definition at line 676 of file MagicWord.php.

Constructor & Destructor Documentation

◆ __construct()

MagicWordArray::__construct (   $names = array())
Parameters
$namesarray

Definition at line 685 of file MagicWord.php.

References $names.

Member Function Documentation

◆ add()

MagicWordArray::add (   $name)

Add a magic word by name.

Parameters
$namestring

Definition at line 694 of file MagicWord.php.

References $name.

◆ addArray()

MagicWordArray::addArray (   $names)

Add a number of magic words by name.

Parameters
$namesarray

Definition at line 704 of file MagicWord.php.

References $names.

◆ getBaseRegex()

MagicWordArray::getBaseRegex ( )

Get the base regex.

Definition at line 733 of file MagicWord.php.

References $baseRegex, $name, array(), as, and MagicWord\get().

Referenced by getRegex(), getRegexStart(), and getVariableStartToEndRegex().

◆ getHash()

MagicWordArray::getHash ( )

Get a 2-d hashtable for this array.

Definition at line 712 of file MagicWord.php.

References $hash, $name, $wgContLang, array(), as, MagicWord\get(), and global.

Referenced by matchStartToEnd().

◆ getNames()

MagicWordArray::getNames ( )
Since
1.20
Returns
array

Definition at line 818 of file MagicWord.php.

References $names.

◆ getRegex()

MagicWordArray::getRegex ( )

Get an unanchored regex that does not match parameters.

Definition at line 757 of file MagicWord.php.

References $regex, array(), and getBaseRegex().

Referenced by getVariableRegex(), and matchAndRemove().

◆ getRegexStart()

MagicWordArray::getRegexStart ( )

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

Returns
array

Definition at line 785 of file MagicWord.php.

References array(), and getBaseRegex().

Referenced by matchStartAndRemove().

◆ getVariableRegex()

MagicWordArray::getVariableRegex ( )

Get a regex for matching variables with parameters.

Returns
string

Definition at line 776 of file MagicWord.php.

References getRegex().

◆ getVariableStartToEndRegex()

MagicWordArray::getVariableStartToEndRegex ( )

Get an anchored regex for matching variables with parameters.

Returns
array

Definition at line 802 of file MagicWord.php.

References array(), and getBaseRegex().

Referenced by matchVariableStartToEnd().

◆ matchAndRemove()

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
$textstring
Returns
array

Definition at line 904 of file MagicWord.php.

References $matches, $name, $regex, array(), as, getRegex(), list, and parseMatch().

◆ matchStartAndRemove()

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
$textstring
Returns
int|bool False on failure

Definition at line 931 of file MagicWord.php.

References $regex, as, getRegexStart(), list, and parseMatch().

◆ matchStartToEnd()

MagicWordArray::matchStartToEnd (   $text)

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

Parameters
$textstring
Returns
string|bool False on failure

Definition at line 883 of file MagicWord.php.

References $hash, $wgContLang, getHash(), and global.

◆ matchVariableStartToEnd()

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
$textstring
Returns
array

Definition at line 862 of file MagicWord.php.

References $regex, array(), as, getVariableStartToEndRegex(), and parseMatch().

◆ 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.

Parameters
$marray
Exceptions
MWException
Returns
array

Definition at line 832 of file MagicWord.php.

References $value, array(), and list.

Referenced by matchAndRemove(), matchStartAndRemove(), and matchVariableStartToEnd().

Member Data Documentation

◆ $baseRegex

MagicWordArray::$baseRegex

Definition at line 679 of file MagicWord.php.

Referenced by getBaseRegex().

◆ $hash

MagicWordArray::$hash

Definition at line 678 of file MagicWord.php.

Referenced by getHash(), and matchStartToEnd().

◆ $matches

MagicWordArray::$matches

Definition at line 680 of file MagicWord.php.

Referenced by matchAndRemove().

◆ $names

MagicWordArray::$names = array()

Definition at line 677 of file MagicWord.php.

Referenced by __construct(), addArray(), and getNames().

◆ $regex

MagicWordArray::$regex

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