12 function __construct( $conf ) {
13 if ( !isset( $conf['parsers'] ) ) {
14 throw new MWException( __METHOD__
. ': no parsers specified' );
17 $this->dtUniqPrefix
= "\x7fUNIQ" . Parser
::getRandomString();
21 if ( !is_null( $this->parsers
) ) {
26 static $doneHook = false;
29 $wgHooks['ParserClearState'][] = array( $this, 'onClearState' );
32 foreach ( $this->conf
['parsers'] as $i => $parserConf ) {
33 if ( !is_array( $parserConf ) ) {
35 $parserConf = array( 'class' => $parserConf );
37 $class = $parserConf['class'];
39 $this->parsers
[$i] = new $class( $parserConf );
43 function __call( $name, $args ) {
49 foreach ( $this->parsers
as $i => $parser ) {
50 $currentResult = call_user_func_array( array( &$this->parsers
[$i], $name ), $args );
54 if ( is_object( $lastResult ) ) {
55 if ( $lastResult != $currentResult ) {
59 if ( $lastResult !== $currentResult ) {
64 $results[$i] = $currentResult;
65 $lastResult = $currentResult;
68 throw new MWException( "Parser_DiffTest: results mismatch on call to $name\n" .
69 'Arguments: ' . var_export( $args, true ) . "\n" .
70 'Results: ' . var_export( $results, true ) . "\n" );
75 function setFunctionHook( $id, $callback, $flags = 0 ) {
77 foreach ( $this->parsers
as $i => $parser ) {
78 $parser->setFunctionHook( $id, $callback, $flags );
82 function onClearState( &$parser ) {
83 // hack marker prefixes to get identical output
84 $parser->mUniqPrefix
= $this->dtUniqPrefix
;