From: Daimona Eaytoy Date: Fri, 30 Aug 2019 13:09:51 +0000 (+0200) Subject: Unsuppress more phan issues (part 3) X-Git-Tag: 1.34.0-rc.0~467 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=5eac6d131c2a77d04b019d4c60aa02a4f98c7903;p=lhc%2Fweb%2Fwiklou.git Unsuppress more phan issues (part 3) Bug: T231636 Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd Change-Id: I58e67c2b38389df874438deada4239510d21654f --- diff --git a/.phan/config.php b/.phan/config.php index 893eebb418..bc9526ac57 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -78,26 +78,18 @@ $cfg['exclude_analysis_directory_list'] = [ $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 diff --git a/.phan/stubs/excimer.php b/.phan/stubs/excimer.php index e87d4cd9b5..d663a44b16 100644 --- a/.phan/stubs/excimer.php +++ b/.phan/stubs/excimer.php @@ -22,7 +22,7 @@ class ExcimerProfiler { } public function stop() { } - public function getLog() { + public function getLog() : ExcimerLog { } public function flush() { } @@ -33,8 +33,14 @@ class ExcimerLog { } function formatCollapsed() { } + /** + * @return array[] + */ function aggregateByFunction() { } + /** + * @return int + */ function getEventCount() { } function current() { diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 739c10283e..5a874d5bcb 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1278,7 +1278,7 @@ $wgMaxAnimatedGifArea = 1.25e7; * $wgTiffThumbnailType = [ 'jpg', 'image/jpeg' ]; * @endcode */ -$wgTiffThumbnailType = false; +$wgTiffThumbnailType = []; /** * If rendered thumbnail files are older than this timestamp, they diff --git a/includes/FauxRequest.php b/includes/FauxRequest.php index ecbc6e3373..78f6ca9afa 100644 --- a/includes/FauxRequest.php +++ b/includes/FauxRequest.php @@ -88,6 +88,7 @@ class FauxRequest extends WebRequest { /** * @return array + * @suppress PhanParamSignatureMismatch */ public function getValues() { return $this->data; diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index cc998c7223..9e7dd8ff16 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2892,6 +2892,7 @@ function wfUnpack( $format, $data, $length = false ) { $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" ); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 9af16d39f8..327bc8fa74 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1820,14 +1820,10 @@ class OutputPage extends ContextSource { * @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 `
` - * @private */ private function addWikiTextTitleInternal( $text, Title $title, $linestart, $interface, $wrapperClass = null diff --git a/includes/Permissions/PermissionManager.php b/includes/Permissions/PermissionManager.php index 37791d0a14..6c614f6ef8 100644 --- a/includes/Permissions/PermissionManager.php +++ b/includes/Permissions/PermissionManager.php @@ -1220,7 +1220,8 @@ class PermissionManager { * 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 */ @@ -1238,7 +1239,8 @@ class PermissionManager { * 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 */ diff --git a/includes/Rest/HeaderContainer.php b/includes/Rest/HeaderContainer.php index a71f6a6ce1..528bac1ad0 100644 --- a/includes/Rest/HeaderContainer.php +++ b/includes/Rest/HeaderContainer.php @@ -51,7 +51,6 @@ class HeaderContainer { * 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 */ diff --git a/includes/WebRequest.php b/includes/WebRequest.php index defe07eaee..bbaa10fea3 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -39,7 +39,10 @@ use MediaWiki\Session\SessionManager; * @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. diff --git a/includes/api/ApiAuthManagerHelper.php b/includes/api/ApiAuthManagerHelper.php index 2f66277ec4..7a548cc2f9 100644 --- a/includes/api/ApiAuthManagerHelper.php +++ b/includes/api/ApiAuthManagerHelper.php @@ -306,8 +306,6 @@ class ApiAuthManagerHelper { /** * Clean up a field array for output - * @param ApiBase $module For context and parameters 'mergerequestfields' - * and 'messageformat' * @param array $fields * @return array */ diff --git a/includes/api/ApiImportReporter.php b/includes/api/ApiImportReporter.php index be53c67c33..c4a432cf64 100644 --- a/includes/api/ApiImportReporter.php +++ b/includes/api/ApiImportReporter.php @@ -34,6 +34,7 @@ class ApiImportReporter extends ImportReporter { * @param int $successCount * @param array $pageInfo * @return void + * @suppress PhanParamSignatureMismatch */ public function reportPage( $title, $foreignTitle, $revisionCount, $successCount, $pageInfo ) { // Add a result entry diff --git a/includes/cache/localisation/LocalisationCache.php b/includes/cache/localisation/LocalisationCache.php index ffc7cd00d6..26468452b4 100644 --- a/includes/cache/localisation/LocalisationCache.php +++ b/includes/cache/localisation/LocalisationCache.php @@ -731,6 +731,7 @@ class LocalisationCache { 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 ); @@ -826,7 +827,7 @@ class LocalisationCache { 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 ); @@ -835,16 +836,11 @@ class LocalisationCache { # 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 @@ -932,16 +928,14 @@ class LocalisationCache { # 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 ] ); } } } diff --git a/includes/context/ContextSource.php b/includes/context/ContextSource.php index 618253859d..a21f404b85 100644 --- a/includes/context/ContextSource.php +++ b/includes/context/ContextSource.php @@ -163,6 +163,7 @@ abstract class ContextSource implements IContextSource { * @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 */ ) { diff --git a/includes/context/DerivativeContext.php b/includes/context/DerivativeContext.php index d32617e0c3..e4340ce2db 100644 --- a/includes/context/DerivativeContext.php +++ b/includes/context/DerivativeContext.php @@ -257,6 +257,7 @@ class DerivativeContext extends ContextSource implements MutableContext { * @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 ) { diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index 6eeac1c72d..e6a856cf12 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -411,6 +411,7 @@ class RequestContext implements IContextSource, MutableContext { * @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 ) { diff --git a/includes/diff/ArrayDiffFormatter.php b/includes/diff/ArrayDiffFormatter.php index 70a963ba10..188135fcf9 100644 --- a/includes/diff/ArrayDiffFormatter.php +++ b/includes/diff/ArrayDiffFormatter.php @@ -34,6 +34,7 @@ class ArrayDiffFormatter extends DiffFormatter { * @param Diff $diff A Diff object. * * @return array[] List of associative arrays, each describing a difference. + * @suppress PhanParamSignatureMismatch */ public function format( $diff ) { $oldline = 1; diff --git a/includes/export/DumpNamespaceFilter.php b/includes/export/DumpNamespaceFilter.php index 0b8afa216f..f99746e3a0 100644 --- a/includes/export/DumpNamespaceFilter.php +++ b/includes/export/DumpNamespaceFilter.php @@ -35,7 +35,7 @@ class DumpNamespaceFilter extends DumpFilter { /** * @param DumpOutput &$sink - * @param array $param + * @param string $param * @throws MWException */ function __construct( &$sink, $param ) { @@ -61,7 +61,7 @@ class DumpNamespaceFilter extends DumpFilter { "NS_CATEGORY" => NS_CATEGORY, "NS_CATEGORY_TALK" => NS_CATEGORY_TALK ]; - if ( $param { 0 } == '!' ) { + if ( $param[0] == '!' ) { $this->invert = true; $param = substr( $param, 1 ); } diff --git a/includes/export/DumpPipeOutput.php b/includes/export/DumpPipeOutput.php index a353c44761..0521c5a131 100644 --- a/includes/export/DumpPipeOutput.php +++ b/includes/export/DumpPipeOutput.php @@ -32,6 +32,7 @@ use MediaWiki\Shell\Shell; */ class DumpPipeOutput extends DumpFileOutput { protected $command, $filename; + /** @var resource|bool */ protected $procOpenResource = false; /** diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index 314c4c30f0..655fd0de65 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -176,10 +176,10 @@ class ForeignAPIRepo extends FileRepo { /** * @param string $virtualUrl - * @return false + * @return array */ function getFileProps( $virtualUrl ) { - return false; + return []; } /** diff --git a/includes/historyblob/ConcatenatedGzipHistoryBlob.php b/includes/historyblob/ConcatenatedGzipHistoryBlob.php index 7824872815..6e760fae1b 100644 --- a/includes/historyblob/ConcatenatedGzipHistoryBlob.php +++ b/includes/historyblob/ConcatenatedGzipHistoryBlob.php @@ -25,7 +25,14 @@ * 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; diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index ed151e6366..f4dad390cf 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -294,6 +294,7 @@ class HTMLForm extends ContextSource { * * @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...*/ ) { diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 590b9e7cb3..91c6e6a8d0 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -5,6 +5,7 @@ * be a subclass of this. */ abstract class HTMLFormField { + /** @var array|array[] */ public $mParams; protected $mValidationCallback; diff --git a/includes/htmlform/fields/HTMLCheckMatrix.php b/includes/htmlform/fields/HTMLCheckMatrix.php index 8e51858d9a..595b71e2a0 100644 --- a/includes/htmlform/fields/HTMLCheckMatrix.php +++ b/includes/htmlform/fields/HTMLCheckMatrix.php @@ -77,6 +77,7 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable { * 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 */ diff --git a/includes/htmlform/fields/HTMLMultiSelectField.php b/includes/htmlform/fields/HTMLMultiSelectField.php index 1c4a785fa3..c373f45578 100644 --- a/includes/htmlform/fields/HTMLMultiSelectField.php +++ b/includes/htmlform/fields/HTMLMultiSelectField.php @@ -137,6 +137,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable * @since 1.28 * @param string[] $value * @return string|OOUI\CheckboxMultiselectInputWidget + * @suppress PhanParamSignatureMismatch */ public function getInputOOUI( $value ) { $this->mParent->getOutput()->addModules( 'oojs-ui-widgets' ); diff --git a/includes/language/Message.php b/includes/language/Message.php index 0c1ef1388d..35cc34881d 100644 --- a/includes/language/Message.php +++ b/includes/language/Message.php @@ -406,6 +406,7 @@ class Message implements MessageSpecifier, Serializable { * * @param string|string[]|MessageSpecifier $key * @param mixed $param,... Parameters as strings. + * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847 * * @return Message */ diff --git a/includes/language/MessageLocalizer.php b/includes/language/MessageLocalizer.php index 9a1796b140..fc514390dd 100644 --- a/includes/language/MessageLocalizer.php +++ b/includes/language/MessageLocalizer.php @@ -36,6 +36,7 @@ interface MessageLocalizer { * @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 /*...*/ ); diff --git a/includes/libs/http/MultiHttpClient.php b/includes/libs/http/MultiHttpClient.php index 2e418b96b9..ed81a792f0 100644 --- a/includes/libs/http/MultiHttpClient.php +++ b/includes/libs/http/MultiHttpClient.php @@ -150,7 +150,7 @@ class MultiHttpClient implements LoggerAwareInterface { * 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) @@ -182,7 +182,7 @@ class MultiHttpClient implements LoggerAwareInterface { * * @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) @@ -293,6 +293,7 @@ class MultiHttpClient implements LoggerAwareInterface { * - reqTimeout : default request timeout * @return resource * @throws Exception + * @suppress PhanTypeMismatchArgumentInternal */ protected function getCurlHandle( array &$req, array $opts = [] ) { $ch = curl_init(); @@ -529,7 +530,7 @@ class MultiHttpClient implements LoggerAwareInterface { /** * 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 ) { diff --git a/includes/libs/mime/XmlTypeCheck.php b/includes/libs/mime/XmlTypeCheck.php index f25287fc7d..9d66326744 100644 --- a/includes/libs/mime/XmlTypeCheck.php +++ b/includes/libs/mime/XmlTypeCheck.php @@ -150,7 +150,8 @@ class XmlTypeCheck { } /** - * @param string $fname the filename + * @param string $xml + * @param bool $isFile */ private function validateFromInput( $xml, $isFile ) { $reader = new XMLReader(); diff --git a/includes/libs/objectcache/RedisBagOStuff.php b/includes/libs/objectcache/RedisBagOStuff.php index 57a2507b7e..aaed69f441 100644 --- a/includes/libs/objectcache/RedisBagOStuff.php +++ b/includes/libs/objectcache/RedisBagOStuff.php @@ -28,6 +28,7 @@ * * @ingroup Cache * @ingroup Redis + * @phan-file-suppress PhanTypeComparisonFromArray It's unclear whether exec() can return false */ class RedisBagOStuff extends MediumSpecificBagOStuff { /** @var RedisConnectionPool */ diff --git a/includes/libs/rdbms/database/DatabaseMysqli.php b/includes/libs/rdbms/database/DatabaseMysqli.php index 8931ae266e..106772b346 100644 --- a/includes/libs/rdbms/database/DatabaseMysqli.php +++ b/includes/libs/rdbms/database/DatabaseMysqli.php @@ -33,6 +33,7 @@ use stdClass; * @ingroup Database * @since 1.22 * @see Database + * @phan-file-suppress PhanParamSignatureMismatch resource vs mysqli_result */ class DatabaseMysqli extends DatabaseMysqlBase { /** diff --git a/includes/libs/rdbms/database/IDatabase.php b/includes/libs/rdbms/database/IDatabase.php index 68735e9d94..41f7cb63b4 100644 --- a/includes/libs/rdbms/database/IDatabase.php +++ b/includes/libs/rdbms/database/IDatabase.php @@ -902,7 +902,7 @@ interface IDatabase { * 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__), @@ -1287,7 +1287,7 @@ interface IDatabase { * @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() diff --git a/includes/logging/LogEntryBase.php b/includes/logging/LogEntryBase.php index 170fc2975f..4fff1de3a2 100644 --- a/includes/logging/LogEntryBase.php +++ b/includes/logging/LogEntryBase.php @@ -64,7 +64,7 @@ abstract class LogEntryBase implements LogEntry { * * @since 1.26 * @param string $blob - * @return array + * @return array|false */ public static function extractParams( $blob ) { return unserialize( $blob ); diff --git a/includes/media/ExifBitmapHandler.php b/includes/media/ExifBitmapHandler.php index fa9e1dc90c..9058340fb6 100644 --- a/includes/media/ExifBitmapHandler.php +++ b/includes/media/ExifBitmapHandler.php @@ -80,7 +80,7 @@ class ExifBitmapHandler extends BitmapHandler { /** * @param File $image - * @param array $metadata + * @param string $metadata * @return bool|int */ public function isMetadataValid( $image, $metadata ) { diff --git a/includes/media/TiffHandler.php b/includes/media/TiffHandler.php index 15c4dbf1e6..880d382b4f 100644 --- a/includes/media/TiffHandler.php +++ b/includes/media/TiffHandler.php @@ -62,7 +62,7 @@ class TiffHandler extends ExifBitmapHandler { * @param string $ext * @param string $mime * @param array|null $params - * @return bool + * @return array */ public function getThumbType( $ext, $mime, $params = null ) { global $wgTiffThumbnailType; diff --git a/includes/parser/PPDStackElement_Hash.php b/includes/parser/PPDStackElement_Hash.php index 5de5f479e9..816548ce7d 100644 --- a/includes/parser/PPDStackElement_Hash.php +++ b/includes/parser/PPDStackElement_Hash.php @@ -35,9 +35,11 @@ class PPDStackElement_Hash extends PPDStackElement { * * @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 ) { diff --git a/includes/parser/PPFrame.php b/includes/parser/PPFrame.php index 79c7c3b30a..3f147f01c3 100644 --- a/includes/parser/PPFrame.php +++ b/includes/parser/PPFrame.php @@ -69,6 +69,7 @@ interface PPFrame { * @param string $sep * @param int $flags * @param string|PPNode $args,... + * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847 * @return string */ public function implodeWithFlags( $sep, $flags /*, ... */ ); @@ -77,6 +78,7 @@ interface PPFrame { * Implode with no flags specified * @param string $sep * @param string|PPNode $args,... + * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847 * @return string */ public function implode( $sep /*, ... */ ); @@ -85,20 +87,22 @@ interface PPFrame { * 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 diff --git a/includes/parser/PPFrame_DOM.php b/includes/parser/PPFrame_DOM.php index e3c12eb597..00bfe98959 100644 --- a/includes/parser/PPFrame_DOM.php +++ b/includes/parser/PPFrame_DOM.php @@ -458,6 +458,7 @@ class PPFrame_DOM implements PPFrame { * @param string $sep * @param string|PPNode_DOM|DOMNode ...$args * @return array + * @suppress PhanParamSignatureMismatch */ public function virtualImplode( $sep, ...$args ) { $out = []; @@ -489,6 +490,7 @@ class PPFrame_DOM implements PPFrame { * @param string $end * @param string|PPNode_DOM|DOMNode ...$args * @return array + * @suppress PhanParamSignatureMismatch */ public function virtualBracketedImplode( $start, $sep, $end, ...$args ) { $out = [ $start ]; diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 130667e7d6..267402fce7 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2010,6 +2010,7 @@ class Parser { */ 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" ); diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php index 00c290357e..70e38ee74a 100644 --- a/includes/preferences/DefaultPreferencesFactory.php +++ b/includes/preferences/DefaultPreferencesFactory.php @@ -1726,6 +1726,7 @@ class DefaultPreferencesFactory implements PreferencesFactory { */ protected function getTimeZoneList( Language $language ) { $identifiers = DateTimeZone::listIdentifiers(); + // @phan-suppress-next-line PhanTypeComparisonFromArray See phan issue #3162 if ( $identifiers === false ) { return []; } diff --git a/includes/profiler/ProfilerExcimer.php b/includes/profiler/ProfilerExcimer.php index 20f9a78508..ab59efed72 100644 --- a/includes/profiler/ProfilerExcimer.php +++ b/includes/profiler/ProfilerExcimer.php @@ -1,7 +1,9 @@ $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'] ) ) ] ); diff --git a/includes/specials/SpecialListGroupRights.php b/includes/specials/SpecialListGroupRights.php index 7f00311ca8..33641cd333 100644 --- a/includes/specials/SpecialListGroupRights.php +++ b/includes/specials/SpecialListGroupRights.php @@ -264,6 +264,7 @@ class SpecialListGroupRights extends SpecialPage { ]; 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 diff --git a/includes/specials/helpers/ImportReporter.php b/includes/specials/helpers/ImportReporter.php index 80638042b0..0ae708ac14 100644 --- a/includes/specials/helpers/ImportReporter.php +++ b/includes/specials/helpers/ImportReporter.php @@ -30,6 +30,9 @@ class ImportReporter extends ContextSource { private $mOriginalLogCallback = null; private $mOriginalPageOutCallback = null; private $mLogItemCount = 0; + private $mPageCount; + private $mIsUpload; + private $mInterwiki; /** * @param WikiImporter $importer diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index fb9dcf56d2..3368e29aed 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -1763,7 +1763,6 @@ abstract class UploadBase { * 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 ) { diff --git a/includes/user/PasswordReset.php b/includes/user/PasswordReset.php index aada3192e3..fd8eb3fac1 100644 --- a/includes/user/PasswordReset.php +++ b/includes/user/PasswordReset.php @@ -70,8 +70,6 @@ class PasswordReset implements LoggerAwareInterface { /** * 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 */ diff --git a/includes/user/UserNamePrefixSearch.php b/includes/user/UserNamePrefixSearch.php index b7d5058211..c185babcfb 100644 --- a/includes/user/UserNamePrefixSearch.php +++ b/includes/user/UserNamePrefixSearch.php @@ -65,6 +65,6 @@ class UserNamePrefixSearch { $joinConds ); - return $res === false ? [] : $res; + return $res; } } diff --git a/includes/utils/ClassCollector.php b/includes/utils/ClassCollector.php index 12b8a707bd..a9f7dd24bb 100644 --- a/includes/utils/ClassCollector.php +++ b/includes/utils/ClassCollector.php @@ -126,7 +126,7 @@ class ClassCollector { /** * Accepts the next token in an expect sequence * - * @param array $token + * @param array|string $token */ protected function tryEndExpect( $token ) { switch ( $this->startToken[0] ) { diff --git a/languages/Language.php b/languages/Language.php index ff66b25815..913620367b 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -534,6 +534,7 @@ class Language { # 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 ] ); diff --git a/maintenance/convertExtensionToRegistration.php b/maintenance/convertExtensionToRegistration.php index 3db0511eae..b0ac638fd9 100644 --- a/maintenance/convertExtensionToRegistration.php +++ b/maintenance/convertExtensionToRegistration.php @@ -168,10 +168,8 @@ class ConvertExtensionToRegistration extends Maintenance { $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." ); @@ -264,9 +262,8 @@ class ConvertExtensionToRegistration extends Maintenance { $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." ); diff --git a/maintenance/includes/TextPassDumper.php b/maintenance/includes/TextPassDumper.php index 04767fa900..2e5cc4feb3 100644 --- a/maintenance/includes/TextPassDumper.php +++ b/maintenance/includes/TextPassDumper.php @@ -64,7 +64,8 @@ class TextPassDumper extends BackupDumper { 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; /** @@ -431,7 +432,7 @@ TEXT /** * @throws MWException Failure to parse XML input - * @param string $input + * @param resource $input * @return bool */ function readDump( $input ) { diff --git a/maintenance/populateRevisionSha1.php b/maintenance/populateRevisionSha1.php index f91a5b6ed3..d1c71dedea 100644 --- a/maintenance/populateRevisionSha1.php +++ b/maintenance/populateRevisionSha1.php @@ -125,7 +125,6 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { /** * @param MediaWiki\Revision\RevisionStore $revStore - * @param string $emptySha1 * @return int */ protected function doSha1LegacyUpdates( $revStore ) {