From e2e543f7c2a98f40c9b43ba3989d0f6689f4cb67 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Fri, 30 Aug 2019 19:56:27 +0200 Subject: [PATCH] Unsuppress more phan issues (part 5) Bug: T231636 Depends-On: I6e5fba7bd273219b1206559420b5bdb78734aa84 Change-Id: I50377746f01749b058c39fd8229f9d566224cc43 --- .phan/config.php | 18 ++++++++++++++---- includes/EditPage.php | 2 +- includes/FileDeleteForm.php | 1 + includes/LinkFilter.php | 1 + includes/Linker.php | 6 +++--- includes/Setup.php | 1 + includes/Title.php | 2 +- includes/api/ApiAuthManagerHelper.php | 3 +++ includes/api/ApiBlock.php | 1 + includes/api/ApiEditPage.php | 1 + includes/api/ApiPageSet.php | 1 + includes/api/ApiQueryBacklinks.php | 2 +- includes/api/ApiQueryDeletedrevs.php | 2 +- includes/api/ApiUnblock.php | 10 ++++++---- includes/api/ApiUndelete.php | 10 ++++++---- includes/api/ApiUpload.php | 1 + includes/api/ApiUserrights.php | 1 + includes/api/ApiValidatePassword.php | 1 + includes/api/SearchApi.php | 2 ++ includes/auth/AuthenticationRequest.php | 2 +- includes/auth/Throttler.php | 4 ++-- includes/changes/EnhancedChangesList.php | 4 ++-- includes/content/ContentHandler.php | 1 + includes/content/FileContentHandler.php | 1 + includes/filerepo/file/LocalFile.php | 1 + includes/htmlform/HTMLForm.php | 7 +++++++ includes/installer/Installer.php | 2 +- includes/jobqueue/JobQueueGroup.php | 3 ++- includes/libs/XhprofData.php | 8 ++++---- .../libs/objectcache/MultiWriteBagOStuff.php | 1 + .../objectcache/wancache/WANObjectCache.php | 2 ++ includes/media/IPTC.php | 1 + includes/page/Article.php | 1 + .../preferences/DefaultPreferencesFactory.php | 1 + includes/search/SearchEngine.php | 1 + .../specialpage/AuthManagerSpecialPage.php | 4 ++-- includes/specials/SpecialContributions.php | 1 + includes/specials/SpecialEditWatchlist.php | 1 + includes/specials/SpecialMovepage.php | 2 -- includes/specials/SpecialUndelete.php | 2 ++ includes/specials/SpecialWhatLinksHere.php | 2 ++ includes/specials/pagers/BlockListPager.php | 3 ++- maintenance/categoryChangesAsRdf.php | 6 ++++-- maintenance/includes/TextPassDumper.php | 1 + maintenance/populateArchiveRevId.php | 2 +- maintenance/updateCollation.php | 5 ++--- maintenance/updateExtensionJsonSchema.php | 2 +- 47 files changed, 95 insertions(+), 42 deletions(-) diff --git a/.phan/config.php b/.phan/config.php index 29729ae1c7..6405cec1cf 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -82,8 +82,6 @@ $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ "PhanParamReqAfterOpt", // approximate error count: 110 "PhanParamTooMany", - // approximate error count: 63 - "PhanTypeArraySuspicious", // approximate error count: 88 "PhanTypeInvalidDimOffset", // approximate error count: 60 @@ -94,8 +92,6 @@ $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ "PhanUndeclaredMethod", // approximate error count: 752 "PhanUndeclaredProperty", - // approximate error count: 53 - "PhanUndeclaredVariableDim", ] ); $cfg['ignore_undeclared_variables_in_global_scope'] = true; @@ -103,6 +99,20 @@ $cfg['globals_type_map'] = array_merge( $cfg['globals_type_map'], [ 'IP' => 'string', 'wgGalleryOptions' => 'array', 'wgDummyLanguageCodes' => 'string[]', + 'wgNamespaceProtection' => 'array', + 'wgNamespaceAliases' => 'array', + 'wgLockManagers' => 'array[]', + 'wgForeignFileRepos' => 'array[]', + 'wgDefaultUserOptions' => 'array', + 'wgSkipSkins' => 'string[]', + 'wgLogTypes' => 'string[]', + 'wgLogNames' => 'array', + 'wgLogHeaders' => 'array', + 'wgLogActionsHandlers' => 'array', + 'wgPasswordPolicy' => 'array>', + 'wgVirtualRestConfig' => 'array', + 'wgWANObjectCaches' => 'array[]', + 'wgLocalInterwikis' => 'string[]', ] ); return $cfg; diff --git a/includes/EditPage.php b/includes/EditPage.php index f066a611a1..541541abbd 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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 = []; diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 8272ccf767..56cfd5907a 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -261,6 +261,7 @@ class FileDeleteForm { ); $options = Xml::listDropDownOptionsOoui( $options ); + $fields = []; $fields[] = new OOUI\LabelWidget( [ 'label' => new OOUI\HtmlSnippet( $this->prepareMessage( 'filedelete-intro' ) ) ] ); diff --git a/includes/LinkFilter.php b/includes/LinkFilter.php index 7e1b44d21a..c46df94d3c 100644 --- a/includes/LinkFilter.php +++ b/includes/LinkFilter.php @@ -338,6 +338,7 @@ class LinkFilter { } } + $like = []; $like[] = $bits['scheme'] . $bits['delimiter'] . $bits['host']; if ( $subdomains ) { diff --git a/includes/Linker.php b/includes/Linker.php index 03d2516667..e748b3a045 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -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 diff --git a/includes/Setup.php b/includes/Setup.php index c1c6ef2ae6..1e65f52a95 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -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 ); } diff --git a/includes/Title.php b/includes/Title.php index 1acc7afacc..f621e6611c 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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 ) { diff --git a/includes/api/ApiAuthManagerHelper.php b/includes/api/ApiAuthManagerHelper.php index 7a548cc2f9..9a3f75eb4d 100644 --- a/includes/api/ApiAuthManagerHelper.php +++ b/includes/api/ApiAuthManagerHelper.php @@ -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 ) { diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index 2c1564e085..755f319f98 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -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; diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index e631e3f638..fdf9cf1bf9 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -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: diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index c604322ed2..6afb018e2f 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -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; diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index f82a559f1e..0cda960cc5 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -306,7 +306,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; diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index 1af4d95971..eb787d1cd3 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -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 ); diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php index 0718ac82c3..15c2564488 100644 --- a/includes/api/ApiUnblock.php +++ b/includes/api/ApiUnblock.php @@ -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 ); } diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php index ba9be81bea..9ef17e64df 100644 --- a/includes/api/ApiUndelete.php +++ b/includes/api/ApiUndelete.php @@ -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 ); } diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index b15b9989a0..3a54772f7c 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -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'] ); diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php index 89ec6cbdbc..3aaae70483 100644 --- a/includes/api/ApiUserrights.php +++ b/includes/api/ApiUserrights.php @@ -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( diff --git a/includes/api/ApiValidatePassword.php b/includes/api/ApiValidatePassword.php index 943149da0f..c36759ac9d 100644 --- a/includes/api/ApiValidatePassword.php +++ b/includes/api/ApiValidatePassword.php @@ -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( diff --git a/includes/api/SearchApi.php b/includes/api/SearchApi.php index 02abb1e1c4..6f46c565cd 100644 --- a/includes/api/SearchApi.php +++ b/includes/api/SearchApi.php @@ -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']; } diff --git a/includes/auth/AuthenticationRequest.php b/includes/auth/AuthenticationRequest.php index f59760a39c..74ce60a9a8 100644 --- a/includes/auth/AuthenticationRequest.php +++ b/includes/auth/AuthenticationRequest.php @@ -122,6 +122,7 @@ abstract class AuthenticationRequest { * a 'password' field). * * @return array As above + * @phan-return array */ abstract public function getFieldInfo(); @@ -337,7 +338,6 @@ abstract class AuthenticationRequest { } $options['sensitive'] = !empty( $options['sensitive'] ); - // @phan-suppress-next-line PhanTypeArraySuspiciousNullable $type = $options['type']; if ( !array_key_exists( $name, $merged ) ) { diff --git a/includes/auth/Throttler.php b/includes/auth/Throttler.php index 9d0175ada9..7128fe2d7e 100644 --- a/includes/auth/Throttler.php +++ b/includes/auth/Throttler.php @@ -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 ) { diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 62cf39ee45..e461762c5e 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -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']; diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index 100fa834dc..f1df087354 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -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 diff --git a/includes/content/FileContentHandler.php b/includes/content/FileContentHandler.php index 6a1cc62595..f3f9a97f52 100644 --- a/includes/content/FileContentHandler.php +++ b/includes/content/FileContentHandler.php @@ -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 ); diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index f3116e2d2a..2890360521 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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 ) { diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index f4dad390cf..04be6c4e60 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -242,6 +242,10 @@ class HTMLForm extends ContextSource { protected $mUseMultipart = false; protected $mHiddenFields = []; + /** + * @var array[] + * @phan-var array + */ 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 ) { diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index a3951a1fae..c719c762e3 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -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 ) { diff --git a/includes/jobqueue/JobQueueGroup.php b/includes/jobqueue/JobQueueGroup.php index 06cd04ce6d..7bc97d82fe 100644 --- a/includes/jobqueue/JobQueueGroup.php +++ b/includes/jobqueue/JobQueueGroup.php @@ -397,7 +397,8 @@ class JobQueueGroup { } /** - * @return JobQueue[] + * @return array[] + * @phan-return array}> */ protected function getCoalescedQueues() { global $wgJobTypeConf; diff --git a/includes/libs/XhprofData.php b/includes/libs/XhprofData.php index 90e52f08dd..56e6b199cd 100644 --- a/includes/libs/XhprofData.php +++ b/includes/libs/XhprofData.php @@ -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() */ diff --git a/includes/libs/objectcache/MultiWriteBagOStuff.php b/includes/libs/objectcache/MultiWriteBagOStuff.php index d0aa380bf6..51f7316424 100644 --- a/includes/libs/objectcache/MultiWriteBagOStuff.php +++ b/includes/libs/objectcache/MultiWriteBagOStuff.php @@ -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,replication:string} $params * @throws InvalidArgumentException */ public function __construct( $params ) { diff --git a/includes/libs/objectcache/wancache/WANObjectCache.php b/includes/libs/objectcache/wancache/WANObjectCache.php index b88b49697a..3321254e94 100644 --- a/includes/libs/objectcache/wancache/WANObjectCache.php +++ b/includes/libs/objectcache/wancache/WANObjectCache.php @@ -1305,6 +1305,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'] ?? []; @@ -2421,6 +2422,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; diff --git a/includes/media/IPTC.php b/includes/media/IPTC.php index 683ded107a..c32db28a79 100644 --- a/includes/media/IPTC.php +++ b/includes/media/IPTC.php @@ -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 ); diff --git a/includes/page/Article.php b/includes/page/Article.php index d8cd1c5bc8..3628c7b69d 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -1935,6 +1935,7 @@ class Article implements Page { ); $options = Xml::listDropDownOptionsOoui( $options ); + $fields = []; $fields[] = new OOUI\FieldLayout( new OOUI\DropdownInputWidget( [ 'name' => 'wpDeleteReasonList', diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php index 70e38ee74a..8c44a5e609 100644 --- a/includes/preferences/DefaultPreferencesFactory.php +++ b/includes/preferences/DefaultPreferencesFactory.php @@ -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'; diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 87a7861b3a..66e59e561b 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -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; diff --git a/includes/specialpage/AuthManagerSpecialPage.php b/includes/specialpage/AuthManagerSpecialPage.php index e1f0588de5..993415015c 100644 --- a/includes/specialpage/AuthManagerSpecialPage.php +++ b/includes/specialpage/AuthManagerSpecialPage.php @@ -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; diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 9d5f430b3c..1753831a6c 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -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( diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 480e81ae3e..717edc3b05 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -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() diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 0cb3bbae8b..941d1083e9 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -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( "
\n" ); $out->addWikiMsg( $noticeMsg ); diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 9a16a72926..32be932d9b 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -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() ) ] ); diff --git a/includes/specials/SpecialWhatLinksHere.php b/includes/specials/SpecialWhatLinksHere.php index 18c10bf706..2840086526 100644 --- a/includes/specials/SpecialWhatLinksHere.php +++ b/includes/specials/SpecialWhatLinksHere.php @@ -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; diff --git a/includes/specials/pagers/BlockListPager.php b/includes/specials/pagers/BlockListPager.php index d61a1beed9..6faf22bbea 100644 --- a/includes/specials/pagers/BlockListPager.php +++ b/includes/specials/pagers/BlockListPager.php @@ -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' ), diff --git a/maintenance/categoryChangesAsRdf.php b/maintenance/categoryChangesAsRdf.php index c4f175f3b9..f794abb0b0 100644 --- a/maintenance/categoryChangesAsRdf.php +++ b/maintenance/categoryChangesAsRdf.php @@ -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' => [ diff --git a/maintenance/includes/TextPassDumper.php b/maintenance/includes/TextPassDumper.php index bcf84aaf60..d473486bdb 100644 --- a/maintenance/includes/TextPassDumper.php +++ b/maintenance/includes/TextPassDumper.php @@ -303,6 +303,7 @@ TEXT $param = $split[1]; } $fileURIs = explode( ';', $param ); + $newFileURIs = []; foreach ( $fileURIs as $URI ) { switch ( $val ) { case "file": diff --git a/maintenance/populateArchiveRevId.php b/maintenance/populateArchiveRevId.php index c85e194eef..84b962af37 100644 --- a/maintenance/populateArchiveRevId.php +++ b/maintenance/populateArchiveRevId.php @@ -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 ), diff --git a/maintenance/updateCollation.php b/maintenance/updateCollation.php index ebace75eab..19fc54a4d7 100644 --- a/maintenance/updateCollation.php +++ b/maintenance/updateCollation.php @@ -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 { diff --git a/maintenance/updateExtensionJsonSchema.php b/maintenance/updateExtensionJsonSchema.php index a27c8a517f..c9fb78054c 100644 --- a/maintenance/updateExtensionJsonSchema.php +++ b/maintenance/updateExtensionJsonSchema.php @@ -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" ); } -- 2.20.1