Merge "phpcs: Normalize methods declarations to "[final abstract] [visibility]"."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 19 Feb 2013 17:16:16 +0000 (17:16 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 19 Feb 2013 17:16:16 +0000 (17:16 +0000)
1  2 
tests/parser/parserTest.inc
tests/selenium/Selenium.php
tests/selenium/SeleniumTestSuite.php

@@@ -74,7 -74,6 +74,7 @@@ class ParserTest 
  
        public $regex = "";
        private $savedGlobals = array();
 +
        /**
         * Sets terminal colorization and diff/quick modes depending on OS and
         * command-line options (--color and --quick).
                $this->color = !wfIsWindows() && Maintenance::posix_isatty( 1 );
  
                if ( isset( $options['color'] ) ) {
 -                      switch( $options['color'] ) {
 -                      case 'no':
 -                              $this->color = false;
 -                              break;
 -                      case 'yes':
 -                      default:
 -                              $this->color = true;
 -                              break;
 +                      switch ( $options['color'] ) {
 +                              case 'no':
 +                                      $this->color = false;
 +                                      break;
 +                              case 'yes':
 +                              default:
 +                                      $this->color = true;
 +                                      break;
                        }
                }
  
                $this->showProgress = !isset( $options['quiet'] );
                $this->showFailure = !(
                        isset( $options['quiet'] )
 -                      && ( isset( $options['record'] )
 +                              && ( isset( $options['record'] )
                                || isset( $options['compare'] ) ) ); // redundant output
  
                $this->showOutput = isset( $options['show-output'] );
                $wgExtensionAssetsPath = '/extensions';
                $wgThumbnailScriptPath = false;
                $wgLockManagers = array( array(
 -                      'name'          => 'fsLockManager',
 -                      'class'         => 'FSLockManager',
 +                      'name' => 'fsLockManager',
 +                      'class' => 'FSLockManager',
                        'lockDirectory' => wfTempDir() . '/test-repo/lockdir',
                ), array(
 -                      'name'          => 'nullLockManager',
 -                      'class'         => 'NullLockManager',
 +                      'name' => 'nullLockManager',
 +                      'class' => 'NullLockManager',
                ) );
                $wgLocalFileRepo = array(
 -                      'class'           => 'LocalRepo',
 -                      'name'            => 'local',
 -                      'url'             => 'http://example.com/images',
 -                      'hashLevels'      => 2,
 +                      'class' => 'LocalRepo',
 +                      'name' => 'local',
 +                      'url' => 'http://example.com/images',
 +                      'hashLevels' => 2,
                        'transformVia404' => false,
 -                      'backend'         => new FSFileBackend( array(
 -                              'name'        => 'local-backend',
 +                      'backend' => new FSFileBackend( array(
 +                              'name' => 'local-backend',
                                'lockManager' => 'fsLockManager',
                                'containerPaths' => array(
 -                                      'local-public'  => wfTempDir() . '/test-repo/public',
 -                                      'local-thumb'   => wfTempDir() . '/test-repo/thumb',
 -                                      'local-temp'    => wfTempDir() . '/test-repo/temp',
 +                                      'local-public' => wfTempDir() . '/test-repo/public',
 +                                      'local-thumb' => wfTempDir() . '/test-repo/thumb',
 +                                      'local-temp' => wfTempDir() . '/test-repo/temp',
                                        'local-deleted' => wfTempDir() . '/test-repo/deleted',
                                )
                        ) )
                $wgRequest = $context->getRequest();
  
                if ( $wgStyleDirectory === false ) {
 -                      $wgStyleDirectory   = "$IP/skins";
 +                      $wgStyleDirectory = "$IP/skins";
                }
  
        }
  
 -      public function setupRecorder ( $options ) {
 +      public function setupRecorder( $options ) {
                if ( isset( $options['record'] ) ) {
                        $this->recorder = new DbTestRecorder( $this );
                        $this->recorder->version = isset( $options['setversion'] ) ?
 -                                      $options['setversion'] : SpecialVersion::getVersion();
 +                              $options['setversion'] : SpecialVersion::getVersion();
                } elseif ( isset( $options['compare'] ) ) {
                        $this->recorder = new DbTestPreviewer( $this );
                } else {
         * Remove last character if it is a newline
         * @group utility
         */
-       static public function chomp( $s ) {
+       public static function chomp( $s ) {
                if ( substr( $s, -1 ) === "\n" ) {
                        return substr( $s, 0, -1 );
 -              }
 -              else {
 +              } else {
                        return $s;
                }
        }
  
                        $this->teardownDatabase();
                        $this->recorder->report();
 -              } catch (DBError $e) {
 +              } catch ( DBError $e ) {
                        echo $e->getMessage();
                }
                $this->recorder->end();
  
                if ( isset( $opts['title'] ) ) {
                        $titleText = $opts['title'];
 -              }
 -              else {
 +              } else {
                        $titleText = 'Parser test';
                }
  
                        'wgArticlePath' => '/wiki/$1',
                        'wgActionPaths' => array(),
                        'wgLockManagers' => array( array(
 -                              'name'          => 'fsLockManager',
 -                              'class'         => 'FSLockManager',
 +                              'name' => 'fsLockManager',
 +                              'class' => 'FSLockManager',
                                'lockDirectory' => $this->uploadDir . '/lockdir',
                        ), array(
 -                              'name'          => 'nullLockManager',
 -                              'class'         => 'NullLockManager',
 +                              'name' => 'nullLockManager',
 +                              'class' => 'NullLockManager',
                        ) ),
                        'wgLocalFileRepo' => array(
                                'class' => 'LocalRepo',
                                'url' => 'http://example.com/images',
                                'hashLevels' => 2,
                                'transformVia404' => false,
 -                              'backend'         => new FSFileBackend( array(
 -                                      'name'        => 'local-backend',
 +                              'backend' => new FSFileBackend( array(
 +                                      'name' => 'local-backend',
                                        'lockManager' => 'fsLockManager',
                                        'containerPaths' => array(
 -                                              'local-public'  => $this->uploadDir,
 -                                              'local-thumb'   => $this->uploadDir . '/thumb',
 -                                              'local-temp'    => $this->uploadDir . '/temp',
 +                                              'local-public' => $this->uploadDir,
 +                                              'local-thumb' => $this->uploadDir . '/thumb',
 +                                              'local-temp' => $this->uploadDir . '/temp',
                                                'local-deleted' => $this->uploadDir . '/delete',
                                        )
                                ) )
                        'wgVariantArticlePath' => false,
                        'wgGroupPermissions' => array( '*' => array(
                                'createaccount' => true,
 -                              'read'          => true,
 -                              'edit'          => true,
 -                              'createpage'    => true,
 -                              'createtalk'    => true,
 +                              'read' => true,
 +                              'edit' => true,
 +                              'createpage' => true,
 +                              'createtalk' => true,
                        ) ),
                        'wgNamespaceProtection' => array( NS_MEDIAWIKI => 'editinterface' ),
                        'wgDefaultExternalStore' => array(),
                $tables = array( 'user', 'user_properties', 'user_former_groups', 'page', 'page_restrictions',
                        'protected_titles', 'revision', 'text', 'pagelinks', 'imagelinks',
                        'categorylinks', 'templatelinks', 'externallinks', 'langlinks', 'iwlinks',
 -                      'site_stats', 'hitcounter',     'ipblocks', 'image', 'oldimage',
 +                      'site_stats', 'hitcounter', 'ipblocks', 'image', 'oldimage',
                        'recentchanges', 'watchlist', 'interwiki', 'logging',
                        'querycache', 'objectcache', 'job', 'l10n_cache', 'redirect', 'querycachetwo',
                        'archive', 'user_groups', 'page_props', 'category', 'msg_resource', 'msg_resource_links'
  
                        # Anonymous user
                        $this->db->insert( 'user', array(
 -                              'user_id'         => 0,
 -                              'user_name'       => 'Anonymous' ) );
 +                              'user_id' => 0,
 +                              'user_name' => 'Anonymous' ) );
                }
  
                # Hack: insert a few Wikipedia in-project interwiki prefixes,
                # for testing inter-language links
                $this->db->insert( 'interwiki', array(
                        array( 'iw_prefix' => 'wikipedia',
 -                                 'iw_url'    => 'http://en.wikipedia.org/wiki/$1',
 -                                 'iw_api'    => '',
 -                                 'iw_wikiid' => '',
 -                                 'iw_local'  => 0 ),
 +                              'iw_url' => 'http://en.wikipedia.org/wiki/$1',
 +                              'iw_api' => '',
 +                              'iw_wikiid' => '',
 +                              'iw_local' => 0 ),
                        array( 'iw_prefix' => 'meatball',
 -                                 'iw_url'    => 'http://www.usemod.com/cgi-bin/mb.pl?$1',
 -                                 'iw_api'    => '',
 -                                 'iw_wikiid' => '',
 -                                 'iw_local'  => 0 ),
 +                              'iw_url' => 'http://www.usemod.com/cgi-bin/mb.pl?$1',
 +                              'iw_api' => '',
 +                              'iw_wikiid' => '',
 +                              'iw_local' => 0 ),
                        array( 'iw_prefix' => 'zh',
 -                                 'iw_url'    => 'http://zh.wikipedia.org/wiki/$1',
 -                                 'iw_api'    => '',
 -                                 'iw_wikiid' => '',
 -                                 'iw_local'  => 1 ),
 +                              'iw_url' => 'http://zh.wikipedia.org/wiki/$1',
 +                              'iw_api' => '',
 +                              'iw_wikiid' => '',
 +                              'iw_local' => 1 ),
                        array( 'iw_prefix' => 'es',
 -                                 'iw_url'    => 'http://es.wikipedia.org/wiki/$1',
 -                                 'iw_api'    => '',
 -                                 'iw_wikiid' => '',
 -                                 'iw_local'  => 1 ),
 +                              'iw_url' => 'http://es.wikipedia.org/wiki/$1',
 +                              'iw_api' => '',
 +                              'iw_wikiid' => '',
 +                              'iw_local' => 1 ),
                        array( 'iw_prefix' => 'fr',
 -                                 'iw_url'    => 'http://fr.wikipedia.org/wiki/$1',
 -                                 'iw_api'    => '',
 -                                 'iw_wikiid' => '',
 -                                 'iw_local'  => 1 ),
 +                              'iw_url' => 'http://fr.wikipedia.org/wiki/$1',
 +                              'iw_api' => '',
 +                              'iw_wikiid' => '',
 +                              'iw_local' => 1 ),
                        array( 'iw_prefix' => 'ru',
 -                                 'iw_url'    => 'http://ru.wikipedia.org/wiki/$1',
 -                                 'iw_api'    => '',
 -                                 'iw_wikiid' => '',
 -                                 'iw_local'  => 1 ),
 -                      ) );
 +                              'iw_url' => 'http://ru.wikipedia.org/wiki/$1',
 +                              'iw_api' => '',
 +                              'iw_wikiid' => '',
 +                              'iw_local' => 1 ),
 +              ) );
  
                # Update certain things in site_stats
                $this->db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ) );
                $user = User::createNew( 'WikiSysop' );
                $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) );
                $image->recordUpload2( '', 'Upload of some lame file', 'Some lame file', array(
 -                      'size'        => 12345,
 -                      'width'       => 1941,
 -                      'height'      => 220,
 -                      'bits'        => 24,
 -                      'media_type'  => MEDIATYPE_BITMAP,
 -                      'mime'        => 'image/jpeg',
 -                      'metadata'    => serialize( array() ),
 -                      'sha1'        => wfBaseConvert( '', 16, 36, 31 ),
 -                      'fileExists'  => true
 -                      ), $this->db->timestamp( '20010115123500' ), $user );
 +                      'size' => 12345,
 +                      'width' => 1941,
 +                      'height' => 220,
 +                      'bits' => 24,
 +                      'media_type' => MEDIATYPE_BITMAP,
 +                      'mime' => 'image/jpeg',
 +                      'metadata' => serialize( array() ),
 +                      'sha1' => wfBaseConvert( '', 16, 36, 31 ),
 +                      'fileExists' => true
 +              ), $this->db->timestamp( '20010115123500' ), $user );
  
                # This image will be blacklisted in [[MediaWiki:Bad image list]]
                $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Bad.jpg' ) );
                $image->recordUpload2( '', 'zomgnotcensored', 'Borderline image', array(
 -                      'size'        => 12345,
 -                      'width'       => 320,
 -                      'height'      => 240,
 -                      'bits'        => 24,
 -                      'media_type'  => MEDIATYPE_BITMAP,
 -                      'mime'        => 'image/jpeg',
 -                      'metadata'    => serialize( array() ),
 -                      'sha1'        => wfBaseConvert( '', 16, 36, 31 ),
 -                      'fileExists'  => true
 -                      ), $this->db->timestamp( '20010115123500' ), $user );
 +                      'size' => 12345,
 +                      'width' => 320,
 +                      'height' => 240,
 +                      'bits' => 24,
 +                      'media_type' => MEDIATYPE_BITMAP,
 +                      'mime' => 'image/jpeg',
 +                      'metadata' => serialize( array() ),
 +                      'sha1' => wfBaseConvert( '', 16, 36, 31 ),
 +                      'fileExists' => true
 +              ), $this->db->timestamp( '20010115123500' ), $user );
        }
  
        public function teardownDatabase() {
                $this->databaseSetupDone = false;
  
                if ( $this->useTemporaryTables ) {
 -                      if( $this->db->getType() == 'sqlite' ) {
 +                      if ( $this->db->getType() == 'sqlite' ) {
                                # Under SQLite the searchindex table is virtual and need
                                # to be explicitly destroyed. See bug 29912
                                # See also MediaWikiTestCase::destroyDB()
                        $this->db->query( $sql );
                }
  
 -              if ( $this->db->getType() == 'oracle' )
 +              if ( $this->db->getType() == 'oracle' ) {
                        $this->db->query( 'BEGIN FILL_WIKI_INFO; END;' );
 +              }
  
                $this->teardownGlobals();
        }
  
                // delete the files first, then the dirs.
                self::deleteFiles(
 -                      array (
 +                      array(
                                "$dir/3/3a/Foobar.jpg",
                                "$dir/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg",
                                "$dir/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg",
                );
  
                self::deleteDirs(
 -                      array (
 +                      array(
                                "$dir/3/3a",
                                "$dir/3",
                                "$dir/thumb/6/65",
                $outfile = "$prefix-$outFileTail";
                $this->dumpToFile( $output, $outfile );
  
 -              $shellInfile = wfEscapeShellArg($infile);
 -              $shellOutfile = wfEscapeShellArg($outfile);
 +              $shellInfile = wfEscapeShellArg( $infile );
 +              $shellOutfile = wfEscapeShellArg( $outfile );
  
                global $wgDiff3;
                // we assume that people with diff3 also have usual diff
                return preg_replace(
                        array( '/^(-.*)$/m', '/^(\+.*)$/m' ),
                        array( $this->term->color( 34 ) . '$1' . $this->term->reset(),
 -                                 $this->term->color( 31 ) . '$1' . $this->term->reset() ),
 +                              $this->term->color( 31 ) . '$1' . $this->term->reset() ),
                        $text );
        }
  
         * @param $line Integer: the input line number, for reporting errors
         * @param $ignoreDuplicate Boolean: whether to silently ignore duplicate pages
         */
-       static public function addArticle( $name, $text, $line = 'unknown', $ignoreDuplicate = '' ) {
+       public static function addArticle( $name, $text, $line = 'unknown', $ignoreDuplicate = '' ) {
                global $wgCapitalLinks;
  
                $oldCapitalLinks = $wgCapitalLinks;
        public function requireHook( $name ) {
                global $wgParser;
  
 -              $wgParser->firstCallInit( ); // make sure hooks are loaded.
 +              $wgParser->firstCallInit(); // make sure hooks are loaded.
  
                if ( isset( $wgParser->mTagHooks[$name] ) ) {
                        $this->hooks[$name] = $wgParser->mTagHooks[$name];
        public function requireFunctionHook( $name ) {
                global $wgParser;
  
 -              $wgParser->firstCallInit( ); // make sure hooks are loaded.
 +              $wgParser->firstCallInit(); // make sure hooks are loaded.
  
                if ( isset( $wgParser->mFunctionHooks[$name] ) ) {
                        $this->functionHooks[$name] = $wgParser->mFunctionHooks[$name];
        private function wellFormed( $text ) {
                $html =
                        Sanitizer::hackDocType() .
 -                      '<html>' .
 -                      $text .
 -                      '</html>';
 +                              '<html>' .
 +                              $text .
 +                              '</html>';
  
                $parser = xml_parser_create( "UTF-8" );
  
@@@ -47,9 -47,7 +47,9 @@@ class Selenium 
        public function start() {
                $this->tester = new Testing_Selenium( $this->browser, self::$url, $this->host,
                        $this->port, $this->timeout );
 -              if ( method_exists( $this->tester, "setVerbose" ) ) $this->tester->setVerbose( $this->verbose );
 +              if ( method_exists( $this->tester, "setVerbose" ) ) {
 +                      $this->tester->setVerbose( $this->verbose );
 +              }
  
                $this->tester->start();
                $this->isStarted = true;
@@@ -96,7 -94,7 +96,7 @@@
                $this->logger = $logger;
        }
  
 -      public function getLogger( ) {
 +      public function getLogger() {
                return $this->logger;
        }
  
                self::$url = $url;
        }
  
-       static public function getUrl() {
+       public static function getUrl() {
                return self::$url;
        }
  
                $this->user = $user;
        }
  
 -        // Function to get username
 -        public function getUser() {
 +      // Function to get username
 +      public function getUser() {
                return $this->user;
        }
 -        
 +
  
        public function setPass( $pass ) {
                $this->pass = $pass;
        }
  
 -    //add function to get password    
 -      public function getPass(  ) {
 +      //add function to get password
 +      public function getPass() {
                return $this->pass;
        }
 -       
 -      
 +
        public function setHost( $host ) {
                $this->host = $host;
        }
                $this->junitlogfile = $junitlogfile;
        }
  
 -      public function getJUnitLogfile( ) {
 +      public function getJUnitLogfile() {
                return $this->junitlogfile;
        }
  
        }
  
        public function setBrowser( $b ) {
 -              if ($this->runagainstgrid) {
 +              if ( $this->runagainstgrid ) {
                        $this->browser = $b;
                        return true;
                }
        }
  
        // Prevent external cloning
 -      protected function __clone() { }
 +      protected function __clone() {}
        // Prevent external construction
        // protected function __construct() {}
  }
@@@ -11,7 -11,7 +11,7 @@@ abstract class SeleniumTestSuite extend
        const RESULT_OK = 2;
        const RESULT_ERROR = 3;
  
-       public abstract function addTests();
+       abstract public function addTests();
  
        public function setUp() {
                // Hack because because PHPUnit version 3.0.6 which is on prototype does not
@@@ -25,7 -25,7 +25,7 @@@
                if ( $this->triggerClientTestResources ) {
                        $this->selenium->open( $this->selenium->getUrl() . '/index.php?setupTestSuite=' . $this->getName() );
                        //wait a little longer for the db operation
 -                      $this->selenium->waitForPageToLoad( 6000  );
 +                      $this->selenium->waitForPageToLoad( 6000 );
                }
                if ( $this->loginBeforeTests ) {
                        $this->login();
@@@ -50,7 -50,7 +50,7 @@@
        protected function setLoginBeforeTests( $loginBeforeTests = true ) {
                $this->loginBeforeTests = $loginBeforeTests;
        }
 -      
 +
        protected function setTriggerClientTestResources( $triggerClientTestResources = true ) {
                $this->triggerClientTestResources = $triggerClientTestResources;
        }