Merge "Allow CompositeBlock::appliesToRight to return null when unsure"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 1 Sep 2019 21:30:26 +0000 (21:30 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 1 Sep 2019 21:30:26 +0000 (21:30 +0000)
93 files changed:
.phan/config.php
includes/EditPage.php
includes/FileDeleteForm.php
includes/GlobalFunctions.php
includes/LinkFilter.php
includes/Linker.php
includes/MovePage.php
includes/Revision/RenderedRevision.php
includes/Revision/RevisionRenderer.php
includes/Revision/RevisionStore.php
includes/Setup.php
includes/Title.php
includes/api/ApiAuthManagerHelper.php
includes/api/ApiBlock.php
includes/api/ApiEditPage.php
includes/api/ApiMain.php
includes/api/ApiOpenSearch.php
includes/api/ApiPageSet.php
includes/api/ApiQueryBacklinks.php
includes/api/ApiQueryDeletedrevs.php
includes/api/ApiQueryInfo.php
includes/api/ApiQueryUserInfo.php
includes/api/ApiUnblock.php
includes/api/ApiUndelete.php
includes/api/ApiUpload.php
includes/api/ApiUserrights.php
includes/api/ApiValidatePassword.php
includes/api/SearchApi.php
includes/auth/AuthenticationRequest.php
includes/auth/Throttler.php
includes/changes/EnhancedChangesList.php
includes/changes/RecentChange.php
includes/changetags/ChangeTags.php
includes/content/ContentHandler.php
includes/content/FileContentHandler.php
includes/diff/DiffEngine.php
includes/filerepo/RepoGroup.php
includes/filerepo/file/LocalFile.php
includes/historyblob/DiffHistoryBlob.php
includes/htmlform/HTMLForm.php
includes/http/HttpRequestFactory.php
includes/http/MWHttpRequest.php
includes/import/WikiImporter.php
includes/installer/Installer.php
includes/jobqueue/JobQueueGroup.php
includes/libs/MappedIterator.php
includes/libs/XhprofData.php
includes/libs/filebackend/FileBackend.php
includes/libs/http/MultiHttpClient.php
includes/libs/objectcache/BagOStuff.php
includes/libs/objectcache/HashBagOStuff.php
includes/libs/objectcache/MediumSpecificBagOStuff.php
includes/libs/objectcache/MultiWriteBagOStuff.php
includes/libs/objectcache/wancache/WANObjectCache.php
includes/logging/BlockLogFormatter.php
includes/logging/ManualLogEntry.php
includes/logging/PatrolLog.php
includes/media/IPTC.php
includes/page/Article.php
includes/page/PageArchive.php
includes/page/WikiPage.php
includes/parser/Parser.php
includes/preferences/DefaultPreferencesFactory.php
includes/registration/ExtensionRegistry.php
includes/resourceloader/ResourceLoaderClientHtml.php
includes/revisiondelete/RevDelList.php
includes/search/SearchEngine.php
includes/session/SessionManager.php
includes/shell/Shell.php
includes/skins/BaseTemplate.php
includes/specialpage/AuthManagerSpecialPage.php
includes/specials/SpecialBlock.php
includes/specials/SpecialContributions.php
includes/specials/SpecialEditWatchlist.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialPageLanguage.php
includes/specials/SpecialUnblock.php
includes/specials/SpecialUndelete.php
includes/specials/SpecialUserrights.php
includes/specials/SpecialWhatLinksHere.php
includes/specials/forms/UploadForm.php
includes/specials/helpers/ImportReporter.php
includes/specials/pagers/BlockListPager.php
includes/widget/ComplexTitleInputWidget.php
maintenance/categoryChangesAsRdf.php
maintenance/convertExtensionToRegistration.php
maintenance/includes/TextPassDumper.php
maintenance/populateArchiveRevId.php
maintenance/sql.php
maintenance/storage/compressOld.php
maintenance/updateCollation.php
maintenance/updateExtensionJsonSchema.php
tests/phpunit/bootstrap.php

index 29729ae..e02dba7 100644 (file)
@@ -76,26 +76,21 @@ $cfg['exclude_analysis_directory_list'] = [
 ];
 
 $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [
-       // approximate error count: 22
-       "PhanAccessMethodInternal",
        // approximate error count: 19
-       "PhanParamReqAfterOpt",
+       "PhanParamReqAfterOpt", // False positives with nullables, ref phan issue #3159
        // approximate error count: 110
-       "PhanParamTooMany",
-       // approximate error count: 63
-       "PhanTypeArraySuspicious",
-       // approximate error count: 88
-       "PhanTypeInvalidDimOffset",
-       // approximate error count: 60
-       "PhanTypeMismatchArgument",
+       "PhanParamTooMany", // False positives with variargs. Unsuppress after dropping HHVM
+
+       // approximate error count: 22
+       "PhanAccessMethodInternal",
        // approximate error count: 36
        "PhanUndeclaredConstant",
+       // approximate error count: 60
+       "PhanTypeMismatchArgument",
        // approximate error count: 219
        "PhanUndeclaredMethod",
        // approximate error count: 752
        "PhanUndeclaredProperty",
-       // approximate error count: 53
-       "PhanUndeclaredVariableDim",
 ] );
 
 $cfg['ignore_undeclared_variables_in_global_scope'] = true;
@@ -103,6 +98,20 @@ $cfg['globals_type_map'] = array_merge( $cfg['globals_type_map'], [
        'IP' => 'string',
        'wgGalleryOptions' => 'array',
        'wgDummyLanguageCodes' => 'string[]',
+       'wgNamespaceProtection' => 'array<string,string|string[]>',
+       'wgNamespaceAliases' => 'array<string,int>',
+       'wgLockManagers' => 'array[]',
+       'wgForeignFileRepos' => 'array[]',
+       'wgDefaultUserOptions' => 'array',
+       'wgSkipSkins' => 'string[]',
+       'wgLogTypes' => 'string[]',
+       'wgLogNames' => 'array<string,string>',
+       'wgLogHeaders' => 'array<string,string>',
+       'wgLogActionsHandlers' => 'array<string,class-string>',
+       'wgPasswordPolicy' => 'array<string,array<string,string|array>>',
+       'wgVirtualRestConfig' => 'array<string,array>',
+       'wgWANObjectCaches' => 'array[]',
+       'wgLocalInterwikis' => 'string[]',
 ] );
 
 return $cfg;
index f066a61..541541a 100644 (file)
@@ -4166,7 +4166,7 @@ ERROR;
         *  - 'legacy-name' (optional): short name for backwards-compatibility
         * @param array $checked Array of checkbox name (matching the 'legacy-name') => bool,
         *   where bool indicates the checked status of the checkbox
-        * @return array
+        * @return array[]
         */
        public function getCheckboxesDefinition( $checked ) {
                $checkboxes = [];
index 8272ccf..75eedcc 100644 (file)
@@ -181,7 +181,7 @@ class FileDeleteForm {
                                $logEntry->setPerformer( $user );
                                $logEntry->setTarget( $title );
                                $logEntry->setComment( $logComment );
-                               $logEntry->setTags( $tags );
+                               $logEntry->addTags( $tags );
                                $logid = $logEntry->insert();
                                $logEntry->publish( $logid );
 
@@ -212,7 +212,7 @@ class FileDeleteForm {
                                                $logEntry->setPerformer( $user );
                                                $logEntry->setTarget( clone $title );
                                                $logEntry->setComment( $reason );
-                                               $logEntry->setTags( $tags );
+                                               $logEntry->addTags( $tags );
                                                $logid = $logEntry->insert();
                                                $dbw->onTransactionPreCommitOrIdle(
                                                        function () use ( $logEntry, $logid ) {
@@ -261,6 +261,7 @@ class FileDeleteForm {
                );
                $options = Xml::listDropDownOptionsOoui( $options );
 
+               $fields = [];
                $fields[] = new OOUI\LabelWidget( [ 'label' => new OOUI\HtmlSnippet(
                        $this->prepareMessage( 'filedelete-intro' ) ) ]
                );
index 4ae9237..2cde173 100644 (file)
@@ -2116,6 +2116,7 @@ function wfEscapeShellArg( ...$args ) {
  *     including errors from limit.sh
  *   - profileMethod: By default this function will profile based on the calling
  *     method. Set this to a string for an alternative method to profile from
+ * @phan-param array{duplicateStderr?:bool,profileMethod?:string} $options
  *
  * @return string Collected stdout as a string
  * @deprecated since 1.30 use class MediaWiki\Shell\Shell
@@ -2134,6 +2135,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = [],
        }
 
        $includeStderr = isset( $options['duplicateStderr'] ) && $options['duplicateStderr'];
+       // @phan-suppress-next-line PhanTypeInvalidDimOffset
        $profileMethod = $options['profileMethod'] ?? wfGetCaller();
 
        try {
@@ -2190,6 +2192,7 @@ function wfShellExecWithStderr( $cmd, &$retval = null, $environ = [], $limits =
  * @param array $options Associative array of options:
  *     'php': The path to the php executable
  *     'wrapper': Path to a PHP wrapper to handle the maintenance script
+ * @phan-param array{php?:string,wrapper?:string} $options
  * @return string
  */
 function wfShellWikiCmd( $script, array $parameters = [], array $options = [] ) {
@@ -2197,6 +2200,7 @@ function wfShellWikiCmd( $script, array $parameters = [], array $options = [] )
        // Give site config file a chance to run the script in a wrapper.
        // The caller may likely want to call wfBasename() on $script.
        Hooks::run( 'wfShellWikiCmd', [ &$script, &$parameters, &$options ] );
+       // @phan-suppress-next-line PhanTypeInvalidDimOffset
        $cmd = [ $options['php'] ?? $wgPhpCli ];
        if ( isset( $options['wrapper'] ) ) {
                $cmd[] = $options['wrapper'];
index 7e1b44d..c46df94 100644 (file)
@@ -338,6 +338,7 @@ class LinkFilter {
                        }
                }
 
+               $like = [];
                $like[] = $bits['scheme'] . $bits['delimiter'] . $bits['host'];
 
                if ( $subdomains ) {
index 03d2516..e748b3a 100644 (file)
@@ -1040,7 +1040,7 @@ class Linker {
                }
 
                $userTalkPage = new TitleValue( NS_USER_TALK, strtr( $userText, ' ', '_' ) );
-               $moreLinkAttribs['class'] = 'mw-usertoollinks-talk';
+               $moreLinkAttribs = [ 'class' => 'mw-usertoollinks-talk' ];
 
                return self::link( $userTalkPage,
                        wfMessage( 'talkpagelinktext' )->escaped(),
@@ -1062,7 +1062,7 @@ class Linker {
                }
 
                $blockPage = SpecialPage::getTitleFor( 'Block', $userText );
-               $moreLinkAttribs['class'] = 'mw-usertoollinks-block';
+               $moreLinkAttribs = [ 'class' => 'mw-usertoollinks-block' ];
 
                return self::link( $blockPage,
                        wfMessage( 'blocklink' )->escaped(),
@@ -1083,7 +1083,7 @@ class Linker {
                }
 
                $emailPage = SpecialPage::getTitleFor( 'Emailuser', $userText );
-               $moreLinkAttribs['class'] = 'mw-usertoollinks-mail';
+               $moreLinkAttribs = [ 'class' => 'mw-usertoollinks-mail' ];
                return self::link( $emailPage,
                        wfMessage( 'emaillink' )->escaped(),
                        $moreLinkAttribs
index 5f2aceb..4180e32 100644 (file)
@@ -598,7 +598,7 @@ class MovePage {
                                '4::oldtitle' => $this->oldTitle->getPrefixedText(),
                        ] );
                        $logEntry->setRelations( [ 'pr_id' => $logRelationsValues ] );
-                       $logEntry->setTags( $changeTags );
+                       $logEntry->addTags( $changeTags );
                        $logId = $logEntry->insert();
                        $logEntry->publish( $logId );
                }
@@ -895,7 +895,7 @@ class MovePage {
                # Log the move
                $logid = $logEntry->insert();
 
-               $logEntry->setTags( $changeTags );
+               $logEntry->addTags( $changeTags );
                $logEntry->publish( $logid );
 
                return $nullRevision;
index 3bc8dda..ba229d1 100644 (file)
@@ -185,6 +185,7 @@ class RenderedRevision implements SlotRenderingProvider {
         * @param array $hints Hints given as an associative array. Known keys:
         *      - 'generate-html' => bool: Whether the caller is interested in output HTML (as opposed
         *        to just meta-data). Default is to generate HTML.
+        * @phan-param array{generate-html?:bool} $hints
         *
         * @return ParserOutput
         */
@@ -212,6 +213,7 @@ class RenderedRevision implements SlotRenderingProvider {
         * @param array $hints Hints given as an associative array. Known keys:
         *      - 'generate-html' => bool: Whether the caller is interested in output HTML (as opposed
         *        to just meta-data). Default is to generate HTML.
+        * @phan-param array{generate-html?:bool} $hints
         *
         * @throws SuppressedDataException if the content is not accessible for the audience
         *         specified in the constructor.
index 3c3b6a9..ea90255 100644 (file)
@@ -95,6 +95,7 @@ class RevisionRenderer {
         *        matched the $rev and $options. This mechanism is intended as a temporary stop-gap,
         *        for the time until caches have been changed to store RenderedRevision states instead
         *        of ParserOutput objects.
+        * @phan-param array{use-master?:bool,audience?:int,known-revision-output?:ParserOutput} $hints
         *
         * @return RenderedRevision|null The rendered revision, or null if the audience checks fails.
         */
@@ -108,6 +109,7 @@ class RevisionRenderer {
                        throw new InvalidArgumentException( 'Mismatching wiki ID ' . $rev->getWikiId() );
                }
 
+               // @phan-suppress-next-line PhanTypeInvalidDimOffset
                $audience = $hints['audience']
                        ?? ( $forUser ? RevisionRecord::FOR_THIS_USER : RevisionRecord::FOR_PUBLIC );
 
@@ -121,6 +123,7 @@ class RevisionRenderer {
                        $options = ParserOptions::newCanonical( $forUser ?: 'canonical' );
                }
 
+               // @phan-suppress-next-line PhanTypeInvalidDimOffset
                $useMaster = $hints['use-master'] ?? false;
 
                $dbIndex = $useMaster
index 9e8dfe7..818a536 100644 (file)
@@ -2324,6 +2324,7 @@ class RevisionStore
         *  - tables: (string[]) to include in the `$table` to `IDatabase->select()`
         *  - fields: (string[]) to include in the `$vars` to `IDatabase->select()`
         *  - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
+        * @phan-return array{tables:string[],fields:string[],joins:array}
         */
        public function getQueryInfo( $options = [] ) {
                $ret = [
index c1c6ef2..1e65f52 100644 (file)
@@ -386,6 +386,7 @@ $wgSkipSkins[] = 'apioutput';
 if ( $wgLocalInterwiki ) {
        // Hard deprecated in 1.34.
        wfDeprecated( '$wgLocalInterwiki â€“ use $wgLocalInterwikis instead', '1.23' );
+       // @phan-suppress-next-line PhanUndeclaredVariableDim
        array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
 }
 
index 1acc7af..f621e66 100644 (file)
@@ -2955,7 +2955,7 @@ class Title implements LinkTarget, IDBAccessObject {
                }
 
                $dbr = wfGetDB( DB_REPLICA );
-               $conds['page_namespace'] = $this->mNamespace;
+               $conds = [ 'page_namespace' => $this->mNamespace ];
                $conds[] = 'page_title ' . $dbr->buildLike( $this->mDbkeyform . '/', $dbr->anyString() );
                $options = [];
                if ( $limit > -1 ) {
index 7a548cc..9a3f75e 100644 (file)
@@ -307,6 +307,9 @@ class ApiAuthManagerHelper {
        /**
         * Clean up a field array for output
         * @param array $fields
+        * @codingStandardsIgnoreStart
+        * @phan-param array{type:string,options:array,value:string,label:Message,help:Message,optional:bool,sensitive:bool,skippable:bool} $fields
+        * @codingStandardsIgnoreEnd
         * @return array
         */
        private function formatFields( array $fields ) {
index 2c1564e..755f319 100644 (file)
@@ -141,6 +141,7 @@ class ApiBlock extends ApiBase {
                }
 
                list( $target, /*...*/ ) = SpecialBlock::getTargetAndType( $params['user'] );
+               $res = [];
                $res['user'] = $params['user'];
                $res['userID'] = $target instanceof User ? $target->getId() : 0;
 
index e631e3f..fdf9cf1 100644 (file)
@@ -378,6 +378,7 @@ class ApiEditPage extends ApiBase {
                $status = $ep->attemptSave( $result );
                $wgRequest = $oldRequest;
 
+               $r = [];
                switch ( $status->value ) {
                        case EditPage::AS_HOOK_ERROR:
                        case EditPage::AS_HOOK_ERROR_EXPECTED:
index 641aa9f..574d83b 100644 (file)
@@ -153,6 +153,7 @@ class ApiMain extends ApiBase {
        private $mModule;
 
        private $mCacheMode = 'private';
+       /** @var array */
        private $mCacheControl = [];
        private $mParamsUsed = [];
        private $mParamsSensitive = [];
index 6a575ec..0ba4a0e 100644 (file)
@@ -96,6 +96,7 @@ class ApiOpenSearch extends ApiBase {
                        // Trim extracts, if necessary
                        $length = $this->getConfig()->get( 'OpenSearchDescriptionLength' );
                        foreach ( $results as &$r ) {
+                               // @phan-suppress-next-line PhanTypeInvalidDimOffset
                                if ( is_string( $r['extract'] ) && !$r['extract trimmed'] ) {
                                        $r['extract'] = self::trimExtract( $r['extract'], $length );
                                }
index c604322..6afb018 100644 (file)
@@ -77,6 +77,7 @@ class ApiPageSet extends ApiBase {
        private $mGeneratorData = []; // [ns][dbkey] => data array
        private $mFakePageId = -1;
        private $mCacheMode = 'public';
+       /** @var array */
        private $mRequestedPageFields = [];
        /** @var int */
        private $mDefaultNamespace = NS_MAIN;
index f82a559..6c1eb0f 100644 (file)
@@ -35,7 +35,10 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
         */
        private $rootTitle;
 
-       private $params, $cont, $redirect;
+       private $params;
+       /** @var array */
+       private $cont;
+       private $redirect;
        private $bl_ns, $bl_from, $bl_from_ns, $bl_table, $bl_code, $bl_title, $bl_fields, $hasNS;
 
        /**
@@ -306,7 +309,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                        }
 
                        if ( is_null( $resultPageSet ) ) {
-                               $a['pageid'] = (int)$row->page_id;
+                               $a = [ 'pageid' => (int)$row->page_id ];
                                ApiQueryBase::addTitleInfo( $a, Title::makeTitle( $row->page_namespace, $row->page_title ) );
                                if ( $row->page_is_redirect ) {
                                        $a['redirect'] = true;
@@ -323,6 +326,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
        /**
         * @param ApiPageSet $resultPageSet
         * @return void
+        * @suppress PhanTypeInvalidDimOffset
         */
        private function run( $resultPageSet = null ) {
                $this->params = $this->extractRequestParams( false );
index 1af4d95..eb787d1 100644 (file)
@@ -368,7 +368,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                        if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
                                $pageID = $newPageID++;
                                $pageMap[$row->ar_namespace][$row->ar_title] = $pageID;
-                               $a['revisions'] = [ $rev ];
+                               $a = [ 'revisions' => [ $rev ] ];
                                ApiResult::setIndexedTagName( $a['revisions'], 'rev' );
                                $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
                                ApiQueryBase::addTitleInfo( $a, $title );
index ac7e5cc..98474c7 100644 (file)
@@ -118,6 +118,7 @@ class ApiQueryInfo extends ApiQueryBase {
                return $this->tokenFunctions;
        }
 
+       /** @var string[] */
        protected static $cachedTokens = [];
 
        /**
index ab8d93a..12d7435 100644 (file)
@@ -34,7 +34,9 @@ class ApiQueryUserInfo extends ApiQueryBase {
 
        const WL_UNREAD_LIMIT = 1000;
 
+       /** @var array */
        private $params = [];
+       /** @var array */
        private $prop = [];
 
        public function __construct( ApiQuery $query, $moduleName ) {
index 0718ac8..15c2564 100644 (file)
@@ -86,11 +86,13 @@ class ApiUnblock extends ApiBase {
                        $this->dieStatus( $this->errorArrayToStatus( $retval ) );
                }
 
-               $res['id'] = $block->getId();
                $target = $block->getType() == DatabaseBlock::TYPE_AUTO ? '' : $block->getTarget();
-               $res['user'] = $target instanceof User ? $target->getName() : $target;
-               $res['userid'] = $target instanceof User ? $target->getId() : 0;
-               $res['reason'] = $params['reason'];
+               $res = [
+                       'id' => $block->getId(),
+                       'user' => $target instanceof User ? $target->getName() : $target,
+                       'userid' => $target instanceof User ? $target->getId() : 0,
+                       'reason' => $params['reason']
+               ];
                $this->getResult()->addValue( null, $this->getModuleName(), $res );
        }
 
index ba9be81..9ef17e6 100644 (file)
@@ -84,10 +84,12 @@ class ApiUndelete extends ApiBase {
 
                $this->setWatch( $params['watchlist'], $titleObj );
 
-               $info['title'] = $titleObj->getPrefixedText();
-               $info['revisions'] = (int)$retval[0];
-               $info['fileversions'] = (int)$retval[1];
-               $info['reason'] = $retval[2];
+               $info = [
+                       'title' => $titleObj->getPrefixedText(),
+                       'revisions' => (int)$retval[0],
+                       'fileversions' => (int)$retval[1],
+                       'reason' => $retval[2]
+               ];
                $this->getResult()->addValue( null, $this->getModuleName(), $info );
        }
 
index b15b998..3a54772 100644 (file)
@@ -793,6 +793,7 @@ class ApiUpload extends ApiBase {
                        }
                }
 
+               $result = [];
                // No errors, no warnings: do the upload
                if ( $this->mParams['async'] ) {
                        $progress = UploadBase::getSessionStatus( $this->getUser(), $this->mParams['filekey'] );
index 89ec6cb..3aaae70 100644 (file)
@@ -112,6 +112,7 @@ class ApiUserrights extends ApiBase {
 
                $form = $this->getUserRightsPage();
                $form->setContext( $this->getContext() );
+               $r = [];
                $r['user'] = $user->getName();
                $r['userid'] = $user->getId();
                list( $r['added'], $r['removed'] ) = $form->doSaveUserGroups(
index 943149d..c36759a 100644 (file)
@@ -33,6 +33,7 @@ class ApiValidatePassword extends ApiBase {
                        $user = $this->getUser();
                }
 
+               $r = [];
                $validity = $user->checkPasswordValidity( $params['password'] );
                $r['validity'] = $validity->isGood() ? 'Good' : ( $validity->isOK() ? 'Change' : 'Invalid' );
                $messages = array_merge(
index 02abb1e..6f46c56 100644 (file)
@@ -99,6 +99,7 @@ trait SearchApi {
         *
         * @return array array containing available additional api param definitions.
         *  Empty if profiles are not supported by the searchEngine implementation.
+        * @suppress PhanTypeMismatchDimFetch
         */
        private function buildProfileApiParam() {
                $configs = $this->getSearchProfileParams();
@@ -119,6 +120,7 @@ trait SearchApi {
                                if ( isset( $profile['desc-message'] ) ) {
                                        $helpMessages[$profile['name']] = $profile['desc-message'];
                                }
+
                                if ( !empty( $profile['default'] ) ) {
                                        $defaultProfile = $profile['name'];
                                }
index f59760a..1a2442c 100644 (file)
@@ -122,6 +122,7 @@ abstract class AuthenticationRequest {
         * a 'password' field).
         *
         * @return array As above
+        * @phan-return array<string,array{type:string,options?:array,value?:string,label:Message,help:Message,optional?:bool,sensitive?:bool,skippable?:bool}>
         */
        abstract public function getFieldInfo();
 
@@ -297,6 +298,7 @@ abstract class AuthenticationRequest {
         * @param AuthenticationRequest[] $reqs
         * @return array
         * @throws \UnexpectedValueException If fields cannot be merged
+        * @suppress PhanTypeInvalidDimOffset
         */
        public static function mergeFieldInfo( array $reqs ) {
                $merged = [];
@@ -337,7 +339,6 @@ abstract class AuthenticationRequest {
                                }
 
                                $options['sensitive'] = !empty( $options['sensitive'] );
-                               // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
                                $type = $options['type'];
 
                                if ( !array_key_exists( $name, $merged ) ) {
index 9d0175a..7128fe2 100644 (file)
@@ -40,7 +40,7 @@ class Throttler implements LoggerAwareInterface {
        /**
         * See documentation of $wgPasswordAttemptThrottle for format. Old (pre-1.27) format is not
         * allowed here.
-        * @var array
+        * @var array[]
         * @see https://www.mediawiki.org/wiki/Manual:$wgPasswordAttemptThrottle
         */
        protected $conditions;
@@ -179,7 +179,7 @@ class Throttler implements LoggerAwareInterface {
        /**
         * Handles B/C for $wgPasswordAttemptThrottle.
         * @param array $throttleConditions
-        * @return array
+        * @return array[]
         * @see $wgPasswordAttemptThrottle for structure
         */
        protected static function normalizeThrottleConditions( $throttleConditions ) {
index 62cf39e..e461762 100644 (file)
@@ -265,7 +265,7 @@ class EnhancedChangesList extends ChangesList {
                                $block[0], $block[0]->unpatrolled, $block[0]->watched );
                }
 
-               $queryParams['curid'] = $curId;
+               $queryParams = [ 'curid' => $curId ];
 
                # Sub-entries
                $lines = [];
@@ -632,7 +632,7 @@ class EnhancedChangesList extends ChangesList {
        protected function recentChangesBlockLine( $rcObj ) {
                $data = [];
 
-               $query['curid'] = $rcObj->mAttribs['rc_cur_id'];
+               $query = [ 'curid' => $rcObj->mAttribs['rc_cur_id'] ];
 
                $type = $rcObj->mAttribs['rc_type'];
                $logType = $rcObj->mAttribs['rc_log_type'];
index edaa963..1d590d9 100644 (file)
@@ -90,6 +90,7 @@ class RecentChange implements Taggable {
         */
        const SEND_FEED = false;
 
+       /** @var array */
        public $mAttribs = [];
        public $mExtra = [];
 
index 30c2f7a..9ee000d 100644 (file)
@@ -1001,7 +1001,7 @@ class ChangeTags {
                }
                $logEntry->setParameters( $params );
                $logEntry->setRelations( [ 'Tag' => $tag ] );
-               $logEntry->setTags( $logEntryTags );
+               $logEntry->addTags( $logEntryTags );
 
                $logId = $logEntry->insert( $dbw );
                $logEntry->publish( $logId );
index 100fa83..f1df087 100644 (file)
@@ -1260,6 +1260,7 @@ abstract class ContentHandler {
         * @since 1.28
         */
        public function getFieldsForSearchIndex( SearchEngine $engine ) {
+               $fields = [];
                $fields['category'] = $engine->makeSearchFieldMapping(
                        'category',
                        SearchIndexField::INDEX_TYPE_TEXT
index 6a1cc62..f3f9a97 100644 (file)
@@ -11,6 +11,7 @@ use MediaWiki\MediaWikiServices;
 class FileContentHandler extends WikitextContentHandler {
 
        public function getFieldsForSearchIndex( SearchEngine $engine ) {
+               $fields = [];
                $fields['file_media_type'] =
                        $engine->makeSearchFieldMapping( 'file_media_type', SearchIndexField::INDEX_TYPE_KEYWORD );
                $fields['file_media_type']->setFlag( SearchIndexField::FLAG_CASEFOLD );
index ce507d7..6ebec1c 100644 (file)
@@ -47,7 +47,9 @@ use MediaWiki\Diff\ComplexityException;
 class DiffEngine {
 
        // Input variables
+       /** @var string[] */
        private $from;
+       /** @var string[] */
        private $to;
        private $m;
        private $n;
@@ -361,6 +363,7 @@ class DiffEngine {
                         */
                        $max = min( $this->m, $this->n );
                        for ( $forwardBound = 0; $forwardBound < $max
+                               // @phan-suppress-next-line PhanTypeInvalidDimOffset
                                && $this->from[$forwardBound] === $this->to[$forwardBound];
                                ++$forwardBound
                        ) {
index e474ad3..96df29f 100644 (file)
@@ -115,6 +115,8 @@ class RepoGroup {
         *                   user is allowed to view them. Otherwise, such files will not
         *                   be found.
         *   latest:         If true, load from the latest available data into File objects
+        * @phan-param array{time?:mixed,ignoreRedirect?:bool,private?:bool,latest?:bool} $options
+        * @suppress PhanTypeInvalidDimOffset
         * @return File|bool False if title is not found
         */
        function findFile( $title, $options = [] ) {
index f3116e2..0ef6034 100644 (file)
@@ -344,6 +344,7 @@ class LocalFile extends File {
                                $this->loadFromDB( self::READ_NORMAL );
 
                                $fields = $this->getCacheFields( '' );
+                               $cacheVal = [];
                                $cacheVal['fileExists'] = $this->fileExists;
                                if ( $this->fileExists ) {
                                        foreach ( $fields as $field ) {
@@ -1079,6 +1080,7 @@ class LocalFile extends File {
        /**
         * Delete cached transformed files for the current version only.
         * @param array $options
+        * @phan-param array{forThumbRefresh?:bool} $options
         */
        public function purgeThumbnails( $options = [] ) {
                $files = $this->getThumbnails();
@@ -1090,6 +1092,7 @@ class LocalFile extends File {
                array_shift( $urls ); // don't purge directory
 
                // Give media handler a chance to filter the file purge list
+               // @phan-suppress-next-line PhanTypeInvalidDimOffset
                if ( !empty( $options['forThumbRefresh'] ) ) {
                        $handler = $this->getHandler();
                        if ( $handler ) {
@@ -1758,7 +1761,7 @@ class LocalFile extends File {
 
                                        # Add change tags, if any
                                        if ( $tags ) {
-                                               $logEntry->setTags( $tags );
+                                               $logEntry->addTags( $tags );
                                        }
 
                                        # Uploads can be patrolled
index fdb3dc4..5173916 100644 (file)
@@ -155,14 +155,13 @@ class DiffHistoryBlob implements HistoryBlob {
                                        $seqName = 'main';
                                }
                        }
-                       $seq =& $sequences[$seqName];
-                       $tail = $seq['tail'];
+
+                       $tail = $sequences[$seqName]['tail'];
                        $diff = $this->diff( $tail, $text );
-                       $seq['diffs'][] = $diff;
-                       $seq['map'][] = $i;
-                       $seq['tail'] = $text;
+                       $sequences[$seqName]['diffs'][] = $diff;
+                       $sequences[$seqName]['map'][] = $i;
+                       $sequences[$seqName]['tail'] = $text;
                }
-               unset( $seq ); // unlink dangerous alias
 
                // Knit the sequences together
                $tail = '';
index f4dad39..04be6c4 100644 (file)
@@ -242,6 +242,10 @@ class HTMLForm extends ContextSource {
 
        protected $mUseMultipart = false;
        protected $mHiddenFields = [];
+       /**
+        * @var array[]
+        * @phan-var array<array{name:string,value:string,label-message?:string,label?:string,label-raw?:string,id?:string,attribs?:array,flags?:string|string[],framed?:bool}>
+        */
        protected $mButtons = [];
 
        protected $mWrapperLegend = false;
@@ -983,6 +987,9 @@ class HTMLForm extends ContextSource {
         *  - attribs: (array, optional) Additional HTML attributes.
         *  - flags: (string|string[], optional) OOUI flags.
         *  - framed: (boolean=true, optional) OOUI framed attribute.
+        * @codingStandardsIgnoreStart
+        * @phan-param array{name:string,value:string,label-message?:string,label?:string,label-raw?:string,id?:string,attribs?:array,flags?:string|string[],framed?:bool} $data
+        * @codingStandardsIgnoreEnd
         * @return HTMLForm $this for chaining calls (since 1.20)
         */
        public function addButton( $data ) {
index 8e5567b..8433df6 100644 (file)
@@ -58,10 +58,14 @@ class HttpRequestFactory {
         *    - password            Password for HTTP Basic Authentication
         *    - originalRequest     Information about the original request (as a WebRequest object or
         *                          an associative array with 'ip' and 'userAgent').
+        * @codingStandardsIgnoreStart
+        * @phan-param array{timeout?:int,connectTimeout?:int,postData?:array,proxy?:string,noProxy?:bool,sslVerifyHost?:bool,sslVerifyCert?:bool,caInfo?:string,maxRedirects?:int,followRedirects?:bool,userAgent?:string,logger?:\Psr\Logger\LoggerInterface,username?:string,password?:string,originalRequest?:WebRequest|array{ip:string,userAgent:string}} $options
+        * @codingStandardsIgnoreEnd
         * @param string $caller The method making this request, for profiling
         * @throws RuntimeException
         * @return MWHttpRequest
         * @see MWHttpRequest::__construct
+        * @suppress PhanUndeclaredTypeParameter
         */
        public function create( $url, array $options = [], $caller = __METHOD__ ) {
                if ( !Http::$httpEngine ) {
index 41ea1dc..3a2f982 100644 (file)
@@ -46,6 +46,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
        protected $sslVerifyCert = true;
        protected $caInfo = null;
        protected $method = "GET";
+       /** @var array */
        protected $reqHeaders = [];
        protected $url;
        protected $parsedUrl;
@@ -63,6 +64,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
        protected $headerList = [];
        protected $respVersion = "0.9";
        protected $respStatus = "200 Ok";
+       /** @var string[][] */
        protected $respHeaders = [];
 
        /** @var StatusValue */
@@ -86,6 +88,9 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
        /**
         * @param string $url Url to use. If protocol-relative, will be expanded to an http:// URL
         * @param array $options (optional) extra params to pass (see HttpRequestFactory::create())
+        * @codingStandardsIgnoreStart
+        * @phan-param array{timeout?:int,connectTimeout?:int,postData?:array,proxy?:string,noProxy?:bool,sslVerifyHost?:bool,sslVerifyCert?:bool,caInfo?:string,maxRedirects?:int,followRedirects?:bool,userAgent?:string,logger?:LoggerInterface,username?:string,password?:string,originalRequest?:WebRequest|array{ip:string,userAgent:string},method?:string} $options
+        * @codingStandardsIgnoreEnd
         * @param string $caller The method making this request, for profiling
         * @param Profiler|null $profiler An instance of the profiler for profiling, or null
         * @throws Exception
@@ -98,6 +103,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
                $this->url = wfExpandUrl( $url, PROTO_HTTP );
                $this->parsedUrl = wfParseUrl( $this->url );
 
+               // @phan-suppress-next-line PhanTypeInvalidDimOffset
                $this->logger = $options['logger'] ?? new NullLogger();
 
                if ( !$this->parsedUrl || !Http::isValidURI( $this->url ) ) {
@@ -139,6 +145,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
                                // ensure that MWHttpRequest::method is always
                                // uppercased. T38137
                                if ( $o == 'method' ) {
+                                       // @phan-suppress-next-line PhanTypeInvalidDimOffset
                                        $options[$o] = strtoupper( $options[$o] );
                                }
                                $this->$o = $options[$o];
index 68f5b9b..0d1cc68 100644 (file)
@@ -738,6 +738,9 @@ class WikiImporter {
                return $this->logItemCallback( $revision );
        }
 
+       /**
+        * @suppress PhanTypeInvalidDimOffset Phan not reading the reference inside the hook
+        */
        private function handlePage() {
                // Handle page data.
                $this->debug( "Enter page handler." );
index a3951a1..c719c76 100644 (file)
@@ -1270,7 +1270,7 @@ abstract class Installer {
         *
         * @param string $directory Directory to search in, relative to $IP, must be either "extensions"
         *     or "skins"
-        * @return array [ $extName => [ 'screenshots' => [ '...' ] ]
+        * @return array[][] [ $extName => [ 'screenshots' => [ '...' ] ]
         */
        public function findExtensions( $directory = 'extensions' ) {
                switch ( $directory ) {
index 06cd04c..7bc97d8 100644 (file)
@@ -397,7 +397,8 @@ class JobQueueGroup {
        }
 
        /**
-        * @return JobQueue[]
+        * @return array[]
+        * @phan-return array<string,array{queue:JobQueue,types:array<string,class-string>}>
         */
        protected function getCoalescedQueues() {
                global $wgJobTypeConf;
index 4a62e72..9d53a86 100644 (file)
@@ -45,9 +45,10 @@ class MappedIterator extends FilterIterator {
         * the base iterator (post-callback) and will return true if that value should be
         * included in iteration of the MappedIterator (otherwise it will be filtered out).
         *
-        * @param Iterator|Array $iter
+        * @param Iterator|array $iter
         * @param callable $vCallback Value transformation callback
         * @param array $options Options map (includes "accept") (since 1.22)
+        * @phan-param array{accept?:callable} $options
         * @throws UnexpectedValueException
         */
        public function __construct( $iter, $vCallback, array $options = [] ) {
@@ -60,6 +61,7 @@ class MappedIterator extends FilterIterator {
                }
                parent::__construct( $baseIterator );
                $this->vCallback = $vCallback;
+               // @phan-suppress-next-line PhanTypeInvalidDimOffset
                $this->aCallback = $options['accept'] ?? null;
        }
 
index 90e52f0..56e6b19 100644 (file)
@@ -43,13 +43,13 @@ class XhprofData {
 
        /**
         * Per-function inclusive data.
-        * @var array $inclusive
+        * @var array[] $inclusive
         */
        protected $inclusive;
 
        /**
         * Per-function inclusive and exclusive data.
-        * @var array $complete
+        * @var array[] $complete
         */
        protected $complete;
 
@@ -153,7 +153,7 @@ class XhprofData {
         * - max: Maximum value
         * - variance: Variance (spread) of the values
         *
-        * @return array
+        * @return array[]
         * @see getRawData()
         * @see getCompleteMetrics()
         */
@@ -239,7 +239,7 @@ class XhprofData {
         * metrics have an additional 'exclusive' measurement which is the total
         * minus the totals of all child function calls.
         *
-        * @return array
+        * @return array[]
         * @see getRawData()
         * @see getInclusiveMetrics()
         */
index 905e925..428fec6 100644 (file)
@@ -428,7 +428,11 @@ abstract class FileBackend implements LoggerAwareInterface {
         *   - b) predicted operation errors occurred and 'force' was not set
         *
         * @param array $ops List of operations to execute in order
+        * @codingStandardsIgnoreStart
+        * @phan-param array{ignoreMissingSource?:bool,overwrite?:bool,overwriteSame?:bool,headers?:bool} $ops
         * @param array $opts Batch operation options
+        * @phan-param array{force?:bool,nonLocking?:bool,nonJournaled?:bool,parallelize?:bool,bypassReadOnly?:bool,preserveCache?:bool} $opts
+        * @codingStandardsIgnoreEnd
         * @return StatusValue
         */
        final public function doOperations( array $ops, array $opts = [] ) {
@@ -666,7 +670,9 @@ abstract class FileBackend implements LoggerAwareInterface {
         * considered "OK" as long as no fatal errors occurred.
         *
         * @param array $ops Set of operations to execute
+        * @phan-param array{ignoreMissingSource?:bool,headers?:bool} $ops
         * @param array $opts Batch operation options
+        * @phan-param array{bypassReadOnly?:bool} $opts
         * @return StatusValue
         * @since 1.20
         */
index 5e233ae..6b1ef89 100644 (file)
@@ -188,8 +188,12 @@ class MultiHttpClient implements LoggerAwareInterface {
         *   - reqTimeout      : post-connection timeout per request (seconds)
         *   - usePipelining   : whether to use HTTP pipelining if possible
         *   - maxConnsPerHost : maximum number of concurrent connections (per host)
+        * @codingStandardsIgnoreStart
+        * @phan-param array{connTimeout?:int,reqTimeout?:int,usePipelining?:bool,maxConnsPerHost?:int} $opts
+        * @codingStandardsIgnoreEnd
         * @return array $reqs With response array populated for each
         * @throws Exception
+        * @suppress PhanTypeInvalidDimOffset
         */
        private function runMultiCurl( array $reqs, array $opts = [] ) {
                $chm = $this->getCurlMulti();
@@ -400,6 +404,7 @@ class MultiHttpClient implements LoggerAwareInterface {
                                $name = strtolower( $name );
                                $value = trim( $value );
                                if ( isset( $req['response']['headers'][$name] ) ) {
+                                       // @phan-suppress-next-line PhanTypeInvalidDimOffset
                                        $req['response']['headers'][$name] .= ', ' . $value;
                                } else {
                                        $req['response']['headers'][$name] = $value;
@@ -508,6 +513,7 @@ class MultiHttpClient implements LoggerAwareInterface {
                                        if ( isset( $svErrors[0]['params'][0] ) ) {
                                                if ( is_numeric( $svErrors[0]['params'][0] ) ) {
                                                        if ( isset( $svErrors[0]['params'][1] ) ) {
+                                                               // @phan-suppress-next-line PhanTypeInvalidDimOffset
                                                                $req['response']['reason'] = $svErrors[0]['params'][1];
                                                        }
                                                } else {
index 42da5f0..ad3f681 100644 (file)
@@ -91,6 +91,7 @@ abstract class BagOStuff implements IExpiringStore, IStoreKeyEncoder, LoggerAwar
         *   - asyncHandler: Callable to use for scheduling tasks after the web request ends.
         *      In CLI mode, it should run the task immediately.
         * @param array $params
+        * @phan-param array{logger?:Psr\Log\LoggerInterface,asyncHandler?:callable} $params
         */
        public function __construct( array $params = [] ) {
                $this->setLogger( $params['logger'] ?? new NullLogger() );
index 6d0940b..0f7011d 100644 (file)
@@ -47,6 +47,10 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
        /**
         * @param array $params Additional parameters include:
         *   - maxKeys : only allow this many keys (using oldest-first eviction)
+        * @codingStandardsIgnoreStart
+        * @phan-param array{logger?:Psr\Log\LoggerInterface,asyncHandler?:callable,keyspace?:string,reportDupes?:bool,syncTimeout?:int,segmentationSize?:int,segmentedValueMaxSize?:int,maxKeys?:int} $params
+        * @codingStandardsIgnoreEnd
+        * @suppress PhanTypeInvalidDimOffset
         */
        function __construct( $params = [] ) {
                $params['segmentationSize'] = $params['segmentationSize'] ?? INF;
index 9d36187..252c089 100644 (file)
@@ -73,6 +73,9 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
         *      This should be configured to a reasonable size give the site traffic and the
         *      amount of I/O between application and cache servers that the network can handle.
         * @param array $params
+        * @codingStandardsIgnoreStart
+        * @phan-param array{logger?:Psr\Log\LoggerInterface,asyncHandler?:callable,keyspace?:string,reportDupes?:bool,syncTimeout?:int,segmentationSize?:int,segmentedValueMaxSize?:int} $params
+        * @codingStandardsIgnoreEnd
         */
        public function __construct( array $params = [] ) {
                parent::__construct( $params );
index d0aa380..51f7316 100644 (file)
@@ -61,6 +61,7 @@ class MultiWriteBagOStuff extends BagOStuff {
         *      invalidation uses logical TTLs, invalidation uses etag/timestamp
         *      validation against the DB, or merge() is used to handle races.
         * @param array $params
+        * @phan-param array{caches:array<int,array|BagOStuff>,replication:string} $params
         * @throws InvalidArgumentException
         */
        public function __construct( $params ) {
index b88b496..2ce216d 100644 (file)
@@ -578,10 +578,14 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt
         *   - version: Integer version number signifiying the format of the value.
         *      Default: null
         *   - walltime: How long the value took to generate in seconds. Default: 0.0
+        * @codingStandardsIgnoreStart
+        * @phan-param array{lag?:int,since?:int,pending?:bool,lockTSE?:int,staleTTL?:int,creating?:bool,version?:?string,walltime?:int|float} $opts
+        * @codingStandardsIgnoreEnd
         * @note Options added in 1.28: staleTTL
         * @note Options added in 1.33: creating
         * @note Options added in 1.34: version, walltime
         * @return bool Success
+        * @suppress PhanTypeInvalidDimOffset
         */
        final public function set( $key, $value, $ttl = self::TTL_INDEFINITE, array $opts = [] ) {
                $now = $this->getCurrentTime();
@@ -1246,11 +1250,15 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt
         *      most sense for values that are moderately to highly expensive to regenerate and easy
         *      to query for dependency timestamps. The use of "pcTTL" reduces timestamp queries.
         *      Default: null.
+        * @codingStandardsIgnoreStart
+        * @phan-param array{checkKeys?:string[],graceTTL?:int,lockTSE?:int,busyValue?:mixed,pcTTL?:int,pcGroup?:string,version?:int,minAsOf?:int,hotTTR?:int,lowTTL?:int,ageNew?:int,staleTTL?:int,touchedCallback?:callable} $opts
+        * @codingStandardsIgnoreEnd
         * @return mixed Value found or written to the key
         * @note Options added in 1.28: version, busyValue, hotTTR, ageNew, pcGroup, minAsOf
         * @note Options added in 1.31: staleTTL, graceTTL
         * @note Options added in 1.33: touchedCallback
         * @note Callable type hints are not used to avoid class-autoloading
+        * @suppress PhanTypeInvalidDimOffset
         */
        final public function getWithSetCallback( $key, $ttl, $callback, array $opts = [] ) {
                $version = $opts['version'] ?? null;
@@ -1305,6 +1313,7 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt
         *   - Cached or regenerated value version number or null if not versioned
         *   - Timestamp of the current cached value at the key or null if there is no value
         * @note Callable type hints are not used to avoid class-autoloading
+        * @suppress PhanTypeArraySuspicious
         */
        private function fetchOrRegenerate( $key, $ttl, $callback, array $opts ) {
                $checkKeys = $opts['checkKeys'] ?? [];
@@ -1441,6 +1450,7 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt
                                $this->setInterimValue( $key, $value, $lockTSE, $version, $walltime );
                        } else {
                                $finalSetOpts = [
+                                       // @phan-suppress-next-line PhanTypeInvalidDimOffset
                                        'since' => $setOpts['since'] ?? $preCallbackTime,
                                        'version' => $version,
                                        'staleTTL' => $staleTTL,
@@ -2421,6 +2431,7 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt
         *   - curTTL: remaining time-to-live (negative if tombstoned) or null if there is no value
         *   - version: value version number or null if the if there is no value
         *   - tombAsOf: UNIX timestamp of the tombstone or null if there is no tombstone
+        * @phan-return array{0:mixed,1:array{asOf:?mixed,curTTL:?int|float,version:?mixed,tombAsOf:?mixed}}
         */
        private function unwrap( $wrapped, $now ) {
                $value = false;
index ead290f..d27643c 100644 (file)
@@ -262,6 +262,10 @@ class BlockLogFormatter extends LogFormatter {
                return $params;
        }
 
+       /**
+        * @inheritDoc
+        * @suppress PhanTypeInvalidDimOffset
+        */
        public function formatParametersForApi() {
                $ret = parent::formatParametersForApi();
                if ( isset( $ret['flags'] ) ) {
index 1d0bbfd..5326705 100644 (file)
@@ -191,18 +191,20 @@ class ManualLogEntry extends LogEntryBase implements Taggable {
                        wfDebug( 'Overwriting existing ManualLogEntry tags' );
                }
                $this->tags = [];
-               if ( $tags !== null ) {
-                       $this->addTags( $tags );
-               }
+               $this->addTags( $tags );
        }
 
        /**
         * Add change tags for the log entry
         *
         * @since 1.33
-        * @param string|string[] $tags Tags to apply
+        * @param string|string[]|null $tags Tags to apply
         */
        public function addTags( $tags ) {
+               if ( $tags === null ) {
+                       return;
+               }
+
                if ( is_string( $tags ) ) {
                        $tags = [ $tags ];
                }
index d737a4b..9392220 100644 (file)
@@ -63,7 +63,7 @@ class PatrolLog {
                $entry->setTarget( $rc->getTitle() );
                $entry->setParameters( self::buildParams( $rc, $auto ) );
                $entry->setPerformer( $user );
-               $entry->setTags( $tags );
+               $entry->addTags( $tags );
                $logid = $entry->insert();
                if ( !$auto ) {
                        $entry->publish( $logid, 'udp' );
index 683ded1..c32db28 100644 (file)
@@ -36,6 +36,7 @@ class IPTC {
         *
         * @param string $rawData The app13 block from jpeg containing iptc/iim data
         * @return array IPTC metadata array
+        * @suppress PhanTypeArraySuspicious
         */
        static function parse( $rawData ) {
                $parsed = iptcparse( $rawData );
index d8cd1c5..3628c7b 100644 (file)
@@ -1935,6 +1935,7 @@ class Article implements Page {
                );
                $options = Xml::listDropDownOptionsOoui( $options );
 
+               $fields = [];
                $fields[] = new OOUI\FieldLayout(
                        new OOUI\DropdownInputWidget( [
                                'name' => 'wpDeleteReasonList',
index d69a433..40c63d2 100644 (file)
@@ -461,7 +461,7 @@ class PageArchive {
                $logEntry->setPerformer( $user );
                $logEntry->setTarget( $this->title );
                $logEntry->setComment( $comment );
-               $logEntry->setTags( $tags );
+               $logEntry->addTags( $tags );
                $logEntry->setParameters( [
                        ':assoc:count' => [
                                'revisions' => $textRestored,
index b4b5927..4f0f2e2 100644 (file)
@@ -2392,7 +2392,7 @@ class WikiPage implements Page, IDBAccessObject {
                if ( !is_null( $nullRevision ) ) {
                        $logEntry->setAssociatedRevId( $nullRevision->getId() );
                }
-               $logEntry->setTags( $tags );
+               $logEntry->addTags( $tags );
                if ( $logRelationsField !== null && count( $logRelationsValues ) ) {
                        $logEntry->setRelations( [ $logRelationsField => $logRelationsValues ] );
                }
@@ -2793,7 +2793,7 @@ class WikiPage implements Page, IDBAccessObject {
                        $logEntry->setPerformer( $deleter );
                        $logEntry->setTarget( $logTitle );
                        $logEntry->setComment( $reason );
-                       $logEntry->setTags( $tags );
+                       $logEntry->addTags( $tags );
                        $logid = $logEntry->insert();
 
                        $dbw->onTransactionPreCommitOrIdle(
index 267402f..962313e 100644 (file)
@@ -4271,6 +4271,7 @@ class Parser {
         * @param bool $isMain
         * @return mixed|string
         * @private
+        * @suppress PhanTypeInvalidDimOffset
         */
        public function formatHeadings( $text, $origText, $isMain = true ) {
                # Inhibit editsection links if requested in the page
@@ -5577,6 +5578,7 @@ class Parser {
                Hooks::run( 'ParserMakeImageParams', [ $title, $file, &$params, $this ] );
 
                # Linker does the rest
+               // @phan-suppress-next-line PhanTypeInvalidDimOffset
                $time = $options['time'] ?? false;
                $ret = Linker::makeImageLink( $this, $title, $file, $params['frame'], $params['handler'],
                        $time, $descQuery, $this->mOptions->getThumbSize() );
index 70e38ee..8c44a5e 100644 (file)
@@ -540,6 +540,7 @@ class DefaultPreferencesFactory implements PreferencesFactory {
 
                if ( $this->options->get( 'EnableEmail' ) ) {
                        if ( $canViewPrivateInfo ) {
+                               $helpMessages = [];
                                $helpMessages[] = $this->options->get( 'EmailConfirmToEdit' )
                                                ? 'prefs-help-email-required'
                                                : 'prefs-help-email';
index 3e65f6c..07fe318 100644 (file)
@@ -306,16 +306,6 @@ class ExtensionRegistry {
                                $autoloadNamespaces
                        );
 
-                       if ( isset( $info['AutoloadClasses'] ) ) {
-                               $autoload = $this->processAutoLoader( $dir, $info['AutoloadClasses'] );
-                               $GLOBALS['wgAutoloadClasses'] += $autoload;
-                               $autoloadClasses += $autoload;
-                       }
-                       if ( isset( $info['AutoloadNamespaces'] ) ) {
-                               $autoloadNamespaces += $this->processAutoLoader( $dir, $info['AutoloadNamespaces'] );
-                               AutoLoader::$psr4Namespaces += $autoloadNamespaces;
-                       }
-
                        // get all requirements/dependencies for this extension
                        $requires = $processor->getRequirements( $info, $this->checkDev );
 
index e17b393..e5a0d61 100644 (file)
@@ -424,6 +424,7 @@ JAVASCRIPT;
                                $idx = -1;
                                foreach ( $grpModules as $name => $module ) {
                                        $shouldEmbed = $module->shouldEmbedModule( $context );
+                                       // @phan-suppress-next-line PhanTypeInvalidDimOffset
                                        if ( !$moduleSets || $moduleSets[$idx][0] !== $shouldEmbed ) {
                                                $moduleSets[++$idx] = [ $shouldEmbed, [] ];
                                        }
index 680ae8e..dc43aed 100644 (file)
@@ -394,7 +394,7 @@ abstract class RevDelList extends RevisionListBase {
                }
                $logEntry->setRelations( $relations );
                // Apply change tags to the log entry
-               $logEntry->setTags( $params['tags'] );
+               $logEntry->addTags( $params['tags'] );
                $logId = $logEntry->insert();
                $logEntry->publish( $logId );
        }
index 87a7861..66e59e5 100644 (file)
@@ -727,6 +727,7 @@ abstract class SearchEngine {
         * @param string $profileType the type of profiles
         * @param User|null $user the user requesting the list of profiles
         * @return array|null the list of profiles or null if none available
+        * @phan-return null|array{name:string,desc-message:string,default?:bool}
         */
        public function getProfiles( $profileType, User $user = null ) {
                return null;
index 85f4569..fc117a8 100644 (file)
@@ -287,6 +287,7 @@ final class SessionManager implements SessionManagerInterface {
                                        "$provider returned empty session info with id flagged unsafe"
                                );
                        }
+                       // @phan-suppress-next-line PhanTypeInvalidDimOffset
                        $compare = $infos ? SessionInfo::compare( $infos[0], $info ) : -1;
                        if ( $compare > 0 ) {
                                continue;
index 19fa1da..74d77a8 100644 (file)
@@ -230,6 +230,7 @@ class Shell {
         * @param array $options Associative array of options:
         *     'php': The path to the php executable
         *     'wrapper': Path to a PHP wrapper to handle the maintenance script
+        * @phan-param array{php?:string,wrapper?:string} $options
         * @return Command
         */
        public static function makeScriptCommand( $script, $parameters, $options = [] ): Command {
@@ -237,6 +238,7 @@ class Shell {
                // Give site config file a chance to run the script in a wrapper.
                // The caller may likely want to call wfBasename() on $script.
                Hooks::run( 'wfShellWikiCmd', [ &$script, &$parameters, &$options ] );
+               // @phan-suppress-next-line PhanTypeInvalidDimOffset
                $cmd = [ $options['php'] ?? $wgPhpCli ];
                if ( isset( $options['wrapper'] ) ) {
                        $cmd[] = $options['wrapper'];
index 09e439b..bee4aff 100644 (file)
@@ -444,8 +444,10 @@ abstract class BaseTemplate extends QuickTemplate {
         * @param array $item Array of list item data containing some of a specific set of keys.
         * The "id", "class" and "itemtitle" keys will be used as attributes for the list item,
         * if "active" contains a value of true a "active" class will also be appended to class.
+        * @phan-param array{id?:string,class?:string,itemtitle?:string,active?:bool} $item
         *
         * @param array $options
+        * @phan-param array{tag?:string} $options
         *
         * If you want something other than a "<li>" you can pass a tag name such as
         * "tag" => "span" in the $options array to change the tag used.
@@ -514,6 +516,7 @@ abstract class BaseTemplate extends QuickTemplate {
                if ( isset( $item['itemtitle'] ) ) {
                        $attrs['title'] = $item['itemtitle'];
                }
+               // @phan-suppress-next-line PhanTypeInvalidDimOffset
                return Html::rawElement( $options['tag'] ?? 'li', $attrs, $html );
        }
 
index e1f0588..9934150 100644 (file)
@@ -509,7 +509,7 @@ abstract class AuthManagerSpecialPage extends SpecialPage {
         * Generates a HTMLForm descriptor array from a set of authentication requests.
         * @param AuthenticationRequest[] $requests
         * @param string $action AuthManager action name (one of the AuthManager::ACTION_* constants)
-        * @return array
+        * @return array[]
         */
        protected function getAuthFormDescriptor( $requests, $action ) {
                $fieldInfo = AuthenticationRequest::mergeFieldInfo( $requests );
@@ -600,7 +600,7 @@ abstract class AuthManagerSpecialPage extends SpecialPage {
        /**
         * Adds a sequential tabindex starting from 1 to all form elements. This way the user can
         * use the tab key to traverse the form without having to step through all links and such.
-        * @param array &$formDescriptor
+        * @param array[] &$formDescriptor
         */
        protected function addTabIndex( &$formDescriptor ) {
                $i = 1;
index 59d2806..3a266f2 100644 (file)
@@ -1031,7 +1031,7 @@ class SpecialBlock extends FormSpecialPage {
                $logId = $logEntry->insert();
 
                if ( !empty( $data['Tags'] ) ) {
-                       $logEntry->setTags( $data['Tags'] );
+                       $logEntry->addTags( $data['Tags'] );
                }
 
                $logEntry->publish( $logId );
index 9d5f430..1753831 100644 (file)
@@ -364,6 +364,7 @@ class SpecialContributions extends IncludableSpecialPage {
 
                $linkRenderer = $sp->getLinkRenderer();
 
+               $tools = [];
                # No talk pages for IP ranges.
                if ( !$isRange ) {
                        $tools['user-talk'] = $linkRenderer->makeLink(
index 480e81a..717edc3 100644 (file)
@@ -639,6 +639,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                $linkRenderer = $this->getLinkRenderer();
                $link = $linkRenderer->makeLink( $title );
 
+               $tools = [];
                $tools['talk'] = $linkRenderer->makeLink(
                        $title->getTalkPage(),
                        $this->msg( 'talkpagelinktext' )->text()
index 0cb3bba..941d108 100644 (file)
@@ -285,11 +285,9 @@ class MovePageForm extends UnlistedSpecialPage {
                        # Is the title semi-protected?
                        if ( $this->oldTitle->isSemiProtected( 'move' ) ) {
                                $noticeMsg = 'semiprotectedpagemovewarning';
-                               $classes[] = 'mw-textarea-sprotected';
                        } else {
                                # Then it must be protected based on static groups (regular)
                                $noticeMsg = 'protectedpagemovewarning';
-                               $classes[] = 'mw-textarea-protected';
                        }
                        $out->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
                        $out->addWikiMsg( $noticeMsg );
index c0f004f..1f222f8 100644 (file)
@@ -253,7 +253,7 @@ class SpecialPageLanguage extends FormSpecialPage {
                $entry->setTarget( $title );
                $entry->setParameters( $logParams );
                $entry->setComment( $reason );
-               $entry->setTags( $tags );
+               $entry->addTags( $tags );
 
                $logid = $entry->insert();
                $entry->publish( $logid );
index 31c277a..9b8022b 100644 (file)
@@ -249,7 +249,7 @@ class SpecialUnblock extends SpecialPage {
                $logEntry->setComment( $data['Reason'] );
                $logEntry->setPerformer( $performer );
                if ( isset( $data['Tags'] ) ) {
-                       $logEntry->setTags( $data['Tags'] );
+                       $logEntry->addTags( $data['Tags'] );
                }
                $logEntry->setRelations( [ 'ipb_id' => $block->getId() ] );
                $logId = $logEntry->insert();
index 9a16a72..32be932 100644 (file)
@@ -247,6 +247,7 @@ class SpecialUndelete extends SpecialPage {
 
                $out->enableOOUI();
 
+               $fields = [];
                $fields[] = new OOUI\ActionFieldLayout(
                        new OOUI\TextInputWidget( [
                                'name' => 'prefix',
@@ -768,6 +769,7 @@ class SpecialUndelete extends SpecialPage {
                }
 
                if ( $this->mAllowed && ( $haveRevisions || $haveFiles ) ) {
+                       $fields = [];
                        $fields[] = new OOUI\Layout( [
                                'content' => new OOUI\HtmlSnippet( $this->msg( 'undeleteextrahelp' )->parseAsBlock() )
                        ] );
index 87534eb..a45ccca 100644 (file)
@@ -464,7 +464,7 @@ class UserrightsPage extends SpecialPage {
                ] );
                $logid = $logEntry->insert();
                if ( count( $tags ) ) {
-                       $logEntry->setTags( $tags );
+                       $logEntry->addTags( $tags );
                }
                $logEntry->publish( $logid );
        }
index 18c10bf..2840086 100644 (file)
@@ -117,6 +117,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                $fetchlinks = ( !$hidelinks || !$hideredirs );
 
                // Build query conds in concert for all three tables...
+               $conds = [];
                $conds['pagelinks'] = [
                        'pl_namespace' => $target->getNamespace(),
                        'pl_title' => $target->getDBkey(),
@@ -229,6 +230,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                // Read the rows into an array and remove duplicates
                // templatelinks comes second so that the templatelinks row overwrites the
                // pagelinks row, so we get (inclusion) rather than nothing
+               $rows = [];
                if ( $fetchlinks ) {
                        foreach ( $plRes as $row ) {
                                $row->is_template = 0;
index be28417..1e5f816 100644 (file)
@@ -40,6 +40,7 @@ class UploadForm extends HTMLForm {
 
        protected $mMaxFileSize = [];
 
+       /** @var array */
        protected $mMaxUploadSize = [];
 
        public function __construct( array $options = [], IContextSource $context = null,
index 0ae708a..938b159 100644 (file)
@@ -163,7 +163,7 @@ class ImportReporter extends ContextSource {
                        // Make sure the null revision will be tagged as well
                        $logEntry->setAssociatedRevId( $nullRevId );
                        if ( count( $this->logTags ) ) {
-                               $logEntry->setTags( $this->logTags );
+                               $logEntry->addTags( $this->logTags );
                        }
                        $logid = $logEntry->insert();
                        $logEntry->publish( $logid );
index d61a1be..6faf22b 100644 (file)
@@ -74,7 +74,7 @@ class BlockListPager extends TablePager {
         * @param string $name
         * @param string $value
         * @return string
-        * @suppress PhanTypeArraySuspiciousNullable
+        * @suppress PhanTypeArraySuspiciousNullable,PhanTypeArraySuspicious
         */
        function formatValue( $name, $value ) {
                static $msg = null;
@@ -138,6 +138,7 @@ class BlockListPager extends TablePager {
                                        /* User preference timezone */true
                                ) );
                                if ( $this->getUser()->isAllowed( 'block' ) ) {
+                                       $links = [];
                                        if ( $row->ipb_auto ) {
                                                $links[] = $linkRenderer->makeKnownLink(
                                                        SpecialPage::getTitleFor( 'Unblock' ),
index 392e46d..7737067 100644 (file)
@@ -20,6 +20,7 @@ class ComplexTitleInputWidget extends \OOUI\Widget {
         *   - array $config['namespace'] Configuration for the NamespaceInputWidget dropdown
         *     with list of namespaces
         *   - array $config['title'] Configuration for the TitleInputWidget text field
+        * @phan-param array{namespace?:array,title?:array} $config
         */
        public function __construct( array $config = [] ) {
                // Configuration initialization
index c4f175f..f794abb 100644 (file)
@@ -595,6 +595,8 @@ SPARQL;
                         * TODO: For now, we do full update even though some data hasn't changed,
                         * e.g. parents for parent cat and counts for child cat.
                         */
+                       $childPages = [];
+                       $parentCats = [];
                        foreach ( $batch as $row ) {
                                $childPages[$row->rc_cur_id] = true;
                                $parentCats[$row->rc_title] = true;
@@ -614,7 +616,7 @@ SPARQL;
                        $pages = [];
                        $deleteUrls = [];
 
-                       if ( !empty( $childPages ) ) {
+                       if ( $childPages ) {
                                // Load child rows by ID
                                $childRows = $dbr->select(
                                        [ 'page', 'page_props', 'category' ],
@@ -642,7 +644,7 @@ SPARQL;
                                }
                        }
 
-                       if ( !empty( $parentCats ) ) {
+                       if ( $parentCats ) {
                                // Load parent rows by title
                                $joinConditions = [
                                        'page' => [
index b0ac638..737e65f 100644 (file)
@@ -276,6 +276,11 @@ class ConvertExtensionToRegistration extends Maintenance {
                $this->json[$realName] = $value;
        }
 
+       /**
+        * @param string $realName
+        * @param array[] $value
+        * @suppress PhanTypeInvalidDimOffset
+        */
        protected function handleResourceModules( $realName, $value ) {
                $defaults = [];
                $remote = $this->hasOption( 'skin' ) ? 'remoteSkinPath' : 'remoteExtPath';
index bcf84aa..00d7c90 100644 (file)
@@ -97,6 +97,7 @@ class TextPassDumper extends BackupDumper {
        protected $firstPageWritten = false;
        protected $lastPageWritten = false;
        protected $checkpointJustWritten = false;
+       /** @var string[] */
        protected $checkpointFiles = [];
 
        /**
@@ -303,6 +304,7 @@ TEXT
                        $param = $split[1];
                }
                $fileURIs = explode( ';', $param );
+               $newFileURIs = [];
                foreach ( $fileURIs as $URI ) {
                        switch ( $val ) {
                                case "file":
index c85e194..84b962a 100644 (file)
@@ -122,7 +122,7 @@ class PopulateArchiveRevId extends LoggedUpdateMaintenance {
                                $dbw->doAtomicSection( __METHOD__, function ( IDatabase $dbw, $fname ) {
                                        $dbw->insert( 'revision', self::$dummyRev, $fname );
                                        $id = $dbw->insertId();
-                                       $toDelete[] = $id;
+                                       $toDelete = [ $id ];
 
                                        $maxId = max(
                                                (int)$dbw->selectField( 'archive', 'MAX(ar_rev_id)', [], $fname ),
index 612c092..e7988fe 100644 (file)
@@ -175,9 +175,9 @@ class MwSql extends Maintenance {
                        return $this->sqlPrintResult( $res, $db );
                } catch ( DBQueryError $e ) {
                        if ( $dieOnError ) {
-                               $this->fatalError( $e );
+                               $this->fatalError( (string)$e );
                        } else {
-                               $this->error( $e );
+                               $this->error( (string)$e );
                        }
                }
                return null;
index beb1975..b6aa626 100644 (file)
@@ -223,6 +223,7 @@ class CompressOld extends Maintenance {
         * @param string $extdb
         * @param bool|int $maxPageId
         * @return bool
+        * @suppress PhanTypeInvalidDimOffset
         */
        private function compressWithConcat( $startId, $maxChunkSize, $beginDate,
                $endDate, $extdb = "", $maxPageId = false
index ebace75..19fc54a 100644 (file)
@@ -104,9 +104,8 @@ TEXT
                        'STRAIGHT_JOIN' // per T58041
                ];
 
-               if ( $force ) {
-                       $collationConds = [];
-               } else {
+               $collationConds = [];
+               if ( !$force ) {
                        if ( $this->hasOption( 'previous-collation' ) ) {
                                $collationConds['cl_collation'] = $this->getOption( 'previous-collation' );
                        } else {
index a27c8a5..c9fb780 100644 (file)
@@ -18,7 +18,7 @@ class UpdateExtensionJsonSchema extends Maintenance {
                }
 
                $json = FormatJson::decode( file_get_contents( $filename ), true );
-               if ( $json === null ) {
+               if ( !is_array( $json ) ) {
                        $this->fatalError( "Error: Invalid JSON" );
                }
 
index f227ae1..9e79496 100644 (file)
@@ -74,16 +74,19 @@ wfRequireOnceInGlobalScope( "$IP/includes/Defines.php" );
 wfRequireOnceInGlobalScope( "$IP/includes/DefaultSettings.php" );
 wfRequireOnceInGlobalScope( "$IP/includes/GlobalFunctions.php" );
 
-// Load extensions/skins present in filesystem so that classes can be discovered.
+// Populate classes and namespaces from extensions and skins present in filesystem.
 $directoryToJsonMap = [
-       'extensions' => [ 'extension.json', 'extension-wip.json' ],
-       'skins' => [ 'skin.json', 'skin-wip.json' ]
+       $GLOBALS['wgExtensionDirectory'] => [ 'extension.json', 'extension-wip.json' ],
+       $GLOBALS['wgStyleDirectory'] => [ 'skin.json', 'skin-wip.json' ]
 ];
 foreach ( $directoryToJsonMap as $directory => $jsonFile ) {
-       foreach ( new DirectoryIterator( __DIR__ . '/../../' . $directory ) as $iterator ) {
+       foreach ( new DirectoryIterator( $directory ) as $iterator ) {
                foreach ( $jsonFile as $file ) {
+
                        $jsonPath = $iterator->getPathname() . '/' . $file;
                        if ( file_exists( $jsonPath ) ) {
+                               // ExtensionRegistry->readFromQueue is not used as it checks extension/skin
+                               // dependencies, which we don't need or want for unit tests.
                                $json = file_get_contents( $jsonPath );
                                $info = json_decode( $json, true );
                                $dir = dirname( $jsonPath );