Merge "Add type hints for class properties in SpecialVersion"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 6 Aug 2019 22:18:01 +0000 (22:18 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 6 Aug 2019 22:18:01 +0000 (22:18 +0000)
1  2 
includes/specials/SpecialVersion.php

@@@ -31,13 -31,20 +31,20 @@@ use MediaWiki\MediaWikiServices
   * @ingroup SpecialPage
   */
  class SpecialVersion extends SpecialPage {
+       /**
+        * @var bool
+        */
        protected $firstExtOpened = false;
  
        /**
-        * Stores the current rev id/SHA hash of MediaWiki core
+        * @var string The current rev id/SHA hash of MediaWiki core
         */
        protected $coreId = '';
  
+       /**
+        * @var string[]|false Lazy initialized key/value with message content
+        */
        protected static $extensionTypes = false;
  
        public function __construct() {
        }
  
        /**
 -       * Returns wiki text showing the third party software versions (apache, php, mysql).
 +       * @since 1.34
         *
 -       * @return string
 +       * @return array
         */
 -      public static function softwareInformation() {
 +      public static function getSoftwareInformation() {
                $dbr = wfGetDB( DB_REPLICA );
  
                // Put the software in an array of form 'name' => 'version'. All messages should
                // be loaded here, so feel free to use wfMessage in the 'name'. Raw HTML or
                // wikimarkup can be used.
 -              $software = [];
 -              $software['[https://www.mediawiki.org/ MediaWiki]'] = self::getVersionLinked();
 +              $software = [
 +                      '[https://www.mediawiki.org/ MediaWiki]' => self::getVersionLinked()
 +              ];
 +
                if ( wfIsHHVM() ) {
                        $software['[https://hhvm.com/ HHVM]'] = HHVM_VERSION . " (" . PHP_SAPI . ")";
                } else {
                        $software['[https://php.net/ PHP]'] = PHP_VERSION . " (" . PHP_SAPI . ")";
                }
 +
                $software[$dbr->getSoftwareLink()] = $dbr->getServerInfo();
  
                if ( defined( 'INTL_ICU_VERSION' ) ) {
                // Allow a hook to add/remove items.
                Hooks::run( 'SoftwareInfo', [ &$software ] );
  
 +              return $software;
 +      }
 +
 +      /**
 +       * Returns HTML showing the third party software versions (apache, php, mysql).
 +       *
 +       * @return string HTML table
 +       */
 +      public static function softwareInformation() {
                $out = Xml::element(
                                'h2',
                                [ 'id' => 'mw-version-software' ],
                                wfMessage( 'version-software' )->text()
                        ) .
 -                              Xml::openElement( 'table', [ 'class' => 'wikitable plainlinks', 'id' => 'sv-software' ] ) .
 -                              "<tr>
 -                                      <th>" . wfMessage( 'version-software-product' )->text() . "</th>
 -                                      <th>" . wfMessage( 'version-software-version' )->text() . "</th>
 -                              </tr>\n";
 +                      Xml::openElement( 'table', [ 'class' => 'wikitable plainlinks', 'id' => 'sv-software' ] ) .
 +                      "<tr>
 +                              <th>" . wfMessage( 'version-software-product' )->text() . "</th>
 +                              <th>" . wfMessage( 'version-software-version' )->text() . "</th>
 +                      </tr>\n";
  
 -              foreach ( $software as $name => $version ) {
 +              foreach ( self::getSoftwareInformation() as $name => $version ) {
                        $out .= "<tr>
                                        <td>" . $name . "</td>
                                        <td dir=\"ltr\">" . $version . "</td>
         *
         * @since 1.17
         *
-        * @return array
+        * @return string[]
         */
        public static function getExtensionTypes() {
                if ( self::$extensionTypes === false ) {