WebInstaller inline documentation cleanup
authorThiemo Mättig <thiemo.maettig@wikimedia.de>
Tue, 8 Apr 2014 10:22:43 +0000 (12:22 +0200)
committerThiemo Mättig <thiemo.maettig@wikimedia.de>
Tue, 8 Apr 2014 10:22:43 +0000 (12:22 +0200)
This is a follow-up to Ide17d5af13c416c62a40029848ac17ba24eb5563.
However, I could not fix the "minor style" issue mentioned there
because this would make the line to long.

I fixed lots and lots of other issues instead, e.g.:

* "void" isn't a thing. Added "return null" instead.
* Removed documentation that said "a constructor is a constructor".
* Use "string[]" and such instead of "array" if possible.

Change-Id: I9658c2af58862f1d634cf1b2ba4c9d0f27ee7608

includes/installer/WebInstaller.php
includes/installer/WebInstallerOutput.php
includes/installer/WebInstallerPage.php

index 79fdc99..42672ca 100644 (file)
@@ -44,13 +44,14 @@ class WebInstaller extends Installer {
        /**
         * Cached session array.
         *
-        * @var array
+        * @var array[]
         */
        protected $session;
 
        /**
         * Captured PHP error text. Temporary.
-        * @var array
+        *
+        * @var string[]
         */
        protected $phpErrors;
 
@@ -61,7 +62,8 @@ class WebInstaller extends Installer {
         *    * Add it to this WebInstaller::$pageSequence property
         *    * Add a "config-page-<name>" message
         *    * Add a "WebInstaller_<name>" class
-        * @var array
+        *
+        * @var string[]
         */
        public $pageSequence = array(
                'Language',
@@ -78,7 +80,8 @@ class WebInstaller extends Installer {
 
        /**
         * Out of sequence pages, selectable by the user at any time.
-        * @var array
+        *
+        * @var string[]
         */
        protected $otherPages = array(
                'Restart',
@@ -91,7 +94,8 @@ class WebInstaller extends Installer {
        /**
         * Array of pages which have declared that they have been submitted, have validated
         * their input, and need no further processing.
-        * @var array
+        *
+        * @var bool[]
         */
        protected $happyPages;
 
@@ -99,24 +103,28 @@ class WebInstaller extends Installer {
         * List of "skipped" pages. These are pages that will automatically continue
         * to the next page on any GET request. To avoid breaking the "back" button,
         * they need to be skipped during a back operation.
-        * @var array
+        *
+        * @var bool[]
         */
        protected $skippedPages;
 
        /**
         * Flag indicating that session data may have been lost.
+        *
         * @var bool
         */
        public $showSessionWarning = false;
 
        /**
         * Numeric index of the page we're on
+        *
         * @var int
         */
        protected $tabIndex = 1;
 
        /**
         * Name of the page we're on
+        *
         * @var string
         */
        protected $currentPageName;
@@ -140,9 +148,9 @@ class WebInstaller extends Installer {
        /**
         * Main entry point.
         *
-        * @param array $session initial session array
+        * @param array[] $session initial session array
         *
-        * @return array New session array
+        * @return array[] New session array
         */
        public function execute( array $session ) {
                $this->session = $session;
@@ -396,7 +404,8 @@ class WebInstaller extends Installer {
 
        /**
         * Temporary error handler for session start debugging.
-        * @param $errno
+        *
+        * @param int $errno Unused
         * @param string $errstr
         */
        public function errorHandler( $errno, $errstr ) {
@@ -406,7 +415,7 @@ class WebInstaller extends Installer {
        /**
         * Clean up from execute()
         *
-        * @return array
+        * @return array[]
         */
        public function finish() {
                $this->output->output();
@@ -430,7 +439,8 @@ class WebInstaller extends Installer {
        /**
         * Get a URL for submission back to the same script.
         *
-        * @param array $query
+        * @param string[] $query
+        *
         * @return string
         */
        public function getUrl( $query = array() ) {
@@ -461,8 +471,9 @@ class WebInstaller extends Installer {
         * Get a session variable.
         *
         * @param string $name
-        * @param $default
-        * @return null
+        * @param array $default
+        *
+        * @return array
         */
        public function getSession( $name, $default = null ) {
                if ( !isset( $this->session[$name] ) ) {
@@ -474,6 +485,7 @@ class WebInstaller extends Installer {
 
        /**
         * Set a session variable.
+        *
         * @param string $name Key for the variable
         * @param mixed $value
         */
@@ -483,6 +495,7 @@ class WebInstaller extends Installer {
 
        /**
         * Get the next tabindex attribute value.
+        *
         * @return int
         */
        public function nextTabIndex() {
@@ -770,7 +783,7 @@ class WebInstaller extends Installer {
        /**
         * Get a labelled text box to configure a variable.
         *
-        * @param array $params
+        * @param mixed[] $params
         *    Parameters are:
         *      var:         The variable to be configured (required)
         *      label:       The message name for the label (required)
@@ -817,7 +830,7 @@ class WebInstaller extends Installer {
        /**
         * Get a labelled textarea to configure a variable
         *
-        * @param array $params
+        * @param mixed[] $params
         *    Parameters are:
         *      var:         The variable to be configured (required)
         *      label:       The message name for the label (required)
@@ -866,7 +879,7 @@ class WebInstaller extends Installer {
         * Get a labelled password box to configure a variable.
         *
         * Implements password hiding
-        * @param array $params
+        * @param mixed[] $params
         *    Parameters are:
         *      var:         The variable to be configured (required)
         *      label:       The message name for the label (required)
@@ -895,7 +908,7 @@ class WebInstaller extends Installer {
        /**
         * Get a labelled checkbox to configure a boolean variable.
         *
-        * @param array $params
+        * @param mixed[] $params
         *    Parameters are:
         *      var:         The variable to be configured (required)
         *      label:       The message name for the label (required)
@@ -946,7 +959,7 @@ class WebInstaller extends Installer {
        /**
         * Get a set of labelled radio buttons.
         *
-        * @param array $params
+        * @param mixed[] $params
         *    Parameters are:
         *      var:             The variable to be configured (required)
         *      label:           The message name for the label (required)
@@ -1033,10 +1046,10 @@ class WebInstaller extends Installer {
         * Assumes that variables containing "password" in the name are (potentially
         * fake) passwords.
         *
-        * @param array $varNames
+        * @param string[] $varNames
         * @param string $prefix The prefix added to variables to obtain form names
         *
-        * @return array
+        * @return string[]
         */
        public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
                $newValues = array();
@@ -1063,7 +1076,8 @@ class WebInstaller extends Installer {
        /**
         * Helper for Installer::docLink()
         *
-        * @param $page
+        * @param string $page
+        *
         * @return string
         */
        protected function getDocUrl( $page ) {
@@ -1079,9 +1093,10 @@ class WebInstaller extends Installer {
        /**
         * Extension tag hook for a documentation link.
         *
-        * @param $linkText
-        * @param $attribs
-        * @param $parser
+        * @param string $linkText
+        * @param string[] $attribs
+        * @param Parser $parser Unused
+        *
         * @return string
         */
        public function docLink( $linkText, $attribs, $parser ) {
@@ -1095,9 +1110,10 @@ class WebInstaller extends Installer {
        /**
         * Helper for "Download LocalSettings" link on WebInstall_Complete
         *
-        * @param $text
-        * @param $attribs
-        * @param $parser
+        * @param string $text Unused
+        * @param string[] $attribs Unused
+        * @param Parser $parser Unused
+        *
         * @return string Html for download link
         */
        public function downloadLinkHook( $text, $attribs, $parser ) {
@@ -1138,7 +1154,11 @@ class WebInstaller extends Installer {
                return parent::envCheckPath();
        }
 
+       /**
+        * @return String
+        */
        protected function envGetDefaultServer() {
                return WebRequest::detectServer();
        }
+
 }
index e05a3d4..a5e3c8b 100644 (file)
@@ -33,6 +33,7 @@
  * @since 1.17
  */
 class WebInstallerOutput {
+
        /**
         * The WebInstaller object this WebInstallerOutput is used by.
         *
@@ -52,6 +53,9 @@ class WebInstallerOutput {
         */
        private $headerDone = false;
 
+       /**
+        * @var string
+        */
        public $redirectTarget;
 
        /**
@@ -69,27 +73,39 @@ class WebInstallerOutput {
        private $useShortHeader = false;
 
        /**
-        * Constructor.
-        *
-        * @param $parent WebInstaller
+        * @param WebInstaller $parent
         */
        public function __construct( WebInstaller $parent ) {
                $this->parent = $parent;
        }
 
+       /**
+        * @param string $html
+        */
        public function addHTML( $html ) {
                $this->contents .= $html;
                $this->flush();
        }
 
+       /**
+        * @param string $text
+        */
        public function addWikiText( $text ) {
                $this->addHTML( $this->parent->parse( $text ) );
        }
 
+       /**
+        * @param string $html
+        */
        public function addHTMLNoFlush( $html ) {
                $this->contents .= $html;
        }
 
+       /**
+        * @param string $url
+        *
+        * @throws MWException
+        */
        public function redirect( $url ) {
                if ( $this->headerDone ) {
                        throw new MWException( __METHOD__ . ' called after sending headers' );
@@ -110,6 +126,7 @@ class WebInstallerOutput {
         *   and not properly handling such details as media types in module definitions.
         *
         * @param string $dir 'ltr' or 'rtl'
+        *
         * @return String
         */
        public function getCSS( $dir ) {
@@ -192,6 +209,7 @@ class WebInstallerOutput {
 
        /**
         * "<link>" to index.php?css=foobar for the "<head>"
+        *
         * @return String
         */
        private function getCssUrl() {
@@ -236,7 +254,7 @@ class WebInstallerOutput {
        }
 
        /**
-        * @return array
+        * @return string[]
         */
        public function getHeadAttribs() {
                return array(
@@ -247,6 +265,7 @@ class WebInstallerOutput {
 
        /**
         * Get whether the header has been output
+        *
         * @return bool
         */
        public function headerDone() {
@@ -341,7 +360,11 @@ class WebInstallerOutput {
                echo wfMessage( 'config-title', $wgVersion )->escaped();
        }
 
+       /**
+        * @return string
+        */
        public function getJQuery() {
                return Html::linkedScript( "../resources/jquery/jquery.js" );
        }
+
 }
index 69a460a..3b3473b 100644 (file)
@@ -36,12 +36,13 @@ abstract class WebInstallerPage {
         */
        public $parent;
 
+       /**
+        * @return string
+        */
        abstract public function execute();
 
        /**
-        * Constructor.
-        *
-        * @param $parent WebInstaller
+        * @param WebInstaller $parent
         */
        public function __construct( WebInstaller $parent ) {
                $this->parent = $parent;
@@ -51,12 +52,16 @@ abstract class WebInstallerPage {
         * Is this a slow-running page in the installer? If so, WebInstaller will
         * set_time_limit(0) before calling execute(). Right now this only applies
         * to Install and Upgrade pages
-        * @return bool
+        *
+        * @return bool Always false in this default implementation.
         */
        public function isSlow() {
                return false;
        }
 
+       /**
+        * @param string $html
+        */
        public function addHTML( $html ) {
                $this->parent->output->addHTML( $html );
        }
@@ -124,18 +129,33 @@ abstract class WebInstallerPage {
                $this->addHTML( $s );
        }
 
+       /**
+        * @return string
+        */
        public function getName() {
                return str_replace( 'WebInstaller_', '', get_class( $this ) );
        }
 
+       /**
+        * @return string
+        */
        protected function getId() {
                return array_search( $this->getName(), $this->parent->pageSequence );
        }
 
+       /**
+        * @param string $var
+        *
+        * @return mixed
+        */
        public function getVar( $var ) {
                return $this->parent->getVar( $var );
        }
 
+       /**
+        * @param string $name
+        * @param mixed $value
+        */
        public function setVar( $name, $value ) {
                $this->parent->setVar( $name, $value );
        }
@@ -175,16 +195,21 @@ abstract class WebInstallerPage {
        }
 
        /**
-        * Opposite to startLiveBox()
+        * Opposite to WebInstallerPage::startLiveBox
         */
        protected function endLiveBox() {
                $this->addHTML( '</textarea></div>
 <script>jQuery( "#config-spinner" ).hide()</script>' );
                $this->parent->output->flush();
        }
+
 }
 
 class WebInstaller_Language extends WebInstallerPage {
+
+       /**
+        * @return string|null
+        */
        public function execute() {
                global $wgLang;
                $r = $this->parent->request;
@@ -244,15 +269,18 @@ class WebInstaller_Language extends WebInstallerPage {
                                $this->parent->getHelpBox( 'config-wiki-language-help' ) );
                $this->addHTML( $s );
                $this->endForm( 'continue', false );
+
+               return null;
        }
 
        /**
         * Get a "<select>" for selecting languages.
         *
-        * @param $name
-        * @param $label
-        * @param $selectedCode
-        * @param $helpHtml string
+        * @param string $name
+        * @param string $label
+        * @param string $selectedCode
+        * @param string $helpHtml
+        *
         * @return string
         */
        public function getLanguageSelector( $name, $label, $selectedCode, $helpHtml = '' ) {
@@ -275,9 +303,14 @@ class WebInstaller_Language extends WebInstallerPage {
 
                return $this->parent->label( $label, $name, $s );
        }
+
 }
 
 class WebInstaller_ExistingWiki extends WebInstallerPage {
+
+       /**
+        * @return string
+        */
        public function execute() {
                // If there is no LocalSettings.php, continue to the installer welcome page
                $vars = Installer::getExistingLocalSettings();
@@ -366,6 +399,12 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
                $this->endForm( 'continue' );
        }
 
+       /**
+        * @param string[] $names
+        * @param mixed[] $vars
+        *
+        * @return Status
+        */
        protected function importVariables( $names, $vars ) {
                $status = Status::newGood();
                foreach ( $names as $name ) {
@@ -380,7 +419,9 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
 
        /**
         * Initiate an upgrade of the existing database
-        * @param array $vars Variables from LocalSettings.php
+        *
+        * @param mixed[] $vars Variables from LocalSettings.php
+        *
         * @return Status
         */
        protected function handleExistingUpgrade( $vars ) {
@@ -426,10 +467,14 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
 
                return $status;
        }
+
 }
 
 class WebInstaller_Welcome extends WebInstallerPage {
 
+       /**
+        * @return string
+        */
        public function execute() {
                if ( $this->parent->request->wasPosted() ) {
                        if ( $this->getVar( '_Environment' ) ) {
@@ -451,11 +496,13 @@ class WebInstaller_Welcome extends WebInstallerPage {
 
                return '';
        }
+
 }
 
 class WebInstaller_DBConnect extends WebInstallerPage {
+
        /**
-        * @return string|void When string, "skip" or "continue"
+        * @return string|null When string, "skip" or "continue"
         */
        public function execute() {
                if ( $this->getVar( '_ExistingDBSettings' ) ) {
@@ -529,8 +576,13 @@ class WebInstaller_DBConnect extends WebInstallerPage {
 
                $this->addHTML( $this->parent->label( 'config-db-type', false, $types ) . $settings );
                $this->endForm();
+
+               return null;
        }
 
+       /**
+        * @return Status
+        */
        public function submit() {
                $r = $this->parent->request;
                $type = $r->getVal( 'DBType' );
@@ -545,13 +597,21 @@ class WebInstaller_DBConnect extends WebInstallerPage {
 
                return $installer->submitConnectForm();
        }
+
 }
 
 class WebInstaller_Upgrade extends WebInstallerPage {
+
+       /**
+        * @return bool Always true.
+        */
        public function isSlow() {
                return true;
        }
 
+       /**
+        * @return string|null
+        */
        public function execute() {
                if ( $this->getVar( '_UpgradeDone' ) ) {
                        // Allow regeneration of LocalSettings.php, unless we are working
@@ -603,6 +663,8 @@ class WebInstaller_Upgrade extends WebInstallerPage {
                $this->addHTML( $this->parent->getInfoBox(
                        wfMessage( 'config-can-upgrade', $GLOBALS['wgVersion'] )->plain() ) );
                $this->endForm();
+
+               return null;
        }
 
        public function showDoneMessage() {
@@ -626,10 +688,14 @@ class WebInstaller_Upgrade extends WebInstallerPage {
                $this->parent->restoreLinkPopups();
                $this->endForm( $regenerate ? 'regenerate' : false, false );
        }
+
 }
 
 class WebInstaller_DBSettings extends WebInstallerPage {
 
+       /**
+        * @return string|null
+        */
        public function execute() {
                $installer = $this->parent->getDBInstaller( $this->getVar( 'wgDBtype' ) );
 
@@ -653,11 +719,17 @@ class WebInstaller_DBSettings extends WebInstallerPage {
                $this->startForm();
                $this->addHTML( $form );
                $this->endForm();
+
+               return null;
        }
+
 }
 
 class WebInstaller_Name extends WebInstallerPage {
 
+       /**
+        * @return string
+        */
        public function execute() {
                $r = $this->parent->request;
                if ( $r->wasPosted() ) {
@@ -751,6 +823,9 @@ class WebInstaller_Name extends WebInstallerPage {
                return 'output';
        }
 
+       /**
+        * @return bool
+        */
        public function submit() {
                $retVal = true;
                $this->parent->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
@@ -863,9 +938,14 @@ class WebInstaller_Name extends WebInstallerPage {
 
                return $retVal;
        }
+
 }
 
 class WebInstaller_Options extends WebInstallerPage {
+
+       /**
+        * @return string|null
+        */
        public function execute() {
                if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
                        return 'skip';
@@ -1049,6 +1129,8 @@ class WebInstaller_Options extends WebInstallerPage {
                        $this->getFieldSetEnd()
                );
                $this->endForm();
+
+               return null;
        }
 
        /**
@@ -1077,6 +1159,9 @@ class WebInstaller_Options extends WebInstallerPage {
                return $iframeUrl;
        }
 
+       /**
+        * @return string
+        */
        public function getCCChooser() {
                $iframeAttribs = array(
                        'class' => 'config-cc-iframe',
@@ -1098,6 +1183,9 @@ class WebInstaller_Options extends WebInstallerPage {
                        "</div>\n";
        }
 
+       /**
+        * @return string
+        */
        public function getCCDoneBox() {
                $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
                // If you change this height, also change it in config.css
@@ -1137,6 +1225,9 @@ class WebInstaller_Options extends WebInstallerPage {
                $this->addHTML( $this->getCCDoneBox() );
        }
 
+       /**
+        * @return bool
+        */
        public function submit() {
                $this->parent->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
                        'wgEnableEmail', 'wgPasswordSender', 'wgEnableUploads', 'wgLogo',
@@ -1216,13 +1307,21 @@ class WebInstaller_Options extends WebInstallerPage {
 
                return true;
        }
+
 }
 
 class WebInstaller_Install extends WebInstallerPage {
+
+       /**
+        * @return bool Always true.
+        */
        public function isSlow() {
                return true;
        }
 
+       /**
+        * @return string|bool
+        */
        public function execute() {
                if ( $this->getVar( '_UpgradeDone' ) ) {
                        return 'skip';
@@ -1251,6 +1350,9 @@ class WebInstaller_Install extends WebInstallerPage {
                return true;
        }
 
+       /**
+        * @param string $step
+        */
        public function startStage( $step ) {
                // Messages: config-install-database, config-install-tables, config-install-interwiki,
                // config-install-stats, config-install-keys, config-install-sysop, config-install-mainpage
@@ -1263,8 +1365,8 @@ class WebInstaller_Install extends WebInstallerPage {
        }
 
        /**
-        * @param $step
-        * @param $status Status
+        * @param string $step
+        * @param Status $status
         */
        public function endStage( $step, $status ) {
                if ( $step == 'extension-tables' ) {
@@ -1280,9 +1382,11 @@ class WebInstaller_Install extends WebInstallerPage {
                        $this->parent->showStatusBox( $status );
                }
        }
+
 }
 
 class WebInstaller_Complete extends WebInstallerPage {
+
        public function execute() {
                // Pop up a dialog box, to make it difficult for the user to forget
                // to download the file
@@ -1316,10 +1420,14 @@ class WebInstaller_Complete extends WebInstallerPage {
                $this->parent->restoreLinkPopups();
                $this->endForm( false, false );
        }
+
 }
 
 class WebInstaller_Restart extends WebInstallerPage {
 
+       /**
+        * @return string|null
+        */
        public function execute() {
                $r = $this->parent->request;
                if ( $r->wasPosted() ) {
@@ -1335,11 +1443,17 @@ class WebInstaller_Restart extends WebInstallerPage {
                $s = $this->parent->getWarningBox( wfMessage( 'config-help-restart' )->plain() );
                $this->addHTML( $s );
                $this->endForm( 'restart' );
+
+               return null;
        }
+
 }
 
 abstract class WebInstaller_Document extends WebInstallerPage {
 
+       /**
+        * @return string
+        */
        abstract protected function getFileName();
 
        public function execute() {
@@ -1350,6 +1464,9 @@ abstract class WebInstaller_Document extends WebInstallerPage {
                $this->endForm( false );
        }
 
+       /**
+        * @return string
+        */
        public function getFileContents() {
                $file = __DIR__ . '/../../' . $this->getFileName();
                if ( !file_exists( $file ) ) {
@@ -1358,15 +1475,26 @@ abstract class WebInstaller_Document extends WebInstallerPage {
 
                return file_get_contents( $file );
        }
+
 }
 
 class WebInstaller_Readme extends WebInstaller_Document {
+
+       /**
+        * @return string
+        */
        protected function getFileName() {
                return 'README';
        }
+
 }
 
 class WebInstaller_ReleaseNotes extends WebInstaller_Document {
+
+       /**
+        * @throws MWException
+        * @return string
+        */
        protected function getFileName() {
                global $wgVersion;
 
@@ -1376,16 +1504,27 @@ class WebInstaller_ReleaseNotes extends WebInstaller_Document {
 
                return 'RELEASE-NOTES-' . $result[1] . '.' . $result[2];
        }
+
 }
 
 class WebInstaller_UpgradeDoc extends WebInstaller_Document {
+
+       /**
+        * @return string
+        */
        protected function getFileName() {
                return 'UPGRADE';
        }
+
 }
 
 class WebInstaller_Copying extends WebInstaller_Document {
+
+       /**
+        * @return string
+        */
        protected function getFileName() {
                return 'COPYING';
        }
+
 }