Merge "Unsuppress another phan issue (part 7)"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 3 Sep 2019 17:45:53 +0000 (17:45 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 3 Sep 2019 17:45:53 +0000 (17:45 +0000)
includes/installer/CliInstaller.php
includes/installer/Installer.php
includes/installer/WebInstallerOptions.php

index 0ff34b0..424c9d7 100644 (file)
@@ -120,11 +120,7 @@ class CliInstaller extends Installer {
                        }
                        $this->setVar( '_Extensions', $status->value );
                } elseif ( isset( $options['with-extensions'] ) ) {
-                       $status = $this->findExtensions();
-                       if ( !$status->isOK() ) {
-                               throw new InstallException( $status );
-                       }
-                       $this->setVar( '_Extensions', array_keys( $status->value ) );
+                       $this->setVar( '_Extensions', array_keys( $this->findExtensions() ) );
                }
 
                // Set up the default skins
@@ -135,11 +131,7 @@ class CliInstaller extends Installer {
                        }
                        $skins = $status->value;
                } else {
-                       $status = $this->findExtensions( 'skins' );
-                       if ( !$status->isOK() ) {
-                               throw new InstallException( $status );
-                       }
-                       $skins = array_keys( $status->value );
+                       $skins = array_keys( $this->findExtensions( 'skins' ) );
                }
                $this->setVar( '_Skins', $skins );
 
index ccc548b..620cdf0 100644 (file)
@@ -1271,8 +1271,7 @@ abstract class Installer {
         *
         * @param string $directory Directory to search in, relative to $IP, must be either "extensions"
         *     or "skins"
-        * @return Status An object containing an error list. If there were no errors, an associative
-        *     array of information about the extension can be found in $status->value.
+        * @return array[][] [ $extName => [ 'screenshots' => [ '...' ] ]
         */
        public function findExtensions( $directory = 'extensions' ) {
                switch ( $directory ) {
@@ -1291,40 +1290,33 @@ abstract class Installer {
         *
         * @param string $type Either "extension" or "skin"
         * @param string $directory Directory to search in, relative to $IP
-        * @return Status An object containing an error list. If there were no errors, an associative
-        *     array of information about the extension can be found in $status->value.
+        * @return array [ $extName => [ 'screenshots' => [ '...' ] ]
         */
        protected function findExtensionsByType( $type = 'extension', $directory = 'extensions' ) {
                if ( $this->getVar( 'IP' ) === null ) {
-                       return Status::newGood( [] );
+                       return [];
                }
 
                $extDir = $this->getVar( 'IP' ) . '/' . $directory;
                if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) {
-                       return Status::newGood( [] );
+                       return [];
                }
 
                $dh = opendir( $extDir );
                $exts = [];
-               $status = new Status;
                while ( ( $file = readdir( $dh ) ) !== false ) {
-                       // skip non-dirs and hidden directories
-                       if ( !is_dir( "$extDir/$file" ) || $file[0] === '.' ) {
+                       if ( !is_dir( "$extDir/$file" ) ) {
                                continue;
                        }
-                       $extStatus = $this->getExtensionInfo( $type, $directory, $file );
-                       if ( $extStatus->isOK() ) {
+                       $status = $this->getExtensionInfo( $type, $directory, $file );
+                       if ( $status->isOK() ) {
                                $exts[$file] = $status->value;
-                       } else {
-                               $status->merge( $extStatus );
                        }
                }
                closedir( $dh );
                uksort( $exts, 'strnatcasecmp' );
 
-               $status->value = $exts;
-
-               return $status;
+               return $exts;
        }
 
        /**
index 7c1619a..2412319 100644 (file)
@@ -104,7 +104,7 @@ class WebInstallerOptions extends WebInstallerPage {
                        $this->getFieldsetEnd()
                );
 
-               $skins = $this->parent->findExtensions( 'skins' )->value;
+               $skins = $this->parent->findExtensions( 'skins' );
                $skinHtml = $this->getFieldsetStart( 'config-skins' );
 
                $skinNames = array_map( 'strtolower', array_keys( $skins ) );
@@ -118,7 +118,6 @@ class WebInstallerOptions extends WebInstallerPage {
                                'value' => $chosenSkinName,
                        ] );
 
-                       // @phan-suppress-next-line PhanTypeNoAccessiblePropertiesForeach
                        foreach ( $skins as $skin => $info ) {
                                if ( isset( $info['screenshots'] ) ) {
                                        $screenshotText = $this->makeScreenshotsLink( $skin, $info['screenshots'] );
@@ -145,7 +144,7 @@ class WebInstallerOptions extends WebInstallerPage {
                        $this->getFieldsetEnd();
                $this->addHTML( $skinHtml );
 
-               $extensions = $this->parent->findExtensions()->value;
+               $extensions = $this->parent->findExtensions();
                $dependencyMap = [];
 
                if ( $extensions ) {
@@ -154,7 +153,6 @@ class WebInstallerOptions extends WebInstallerPage {
                        $extByType = [];
                        $types = SpecialVersion::getExtensionTypes();
                        // Sort by type first
-                       // @phan-suppress-next-line PhanTypeNoAccessiblePropertiesForeach
                        foreach ( $extensions as $ext => $info ) {
                                if ( !isset( $info['type'] ) || !isset( $types[$info['type']] ) ) {
                                        // We let extensions normally define custom types, but
@@ -331,8 +329,6 @@ class WebInstallerOptions extends WebInstallerPage {
                if ( count( $screenshots ) > 1 ) {
                        $links = [];
                        $counter = 1;
-
-                       // @phan-suppress-next-line PhanTypeNoAccessiblePropertiesForeach
                        foreach ( $screenshots as $shot ) {
                                $links[] = Html::element(
                                        'a',
@@ -452,7 +448,7 @@ class WebInstallerOptions extends WebInstallerPage {
         * @return bool
         */
        public function submitSkins() {
-               $skins = array_keys( $this->parent->findExtensions( 'skins' )->value );
+               $skins = array_keys( $this->parent->findExtensions( 'skins' ) );
                $this->parent->setVar( '_Skins', $skins );
 
                if ( $skins ) {
@@ -502,7 +498,7 @@ class WebInstallerOptions extends WebInstallerPage {
                        $this->setVar( 'wgRightsIcon', '' );
                }
 
-               $skinsAvailable = array_keys( $this->parent->findExtensions( 'skins' )->value );
+               $skinsAvailable = array_keys( $this->parent->findExtensions( 'skins' ) );
                $skinsToInstall = [];
                foreach ( $skinsAvailable as $skin ) {
                        $this->parent->setVarsFromRequest( [ "skin-$skin" ] );
@@ -523,7 +519,7 @@ class WebInstallerOptions extends WebInstallerPage {
                        $retVal = false;
                }
 
-               $extsAvailable = array_keys( $this->parent->findExtensions()->value );
+               $extsAvailable = array_keys( $this->parent->findExtensions() );
                $extsToInstall = [];
                foreach ( $extsAvailable as $ext ) {
                        $this->parent->setVarsFromRequest( [ "ext-$ext" ] );