];
$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
* 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
}
$includeStderr = isset( $options['duplicateStderr'] ) && $options['duplicateStderr'];
+ // @phan-suppress-next-line PhanTypeInvalidDimOffset
$profileMethod = $options['profileMethod'] ?? wfGetCaller();
try {
* @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 = [] ) {
// 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'];
* @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
*/
* @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.
* 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.
*/
throw new InvalidArgumentException( 'Mismatching wiki ID ' . $rev->getWikiId() );
}
+ // @phan-suppress-next-line PhanTypeInvalidDimOffset
$audience = $hints['audience']
?? ( $forUser ? RevisionRecord::FOR_THIS_USER : RevisionRecord::FOR_PUBLIC );
$options = ParserOptions::newCanonical( $forUser ?: 'canonical' );
}
+ // @phan-suppress-next-line PhanTypeInvalidDimOffset
$useMaster = $hints['use-master'] ?? false;
$dbIndex = $useMaster
* - 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 = [
private $mModule;
private $mCacheMode = 'private';
+ /** @var array */
private $mCacheControl = [];
private $mParamsUsed = [];
private $mParamsSensitive = [];
// 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 );
}
*/
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;
/**
/**
* @param ApiPageSet $resultPageSet
* @return void
+ * @suppress PhanTypeInvalidDimOffset
*/
private function run( $resultPageSet = null ) {
$this->params = $this->extractRequestParams( false );
return $this->tokenFunctions;
}
+ /** @var string[] */
protected static $cachedTokens = [];
/**
const WL_UNREAD_LIMIT = 1000;
+ /** @var array */
private $params = [];
+ /** @var array */
private $prop = [];
public function __construct( ApiQuery $query, $moduleName ) {
* @param AuthenticationRequest[] $reqs
* @return array
* @throws \UnexpectedValueException If fields cannot be merged
+ * @suppress PhanTypeInvalidDimOffset
*/
public static function mergeFieldInfo( array $reqs ) {
$merged = [];
*/
const SEND_FEED = false;
+ /** @var array */
public $mAttribs = [];
public $mExtra = [];
class DiffEngine {
// Input variables
+ /** @var string[] */
private $from;
+ /** @var string[] */
private $to;
private $m;
private $n;
*/
$max = min( $this->m, $this->n );
for ( $forwardBound = 0; $forwardBound < $max
+ // @phan-suppress-next-line PhanTypeInvalidDimOffset
&& $this->from[$forwardBound] === $this->to[$forwardBound];
++$forwardBound
) {
* 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 = [] ) {
/**
* 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();
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 ) {
$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 = '';
* - 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 ) {
protected $sslVerifyCert = true;
protected $caInfo = null;
protected $method = "GET";
+ /** @var array */
protected $reqHeaders = [];
protected $url;
protected $parsedUrl;
protected $headerList = [];
protected $respVersion = "0.9";
protected $respStatus = "200 Ok";
+ /** @var string[][] */
protected $respHeaders = [];
/** @var StatusValue */
/**
* @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
$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 ) ) {
// 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];
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." );
* 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 = [] ) {
}
parent::__construct( $baseIterator );
$this->vCallback = $vCallback;
+ // @phan-suppress-next-line PhanTypeInvalidDimOffset
$this->aCallback = $options['accept'] ?? null;
}
* - 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 = [] ) {
* 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
*/
* - 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();
$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;
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 {
* - 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() );
/**
* @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;
* 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 );
* - 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();
* 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;
$this->setInterimValue( $key, $value, $lockTSE, $version, $walltime );
} else {
$finalSetOpts = [
+ // @phan-suppress-next-line PhanTypeInvalidDimOffset
'since' => $setOpts['since'] ?? $preCallbackTime,
'version' => $version,
'staleTTL' => $staleTTL,
return $params;
}
+ /**
+ * @inheritDoc
+ * @suppress PhanTypeInvalidDimOffset
+ */
public function formatParametersForApi() {
$ret = parent::formatParametersForApi();
if ( isset( $ret['flags'] ) ) {
* @param bool $isMain
* @return mixed|string
* @private
+ * @suppress PhanTypeInvalidDimOffset
*/
public function formatHeadings( $text, $origText, $isMain = true ) {
# Inhibit editsection links if requested in the page
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() );
$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, [] ];
}
"$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;
* @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 {
// 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'];
* @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.
if ( isset( $item['itemtitle'] ) ) {
$attrs['title'] = $item['itemtitle'];
}
+ // @phan-suppress-next-line PhanTypeInvalidDimOffset
return Html::rawElement( $options['tag'] ?? 'li', $attrs, $html );
}
protected $mMaxFileSize = [];
+ /** @var array */
protected $mMaxUploadSize = [];
public function __construct( array $options = [], IContextSource $context = null,
* - 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
$this->json[$realName] = $value;
}
+ /**
+ * @param string $realName
+ * @param array[] $value
+ * @suppress PhanTypeInvalidDimOffset
+ */
protected function handleResourceModules( $realName, $value ) {
$defaults = [];
$remote = $this->hasOption( 'skin' ) ? 'remoteSkinPath' : 'remoteExtPath';
protected $firstPageWritten = false;
protected $lastPageWritten = false;
protected $checkpointJustWritten = false;
+ /** @var string[] */
protected $checkpointFiles = [];
/**
* @param string $extdb
* @param bool|int $maxPageId
* @return bool
+ * @suppress PhanTypeInvalidDimOffset
*/
private function compressWithConcat( $startId, $maxChunkSize, $beginDate,
$endDate, $extdb = "", $maxPageId = false