9 function __construct( $conf ) {
10 if ( !isset( $conf['parsers'] ) ) {
11 throw new MWException( __METHOD__
. ': no parsers specified' );
14 $this->dtUniqPrefix
= "\x7fUNIQ" . Parser
::getRandomString();
18 if ( !is_null( $this->parsers
) ) {
23 static $doneHook = false;
26 $wgHooks['ParserClearState'][] = array( $this, 'onClearState' );
29 foreach ( $this->conf
['parsers'] as $i => $parserConf ) {
30 if ( !is_array( $parserConf ) ) {
32 $parserConf = array( 'class' => $parserConf );
34 $class = $parserConf['class'];
36 $this->parsers
[$i] = new $class( $parserConf );
40 function __call( $name, $args ) {
46 foreach ( $this->parsers
as $i => $parser ) {
47 $currentResult = call_user_func_array( array( &$this->parsers
[$i], $name ), $args );
51 if ( is_object( $lastResult ) ) {
52 if ( $lastResult != $currentResult ) {
56 if ( $lastResult !== $currentResult ) {
61 $results[$i] = $currentResult;
62 $lastResult = $currentResult;
65 throw new MWException( "Parser_DiffTest: results mismatch on call to $name\n" .
66 'Arguments: ' . var_export( $args, true ) . "\n" .
67 'Results: ' . var_export( $results, true ) . "\n" );
72 function setFunctionHook( $id, $callback, $flags = 0 ) {
74 foreach ( $this->parsers
as $i => $parser ) {
75 $parser->setFunctionHook( $id, $callback, $flags );
79 function onClearState( &$parser ) {
80 // hack marker prefixes to get identical output
81 $parser->mUniqPrefix
= $this->dtUniqPrefix
;