$cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [
// approximate error count: 22
"PhanAccessMethodInternal",
- // approximate error count: 22
- "PhanCommentParamWithoutRealParam",
// approximate error count: 19
"PhanParamReqAfterOpt",
- // approximate error count: 20
- "PhanParamSignatureMismatch",
// approximate error count: 110
"PhanParamTooMany",
// approximate error count: 63
"PhanTypeArraySuspicious",
// approximate error count: 28
"PhanTypeArraySuspiciousNullable",
- // approximate error count: 22
- "PhanTypeComparisonFromArray",
// approximate error count: 88
"PhanTypeInvalidDimOffset",
// approximate error count: 60
"PhanTypeMismatchArgument",
- // approximate error count: 20
- "PhanTypeMismatchArgumentInternal",
// approximate error count: 40
"PhanTypeMismatchProperty",
// approximate error count: 36
}
public function stop() {
}
- public function getLog() {
+ public function getLog() : ExcimerLog {
}
public function flush() {
}
}
function formatCollapsed() {
}
+ /**
+ * @return array[]
+ */
function aggregateByFunction() {
}
+ /**
+ * @return int
+ */
function getEventCount() {
}
function current() {
* $wgTiffThumbnailType = [ 'jpg', 'image/jpeg' ];
* @endcode
*/
-$wgTiffThumbnailType = false;
+$wgTiffThumbnailType = [];
/**
* If rendered thumbnail files are older than this timestamp, they
/**
* @return array
+ * @suppress PhanParamSignatureMismatch
*/
public function getValues() {
return $this->data;
$result = unpack( $format, $data );
Wikimedia\restoreWarnings();
+ // @phan-suppress-next-line PhanTypeComparisonFromArray Phan issue #3160
if ( $result === false ) {
// If it cannot extract the packed data.
throw new MWException( "unpack could not unpack binary data" );
* @param string $text Wikitext
* @param Title $title
* @param bool $linestart Is this the start of a line?
- * @param bool $tidy Whether to use tidy.
- * Setting this to false (or omitting it) is deprecated
- * since 1.32; all wikitext should be tidied.
* @param bool $interface Whether it is an interface message
* (for example disables conversion)
* @param string $wrapperClass if not empty, wraps the output in
* a `<div class="$wrapperClass">`
- * @private
*/
private function addWikiTextTitleInternal(
$text, Title $title, $linestart, $interface, $wrapperClass = null
* Check if user is allowed to make any action
*
* @param UserIdentity $user
- * // TODO: HHVM can't create mocks with variable params @param string ...$actions
+ * // TODO: HHVM bug T228695#5450847 @param string ...$actions
+ * @suppress PhanCommentParamWithoutRealParam
* @return bool True if user is allowed to perform *any* of the given actions
* @since 1.34
*/
* Check if user is allowed to make all actions
*
* @param UserIdentity $user
- * // TODO: HHVM can't create mocks with variable params @param string ...$actions
+ * // TODO: HHVM bug T228695#5450847 @param string ...$actions
+ * @suppress PhanCommentParamWithoutRealParam
* @return bool True if user is allowed to perform *all* of the given actions
* @since 1.34
*/
* better served by an HTTP header parsing library which provides the full
* parse tree.
*
- * @param string $name The header name
* @param string|string[] $value The input header value
* @return array
*/
* @ingroup HTTP
*/
class WebRequest {
- protected $data, $headers = [];
+ /** @var array */
+ protected $data;
+ /** @var array */
+ protected $headers = [];
/**
* Flag to make WebRequest::getHeader return an array of values.
/**
* Clean up a field array for output
- * @param ApiBase $module For context and parameters 'mergerequestfields'
- * and 'messageformat'
* @param array $fields
* @return array
*/
* @param int $successCount
* @param array $pageInfo
* @return void
+ * @suppress PhanParamSignatureMismatch
*/
public function reportPage( $title, $foreignTitle, $revisionCount, $successCount, $pageInfo ) {
// Add a result entry
if ( in_array( $key, self::$mergeableMapKeys ) ) {
$value = $value + $fallbackValue;
} elseif ( in_array( $key, self::$mergeableListKeys ) ) {
+ // @phan-suppress-next-line PhanTypeMismatchArgumentInternal
$value = array_unique( array_merge( $fallbackValue, $value ) );
} elseif ( in_array( $key, self::$mergeableAliasListKeys ) ) {
$value = array_merge_recursive( $value, $fallbackValue );
if ( !$code ) {
throw new MWException( "Invalid language code requested" );
}
- $this->recachedLangs[$code] = true;
+ $this->recachedLangs[ $code ] = true;
# Initial values
$initialData = array_fill_keys( self::$allKeys, null );
# Load the primary localisation from the source file
$data = $this->readSourceFilesAndRegisterDeps( $code, $deps );
- if ( $data === false ) {
- $this->logger->debug( __METHOD__ . ": no localisation file for $code, using fallback to en" );
- $coreData['fallback'] = 'en';
- } else {
- $this->logger->debug( __METHOD__ . ": got localisation for $code from source" );
+ $this->logger->debug( __METHOD__ . ": got localisation for $code from source" );
- # Merge primary localisation
- foreach ( $data as $key => $value ) {
- $this->mergeItem( $key, $coreData[$key], $value );
- }
+ # Merge primary localisation
+ foreach ( $data as $key => $value ) {
+ $this->mergeItem( $key, $coreData[ $key ], $value );
}
# Fill in the fallback if it's not there already
# Load the secondary localisation from the source file to
# avoid infinite cycles on cyclic fallbacks
$fbData = $this->readSourceFilesAndRegisterDeps( $csCode, $deps );
- if ( $fbData !== false ) {
- # Only merge the keys that make sense to merge
- foreach ( self::$allKeys as $key ) {
- if ( !isset( $fbData[$key] ) ) {
- continue;
- }
-
- if ( is_null( $coreData[$key] ) || $this->isMergeableKey( $key ) ) {
- $this->mergeItem( $key, $csData[$key], $fbData[$key] );
- }
+ # Only merge the keys that make sense to merge
+ foreach ( self::$allKeys as $key ) {
+ if ( !isset( $fbData[ $key ] ) ) {
+ continue;
+ }
+
+ if ( is_null( $coreData[ $key ] ) || $this->isMergeableKey( $key ) ) {
+ $this->mergeItem( $key, $csData[ $key ], $fbData[ $key ] );
}
}
}
* @param string|string[]|MessageSpecifier $key Message key, or array of keys,
* or a MessageSpecifier.
* @param mixed $args,...
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
* @return Message
*/
public function msg( $key /* $args */ ) {
* @param string|string[]|MessageSpecifier $key Message key, or array of keys,
* or a MessageSpecifier.
* @param mixed $args,... Arguments to wfMessage
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
* @return Message
*/
public function msg( $key ) {
* @param string|string[]|MessageSpecifier $key Message key, or array of keys,
* or a MessageSpecifier.
* @param mixed $args,...
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
* @return Message
*/
public function msg( $key ) {
* @param Diff $diff A Diff object.
*
* @return array[] List of associative arrays, each describing a difference.
+ * @suppress PhanParamSignatureMismatch
*/
public function format( $diff ) {
$oldline = 1;
/**
* @param DumpOutput &$sink
- * @param array $param
+ * @param string $param
* @throws MWException
*/
function __construct( &$sink, $param ) {
"NS_CATEGORY" => NS_CATEGORY,
"NS_CATEGORY_TALK" => NS_CATEGORY_TALK ];
- if ( $param { 0 } == '!' ) {
+ if ( $param[0] == '!' ) {
$this->invert = true;
$param = substr( $param, 1 );
}
*/
class DumpPipeOutput extends DumpFileOutput {
protected $command, $filename;
+ /** @var resource|bool */
protected $procOpenResource = false;
/**
/**
* @param string $virtualUrl
- * @return false
+ * @return array
*/
function getFileProps( $virtualUrl ) {
- return false;
+ return [];
}
/**
* Improves compression ratio by concatenating like objects before gzipping
*/
class ConcatenatedGzipHistoryBlob implements HistoryBlob {
- public $mVersion = 0, $mCompressed = false, $mItems = [], $mDefaultHash = '';
+ public $mVersion = 0;
+ public $mCompressed = false;
+ /**
+ * @var array|string
+ * @fixme Why are some methods treating it as an array, and others as a string, unconditionally?
+ */
+ public $mItems = [];
+ public $mDefaultHash = '';
public $mSize = 0;
public $mMaxSize = 10000000;
public $mMaxCount = 100;
*
* @param string $displayFormat
* @param mixed $arguments,... Additional arguments to pass to the constructor.
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
* @return HTMLForm
*/
public static function factory( $displayFormat/*, $arguments...*/ ) {
* be a subclass of this.
*/
abstract class HTMLFormField {
+ /** @var array|array[] */
public $mParams;
protected $mValidationCallback;
* mParams['columns'] is an array with column labels as keys and column tags as values.
*
* @param array $value Array of the options that should be checked
+ * @suppress PhanParamSignatureMismatch
*
* @return string
*/
* @since 1.28
* @param string[] $value
* @return string|OOUI\CheckboxMultiselectInputWidget
+ * @suppress PhanParamSignatureMismatch
*/
public function getInputOOUI( $value ) {
$this->mParent->getOutput()->addModules( 'oojs-ui-widgets' );
*
* @param string|string[]|MessageSpecifier $key
* @param mixed $param,... Parameters as strings.
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
*
* @return Message
*/
* @param string|string[]|MessageSpecifier $key Message key, or array of keys,
* or a MessageSpecifier.
* @param mixed $params,... Normal message parameters
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
* @return Message
*/
public function msg( $key /*...*/ );
* This is true for the request headers and the response headers. Integer-indexed
* method/URL entries will also be changed to use the corresponding string keys.
*
- * @param array $reqs Map of HTTP request arrays
+ * @param array[] $reqs Map of HTTP request arrays
* @param array $opts
* - connTimeout : connection timeout per request (seconds)
* - reqTimeout : post-connection timeout per request (seconds)
*
* @see MultiHttpClient::runMulti()
*
- * @param array $reqs Map of HTTP request arrays
+ * @param array[] $reqs Map of HTTP request arrays
* @param array $opts
* - connTimeout : connection timeout per request (seconds)
* - reqTimeout : post-connection timeout per request (seconds)
* - reqTimeout : default request timeout
* @return resource
* @throws Exception
+ * @suppress PhanTypeMismatchArgumentInternal
*/
protected function getCurlHandle( array &$req, array $opts = [] ) {
$ch = curl_init();
/**
* Normalize request information
*
- * @param array $reqs the requests to normalize
+ * @param array[] $reqs the requests to normalize
*/
private function normalizeRequests( array &$reqs ) {
foreach ( $reqs as &$req ) {
}
/**
- * @param string $fname the filename
+ * @param string $xml
+ * @param bool $isFile
*/
private function validateFromInput( $xml, $isFile ) {
$reader = new XMLReader();
*
* @ingroup Cache
* @ingroup Redis
+ * @phan-file-suppress PhanTypeComparisonFromArray It's unclear whether exec() can return false
*/
class RedisBagOStuff extends MediumSpecificBagOStuff {
/** @var RedisConnectionPool */
* @ingroup Database
* @since 1.22
* @see Database
+ * @phan-file-suppress PhanParamSignatureMismatch resource vs mysqli_result
*/
class DatabaseMysqli extends DatabaseMysqlBase {
/**
* that field to. The data will be quoted by IDatabase::addQuotes().
* Values with integer keys form unquoted SET statements, which can be used for
* things like "field = field + 1" or similar computed values.
- * @param array $conds An array of conditions (WHERE). See
+ * @param array|string $conds An array of conditions (WHERE). See
* IDatabase::select() for the details of the format of condition
* arrays. Use '*' to update all rows.
* @param string $fname The function name of the caller (from __METHOD__),
* @param string $joinTable The other table.
* @param string $delVar The variable to join on, in the first table.
* @param string $joinVar The variable to join on, in the second table.
- * @param array $conds Condition array of field names mapped to variables,
+ * @param array|string $conds Condition array of field names mapped to variables,
* ANDed together in the WHERE clause
* @param string $fname Calling function name (use __METHOD__) for logs/profiling
* @throws DBError If an error occurs, see IDatabase::query()
*
* @since 1.26
* @param string $blob
- * @return array
+ * @return array|false
*/
public static function extractParams( $blob ) {
return unserialize( $blob );
/**
* @param File $image
- * @param array $metadata
+ * @param string $metadata
* @return bool|int
*/
public function isMetadataValid( $image, $metadata ) {
* @param string $ext
* @param string $mime
* @param array|null $params
- * @return bool
+ * @return array
*/
public function getThumbType( $ext, $mime, $params = null ) {
global $wgTiffThumbnailType;
*
* @param int|bool $openingCount
* @return array
+ * @suppress PhanParamSignatureMismatch
*/
public function breakSyntax( $openingCount = false ) {
if ( $this->open == "\n" ) {
+ // @phan-suppress-next-line PhanTypeMismatchArgumentInternal
$accum = array_merge( [ $this->savedPrefix ], $this->parts[0]->out );
} else {
if ( $openingCount === false ) {
* @param string $sep
* @param int $flags
* @param string|PPNode $args,...
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
* @return string
*/
public function implodeWithFlags( $sep, $flags /*, ... */ );
* Implode with no flags specified
* @param string $sep
* @param string|PPNode $args,...
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
* @return string
*/
public function implode( $sep /*, ... */ );
* Makes an object that, when expand()ed, will be the same as one obtained
* with implode()
* @param string $sep
- * @param string|PPNode $args,...
+ * @param string|PPNode ...$args
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
* @return PPNode
*/
- public function virtualImplode( $sep /*, ... */ );
+ public function virtualImplode( $sep /* ...$args */ );
/**
* Virtual implode with brackets
* @param string $start
* @param string $sep
* @param string $end
- * @param string|PPNode $args,...
+ * @param string|PPNode ...$args
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
* @return PPNode
*/
- public function virtualBracketedImplode( $start, $sep, $end /*, ... */ );
+ public function virtualBracketedImplode( $start, $sep, $end /* ...$args */ );
/**
* Returns true if there are no arguments in this frame
* @param string $sep
* @param string|PPNode_DOM|DOMNode ...$args
* @return array
+ * @suppress PhanParamSignatureMismatch
*/
public function virtualImplode( $sep, ...$args ) {
$out = [];
* @param string $end
* @param string|PPNode_DOM|DOMNode ...$args
* @return array
+ * @suppress PhanParamSignatureMismatch
*/
public function virtualBracketedImplode( $start, $sep, $end, ...$args ) {
$out = [ $start ];
*/
public function replaceExternalLinks( $text ) {
$bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
+ // @phan-suppress-next-line PhanTypeComparisonFromArray See phan issue #3161
if ( $bits === false ) {
throw new MWException( "PCRE needs to be compiled with "
. "--enable-unicode-properties in order for MediaWiki to function" );
*/
protected function getTimeZoneList( Language $language ) {
$identifiers = DateTimeZone::listIdentifiers();
+ // @phan-suppress-next-line PhanTypeComparisonFromArray See phan issue #3162
if ( $identifiers === false ) {
return [];
}
<?php
class ProfilerExcimer extends Profiler {
+ /** @var ExcimerProfiler */
private $cpuProf;
+ /** @var ExcimerProfiler */
private $realProf;
private $period;
* @param string|string[]|MessageSpecifier $key Message key, or array of keys,
* or a MessageSpecifier.
* @param mixed $args,...
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
* @return Message
*/
public function msg( $key ) {
// clear get_last_error without actually raising an error
// from https://www.php.net/manual/en/function.error-get-last.php#113518
- // TODO replace with clear_last_error when requirements are bumped to PHP7
+ // TODO replace with error_clear_last after dropping HHVM
+ // @phan-suppress-next-line PhanTypeMismatchArgumentInternal
set_error_handler( function () {
}, 0 );
AtEase::suppressWarnings();
*
* @since 1.21
*
- * @var array[]
+ * @var array[]|false
*/
protected $localIds = [];
*
* @param string $name Message name
* @param mixed $params,... Message params
+ * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
* @return Message
*/
public function getMsg( $name /* ... */ ) {
/**
* Process the form on POST submission.
* @param array $data
- * @param HTMLForm $form
+ * @param HTMLForm|null $form
+ * @suppress PhanCommentParamWithoutRealParam Many implementations don't have $form
* @return bool|string|array|Status As documented for HTMLForm::trySubmit.
*/
- abstract public function onSubmit( array $data /* $form = null */ );
+ abstract public function onSubmit( array $data /* HTMLForm $form = null */ );
/**
* Do something exciting on successful processing of the form, most likely to show a
'restrictions' => $data['restrictions'],
'grants' => array_merge(
MWGrants::getHiddenGrants(),
+ // @phan-suppress-next-next-line PhanTypeMismatchArgumentInternal See phan issue #3163,
+ // it's probably failing to infer the type of $data['grants']
preg_replace( '/^grant-/', '', $data['grants'] )
)
] );
];
foreach ( $changeGroups as $messageKey => $changeGroup ) {
+ // @phan-suppress-next-line PhanTypeComparisonFromArray
if ( $changeGroup === true ) {
// For grep: listgrouprights-addgroup-all, listgrouprights-removegroup-all,
// listgrouprights-addgroup-self-all, listgrouprights-removegroup-self-all
private $mOriginalLogCallback = null;
private $mOriginalPageOutCallback = null;
private $mLogItemCount = 0;
+ private $mPageCount;
+ private $mIsUpload;
+ private $mInterwiki;
/**
* @param WikiImporter $importer
* Check a block of CSS or CSS fragment for anything that looks like
* it is bringing in remote code.
* @param string $value a string of CSS
- * @param bool $propOnly only check css properties (start regex with :)
* @return bool true if the CSS contains an illegal string, false if otherwise
*/
private static function checkCssFragment( $value ) {
/**
* Check if a given user has permission to use this functionality.
* @param User $user
- * @param bool $displayPassword If set, also check whether the user is allowed to reset the
- * password of another user and see the temporary password.
* @since 1.29 Second argument for displayPassword removed.
* @return StatusValue
*/
$joinConds
);
- return $res === false ? [] : $res;
+ return $res;
}
}
/**
* Accepts the next token in an expect sequence
*
- * @param array $token
+ * @param array|string $token
*/
protected function tryEndExpect( $token ) {
switch ( $this->startToken[0] ) {
# The above mixing may leave namespaces out of canonical order.
# Re-order by namespace ID number...
+ // @phan-suppress-next-line PhanTypeMismatchArgumentInternal
ksort( $this->namespaceNames );
Hooks::run( 'LanguageGetNamespaces', [ &$this->namespaceNames ] );
$this->fatalError( "Error: Closures cannot be converted to JSON. " .
"Please move your extension function somewhere else."
);
- }
- // check if $func exists in the global scope
- if ( function_exists( $func ) ) {
- // @phan-suppress-next-next-line PhanTypeSuspiciousStringExpression
+ } elseif ( function_exists( $func ) ) {
+ // check if $func exists in the global scope
$this->fatalError( "Error: Global functions cannot be converted to JSON. " .
"Please move your extension function ($func) into a class."
);
$this->fatalError( "Error: Closures cannot be converted to JSON. " .
"Please move the handler for $hookName somewhere else."
);
- }
- // Check if $func exists in the global scope
- if ( function_exists( $func ) ) {
+ } elseif ( function_exists( $func ) ) {
+ // Check if $func exists in the global scope
$this->fatalError( "Error: Global functions cannot be converted to JSON. " .
"Please move the handler for $hookName inside a class."
);
protected $bufferSize = 524288; // In bytes. Maximum size to read from the stub in on go.
- protected $php = "php";
+ /** @var array */
+ protected $php = [];
protected $spawn = false;
/**
/**
* @throws MWException Failure to parse XML input
- * @param string $input
+ * @param resource $input
* @return bool
*/
function readDump( $input ) {
/**
* @param MediaWiki\Revision\RevisionStore $revStore
- * @param string $emptySha1
* @return int
*/
protected function doSha1LegacyUpdates( $revStore ) {