Update formatting in maintenance/ (3/4)
[lhc/web/wiklou.git] / maintenance / preprocessorFuzzTest.php
index 20eb0c4..9155623 100644 (file)
  * @ingroup Maintenance
  */
 
-require_once( dirname( __FILE__ ) . '/commandLine.inc' );
+require_once __DIR__ . '/commandLine.inc';
 
 $wgHooks['BeforeParserFetchTemplateAndtitle'][] = 'PPFuzzTester::templateHook';
 
 class PPFuzzTester {
-       var $hairs = array(
+       public $hairs = array(
                '[[', ']]', '{{', '{{', '}}', '}}', '{{{', '}}}',
                '<', '>', '<nowiki', '<gallery', '</nowiki>', '</gallery>', '<nOwIkI>', '</NoWiKi>',
-               '<!--' , '-->',
+               '<!--', '-->',
                "\n==", "==\n",
                '|', '=', "\n", ' ', "\t", "\x7f",
                '~~', '~~~', '~~~~', 'subst:',
@@ -39,13 +39,14 @@ class PPFuzzTester {
                // extensions
                // '<ref>', '</ref>', '<references/>',
        );
-       var $minLength = 0;
-       var $maxLength = 20;
-       var $maxTemplates = 5;
-       // var $outputTypes = array( 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' );
-       var $entryPoints = array( 'testSrvus', 'testPst', 'testPreprocess' );
-       var $verbose = false;
-       static $currentTest = false;
+       public $minLength = 0;
+       public $maxLength = 20;
+       public $maxTemplates = 5;
+       // public $outputTypes = array( 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' );
+       public $entryPoints = array( 'testSrvus', 'testPst', 'testPreprocess' );
+       public $verbose = false;
+
+       private static $currentTest = false;
 
        function execute() {
                if ( !file_exists( 'results' ) ) {
@@ -102,7 +103,6 @@ class PPFuzzTester {
                                file_put_contents( $filename, "Input:\n$testReport\n" );*/
                        }
                }
-               wfLogProfilingData();
        }
 
        function makeInputText( $max = false ) {
@@ -121,6 +121,7 @@ class PPFuzzTester {
                // It's done by the MW UI, so it's a reasonably legitimate thing to do.
                global $wgContLang;
                $s = $wgContLang->normalize( $s );
+
                return $s;
        }
 
@@ -136,12 +137,13 @@ class PPFuzzTester {
 
        function pickEntryPoint() {
                $count = count( $this->entryPoints );
-               return $this->entryPoints[ mt_rand( 0, $count - 1 ) ];
+
+               return $this->entryPoints[mt_rand( 0, $count - 1 )];
        }
 }
 
 class PPFuzzTest {
-       var $templates, $mainText, $title, $entryPoint, $output;
+       public $templates, $mainText, $title, $entryPoint, $output;
 
        function __construct( $tester ) {
                global $wgMaxSigChars;
@@ -155,6 +157,9 @@ class PPFuzzTest {
                $this->templates = array();
        }
 
+       /**
+        * @param Title $title
+        */
        function templateHook( $title ) {
                $titleText = $title->getPrefixedDBkey();
 
@@ -179,6 +184,7 @@ class PPFuzzTest {
                                'text' => $text,
                                'finalTitle' => $finalTitle );
                }
+
                return $this->templates[$titleText];
        }
 
@@ -193,7 +199,13 @@ class PPFuzzTest {
                $options = ParserOptions::newFromUser( $wgUser );
                $options->setTemplateCallback( array( $this, 'templateHook' ) );
                $options->setTimestamp( wfTimestampNow() );
-               $this->output = call_user_func( array( $wgParser, $this->entryPoint ), $this->mainText, $this->title, $options );
+               $this->output = call_user_func(
+                       array( $wgParser, $this->entryPoint ),
+                       $this->mainText,
+                       $this->title,
+                       $options
+               );
+
                return $this->output;
        }
 
@@ -201,7 +213,8 @@ class PPFuzzTest {
                $s = "Title: " . $this->title->getPrefixedDBkey() . "\n" .
 //                     "Output type: {$this->outputType}\n" .
                        "Entry point: {$this->entryPoint}\n" .
-                       "User: " . ( $this->fancySig ? 'fancy' : 'no-fancy' ) . ' ' . var_export( $this->nickname, true ) . "\n" .
+                       "User: " . ( $this->fancySig ? 'fancy' : 'no-fancy' ) .
+                       ' ' . var_export( $this->nickname, true ) . "\n" .
                        "Main text: " . var_export( $this->mainText, true ) . "\n";
                foreach ( $this->templates as $titleText => $template ) {
                        $finalTitle = $template['finalTitle'];
@@ -212,12 +225,13 @@ class PPFuzzTest {
                        }
                }
                $s .= "Output: " . var_export( $this->output, true ) . "\n";
+
                return $s;
        }
 }
 
 class PPFuzzUser extends User {
-       var $ppfz_test, $mDataLoaded;
+       public $ppfz_test, $mDataLoaded;
 
        function load() {
                if ( $this->mDataLoaded ) {
@@ -228,12 +242,12 @@ class PPFuzzUser extends User {
        }
 
        function getOption( $oname, $defaultOverride = null, $ignoreHidden = false ) {
-               if ( $option === 'fancysig' ) {
+               if ( $oname === 'fancysig' ) {
                        return $this->ppfz_test->fancySig;
-               } elseif ( $option === 'nickname' ) {
+               } elseif ( $oname === 'nickname' ) {
                        return $this->ppfz_test->nickname;
                } else {
-                       return parent::getOption( $option, $defaultOverride, $ignoreHidden );
+                       return parent::getOption( $oname, $defaultOverride, $ignoreHidden );
                }
        }
 }