35 if ( !isset(
$conf[
'parsers'] ) ) {
36 throw new MWException( __METHOD__ .
': no parsers specified' );
42 if ( !is_null( $this->parsers ) ) {
47 static $doneHook =
false;
50 $wgHooks[
'ParserClearState'][] =
array( $this,
'onClearState' );
52 if ( isset( $this->conf[
'shortOutput'] ) ) {
53 $this->shortOutput = $this->conf[
'shortOutput'];
56 foreach ( $this->conf[
'parsers']
as $i => $parserConf ) {
57 if ( !is_array( $parserConf ) ) {
59 $parserConf =
array(
'class' => $parserConf );
61 $class = $parserConf[
'class'];
63 $this->parsers[$i] =
new $class( $parserConf );
73 foreach ( $this->parsers
as $i =>
$parser ) {
74 $currentResult = call_user_func_array(
array( &$this->parsers[$i],
$name ),
$args );
78 if ( is_object( $lastResult ) ) {
79 if ( $lastResult != $currentResult ) {
83 if ( $lastResult !== $currentResult ) {
88 $results[$i] = $currentResult;
89 $lastResult = $currentResult;
92 if ( count( $results ) == 2 ) {
93 $resultsList =
array();
94 foreach ( $this->parsers
as $i =>
$parser ) {
95 $resultsList[] = var_export( $results[$i],
true );
97 $diff =
wfDiff( $resultsList[0], $resultsList[1] );
99 $diff =
'[too many parsers]';
101 $msg =
"Parser_DiffTest: results mismatch on call to $name\n";
102 if ( !$this->shortOutput ) {
105 $msg .=
'Results: ' . $this->
formatArray( $results ) .
"\n" .
113 if ( $this->shortOutput ) {
114 foreach ( $array
as $key =>
$value ) {
116 $array[$key] =
"ParserOutput: {$value->getText()}";
120 return var_export( $array,
true );
136 if ( !isset( $this->dtUniqPrefix ) ) {
137 $this->dtUniqPrefix =
$parser->uniqPrefix();