Unsuppress other phan issues with low count
authorDaimona Eaytoy <daimona.wiki@gmail.com>
Thu, 29 Aug 2019 13:19:39 +0000 (15:19 +0200)
committerDaimona Eaytoy <daimona.wiki@gmail.com>
Fri, 30 Aug 2019 09:42:15 +0000 (09:42 +0000)
And also update approximated counts, which for the most part are lower
than reported (hooray!)

Bug: T231636
Depends-On: Ica50297ec7c71a81ba2204f9763499da925067bd
Change-Id: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd

30 files changed:
.phan/config.php
includes/EditPage.php
includes/Title.php
includes/cache/BacklinkCache.php
includes/filerepo/file/File.php
includes/filerepo/file/LocalFile.php
includes/filerepo/file/UnregisteredLocalFile.php
includes/historyblob/DiffHistoryBlob.php
includes/language/Message.php
includes/libs/mime/MSCompoundFileReader.php
includes/libs/rdbms/database/IDatabase.php
includes/libs/stats/SamplingStatsdClient.php
includes/objectcache/ObjectCache.php
includes/page/ImageHistoryPseudoPager.php
includes/parser/PPDPart.php
includes/parser/PPDPart_Hash.php
includes/parser/PPDStackElement_Hash.php
includes/parser/Parser.php
includes/rcfeed/FormattedRCFeed.php
includes/resourceloader/DerivativeResourceLoaderContext.php
includes/resourceloader/ResourceLoaderOOUIImageModule.php
includes/specialpage/ChangesListSpecialPage.php
includes/specialpage/LoginSignupSpecialPage.php
includes/specials/pagers/AllMessagesTablePager.php
includes/user/User.php
includes/utils/AvroValidator.php
languages/Language.php
languages/LanguageConverter.php
maintenance/includes/TextPassDumper.php
maintenance/mergeMessageFileList.php

index 5813b29..893eebb 100644 (file)
@@ -76,47 +76,37 @@ $cfg['exclude_analysis_directory_list'] = [
 ];
 
 $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [
-       // approximate error count: 18
+       // approximate error count: 22
        "PhanAccessMethodInternal",
-       // approximate error count: 17
-       "PhanCommentParamOnEmptyParamList",
-       // approximate error count: 29
+       // approximate error count: 22
        "PhanCommentParamWithoutRealParam",
-       // approximate error count: 21
+       // approximate error count: 19
        "PhanParamReqAfterOpt",
-       // approximate error count: 26
+       // approximate error count: 20
        "PhanParamSignatureMismatch",
-       // approximate error count: 127
+       // approximate error count: 110
        "PhanParamTooMany",
-       // approximate error count: 30
+       // approximate error count: 63
        "PhanTypeArraySuspicious",
-       // approximate error count: 27
+       // approximate error count: 28
        "PhanTypeArraySuspiciousNullable",
-       // approximate error count: 26
+       // approximate error count: 22
        "PhanTypeComparisonFromArray",
-       // approximate error count: 63
+       // approximate error count: 88
        "PhanTypeInvalidDimOffset",
-       // approximate error count: 154
+       // approximate error count: 60
        "PhanTypeMismatchArgument",
-       // approximate error count: 27
+       // approximate error count: 20
        "PhanTypeMismatchArgumentInternal",
-       // approximate error count: 27
-       "PhanTypeMismatchDimFetch",
-       // approximate error count: 10
-       "PhanTypeMismatchForeach",
-       // approximate error count: 77
+       // approximate error count: 40
        "PhanTypeMismatchProperty",
-       // approximate error count: 84
-       "PhanTypeMismatchReturn",
-       // approximate error count: 12
-       "PhanTypeObjectUnsetDeclaredProperty",
-       // approximate error count: 22
+       // approximate error count: 36
        "PhanUndeclaredConstant",
-       // approximate error count: 237
+       // approximate error count: 219
        "PhanUndeclaredMethod",
-       // approximate error count: 846
+       // approximate error count: 752
        "PhanUndeclaredProperty",
-       // approximate error count: 55
+       // approximate error count: 53
        "PhanUndeclaredVariableDim",
 ] );
 
index e51fc52..f066a61 100644 (file)
@@ -1127,7 +1127,7 @@ class EditPage {
         * @return string|null
         */
        protected function importContentFormData( &$request ) {
-               return; // Don't do anything, EditPage already extracted wpTextbox1
+               return null; // Don't do anything, EditPage already extracted wpTextbox1
        }
 
        /**
index 96f196f..8c5bbdc 100644 (file)
@@ -1250,6 +1250,7 @@ class Title implements LinkTarget, IDBAccessObject {
         * @param int|int[] $namespaces,... The namespaces to check for
         * @return bool
         * @since 1.19
+        * @suppress PhanCommentParamOnEmptyParamList Cannot make variadic due to HHVM bug, T191668#5263929
         */
        public function inNamespaces( /* ... */ ) {
                $namespaces = func_get_args();
index c2fb52a..2696302 100644 (file)
@@ -135,7 +135,7 @@ class BacklinkCache {
                $this->partitionCache = [];
                $this->fullResultCache = [];
                $this->wanCache->touchCheckKey( $this->makeCheckKey() );
-               unset( $this->db );
+               $this->db = null;
        }
 
        /**
@@ -153,7 +153,7 @@ class BacklinkCache {
         * @return IDatabase
         */
        protected function getDB() {
-               if ( !isset( $this->db ) ) {
+               if ( $this->db === null ) {
                        $this->db = wfGetDB( DB_REPLICA );
                }
 
index 5f6a0cb..d14e0de 100644 (file)
@@ -305,7 +305,7 @@ abstract class File implements IDBAccessObject {
         * @return string
         */
        public function getName() {
-               if ( !isset( $this->name ) ) {
+               if ( $this->name === null ) {
                        $this->assertRepoDefined();
                        $this->name = $this->repo->getNameFromTitle( $this->title );
                }
@@ -1521,7 +1521,7 @@ abstract class File implements IDBAccessObject {
         * @return string
         */
        function getHashPath() {
-               if ( !isset( $this->hashPath ) ) {
+               if ( $this->hashPath === null ) {
                        $this->assertRepoDefined();
                        $this->hashPath = $this->repo->getHashPath( $this->getName() );
                }
index 6143c31..f3116e2 100644 (file)
@@ -1946,8 +1946,8 @@ class LocalFile extends File {
                        // Now switch the object
                        $this->title = $target;
                        // Force regeneration of the name and hashpath
-                       unset( $this->name );
-                       unset( $this->hashPath );
+                       $this->name = null;
+                       $this->hashPath = null;
                }
 
                return $status;
index 2865ce5..4292ea0 100644 (file)
@@ -43,7 +43,7 @@ class UnregisteredLocalFile extends File {
        /** @var bool|string */
        protected $mime;
 
-       /** @var array Dimension data */
+       /** @var array[]|bool[] Dimension data */
        protected $dims;
 
        /** @var bool|string Handler-specific metadata which will be saved in the img_metadata field */
@@ -108,7 +108,7 @@ class UnregisteredLocalFile extends File {
 
        /**
         * @param int $page
-        * @return bool
+        * @return array|bool
         */
        private function cachePageDimensions( $page = 1 ) {
                $page = (int)$page;
index 8d92fe5..fdb3dc4 100644 (file)
@@ -333,7 +333,7 @@ class DiffHistoryBlob implements HistoryBlob {
                // addItem() doesn't work if mItems is partially filled from mDiffs
                $this->mFrozen = true;
                $info = unserialize( gzinflate( $this->mCompressed ) );
-               unset( $this->mCompressed );
+               $this->mCompressed = null;
 
                if ( !$info ) {
                        // Empty object
index 12007fa..0c1ef13 100644 (file)
@@ -158,6 +158,8 @@ use MediaWiki\MediaWikiServices;
  * @see https://www.mediawiki.org/wiki/Localisation
  *
  * @since 1.17
+ * @phan-file-suppress PhanCommentParamOnEmptyParamList Cannot make variadic due to HHVM bug,
+ *   T191668#5263929
  */
 class Message implements MessageSpecifier, Serializable {
        /** Use message text as-is */
index 26e9685..34d612a 100644 (file)
@@ -178,11 +178,22 @@ class MSCompoundFileReader {
                );
        }
 
+       /**
+        * @param int $offset
+        * @param int[] $struct
+        * @return array
+        */
        private function unpackOffset( $offset, $struct ) {
                $block = $this->readOffset( $offset, array_sum( $struct ) );
                return $this->unpack( $block, 0, $struct );
        }
 
+       /**
+        * @param string $block
+        * @param int $offset
+        * @param int[] $struct
+        * @return array
+        */
        private function unpack( $block, $offset, $struct ) {
                $data = [];
                foreach ( $struct as $key => $length ) {
index b4eb89a..68735e9 100644 (file)
@@ -959,7 +959,7 @@ interface IDatabase {
         * @param array $valuedata
         * @param string $valuename
         *
-        * @return string
+        * @return array|string
         * @deprecated Since 1.33
         */
        public function aggregateValue( $valuedata, $valuename = 'value' );
index 6494c26..172ead3 100644 (file)
@@ -84,7 +84,7 @@ class SamplingStatsdClient extends StatsdClient {
                        $data = [ $data ];
                }
                if ( !$data ) {
-                       return;
+                       return 0;
                }
                foreach ( $data as $item ) {
                        if ( !( $item instanceof StatsdDataInterface ) ) {
@@ -109,7 +109,7 @@ class SamplingStatsdClient extends StatsdClient {
                try {
                        $fp = $this->getSender()->open();
                        if ( !$fp ) {
-                               return;
+                               return 0;
                        }
                        foreach ( $data as $message ) {
                                $written += $this->getSender()->write( $fp, $message );
index 8ffe824..5e99ac9 100644 (file)
@@ -319,6 +319,7 @@ class ObjectCache {
         * @param array $params
         * @return WANObjectCache
         * @throws UnexpectedValueException
+        * @suppress PhanTypeMismatchReturn
         */
        public static function newWANCacheFromParams( array $params ) {
                global $wgCommandLineMode, $wgSecretKey;
index 799c33a..17a6d51 100644 (file)
@@ -77,7 +77,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
        }
 
        public function getQueryInfo() {
-               return false;
+               return [];
        }
 
        /**
index 1873730..b56527a 100644 (file)
@@ -33,6 +33,9 @@ class PPDPart {
        //   commentEnd   Past-the-end input pointer for the last comment encountered
        //   visualEnd    Past-the-end input pointer for the end of the accumulator minus comments
 
+       /**
+        * @param string $out
+        */
        public function __construct( $out = '' ) {
                $this->out = $out;
        }
index 7507f06..327dd77 100644 (file)
@@ -25,6 +25,9 @@
 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
 class PPDPart_Hash extends PPDPart {
 
+       /**
+        * @param string $out
+        */
        public function __construct( $out = '' ) {
                if ( $out !== '' ) {
                        $accum = [ $out ];
index 26351b2..5de5f47 100644 (file)
@@ -59,6 +59,7 @@ class PPDStackElement_Hash extends PPDStackElement {
                                } else {
                                        $accum[++$lastIndex] = '|';
                                }
+                               // @phan-suppress-next-line PhanTypeMismatchForeach
                                foreach ( $part->out as $node ) {
                                        if ( is_string( $node ) && is_string( $accum[$lastIndex] ) ) {
                                                $accum[$lastIndex] .= $node;
index d7a15af..130667e 100644 (file)
@@ -411,6 +411,7 @@ class Parser {
         */
        public function __destruct() {
                if ( isset( $this->mLinkHolders ) ) {
+                       // @phan-suppress-next-line PhanTypeObjectUnsetDeclaredProperty
                        unset( $this->mLinkHolders );
                }
                // @phan-suppress-next-line PhanTypeSuspiciousNonTraversableForeach
index d0b7ae3..9b5b29e 100644 (file)
@@ -61,6 +61,7 @@ abstract class FormattedRCFeed extends RCFeed {
                        // @codeCoverageIgnoreStart
                        // T109544 - If a feed formatter returns null, this will otherwise cause an
                        // error in at least RedisPubSubFeedEngine. Not sure best to handle this.
+                       // @phan-suppress-next-line PhanTypeMismatchReturn
                        return;
                        // @codeCoverageIgnoreEnd
                }
index b11bd6f..cf0b3c2 100644 (file)
@@ -54,6 +54,7 @@ class DerivativeResourceLoaderContext extends ResourceLoaderContext {
                if ( $this->modules === self::INHERIT_VALUE ) {
                        return $this->context->getModules();
                }
+               // @phan-suppress-next-line PhanTypeMismatchReturn
                return $this->modules;
        }
 
index 689ae58..9c204fc 100644 (file)
@@ -98,7 +98,7 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule {
                if ( $module ) {
                        $dataPath = $this->getThemeImagesPath( $theme, $module );
                        if ( !$dataPath ) {
-                               return false;
+                               return [];
                        }
                } else {
                        // Backwards-compatibility for things that probably shouldn't have used this class...
index 3893e92..0954c45 100644 (file)
@@ -1133,7 +1133,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
         *
         * There is light processing to simplify core maintenance.
         * @param array $definition
-        * @phan-param array<int,array{class:string}> $definition
+        * @phan-param array<int,array{class:string,filters:array}> $definition
         */
        protected function registerFiltersFromDefinitions( array $definition ) {
                $autoFillPriority = -1;
index d609d22..62818a1 100644 (file)
@@ -209,6 +209,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
 
        /**
         * @param string|null $subPage
+        * @suppress PhanTypeObjectUnsetDeclaredProperty
         */
        public function execute( $subPage ) {
                if ( $this->mPosted ) {
index 45d77ce..bd27919 100644 (file)
@@ -354,7 +354,7 @@ class AllMessagesTablePager extends TablePager {
        }
 
        function getQueryInfo() {
-               return '';
+               return [];
        }
 
 }
index b0ee5cb..061c60f 100644 (file)
@@ -3602,6 +3602,7 @@ class User implements IDBAccessObject, UserIdentity {
         *
         * @param string $permissions,... Permissions to test
         * @return bool True if user is allowed to perform *any* of the given actions
+        * @suppress PhanCommentParamOnEmptyParamList Cannot make variadic due to HHVM bug, T191668#5263929
         */
        public function isAllowedAny() {
                return MediaWikiServices::getInstance()
@@ -3614,6 +3615,7 @@ class User implements IDBAccessObject, UserIdentity {
         * ->getPermissionManager()->userHasAllRights(...) instead
         * @param string $permissions,... Permissions to test
         * @return bool True if the user is allowed to perform *all* of the given actions
+        * @suppress PhanCommentParamOnEmptyParamList Cannot make variadic due to HHVM bug, T191668#5263929
         */
        public function isAllowedAll() {
                return MediaWikiServices::getInstance()
index 153b313..b2d6077 100644 (file)
@@ -124,6 +124,7 @@ class AvroValidator {
                                        $errors[] = $result;
                                }
                                if ( $errors ) {
+                                       // @phan-suppress-next-line PhanTypeMismatchReturn
                                        return [ "Expected any one of these to be true", $errors ];
                                }
                                return "No schemas provided to union";
index dd5c632..ff66b25 100644 (file)
@@ -525,6 +525,7 @@ class Language {
                        }
 
                        # Sometimes a language will be localised but not actually exist on this wiki.
+                       // @phan-suppress-next-line PhanTypeMismatchForeach
                        foreach ( $this->namespaceNames as $key => $text ) {
                                if ( !isset( $validNamespaces[$key] ) ) {
                                        unset( $this->namespaceNames[$key] );
index 61a967d..d1a5720 100644 (file)
@@ -996,6 +996,7 @@ class LanguageConverter {
         */
        private function reloadTables() {
                if ( $this->mTables ) {
+                       // @phan-suppress-next-line PhanTypeObjectUnsetDeclaredProperty
                        unset( $this->mTables );
                }
 
index 21b92c5..04767fa 100644 (file)
@@ -207,6 +207,7 @@ TEXT
         * This function resets $this->lb and closes all connections on it.
         *
         * @throws MWException
+        * @suppress PhanTypeObjectUnsetDeclaredProperty
         */
        function rotateDb() {
                // Cleaning up old connections
index 80e72fb..48a6666 100644 (file)
@@ -157,6 +157,7 @@ class MergeMessageFileList extends Maintenance {
 require_once RUN_MAINTENANCE_IF_MAIN;
 
 $queue = [];
+'@phan-var string[][] $mmfl';
 foreach ( $mmfl['setupFiles'] as $fileName ) {
        if ( strval( $fileName ) === '' ) {
                continue;