Merge "phpunit: Don't bother resetting unused global in UploadFromUrlTestSuite"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 31 Aug 2019 20:40:49 +0000 (20:40 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 31 Aug 2019 20:40:49 +0000 (20:40 +0000)
96 files changed:
.phan/config.php
.phan/stubs/excimer.php
INSTALL
RELEASE-NOTES-1.34
composer.json
includes/DefaultSettings.php
includes/FauxRequest.php
includes/GlobalFunctions.php
includes/MediaWiki.php
includes/OutputPage.php
includes/Permissions/PermissionManager.php
includes/Rest/HeaderContainer.php
includes/Setup.php
includes/Title.php
includes/WebRequest.php
includes/api/ApiAuthManagerHelper.php
includes/api/ApiBase.php
includes/api/ApiEditPage.php
includes/api/ApiImportReporter.php
includes/api/ApiOpenSearch.php
includes/api/ApiQueryUsers.php
includes/api/ApiStashEdit.php
includes/auth/AuthenticationRequest.php
includes/cache/CacheHelper.php
includes/cache/MessageCache.php
includes/cache/localisation/LCStoreCDB.php
includes/cache/localisation/LocalisationCache.php
includes/changes/RecentChange.php
includes/context/ContextSource.php
includes/context/DerivativeContext.php
includes/context/RequestContext.php
includes/diff/ArrayDiffFormatter.php
includes/diff/DiffOp.php
includes/export/DumpNamespaceFilter.php
includes/export/DumpPipeOutput.php
includes/filerepo/ForeignAPIRepo.php
includes/filerepo/file/ForeignAPIFile.php
includes/gallery/ImageGalleryBase.php
includes/historyblob/ConcatenatedGzipHistoryBlob.php
includes/htmlform/HTMLForm.php
includes/htmlform/HTMLFormField.php
includes/htmlform/fields/HTMLAutoCompleteSelectField.php
includes/htmlform/fields/HTMLCheckMatrix.php
includes/htmlform/fields/HTMLMultiSelectField.php
includes/http/GuzzleHttpRequest.php
includes/language/Message.php
includes/language/MessageLocalizer.php
includes/libs/HashRing.php
includes/libs/filebackend/SwiftFileBackend.php
includes/libs/http/MultiHttpClient.php
includes/libs/lockmanager/QuorumLockManager.php
includes/libs/mime/XmlTypeCheck.php
includes/libs/objectcache/RedisBagOStuff.php
includes/libs/rdbms/database/DatabaseMysqli.php
includes/libs/rdbms/database/IDatabase.php
includes/libs/rdbms/database/position/MySQLMasterPos.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php
includes/logging/LogEntryBase.php
includes/media/ExifBitmapHandler.php
includes/media/FormatMetadata.php
includes/media/TiffHandler.php
includes/objectcache/SqlBagOStuff.php
includes/page/WikiPage.php
includes/parser/PPDStackElement_Hash.php
includes/parser/PPFrame.php
includes/parser/PPFrame_DOM.php
includes/parser/Parser.php
includes/preferences/DefaultPreferencesFactory.php
includes/profiler/ProfilerExcimer.php
includes/resourceloader/DerivativeResourceLoaderContext.php
includes/resourceloader/ResourceLoaderContext.php
includes/shell/Command.php
includes/site/Site.php
includes/skins/BaseTemplate.php
includes/specialpage/FormSpecialPage.php
includes/specials/SpecialBotPasswords.php
includes/specials/SpecialListGroupRights.php
includes/specials/helpers/ImportReporter.php
includes/specials/pagers/BlockListPager.php
includes/upload/UploadBase.php
includes/user/PasswordReset.php
includes/user/User.php
includes/user/UserNamePrefixSearch.php
includes/utils/ClassCollector.php
includes/widget/search/SearchFormWidget.php
languages/Language.php
languages/LanguageConverter.php
maintenance/convertExtensionToRegistration.php
maintenance/copyFileBackend.php
maintenance/generateSitemap.php
maintenance/importDump.php
maintenance/includes/TextPassDumper.php
maintenance/populateRevisionSha1.php
maintenance/rebuildmessages.php
maintenance/storage/recompressTracked.php
tests/phpunit/includes/libs/HashRingTest.php

index 893eebb..29729ae 100644 (file)
@@ -78,28 +78,16 @@ $cfg['exclude_analysis_directory_list'] = [
 $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [
        // approximate error count: 22
        "PhanAccessMethodInternal",
-       // approximate error count: 22
-       "PhanCommentParamWithoutRealParam",
        // approximate error count: 19
        "PhanParamReqAfterOpt",
-       // approximate error count: 20
-       "PhanParamSignatureMismatch",
        // approximate error count: 110
        "PhanParamTooMany",
        // approximate error count: 63
        "PhanTypeArraySuspicious",
-       // approximate error count: 28
-       "PhanTypeArraySuspiciousNullable",
-       // approximate error count: 22
-       "PhanTypeComparisonFromArray",
        // approximate error count: 88
        "PhanTypeInvalidDimOffset",
        // approximate error count: 60
        "PhanTypeMismatchArgument",
-       // approximate error count: 20
-       "PhanTypeMismatchArgumentInternal",
-       // approximate error count: 40
-       "PhanTypeMismatchProperty",
        // approximate error count: 36
        "PhanUndeclaredConstant",
        // approximate error count: 219
index e87d4cd..d663a44 100644 (file)
@@ -22,7 +22,7 @@ class ExcimerProfiler {
        }
        public function stop() {
        }
-       public function getLog() {
+       public function getLog() : ExcimerLog {
        }
        public function flush() {
        }
@@ -33,8 +33,14 @@ class ExcimerLog {
        }
        function formatCollapsed() {
        }
+       /**
+        * @return array[]
+        */
        function aggregateByFunction() {
        }
+       /**
+        * @return int
+        */
        function getEventCount() {
        }
        function current() {
diff --git a/INSTALL b/INSTALL
index bf64ab7..07dd9c3 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -5,8 +5,16 @@ Installing MediaWiki
 Starting with MediaWiki 1.2.0, it's possible to install and configure the wiki
 "in-place", as long as you have the necessary prerequisites available.
 
-Required software:
-* Web server with PHP 7.0.0 or HHVM 3.18.5 or higher.
+Required software as of MediaWiki 1.34.0:
+
+* Web server with PHP 7.0.13 or higher, plus the following extesnsions:
+** ctype
+** dom
+** fileinfo
+** iconv
+** json
+** mbstring
+** xml
 * A SQL server, the following types are supported
 ** MySQL 5.5.8 or higher
 ** PostgreSQL 9.2 or higher
index e57dacc..275f4c2 100644 (file)
@@ -485,7 +485,15 @@ because of Phabricator reports.
 == Compatibility ==
 MediaWiki 1.34 requires PHP 7.0.13 or later. Although HHVM 3.18.5 or later is
 supported, it is generally advised to use PHP 7.0.13 or later for long term
-support.
+support. It also requires the following PHP extensions:
+
+* ctype
+* dom
+* fileinfo
+* iconv
+* json
+* mbstring
+* xml
 
 MySQL/MariaDB is the recommended DBMS. PostgreSQL or SQLite can also be used,
 but support for them is somewhat less mature.
index 98e7ebf..dad3c5c 100644 (file)
@@ -20,6 +20,7 @@
                "composer/semver": "1.5.0",
                "cssjanus/cssjanus": "1.3.0",
                "ext-ctype": "*",
+               "ext-dom": "*",
                "ext-fileinfo": "*",
                "ext-iconv": "*",
                "ext-json": "*",
index 739c102..5a874d5 100644 (file)
@@ -1278,7 +1278,7 @@ $wgMaxAnimatedGifArea = 1.25e7;
  *  $wgTiffThumbnailType = [ 'jpg', 'image/jpeg' ];
  * @endcode
  */
-$wgTiffThumbnailType = false;
+$wgTiffThumbnailType = [];
 
 /**
  * If rendered thumbnail files are older than this timestamp, they
index ecbc6e3..78f6ca9 100644 (file)
@@ -88,6 +88,7 @@ class FauxRequest extends WebRequest {
 
        /**
         * @return array
+        * @suppress PhanParamSignatureMismatch
         */
        public function getValues() {
                return $this->data;
index cc998c7..4ae9237 100644 (file)
@@ -1127,6 +1127,7 @@ function wfLogProfilingData() {
        if ( isset( $ctx['forwarded_for'] ) ||
                isset( $ctx['client_ip'] ) ||
                isset( $ctx['from'] ) ) {
+               // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
                $ctx['proxy'] = $_SERVER['REMOTE_ADDR'];
        }
 
@@ -2892,6 +2893,7 @@ function wfUnpack( $format, $data, $length = false ) {
        $result = unpack( $format, $data );
        Wikimedia\restoreWarnings();
 
+       // @phan-suppress-next-line PhanTypeComparisonFromArray Phan issue #3160
        if ( $result === false ) {
                // If it cannot extract the packed data.
                throw new MWException( "unpack could not unpack binary data" );
index 7a6987e..f91477a 100644 (file)
@@ -745,7 +745,7 @@ class MediaWiki {
                        Profiler::instance()->logDataPageOutputOnly();
                } catch ( Exception $e ) {
                        // An error may already have been shown in run(), so just log it to be safe
-                       MWExceptionHandler::rollbackMasterChangesAndLog( $e );
+                       MWExceptionHandler::logException( $e );
                }
 
                // Disable WebResponse setters for post-send processing (T191537).
index 9af16d3..1703565 100644 (file)
@@ -44,7 +44,7 @@ use Wikimedia\WrappedStringList;
  * @todo document
  */
 class OutputPage extends ContextSource {
-       /** @var array Should be private. Used with addMeta() which adds "<meta>" */
+       /** @var string[][] Should be private. Used with addMeta() which adds "<meta>" */
        protected $mMetatags = [];
 
        /** @var array */
@@ -1820,14 +1820,10 @@ class OutputPage extends ContextSource {
         * @param string $text Wikitext
         * @param Title $title
         * @param bool $linestart Is this the start of a line?
-        * @param bool $tidy Whether to use tidy.
-        *             Setting this to false (or omitting it) is deprecated
-        *             since 1.32; all wikitext should be tidied.
         * @param bool $interface Whether it is an interface message
         *   (for example disables conversion)
         * @param string $wrapperClass if not empty, wraps the output in
         *   a `<div class="$wrapperClass">`
-        * @private
         */
        private function addWikiTextTitleInternal(
                $text, Title $title, $linestart, $interface, $wrapperClass = null
index 37791d0..0a8e515 100644 (file)
@@ -85,8 +85,8 @@ class PermissionManager {
        /** @var NamespaceInfo */
        private $nsInfo;
 
-       /** @var string[] Cached results of getAllRights() */
-       private $allRights = false;
+       /** @var string[]|null Cached results of getAllRights() */
+       private $allRights;
 
        /** @var string[][] Cached user rights */
        private $usersRights = null;
@@ -1220,7 +1220,8 @@ class PermissionManager {
         * Check if user is allowed to make any action
         *
         * @param UserIdentity $user
-        * // TODO: HHVM can't create mocks with variable params @param string ...$actions
+        * // TODO: HHVM bug T228695#5450847 @param string ...$actions
+        * @suppress PhanCommentParamWithoutRealParam
         * @return bool True if user is allowed to perform *any* of the given actions
         * @since 1.34
         */
@@ -1238,7 +1239,8 @@ class PermissionManager {
         * Check if user is allowed to make all actions
         *
         * @param UserIdentity $user
-        * // TODO: HHVM can't create mocks with variable params @param string ...$actions
+        * // TODO: HHVM bug T228695#5450847 @param string ...$actions
+        * @suppress PhanCommentParamWithoutRealParam
         * @return bool True if user is allowed to perform *all* of the given actions
         * @since 1.34
         */
@@ -1469,7 +1471,7 @@ class PermissionManager {
         * @return string[] Array of permission names
         */
        public function getAllPermissions() {
-               if ( $this->allRights === false ) {
+               if ( $this->allRights === null ) {
                        if ( count( $this->options->get( 'AvailableRights' ) ) ) {
                                $this->allRights = array_unique( array_merge(
                                        $this->coreRights,
index a71f6a6..528bac1 100644 (file)
@@ -51,7 +51,6 @@ class HeaderContainer {
         * better served by an HTTP header parsing library which provides the full
         * parse tree.
         *
-        * @param string $name The header name
         * @param string|string[] $value The input header value
         * @return array
         */
index 2267800..c1c6ef2 100644 (file)
@@ -789,14 +789,6 @@ if ( $wgCommandLineMode ) {
 $wgMemc = ObjectCache::getLocalClusterInstance();
 $messageMemc = wfGetMessageCacheStorage();
 
-wfDebugLog( 'caches',
-       'cluster: ' . get_class( $wgMemc ) .
-       ', WAN: ' . ( $wgMainWANCache === CACHE_NONE ? 'CACHE_NONE' : $wgMainWANCache ) .
-       ', stash: ' . $wgMainStash .
-       ', message: ' . get_class( $messageMemc ) .
-       ', session: ' . get_class( ObjectCache::getInstance( $wgSessionCacheType ) )
-);
-
 // Most of the config is out, some might want to run hooks here.
 Hooks::run( 'SetupAfterCache' );
 
index 8c5bbdc..3bf87c2 100644 (file)
@@ -178,8 +178,8 @@ class Title implements LinkTarget, IDBAccessObject {
        /** @var bool Whether a page has any subpages */
        private $mHasSubpages;
 
-       /** @var bool The (string) language code of the page's language and content code. */
-       private $mPageLanguage = false;
+       /** @var array|null The (string) language code of the page's language and content code. */
+       private $mPageLanguage;
 
        /** @var string|bool|null The page language code from the database, null if not saved in
         * the database or false if not loaded, yet.
@@ -3163,7 +3163,7 @@ class Title implements LinkTarget, IDBAccessObject {
                $this->mLatestID = false;
                $this->mContentModel = false;
                $this->mEstimateRevisions = null;
-               $this->mPageLanguage = false;
+               $this->mPageLanguage = null;
                $this->mDbPageLanguage = false;
                $this->mIsBigDeletion = null;
        }
index defe07e..bbaa10f 100644 (file)
@@ -39,7 +39,10 @@ use MediaWiki\Session\SessionManager;
  * @ingroup HTTP
  */
 class WebRequest {
-       protected $data, $headers = [];
+       /** @var array */
+       protected $data;
+       /** @var array */
+       protected $headers = [];
 
        /**
         * Flag to make WebRequest::getHeader return an array of values.
index 2f66277..7a548cc 100644 (file)
@@ -306,8 +306,6 @@ class ApiAuthManagerHelper {
 
        /**
         * Clean up a field array for output
-        * @param ApiBase $module For context and parameters 'mergerequestfields'
-        *  and 'messageformat'
         * @param array $fields
         * @return array
         */
index 8b6a3e5..d8134bb 100644 (file)
@@ -274,7 +274,7 @@ abstract class ApiBase extends ContextSource {
        /** @var array Maps extension paths to info arrays */
        private static $extensionInfo = null;
 
-       /** @var int[][][] Cache for self::filterIDs() */
+       /** @var stdClass[][] Cache for self::filterIDs() */
        private static $filterIDsCache = [];
 
        /** $var array Map of web UI block messages to corresponding API messages and codes */
index 3f63a00..e631e3f 100644 (file)
@@ -62,9 +62,7 @@ class ApiEditPage extends ApiBase {
 
                                /** @var Title $newTitle */
                                foreach ( $titles as $id => $newTitle ) {
-                                       if ( !isset( $titles[$id - 1] ) ) {
-                                               $titles[$id - 1] = $oldTitle;
-                                       }
+                                       $titles[ $id - 1 ] = $titles[ $id - 1 ] ?? $oldTitle;
 
                                        $redirValues[] = [
                                                'from' => $titles[$id - 1]->getPrefixedText(),
index be53c67..c4a432c 100644 (file)
@@ -34,6 +34,7 @@ class ApiImportReporter extends ImportReporter {
         * @param int $successCount
         * @param array $pageInfo
         * @return void
+        * @suppress PhanParamSignatureMismatch
         */
        public function reportPage( $title, $foreignTitle, $revisionCount, $successCount, $pageInfo ) {
                // Add a result entry
index 8e2837b..6a575ec 100644 (file)
@@ -111,6 +111,8 @@ class ApiOpenSearch extends ApiBase {
         * @param string $search the search query
         * @param array $params api request params
         * @return array search results. Keys are integers.
+        * @phan-return array<array{title:Title,extract:false,image:false,url:string}>
+        *  Note that phan annotations don't support keys containing a space.
         */
        private function search( $search, array $params ) {
                $searchEngine = $this->buildSearchEngine( $params );
@@ -247,6 +249,7 @@ class ApiOpenSearch extends ApiBase {
                                        if ( is_string( $r['extract'] ) && $r['extract'] !== '' ) {
                                                $item['Description'] = $r['extract'];
                                        }
+                                       // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
                                        if ( is_array( $r['image'] ) && isset( $r['image']['source'] ) ) {
                                                $item['Image'] = array_intersect_key( $r['image'], $imageKeys );
                                        }
index 8e26d37..ce51a67 100644 (file)
@@ -332,8 +332,8 @@ class ApiQueryUsers extends ApiQueryBase {
                                }
                        }
 
-                       $fit = $result->addValue( [ 'query', $this->getModuleName() ],
-                               null, $data[$u] );
+                       // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
+                       $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $data[$u] );
                        if ( !$fit ) {
                                if ( $useNames ) {
                                        $this->setContinueEnumParameter( 'users',
index c3cf5f1..478b0bc 100644 (file)
@@ -131,9 +131,6 @@ class ApiStashEdit extends ApiBase {
                        return;
                }
 
-               // The user will abort the AJAX request by pressing "save", so ignore that
-               ignore_user_abort( true );
-
                if ( $user->pingLimiter( 'stashedit' ) ) {
                        $status = 'ratelimited';
                } else {
index 4200341..f59760a 100644 (file)
@@ -337,12 +337,14 @@ abstract class AuthenticationRequest {
                                }
 
                                $options['sensitive'] = !empty( $options['sensitive'] );
+                               // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
+                               $type = $options['type'];
 
                                if ( !array_key_exists( $name, $merged ) ) {
                                        $merged[$name] = $options;
-                               } elseif ( $merged[$name]['type'] !== $options['type'] ) {
+                               } elseif ( $merged[$name]['type'] !== $type ) {
                                        throw new \UnexpectedValueException( "Field type conflict for \"$name\", " .
-                                               "\"{$merged[$name]['type']}\" vs \"{$options['type']}\""
+                                               "\"{$merged[$name]['type']}\" vs \"$type\""
                                        );
                                } else {
                                        if ( isset( $options['options'] ) ) {
index d798ddb..d1261a8 100644 (file)
@@ -82,9 +82,9 @@ class CacheHelper implements ICacheHelper {
         * Function that gets called when initialization is done.
         *
         * @since 1.20
-        * @var callable
+        * @var callable|null
         */
-       protected $onInitHandler = false;
+       protected $onInitHandler;
 
        /**
         * Elements to build a cache key with.
@@ -183,7 +183,7 @@ class CacheHelper implements ICacheHelper {
                        $this->hasCached = is_array( $cachedChunks );
                        $this->cachedChunks = $this->hasCached ? $cachedChunks : [];
 
-                       if ( $this->onInitHandler !== false ) {
+                       if ( $this->onInitHandler !== null ) {
                                call_user_func( $this->onInitHandler, $this->hasCached );
                        }
                }
index 3a6d892..848d9c9 100644 (file)
@@ -1191,6 +1191,7 @@ class MessageCache {
                        $class = $wgParserConf['class'];
                        if ( $class == ParserDiffTest::class ) {
                                # Uncloneable
+                               // @phan-suppress-next-line PhanTypeMismatchProperty
                                $this->mParser = new $class( $wgParserConf );
                        } else {
                                $this->mParser = clone $parser;
index aad9439..fd9af39 100644 (file)
@@ -33,7 +33,7 @@ use Cdb\Writer;
  */
 class LCStoreCDB implements LCStore {
 
-       /** @var Reader[] */
+       /** @var Reader[]|false[] */
        private $readers;
 
        /** @var Writer */
index ffc7cd0..2646845 100644 (file)
@@ -731,6 +731,7 @@ class LocalisationCache {
                                if ( in_array( $key, self::$mergeableMapKeys ) ) {
                                        $value = $value + $fallbackValue;
                                } elseif ( in_array( $key, self::$mergeableListKeys ) ) {
+                                       // @phan-suppress-next-line PhanTypeMismatchArgumentInternal
                                        $value = array_unique( array_merge( $fallbackValue, $value ) );
                                } elseif ( in_array( $key, self::$mergeableAliasListKeys ) ) {
                                        $value = array_merge_recursive( $value, $fallbackValue );
@@ -826,7 +827,7 @@ class LocalisationCache {
                if ( !$code ) {
                        throw new MWException( "Invalid language code requested" );
                }
-               $this->recachedLangs[$code] = true;
+               $this->recachedLangs[ $code ] = true;
 
                # Initial values
                $initialData = array_fill_keys( self::$allKeys, null );
@@ -835,16 +836,11 @@ class LocalisationCache {
 
                # Load the primary localisation from the source file
                $data = $this->readSourceFilesAndRegisterDeps( $code, $deps );
-               if ( $data === false ) {
-                       $this->logger->debug( __METHOD__ . ": no localisation file for $code, using fallback to en" );
-                       $coreData['fallback'] = 'en';
-               } else {
-                       $this->logger->debug( __METHOD__ . ": got localisation for $code from source" );
+               $this->logger->debug( __METHOD__ . ": got localisation for $code from source" );
 
-                       # Merge primary localisation
-                       foreach ( $data as $key => $value ) {
-                               $this->mergeItem( $key, $coreData[$key], $value );
-                       }
+               # Merge primary localisation
+               foreach ( $data as $key => $value ) {
+                       $this->mergeItem( $key, $coreData[ $key ], $value );
                }
 
                # Fill in the fallback if it's not there already
@@ -932,16 +928,14 @@ class LocalisationCache {
                                # Load the secondary localisation from the source file to
                                # avoid infinite cycles on cyclic fallbacks
                                $fbData = $this->readSourceFilesAndRegisterDeps( $csCode, $deps );
-                               if ( $fbData !== false ) {
-                                       # Only merge the keys that make sense to merge
-                                       foreach ( self::$allKeys as $key ) {
-                                               if ( !isset( $fbData[$key] ) ) {
-                                                       continue;
-                                               }
-
-                                               if ( is_null( $coreData[$key] ) || $this->isMergeableKey( $key ) ) {
-                                                       $this->mergeItem( $key, $csData[$key], $fbData[$key] );
-                                               }
+                               # Only merge the keys that make sense to merge
+                               foreach ( self::$allKeys as $key ) {
+                                       if ( !isset( $fbData[ $key ] ) ) {
+                                               continue;
+                                       }
+
+                                       if ( is_null( $coreData[ $key ] ) || $this->isMergeableKey( $key ) ) {
+                                               $this->mergeItem( $key, $csData[ $key ], $fbData[ $key ] );
                                        }
                                }
                        }
index 0c6a3d1..edaa963 100644 (file)
@@ -94,12 +94,12 @@ class RecentChange implements Taggable {
        public $mExtra = [];
 
        /**
-        * @var Title
+        * @var Title|false
         */
        public $mTitle = false;
 
        /**
-        * @var User
+        * @var User|false
         */
        private $mPerformer = false;
 
index 6182538..a21f404 100644 (file)
@@ -163,6 +163,7 @@ abstract class ContextSource implements IContextSource {
         * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
         *   or a MessageSpecifier.
         * @param mixed $args,...
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         * @return Message
         */
        public function msg( $key /* $args */ ) {
index d32617e..e4340ce 100644 (file)
@@ -257,6 +257,7 @@ class DerivativeContext extends ContextSource implements MutableContext {
         * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
         *   or a MessageSpecifier.
         * @param mixed $args,... Arguments to wfMessage
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         * @return Message
         */
        public function msg( $key ) {
index 6eeac1c..e6a856c 100644 (file)
@@ -411,6 +411,7 @@ class RequestContext implements IContextSource, MutableContext {
         * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
         *   or a MessageSpecifier.
         * @param mixed $args,...
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         * @return Message
         */
        public function msg( $key ) {
index 70a963b..188135f 100644 (file)
@@ -34,6 +34,7 @@ class ArrayDiffFormatter extends DiffFormatter {
         * @param Diff $diff A Diff object.
         *
         * @return array[] List of associative arrays, each describing a difference.
+        * @suppress PhanParamSignatureMismatch
         */
        public function format( $diff ) {
                $oldline = 1;
index 2a1f3e1..df2792f 100644 (file)
@@ -42,12 +42,12 @@ abstract class DiffOp {
        public $type;
 
        /**
-        * @var string[]
+        * @var string[]|false
         */
        public $orig;
 
        /**
-        * @var string[]
+        * @var string[]|false
         */
        public $closing;
 
index 0b8afa2..f99746e 100644 (file)
@@ -35,7 +35,7 @@ class DumpNamespaceFilter extends DumpFilter {
 
        /**
         * @param DumpOutput &$sink
-        * @param array $param
+        * @param string $param
         * @throws MWException
         */
        function __construct( &$sink, $param ) {
@@ -61,7 +61,7 @@ class DumpNamespaceFilter extends DumpFilter {
                        "NS_CATEGORY"       => NS_CATEGORY,
                        "NS_CATEGORY_TALK"  => NS_CATEGORY_TALK ];
 
-               if ( $param { 0 } == '!' ) {
+               if ( $param[0] == '!' ) {
                        $this->invert = true;
                        $param = substr( $param, 1 );
                }
index a353c44..0521c5a 100644 (file)
@@ -32,6 +32,7 @@ use MediaWiki\Shell\Shell;
  */
 class DumpPipeOutput extends DumpFileOutput {
        protected $command, $filename;
+       /** @var resource|bool */
        protected $procOpenResource = false;
 
        /**
index 314c4c3..655fd0d 100644 (file)
@@ -176,10 +176,10 @@ class ForeignAPIRepo extends FileRepo {
 
        /**
         * @param string $virtualUrl
-        * @return false
+        * @return array
         */
        function getFileProps( $virtualUrl ) {
-               return false;
+               return [];
        }
 
        /**
index ab8ef2f..99ead16 100644 (file)
@@ -75,6 +75,7 @@ class ForeignAPIFile extends File {
                                ? count( $data['query']['redirects'] ) - 1
                                : -1;
                        if ( $lastRedirect >= 0 ) {
+                               // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
                                $newtitle = Title::newFromText( $data['query']['redirects'][$lastRedirect]['to'] );
                                $img = new self( $newtitle, $repo, $info, true );
                                $img->redirectedFrom( $title->getDBkey() );
index 991ef79..c6d8ddf 100644 (file)
@@ -75,7 +75,7 @@ abstract class ImageGalleryBase extends ContextSource {
        protected $mHideBadImages;
 
        /**
-        * @var Parser Registered parser object for output callbacks
+        * @var Parser|false Registered parser object for output callbacks
         */
        public $mParser;
 
@@ -88,8 +88,8 @@ abstract class ImageGalleryBase extends ContextSource {
        /** @var array */
        protected $mAttribs = [];
 
-       /** @var bool */
-       private static $modeMapping = false;
+       /** @var array */
+       private static $modeMapping;
 
        /**
         * Get a new image gallery. This is the method other callers
@@ -121,7 +121,7 @@ abstract class ImageGalleryBase extends ContextSource {
        }
 
        private static function loadModes() {
-               if ( self::$modeMapping === false ) {
+               if ( self::$modeMapping === null ) {
                        self::$modeMapping = [
                                'traditional' => TraditionalImageGallery::class,
                                'nolines' => NolinesImageGallery::class,
index 7824872..6e760fa 100644 (file)
  * Improves compression ratio by concatenating like objects before gzipping
  */
 class ConcatenatedGzipHistoryBlob implements HistoryBlob {
-       public $mVersion = 0, $mCompressed = false, $mItems = [], $mDefaultHash = '';
+       public $mVersion = 0;
+       public $mCompressed = false;
+       /**
+        * @var array|string
+        * @fixme Why are some methods treating it as an array, and others as a string, unconditionally?
+        */
+       public $mItems = [];
+       public $mDefaultHash = '';
        public $mSize = 0;
        public $mMaxSize = 10000000;
        public $mMaxCount = 100;
index ed151e6..f4dad39 100644 (file)
@@ -294,6 +294,7 @@ class HTMLForm extends ContextSource {
         *
         * @param string $displayFormat
         * @param mixed $arguments,... Additional arguments to pass to the constructor.
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         * @return HTMLForm
         */
        public static function factory( $displayFormat/*, $arguments...*/ ) {
index 590b9e7..91c6e6a 100644 (file)
@@ -5,6 +5,7 @@
  * be a subclass of this.
  */
 abstract class HTMLFormField {
+       /** @var array|array[] */
        public $mParams;
 
        protected $mValidationCallback;
index 4ae52a9..41c0b3c 100644 (file)
@@ -29,6 +29,8 @@
  * The old name of autocomplete-data[-messages] was autocomplete[-messages] which is still
  * recognized but deprecated since MediaWiki 1.29 since it conflicts with how autocomplete is
  * used in HTMLTextField.
+ *
+ * @phan-file-suppress PhanTypeMismatchProperty This is doing weird things with mClass
  */
 class HTMLAutoCompleteSelectField extends HTMLTextField {
        protected $autocompleteData = [];
index 8e51858..595b71e 100644 (file)
@@ -77,6 +77,7 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
         * mParams['columns'] is an array with column labels as keys and column tags as values.
         *
         * @param array $value Array of the options that should be checked
+        * @suppress PhanParamSignatureMismatch
         *
         * @return string
         */
index 1c4a785..c373f45 100644 (file)
@@ -137,6 +137,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
         * @since 1.28
         * @param string[] $value
         * @return string|OOUI\CheckboxMultiselectInputWidget
+        * @suppress PhanParamSignatureMismatch
         */
        public function getInputOOUI( $value ) {
                $this->mParent->getOutput()->addModules( 'oojs-ui-widgets' );
index 3af7f56..fa6dad7 100644 (file)
@@ -41,6 +41,7 @@ class GuzzleHttpRequest extends MWHttpRequest {
 
        protected $handler = null;
        protected $sink = null;
+       /** @var array */
        protected $guzzleOptions = [ 'http_errors' => false ];
 
        /**
index 0c1ef13..35cc348 100644 (file)
@@ -406,6 +406,7 @@ class Message implements MessageSpecifier, Serializable {
         *
         * @param string|string[]|MessageSpecifier $key
         * @param mixed $param,... Parameters as strings.
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         *
         * @return Message
         */
index 9a1796b..fc51439 100644 (file)
@@ -36,6 +36,7 @@ interface MessageLocalizer {
         * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
         *   or a MessageSpecifier.
         * @param mixed $params,... Normal message parameters
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         * @return Message
         */
        public function msg( $key /*...*/ );
index f8ab6a3..94413c2 100644 (file)
@@ -129,6 +129,12 @@ class HashRing implements Serializable {
                        throw new InvalidArgumentException( "Invalid ring source specified." );
                }
 
+               // Short-circuit for the common single-location case. Note that if there was only one
+               // location and it was ejected from the live ring, getLiveRing() would have error out.
+               if ( count( $this->weightByLocation ) == 1 ) {
+                       return ( $limit > 0 ) ? [ $ring[0][self::KEY_LOCATION] ] : [];
+               }
+
                // Locate the node index for this item's position on the hash ring
                $itemIndex = $this->findNodeIndexForPosition( $this->getItemPosition( $item ), $ring );
 
index 1e9c7c5..6d6451e 100644 (file)
@@ -1049,6 +1049,7 @@ class SwiftFileBackend extends FileBackendStore {
                                $stat = $this->getFileStat( $params );
                        }
 
+                       // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
                        return $stat['xattr'];
                } else {
                        return false;
index 2e418b9..ed81a79 100644 (file)
@@ -150,7 +150,7 @@ class MultiHttpClient implements LoggerAwareInterface {
         * This is true for the request headers and the response headers. Integer-indexed
         * method/URL entries will also be changed to use the corresponding string keys.
         *
-        * @param array $reqs Map of HTTP request arrays
+        * @param array[] $reqs Map of HTTP request arrays
         * @param array $opts
         *   - connTimeout     : connection timeout per request (seconds)
         *   - reqTimeout      : post-connection timeout per request (seconds)
@@ -182,7 +182,7 @@ class MultiHttpClient implements LoggerAwareInterface {
         *
         * @see MultiHttpClient::runMulti()
         *
-        * @param array $reqs Map of HTTP request arrays
+        * @param array[] $reqs Map of HTTP request arrays
         * @param array $opts
         *   - connTimeout     : connection timeout per request (seconds)
         *   - reqTimeout      : post-connection timeout per request (seconds)
@@ -293,6 +293,7 @@ class MultiHttpClient implements LoggerAwareInterface {
         *   - reqTimeout     : default request timeout
         * @return resource
         * @throws Exception
+        * @suppress PhanTypeMismatchArgumentInternal
         */
        protected function getCurlHandle( array &$req, array $opts = [] ) {
                $ch = curl_init();
@@ -529,7 +530,7 @@ class MultiHttpClient implements LoggerAwareInterface {
        /**
         * Normalize request information
         *
-        * @param array $reqs the requests to normalize
+        * @param array[] $reqs the requests to normalize
         */
        private function normalizeRequests( array &$reqs ) {
                foreach ( $reqs as &$req ) {
index 950b283..6478a61 100644 (file)
@@ -38,7 +38,7 @@ abstract class QuorumLockManager extends LockManager {
        final protected function doLockByType( array $pathsByType ) {
                $status = StatusValue::newGood();
 
-               $pathsToLock = []; // (bucket => type => paths)
+               $pathsByTypeByBucket = []; // (bucket => type => paths)
                // Get locks that need to be acquired (buckets => locks)...
                foreach ( $pathsByType as $type => $paths ) {
                        foreach ( $paths as $path ) {
@@ -46,23 +46,27 @@ abstract class QuorumLockManager extends LockManager {
                                        ++$this->locksHeld[$path][$type];
                                } else {
                                        $bucket = $this->getBucketFromPath( $path );
-                                       $pathsToLock[$bucket][$type][] = $path;
+                                       $pathsByTypeByBucket[$bucket][$type][] = $path;
                                }
                        }
                }
 
+               // Acquire locks in each bucket in bucket order to reduce contention. Any blocking
+               // mutexes during the acquisition step will not involve circular waiting on buckets.
+               ksort( $pathsByTypeByBucket );
+
                $lockedPaths = []; // files locked in this attempt (type => paths)
                // Attempt to acquire these locks...
-               foreach ( $pathsToLock as $bucket => $pathsToLockByType ) {
+               foreach ( $pathsByTypeByBucket as $bucket => $bucketPathsByType ) {
                        // Try to acquire the locks for this bucket
-                       $status->merge( $this->doLockingRequestBucket( $bucket, $pathsToLockByType ) );
+                       $status->merge( $this->doLockingRequestBucket( $bucket, $bucketPathsByType ) );
                        if ( !$status->isOK() ) {
                                $status->merge( $this->doUnlockByType( $lockedPaths ) );
 
                                return $status;
                        }
                        // Record these locks as active
-                       foreach ( $pathsToLockByType as $type => $paths ) {
+                       foreach ( $bucketPathsByType as $type => $paths ) {
                                foreach ( $paths as $path ) {
                                        $this->locksHeld[$path][$type] = 1; // locked
                                        // Keep track of what locks were made in this attempt
@@ -77,7 +81,7 @@ abstract class QuorumLockManager extends LockManager {
        protected function doUnlockByType( array $pathsByType ) {
                $status = StatusValue::newGood();
 
-               $pathsToUnlock = []; // (bucket => type => paths)
+               $pathsByTypeByBucket = []; // (bucket => type => paths)
                foreach ( $pathsByType as $type => $paths ) {
                        foreach ( $paths as $path ) {
                                if ( !isset( $this->locksHeld[$path][$type] ) ) {
@@ -88,7 +92,7 @@ abstract class QuorumLockManager extends LockManager {
                                        if ( $this->locksHeld[$path][$type] <= 0 ) {
                                                unset( $this->locksHeld[$path][$type] );
                                                $bucket = $this->getBucketFromPath( $path );
-                                               $pathsToUnlock[$bucket][$type][] = $path;
+                                               $pathsByTypeByBucket[$bucket][$type][] = $path;
                                        }
                                        if ( $this->locksHeld[$path] === [] ) {
                                                unset( $this->locksHeld[$path] ); // no SH or EX locks left for key
@@ -99,8 +103,8 @@ abstract class QuorumLockManager extends LockManager {
 
                // Remove these specific locks if possible, or at least release
                // all locks once this process is currently not holding any locks.
-               foreach ( $pathsToUnlock as $bucket => $pathsToUnlockByType ) {
-                       $status->merge( $this->doUnlockingRequestBucket( $bucket, $pathsToUnlockByType ) );
+               foreach ( $pathsByTypeByBucket as $bucket => $bucketPathsByType ) {
+                       $status->merge( $this->doUnlockingRequestBucket( $bucket, $bucketPathsByType ) );
                }
                if ( $this->locksHeld === [] ) {
                        $status->merge( $this->releaseAllLocks() );
index f25287f..9d66326 100644 (file)
@@ -150,7 +150,8 @@ class XmlTypeCheck {
        }
 
        /**
-        * @param string $fname the filename
+        * @param string $xml
+        * @param bool $isFile
         */
        private function validateFromInput( $xml, $isFile ) {
                $reader = new XMLReader();
index 57a2507..aaed69f 100644 (file)
@@ -28,6 +28,7 @@
  *
  * @ingroup Cache
  * @ingroup Redis
+ * @phan-file-suppress PhanTypeComparisonFromArray It's unclear whether exec() can return false
  */
 class RedisBagOStuff extends MediumSpecificBagOStuff {
        /** @var RedisConnectionPool */
index 8931ae2..106772b 100644 (file)
@@ -33,6 +33,7 @@ use stdClass;
  * @ingroup Database
  * @since 1.22
  * @see Database
+ * @phan-file-suppress PhanParamSignatureMismatch resource vs mysqli_result
  */
 class DatabaseMysqli extends DatabaseMysqlBase {
        /**
index 68735e9..41f7cb6 100644 (file)
@@ -902,7 +902,7 @@ interface IDatabase {
         *   that field to. The data will be quoted by IDatabase::addQuotes().
         *   Values with integer keys form unquoted SET statements, which can be used for
         *   things like "field = field + 1" or similar computed values.
-        * @param array $conds An array of conditions (WHERE). See
+        * @param array|string $conds An array of conditions (WHERE). See
         *   IDatabase::select() for the details of the format of condition
         *   arrays. Use '*' to update all rows.
         * @param string $fname The function name of the caller (from __METHOD__),
@@ -1287,7 +1287,7 @@ interface IDatabase {
         * @param string $joinTable The other table.
         * @param string $delVar The variable to join on, in the first table.
         * @param string $joinVar The variable to join on, in the second table.
-        * @param array $conds Condition array of field names mapped to variables,
+        * @param array|string $conds Condition array of field names mapped to variables,
         *   ANDed together in the WHERE clause
         * @param string $fname Calling function name (use __METHOD__) for logs/profiling
         * @throws DBError If an error occurs, see IDatabase::query()
index 54eca79..fa2c1db 100644 (file)
@@ -17,7 +17,7 @@ use UnexpectedValueException;
  * @see https://dev.mysql.com/doc/refman/5.6/en/replication-gtids-concepts.html
  */
 class MySQLMasterPos implements DBMasterPos {
-       /** @var int One of (BINARY_LOG, GTID_MYSQL, GTID_MARIA) */
+       /** @var string One of (BINARY_LOG, GTID_MYSQL, GTID_MARIA) */
        private $style;
        /** @var string|null Base name of all Binary Log files */
        private $binLog;
index 585a782..771700c 100644 (file)
@@ -68,7 +68,9 @@ class LoadBalancer implements ILoadBalancer {
        /** @var DatabaseDomain Local DB domain ID and default for selectDB() calls */
        private $localDomain;
 
-       /** @var Database[][][] Map of (connection category => server index => IDatabase[]) */
+       /**
+        * @var IDatabase[][][]|Database[][][] Map of (connection category => server index => IDatabase[])
+        */
        private $conns;
 
        /** @var array[] Map of (server index => server config array) */
@@ -99,7 +101,7 @@ class LoadBalancer implements ILoadBalancer {
        private $tableAliases = [];
        /** @var string[] Map of (index alias => index) */
        private $indexAliases = [];
-       /** @var array[] Map of (name => callable) */
+       /** @var callable[] Map of (name => callable) */
        private $trxRecurringCallbacks = [];
        /** @var bool[] Map of (domain => whether to use "temp tables only" mode) */
        private $tempTablesOnlyMode = [];
index 170fc29..4fff1de 100644 (file)
@@ -64,7 +64,7 @@ abstract class LogEntryBase implements LogEntry {
         *
         * @since 1.26
         * @param string $blob
-        * @return array
+        * @return array|false
         */
        public static function extractParams( $blob ) {
                return unserialize( $blob );
index fa9e1dc..9058340 100644 (file)
@@ -80,7 +80,7 @@ class ExifBitmapHandler extends BitmapHandler {
 
        /**
         * @param File $image
-        * @param array $metadata
+        * @param string $metadata
         * @return bool|int
         */
        public function isMetadataValid( $image, $metadata ) {
index f328760..3993795 100644 (file)
@@ -98,6 +98,7 @@ class FormatMetadata extends ContextSource {
         *   Exif::getFilteredData() or BitmapMetadataHandler )
         * @return array
         * @since 1.23
+        * @suppress PhanTypeArraySuspiciousNullable
         */
        public function makeFormattedData( $tags ) {
                $resolutionunit = !isset( $tags['ResolutionUnit'] ) || $tags['ResolutionUnit'] == 2 ? 2 : 3;
index 15c4dbf..880d382 100644 (file)
@@ -62,7 +62,7 @@ class TiffHandler extends ExifBitmapHandler {
         * @param string $ext
         * @param string $mime
         * @param array|null $params
-        * @return bool
+        * @return array
         */
        public function getThumbType( $ext, $mime, $params = null ) {
                global $wgTiffThumbnailType;
index e634edc..d713396 100644 (file)
@@ -144,7 +144,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
                        $this->numServerShards = count( $this->serverInfos );
                } else {
                        // Default to using the main wiki's database servers
-                       $this->serverInfos = false;
+                       $this->serverInfos = [];
                        $this->numServerShards = 1;
                        $this->attrMap[self::ATTR_SYNCWRITES] = self::QOS_SYNCWRITES_BE;
                }
index 4607535..b4b5927 100644 (file)
@@ -68,7 +68,9 @@ class WikiPage implements Page, IDBAccessObject {
         */
        public $mLatest = false;
 
-       /** @var PreparedEdit Map of cache fields (text, parser output, ect) for a proposed/new edit */
+       /**
+        * @var PreparedEdit|false Map of cache fields (text, parser output, ect) for a proposed/new edit
+        */
        public $mPreparedEdit = false;
 
        /**
index 5de5f47..816548c 100644 (file)
@@ -35,9 +35,11 @@ class PPDStackElement_Hash extends PPDStackElement {
         *
         * @param int|bool $openingCount
         * @return array
+        * @suppress PhanParamSignatureMismatch
         */
        public function breakSyntax( $openingCount = false ) {
                if ( $this->open == "\n" ) {
+                       // @phan-suppress-next-line PhanTypeMismatchArgumentInternal
                        $accum = array_merge( [ $this->savedPrefix ], $this->parts[0]->out );
                } else {
                        if ( $openingCount === false ) {
index 79c7c3b..3f147f0 100644 (file)
@@ -69,6 +69,7 @@ interface PPFrame {
         * @param string $sep
         * @param int $flags
         * @param string|PPNode $args,...
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         * @return string
         */
        public function implodeWithFlags( $sep, $flags /*, ... */ );
@@ -77,6 +78,7 @@ interface PPFrame {
         * Implode with no flags specified
         * @param string $sep
         * @param string|PPNode $args,...
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         * @return string
         */
        public function implode( $sep /*, ... */ );
@@ -85,20 +87,22 @@ interface PPFrame {
         * Makes an object that, when expand()ed, will be the same as one obtained
         * with implode()
         * @param string $sep
-        * @param string|PPNode $args,...
+        * @param string|PPNode ...$args
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         * @return PPNode
         */
-       public function virtualImplode( $sep /*, ... */ );
+       public function virtualImplode( $sep /* ...$args */ );
 
        /**
         * Virtual implode with brackets
         * @param string $start
         * @param string $sep
         * @param string $end
-        * @param string|PPNode $args,...
+        * @param string|PPNode ...$args
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         * @return PPNode
         */
-       public function virtualBracketedImplode( $start, $sep, $end /*, ... */ );
+       public function virtualBracketedImplode( $start, $sep, $end /* ...$args */ );
 
        /**
         * Returns true if there are no arguments in this frame
index e3c12eb..00bfe98 100644 (file)
@@ -458,6 +458,7 @@ class PPFrame_DOM implements PPFrame {
         * @param string $sep
         * @param string|PPNode_DOM|DOMNode ...$args
         * @return array
+        * @suppress PhanParamSignatureMismatch
         */
        public function virtualImplode( $sep, ...$args ) {
                $out = [];
@@ -489,6 +490,7 @@ class PPFrame_DOM implements PPFrame {
         * @param string $end
         * @param string|PPNode_DOM|DOMNode ...$args
         * @return array
+        * @suppress PhanParamSignatureMismatch
         */
        public function virtualBracketedImplode( $start, $sep, $end, ...$args ) {
                $out = [ $start ];
index 130667e..267402f 100644 (file)
@@ -2010,6 +2010,7 @@ class Parser {
         */
        public function replaceExternalLinks( $text ) {
                $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
+               // @phan-suppress-next-line PhanTypeComparisonFromArray See phan issue #3161
                if ( $bits === false ) {
                        throw new MWException( "PCRE needs to be compiled with "
                                . "--enable-unicode-properties in order for MediaWiki to function" );
index 00c2903..70e38ee 100644 (file)
@@ -1726,6 +1726,7 @@ class DefaultPreferencesFactory implements PreferencesFactory {
         */
        protected function getTimeZoneList( Language $language ) {
                $identifiers = DateTimeZone::listIdentifiers();
+               // @phan-suppress-next-line PhanTypeComparisonFromArray See phan issue #3162
                if ( $identifiers === false ) {
                        return [];
                }
index 20f9a78..ab59efe 100644 (file)
@@ -1,7 +1,9 @@
 <?php
 
 class ProfilerExcimer extends Profiler {
+       /** @var ExcimerProfiler */
        private $cpuProf;
+       /** @var ExcimerProfiler */
        private $realProf;
        private $period;
 
index cf0b3c2..d84a92a 100644 (file)
@@ -35,6 +35,7 @@ class DerivativeResourceLoaderContext extends ResourceLoaderContext {
         */
        private $context;
 
+       /** @var int|array */
        protected $modules = self::INHERIT_VALUE;
        protected $language = self::INHERIT_VALUE;
        protected $direction = self::INHERIT_VALUE;
@@ -54,7 +55,7 @@ class DerivativeResourceLoaderContext extends ResourceLoaderContext {
                if ( $this->modules === self::INHERIT_VALUE ) {
                        return $this->context->getModules();
                }
-               // @phan-suppress-next-line PhanTypeMismatchReturn
+
                return $this->modules;
        }
 
index c3948cb..95b8ff0 100644 (file)
@@ -55,6 +55,7 @@ class ResourceLoaderContext implements MessageLocalizer {
        protected $direction;
        protected $hash;
        protected $userObj;
+       /** @var ResourceLoaderImage|false */
        protected $imageObj;
 
        /**
@@ -214,6 +215,7 @@ class ResourceLoaderContext implements MessageLocalizer {
         * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
         *   or a MessageSpecifier.
         * @param mixed $args,...
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         * @return Message
         */
        public function msg( $key ) {
index 4ba7868..60eae42 100644 (file)
@@ -429,7 +429,8 @@ class Command {
 
                        // clear get_last_error without actually raising an error
                        // from https://www.php.net/manual/en/function.error-get-last.php#113518
-                       // TODO replace with clear_last_error when requirements are bumped to PHP7
+                       // TODO replace with error_clear_last after dropping HHVM
+                       // @phan-suppress-next-line PhanTypeMismatchArgumentInternal
                        set_error_handler( function () {
                        }, 0 );
                        AtEase::suppressWarnings();
index ec13765..bcf8b32 100644 (file)
@@ -89,7 +89,7 @@ class Site implements Serializable {
         *
         * @since 1.21
         *
-        * @var array[]
+        * @var array[]|false
         */
        protected $localIds = [];
 
index cad69a5..09e439b 100644 (file)
@@ -33,6 +33,7 @@ abstract class BaseTemplate extends QuickTemplate {
         *
         * @param string $name Message name
         * @param mixed $params,... Message params
+        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
         * @return Message
         */
        public function getMsg( $name /* ... */ ) {
index 939460f..fb69f63 100644 (file)
@@ -150,10 +150,11 @@ abstract class FormSpecialPage extends SpecialPage {
        /**
         * Process the form on POST submission.
         * @param array $data
-        * @param HTMLForm $form
+        * @param HTMLForm|null $form
+        * @suppress PhanCommentParamWithoutRealParam Many implementations don't have $form
         * @return bool|string|array|Status As documented for HTMLForm::trySubmit.
         */
-       abstract public function onSubmit( array $data /* $form = null */ );
+       abstract public function onSubmit( array $data /* HTMLForm $form = null */ );
 
        /**
         * Do something exciting on successful processing of the form, most likely to show a
index 7f075ed..6059cea 100644 (file)
@@ -316,6 +316,8 @@ class SpecialBotPasswords extends FormSpecialPage {
                        'restrictions' => $data['restrictions'],
                        'grants' => array_merge(
                                MWGrants::getHiddenGrants(),
+                               // @phan-suppress-next-next-line PhanTypeMismatchArgumentInternal See phan issue #3163,
+                               // it's probably failing to infer the type of $data['grants']
                                preg_replace( '/^grant-/', '', $data['grants'] )
                        )
                ] );
index 7f00311..33641cd 100644 (file)
@@ -264,6 +264,7 @@ class SpecialListGroupRights extends SpecialPage {
                ];
 
                foreach ( $changeGroups as $messageKey => $changeGroup ) {
+                       // @phan-suppress-next-line PhanTypeComparisonFromArray
                        if ( $changeGroup === true ) {
                                // For grep: listgrouprights-addgroup-all, listgrouprights-removegroup-all,
                                // listgrouprights-addgroup-self-all, listgrouprights-removegroup-self-all
index 8063804..0ae708a 100644 (file)
@@ -30,6 +30,9 @@ class ImportReporter extends ContextSource {
        private $mOriginalLogCallback = null;
        private $mOriginalPageOutCallback = null;
        private $mLogItemCount = 0;
+       private $mPageCount;
+       private $mIsUpload;
+       private $mInterwiki;
 
        /**
         * @param WikiImporter $importer
index 77b7326..d61a1be 100644 (file)
@@ -70,6 +70,12 @@ class BlockListPager extends TablePager {
                return $headers;
        }
 
+       /**
+        * @param string $name
+        * @param string $value
+        * @return string
+        * @suppress PhanTypeArraySuspiciousNullable
+        */
        function formatValue( $name, $value ) {
                static $msg = null;
                if ( $msg === null ) {
index fb9dcf5..3368e29 100644 (file)
@@ -1763,7 +1763,6 @@ abstract class UploadBase {
         * Check a block of CSS or CSS fragment for anything that looks like
         * it is bringing in remote code.
         * @param string $value a string of CSS
-        * @param bool $propOnly only check css properties (start regex with :)
         * @return bool true if the CSS contains an illegal string, false if otherwise
         */
        private static function checkCssFragment( $value ) {
index aada319..fd8eb3f 100644 (file)
@@ -70,8 +70,6 @@ class PasswordReset implements LoggerAwareInterface {
        /**
         * Check if a given user has permission to use this functionality.
         * @param User $user
-        * @param bool $displayPassword If set, also check whether the user is allowed to reset the
-        *   password of another user and see the temporary password.
         * @since 1.29 Second argument for displayPassword removed.
         * @return StatusValue
         */
index 23c4cfb..82f2ddc 100644 (file)
@@ -110,12 +110,6 @@ class User implements IDBAccessObject, UserIdentity {
                'mActorId',
        ];
 
-       /**
-        * @var string[]
-        * @var string[] Cached results of getAllRights()
-        */
-       protected static $mAllRights = false;
-
        /** Cache variables */
        // @{
        /** @var int */
index b7d5058..c185bab 100644 (file)
@@ -65,6 +65,6 @@ class UserNamePrefixSearch {
                        $joinConds
                );
 
-               return $res === false ? [] : $res;
+               return $res;
        }
 }
index 12b8a70..cf62f6d 100644 (file)
@@ -39,7 +39,7 @@ class ClassCollector {
        protected $startToken;
 
        /**
-        * @var array List of tokens that are members of the current expect sequence
+        * @var array[]|string[] List of tokens that are members of the current expect sequence
         */
        protected $tokens;
 
@@ -126,7 +126,7 @@ class ClassCollector {
        /**
         * Accepts the next token in an expect sequence
         *
-        * @param array $token
+        * @param array|string $token
         */
        protected function tryEndExpect( $token ) {
                switch ( $this->startToken[0] ) {
index 62ee9cb..fedac4b 100644 (file)
@@ -148,6 +148,7 @@ class SearchFormWidget {
         * @param string $profile The currently selected profile
         * @param string $term The user provided search terms
         * @return string HTML
+        * @suppress PhanTypeArraySuspiciousNullable
         */
        protected function profileTabsHtml( $profile, $term ) {
                $bareterm = $this->startsWithImage( $term )
index ff66b25..7ee6a65 100644 (file)
@@ -61,7 +61,9 @@ class Language {
 
        public $mVariants, $mCode, $mLoaded = false;
        public $mMagicExtensions = [];
-       private $mHtmlCode = null, $mParentLanguage = false;
+       private $mHtmlCode = null;
+       /** @var Language|false */
+       private $mParentLanguage = false;
 
        public $dateFormatStrings = [];
        public $mExtendedSpecialPageAliases;
@@ -455,6 +457,7 @@ class Language {
        }
 
        function __construct() {
+               // @phan-suppress-next-line PhanTypeMismatchProperty
                $this->mConverter = new FakeConverter( $this );
                // Set the code to the name of the descendant
                if ( static::class === 'Language' ) {
@@ -534,6 +537,7 @@ class Language {
 
                        # The above mixing may leave namespaces out of canonical order.
                        # Re-order by namespace ID number...
+                       // @phan-suppress-next-line PhanTypeMismatchArgumentInternal
                        ksort( $this->namespaceNames );
 
                        Hooks::run( 'LanguageGetNamespaces', [ &$this->namespaceNames ] );
@@ -3234,6 +3238,7 @@ class Language {
                $fallbackChain = array_reverse( $fallbackChain );
                foreach ( $fallbackChain as $code ) {
                        if ( isset( $newWords[$code] ) ) {
+                               // @phan-suppress-next-line PhanTypeMismatchProperty
                                $this->mMagicExtensions = $newWords[$code] + $this->mMagicExtensions;
                        }
                }
index d1a5720..350aa67 100644 (file)
@@ -63,8 +63,7 @@ class LanguageConverter {
        public $mTablesLoaded = false;
 
        /**
-        * @var ReplacementArray[]
-        * @phan-var array<string,ReplacementArray>
+        * @var ReplacementArray[]|bool[]
         */
        public $mTables;
 
@@ -958,7 +957,7 @@ class LanguageConverter {
                }
 
                $this->mTablesLoaded = true;
-               $this->mTables = false;
+               $this->mTables = null;
                $cache = ObjectCache::getInstance( $wgLanguageConverterCacheType );
                $cacheKey = $cache->makeKey( 'conversiontables', $this->mMainLanguageCode );
                if ( $fromCache ) {
index 3db0511..b0ac638 100644 (file)
@@ -168,10 +168,8 @@ class ConvertExtensionToRegistration extends Maintenance {
                                $this->fatalError( "Error: Closures cannot be converted to JSON. " .
                                        "Please move your extension function somewhere else."
                                );
-                       }
-                       // check if $func exists in the global scope
-                       if ( function_exists( $func ) ) {
-                               // @phan-suppress-next-next-line PhanTypeSuspiciousStringExpression
+                       } elseif ( function_exists( $func ) ) {
+                               // check if $func exists in the global scope
                                $this->fatalError( "Error: Global functions cannot be converted to JSON. " .
                                        "Please move your extension function ($func) into a class."
                                );
@@ -264,9 +262,8 @@ class ConvertExtensionToRegistration extends Maintenance {
                                        $this->fatalError( "Error: Closures cannot be converted to JSON. " .
                                                "Please move the handler for $hookName somewhere else."
                                        );
-                               }
-                               // Check if $func exists in the global scope
-                               if ( function_exists( $func ) ) {
+                               } elseif ( function_exists( $func ) ) {
+                                       // Check if $func exists in the global scope
                                        $this->fatalError( "Error: Global functions cannot be converted to JSON. " .
                                                "Please move the handler for $hookName inside a class."
                                        );
index 1142325..ce40638 100644 (file)
@@ -358,6 +358,7 @@ class CopyFileBackend extends Maintenance {
                        // backends in FileBackendMultiWrite (since they get writes second, they have
                        // higher timestamps). However, when copying the other way, this hits loads of
                        // false positives (possibly 100%) and wastes a bunch of time on GETs/PUTs.
+                       // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
                        $same = ( $srcStat['mtime'] <= $dstStat['mtime'] );
                } else {
                        // This is the slowest method which does many per-file HEADs (unless an object
index aef45bf..4c3fe7b 100644 (file)
@@ -132,7 +132,7 @@ class GenerateSitemap extends Maintenance {
        /**
         * A resource pointing to a sitemap file
         *
-        * @var resource
+        * @var resource|false
         */
        public $file;
 
index c2c5ccf..0ff3622 100644 (file)
@@ -41,6 +41,7 @@ class BackupReader extends Maintenance {
        public $uploads = false;
        protected $uploadCount = 0;
        public $imageBasePath = false;
+       /** @var array|false */
        public $nsFilter = false;
 
        function __construct() {
index 04767fa..bcf84aa 100644 (file)
@@ -64,7 +64,8 @@ class TextPassDumper extends BackupDumper {
 
        protected $bufferSize = 524288; // In bytes. Maximum size to read from the stub in on go.
 
-       protected $php = "php";
+       /** @var array */
+       protected $php = [];
        protected $spawn = false;
 
        /**
@@ -73,14 +74,14 @@ class TextPassDumper extends BackupDumper {
        protected $spawnProc = false;
 
        /**
-        * @var bool|resource
+        * @var resource
         */
-       protected $spawnWrite = false;
+       protected $spawnWrite;
 
        /**
-        * @var bool|resource
+        * @var resource
         */
-       protected $spawnRead = false;
+       protected $spawnRead;
 
        /**
         * @var bool|resource
@@ -431,7 +432,7 @@ TEXT
 
        /**
         * @throws MWException Failure to parse XML input
-        * @param string $input
+        * @param resource $input
         * @return bool
         */
        function readDump( $input ) {
@@ -808,11 +809,11 @@ TEXT
                if ( $this->spawnRead ) {
                        fclose( $this->spawnRead );
                }
-               $this->spawnRead = false;
+               $this->spawnRead = null;
                if ( $this->spawnWrite ) {
                        fclose( $this->spawnWrite );
                }
-               $this->spawnWrite = false;
+               $this->spawnWrite = null;
                if ( $this->spawnErr ) {
                        fclose( $this->spawnErr );
                }
index f91a5b6..d1c71de 100644 (file)
@@ -125,7 +125,6 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
 
        /**
         * @param MediaWiki\Revision\RevisionStore $revStore
-        * @param string $emptySha1
         * @return int
         */
        protected function doSha1LegacyUpdates( $revStore ) {
index 88eaf67..2f8dcc4 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 /**
- * Purge all languages from the message cache.
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * @ingroup Maintenance
  */
 
+use MediaWiki\MediaWikiServices;
+
 require_once __DIR__ . '/Maintenance.php';
 
 /**
- * Maintenance script that purges all languages from the message cache.
+ * Maintenance script that purges cache used by MessageCache.
  *
  * @ingroup Maintenance
  */
 class RebuildMessages extends Maintenance {
        public function __construct() {
                parent::__construct();
-               $this->addDescription( 'Purge all language messages from the cache' );
+               $this->addDescription( 'Purge the MessageCache for all interface languages.' );
        }
 
        public function execute() {
-               global $wgLocalDatabases, $wgDBname, $wgEnableSidebarCache, $messageMemc;
-               if ( $wgLocalDatabases ) {
-                       $databases = $wgLocalDatabases;
-               } else {
-                       $databases = [ $wgDBname ];
-               }
-
-               foreach ( $databases as $db ) {
-                       $this->output( "Deleting message cache for {$db}... " );
-                       $messageMemc->delete( "{$db}:messages" );
-                       if ( $wgEnableSidebarCache ) {
-                               $messageMemc->delete( "{$db}:sidebar" );
-                       }
-                       $this->output( "Deleted\n" );
-               }
+               $this->output( "Purging message cache for all languages on this wiki... " );
+               $messageCache = MediaWikiServices::getInstance()->getMessageCache();
+               $messageCache->clear();
+               $this->output( "Done\n" );
        }
 }
 
index 92b6679..316d2d2 100644 (file)
@@ -710,7 +710,7 @@ class CgzCopyTransaction {
        /** @var RecompressTracked */
        public $parent;
        public $blobClass;
-       /** @var ConcatenatedGzipHistoryBlob */
+       /** @var ConcatenatedGzipHistoryBlob|false */
        public $cgz;
        public $referrers;
 
index 4afe3b5..8ddb7c9 100644 (file)
@@ -24,6 +24,32 @@ class HashRingTest extends PHPUnit\Framework\TestCase {
                }
        }
 
+       public function testHashRingSingleLocation() {
+               // SHA-1 based and weighted
+               $ring = new HashRing( [ 's1' => 1 ], 'sha1' );
+
+               $this->assertEquals(
+                       [ 's1' => 1 ],
+                       $ring->getLocationWeights(),
+                       'Normalized location weights'
+               );
+
+               for ( $i = 0; $i < 5; $i++ ) {
+                       $this->assertEquals(
+                               's1',
+                               $ring->getLocation( "hello$i" ),
+                               'Items placed at proper locations'
+                       );
+                       $this->assertEquals(
+                               [ 's1' ],
+                               $ring->getLocations( "hello$i", 2 ),
+                               'Items placed at proper locations'
+                       );
+               }
+
+               $this->assertEquals( [], $ring->getLocations( "helloX", 0 ), "Limit of 0" );
+       }
+
        public function testHashRingMapping() {
                // SHA-1 based and weighted
                $ring = new HashRing(