From 327e8ea41681487382d8abe7cb111501954b9d1b Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Fri, 30 Aug 2019 20:17:32 +0200 Subject: [PATCH] Unsuppress phan issues part 6 Bug: T231636 Depends-On: I50377746f01749b058c39fd8229f9d566224cc43 Change-Id: I2cd24e73726394e3200a570c45d5e86b6849bfa9 --- .phan/config.php | 15 +++++++-------- includes/GlobalFunctions.php | 4 ++++ includes/Revision/RenderedRevision.php | 2 ++ includes/Revision/RevisionRenderer.php | 3 +++ includes/Revision/RevisionStore.php | 1 + includes/api/ApiMain.php | 1 + includes/api/ApiOpenSearch.php | 1 + includes/api/ApiQueryBacklinks.php | 6 +++++- includes/api/ApiQueryInfo.php | 1 + includes/api/ApiQueryUserInfo.php | 2 ++ includes/auth/AuthenticationRequest.php | 1 + includes/changes/RecentChange.php | 1 + includes/diff/DiffEngine.php | 3 +++ includes/filerepo/RepoGroup.php | 2 ++ includes/filerepo/file/LocalFile.php | 2 ++ includes/historyblob/DiffHistoryBlob.php | 11 +++++------ includes/http/HttpRequestFactory.php | 4 ++++ includes/http/MWHttpRequest.php | 7 +++++++ includes/import/WikiImporter.php | 3 +++ includes/libs/MappedIterator.php | 4 +++- includes/libs/filebackend/FileBackend.php | 6 ++++++ includes/libs/http/MultiHttpClient.php | 6 ++++++ includes/libs/objectcache/BagOStuff.php | 1 + includes/libs/objectcache/HashBagOStuff.php | 4 ++++ .../libs/objectcache/MediumSpecificBagOStuff.php | 3 +++ .../libs/objectcache/wancache/WANObjectCache.php | 9 +++++++++ includes/logging/BlockLogFormatter.php | 4 ++++ includes/parser/Parser.php | 2 ++ .../resourceloader/ResourceLoaderClientHtml.php | 1 + includes/session/SessionManager.php | 1 + includes/shell/Shell.php | 2 ++ includes/skins/BaseTemplate.php | 3 +++ includes/specials/forms/UploadForm.php | 1 + includes/widget/ComplexTitleInputWidget.php | 1 + maintenance/convertExtensionToRegistration.php | 5 +++++ maintenance/includes/TextPassDumper.php | 1 + maintenance/storage/compressOld.php | 1 + 37 files changed, 109 insertions(+), 16 deletions(-) diff --git a/.phan/config.php b/.phan/config.php index 6405cec1cf..e02dba7e15 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -76,18 +76,17 @@ $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: 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 diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 4ae9237116..2cde173236 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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']; diff --git a/includes/Revision/RenderedRevision.php b/includes/Revision/RenderedRevision.php index 3bc8dda578..ba229d1e8a 100644 --- a/includes/Revision/RenderedRevision.php +++ b/includes/Revision/RenderedRevision.php @@ -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. diff --git a/includes/Revision/RevisionRenderer.php b/includes/Revision/RevisionRenderer.php index 3c3b6a99e6..ea9025535a 100644 --- a/includes/Revision/RevisionRenderer.php +++ b/includes/Revision/RevisionRenderer.php @@ -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 diff --git a/includes/Revision/RevisionStore.php b/includes/Revision/RevisionStore.php index 9e8dfe7e40..818a53619d 100644 --- a/includes/Revision/RevisionStore.php +++ b/includes/Revision/RevisionStore.php @@ -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 = [ diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 641aa9f51e..574d83bd18 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -153,6 +153,7 @@ class ApiMain extends ApiBase { private $mModule; private $mCacheMode = 'private'; + /** @var array */ private $mCacheControl = []; private $mParamsUsed = []; private $mParamsSensitive = []; diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index 6a575ec3e0..0ba4a0e4a5 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -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 ); } diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 0cda960cc5..6c1eb0f489 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -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; /** @@ -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 ); diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index ac7e5cc8c7..98474c763b 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -118,6 +118,7 @@ class ApiQueryInfo extends ApiQueryBase { return $this->tokenFunctions; } + /** @var string[] */ protected static $cachedTokens = []; /** diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index ab8d93a4f9..12d7435453 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -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 ) { diff --git a/includes/auth/AuthenticationRequest.php b/includes/auth/AuthenticationRequest.php index 74ce60a9a8..1a2442c9ad 100644 --- a/includes/auth/AuthenticationRequest.php +++ b/includes/auth/AuthenticationRequest.php @@ -298,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 = []; diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index edaa963ffe..1d590d9c36 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -90,6 +90,7 @@ class RecentChange implements Taggable { */ const SEND_FEED = false; + /** @var array */ public $mAttribs = []; public $mExtra = []; diff --git a/includes/diff/DiffEngine.php b/includes/diff/DiffEngine.php index ce507d7a83..6ebec1cd18 100644 --- a/includes/diff/DiffEngine.php +++ b/includes/diff/DiffEngine.php @@ -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 ) { diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php index e474ad3084..96df29ff51 100644 --- a/includes/filerepo/RepoGroup.php +++ b/includes/filerepo/RepoGroup.php @@ -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 = [] ) { diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 2890360521..cd789d993b 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1080,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(); @@ -1091,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 ) { diff --git a/includes/historyblob/DiffHistoryBlob.php b/includes/historyblob/DiffHistoryBlob.php index fdb3dc4daa..5173916b9b 100644 --- a/includes/historyblob/DiffHistoryBlob.php +++ b/includes/historyblob/DiffHistoryBlob.php @@ -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 = ''; diff --git a/includes/http/HttpRequestFactory.php b/includes/http/HttpRequestFactory.php index 8e5567b001..8433df6e08 100644 --- a/includes/http/HttpRequestFactory.php +++ b/includes/http/HttpRequestFactory.php @@ -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 ) { diff --git a/includes/http/MWHttpRequest.php b/includes/http/MWHttpRequest.php index 41ea1dce35..3a2f982a04 100644 --- a/includes/http/MWHttpRequest.php +++ b/includes/http/MWHttpRequest.php @@ -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]; diff --git a/includes/import/WikiImporter.php b/includes/import/WikiImporter.php index 68f5b9b8bf..0d1cc6804a 100644 --- a/includes/import/WikiImporter.php +++ b/includes/import/WikiImporter.php @@ -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." ); diff --git a/includes/libs/MappedIterator.php b/includes/libs/MappedIterator.php index 4a62e72909..9d53a861f6 100644 --- a/includes/libs/MappedIterator.php +++ b/includes/libs/MappedIterator.php @@ -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; } diff --git a/includes/libs/filebackend/FileBackend.php b/includes/libs/filebackend/FileBackend.php index 905e925c40..428fec6062 100644 --- a/includes/libs/filebackend/FileBackend.php +++ b/includes/libs/filebackend/FileBackend.php @@ -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 */ diff --git a/includes/libs/http/MultiHttpClient.php b/includes/libs/http/MultiHttpClient.php index 5e233aeb12..6b1ef89f46 100644 --- a/includes/libs/http/MultiHttpClient.php +++ b/includes/libs/http/MultiHttpClient.php @@ -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 { diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index 42da5f070e..ad3f681153 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -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() ); diff --git a/includes/libs/objectcache/HashBagOStuff.php b/includes/libs/objectcache/HashBagOStuff.php index 6d0940b557..0f7011d60c 100644 --- a/includes/libs/objectcache/HashBagOStuff.php +++ b/includes/libs/objectcache/HashBagOStuff.php @@ -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; diff --git a/includes/libs/objectcache/MediumSpecificBagOStuff.php b/includes/libs/objectcache/MediumSpecificBagOStuff.php index 9d361876ce..252c08975e 100644 --- a/includes/libs/objectcache/MediumSpecificBagOStuff.php +++ b/includes/libs/objectcache/MediumSpecificBagOStuff.php @@ -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 ); diff --git a/includes/libs/objectcache/wancache/WANObjectCache.php b/includes/libs/objectcache/wancache/WANObjectCache.php index 3321254e94..2ce216d08a 100644 --- a/includes/libs/objectcache/wancache/WANObjectCache.php +++ b/includes/libs/objectcache/wancache/WANObjectCache.php @@ -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; @@ -1442,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, diff --git a/includes/logging/BlockLogFormatter.php b/includes/logging/BlockLogFormatter.php index ead290f062..d27643ce0d 100644 --- a/includes/logging/BlockLogFormatter.php +++ b/includes/logging/BlockLogFormatter.php @@ -262,6 +262,10 @@ class BlockLogFormatter extends LogFormatter { return $params; } + /** + * @inheritDoc + * @suppress PhanTypeInvalidDimOffset + */ public function formatParametersForApi() { $ret = parent::formatParametersForApi(); if ( isset( $ret['flags'] ) ) { diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 267402fce7..962313e43e 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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() ); diff --git a/includes/resourceloader/ResourceLoaderClientHtml.php b/includes/resourceloader/ResourceLoaderClientHtml.php index e17b393a57..e5a0d6114f 100644 --- a/includes/resourceloader/ResourceLoaderClientHtml.php +++ b/includes/resourceloader/ResourceLoaderClientHtml.php @@ -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, [] ]; } diff --git a/includes/session/SessionManager.php b/includes/session/SessionManager.php index 85f4569e81..fc117a8c9c 100644 --- a/includes/session/SessionManager.php +++ b/includes/session/SessionManager.php @@ -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; diff --git a/includes/shell/Shell.php b/includes/shell/Shell.php index 19fa1da894..74d77a845b 100644 --- a/includes/shell/Shell.php +++ b/includes/shell/Shell.php @@ -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']; diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php index 09e439b836..bee4affab6 100644 --- a/includes/skins/BaseTemplate.php +++ b/includes/skins/BaseTemplate.php @@ -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 "
  • " 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 ); } diff --git a/includes/specials/forms/UploadForm.php b/includes/specials/forms/UploadForm.php index be2841749b..1e5f8168d6 100644 --- a/includes/specials/forms/UploadForm.php +++ b/includes/specials/forms/UploadForm.php @@ -40,6 +40,7 @@ class UploadForm extends HTMLForm { protected $mMaxFileSize = []; + /** @var array */ protected $mMaxUploadSize = []; public function __construct( array $options = [], IContextSource $context = null, diff --git a/includes/widget/ComplexTitleInputWidget.php b/includes/widget/ComplexTitleInputWidget.php index 392e46dc89..77370674f5 100644 --- a/includes/widget/ComplexTitleInputWidget.php +++ b/includes/widget/ComplexTitleInputWidget.php @@ -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 diff --git a/maintenance/convertExtensionToRegistration.php b/maintenance/convertExtensionToRegistration.php index b0ac638fd9..737e65f343 100644 --- a/maintenance/convertExtensionToRegistration.php +++ b/maintenance/convertExtensionToRegistration.php @@ -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'; diff --git a/maintenance/includes/TextPassDumper.php b/maintenance/includes/TextPassDumper.php index d473486bdb..00d7c90618 100644 --- a/maintenance/includes/TextPassDumper.php +++ b/maintenance/includes/TextPassDumper.php @@ -97,6 +97,7 @@ class TextPassDumper extends BackupDumper { protected $firstPageWritten = false; protected $lastPageWritten = false; protected $checkpointJustWritten = false; + /** @var string[] */ protected $checkpointFiles = []; /** diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php index beb1975fad..b6aa62623a 100644 --- a/maintenance/storage/compressOld.php +++ b/maintenance/storage/compressOld.php @@ -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 -- 2.20.1