aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaimona Eaytoy <daimona.wiki@gmail.com>2019-08-29 15:19:39 +0200
committerDaimona Eaytoy <daimona.wiki@gmail.com>2019-08-30 09:42:15 +0000
commitfb3428eb8f16235269fb34a98fab664c3732cba2 (patch)
tree37d80539426fa13bac273bda0c46ff3665bde858
parent7f7efbe026b01be36019c26571224a6e8a178677 (diff)
downloadmediawikicore-fb3428eb8f16235269fb34a98fab664c3732cba2.tar.gz
mediawikicore-fb3428eb8f16235269fb34a98fab664c3732cba2.zip
Unsuppress other phan issues with low count
And also update approximated counts, which for the most part are lower than reported (hooray!) Bug: T231636 Depends-On: Ica50297ec7c71a81ba2204f9763499da925067bd Change-Id: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
-rw-r--r--.phan/config.php42
-rw-r--r--includes/EditPage.php2
-rw-r--r--includes/Title.php1
-rw-r--r--includes/cache/BacklinkCache.php4
-rw-r--r--includes/filerepo/file/File.php4
-rw-r--r--includes/filerepo/file/LocalFile.php4
-rw-r--r--includes/filerepo/file/UnregisteredLocalFile.php4
-rw-r--r--includes/historyblob/DiffHistoryBlob.php2
-rw-r--r--includes/language/Message.php2
-rw-r--r--includes/libs/mime/MSCompoundFileReader.php11
-rw-r--r--includes/libs/rdbms/database/IDatabase.php2
-rw-r--r--includes/libs/stats/SamplingStatsdClient.php4
-rw-r--r--includes/objectcache/ObjectCache.php1
-rw-r--r--includes/page/ImageHistoryPseudoPager.php2
-rw-r--r--includes/parser/PPDPart.php3
-rw-r--r--includes/parser/PPDPart_Hash.php3
-rw-r--r--includes/parser/PPDStackElement_Hash.php1
-rw-r--r--includes/parser/Parser.php1
-rw-r--r--includes/rcfeed/FormattedRCFeed.php1
-rw-r--r--includes/resourceloader/DerivativeResourceLoaderContext.php1
-rw-r--r--includes/resourceloader/ResourceLoaderOOUIImageModule.php2
-rw-r--r--includes/specialpage/ChangesListSpecialPage.php2
-rw-r--r--includes/specialpage/LoginSignupSpecialPage.php1
-rw-r--r--includes/specials/pagers/AllMessagesTablePager.php2
-rw-r--r--includes/user/User.php2
-rw-r--r--includes/utils/AvroValidator.php1
-rw-r--r--languages/Language.php1
-rw-r--r--languages/LanguageConverter.php1
-rw-r--r--maintenance/includes/TextPassDumper.php1
-rw-r--r--maintenance/mergeMessageFileList.php1
30 files changed, 66 insertions, 43 deletions
diff --git a/.phan/config.php b/.phan/config.php
index 5813b294682c..893eebb4189d 100644
--- a/.phan/config.php
+++ b/.phan/config.php
@@ -76,47 +76,37 @@ $cfg['exclude_analysis_directory_list'] = [
];
$cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [
- // approximate error count: 18
+ // approximate error count: 22
"PhanAccessMethodInternal",
- // approximate error count: 17
- "PhanCommentParamOnEmptyParamList",
- // approximate error count: 29
+ // approximate error count: 22
"PhanCommentParamWithoutRealParam",
- // approximate error count: 21
+ // approximate error count: 19
"PhanParamReqAfterOpt",
- // approximate error count: 26
+ // approximate error count: 20
"PhanParamSignatureMismatch",
- // approximate error count: 127
+ // approximate error count: 110
"PhanParamTooMany",
- // approximate error count: 30
+ // approximate error count: 63
"PhanTypeArraySuspicious",
- // approximate error count: 27
+ // approximate error count: 28
"PhanTypeArraySuspiciousNullable",
- // approximate error count: 26
+ // approximate error count: 22
"PhanTypeComparisonFromArray",
- // approximate error count: 63
+ // approximate error count: 88
"PhanTypeInvalidDimOffset",
- // approximate error count: 154
+ // approximate error count: 60
"PhanTypeMismatchArgument",
- // approximate error count: 27
+ // approximate error count: 20
"PhanTypeMismatchArgumentInternal",
- // approximate error count: 27
- "PhanTypeMismatchDimFetch",
- // approximate error count: 10
- "PhanTypeMismatchForeach",
- // approximate error count: 77
+ // approximate error count: 40
"PhanTypeMismatchProperty",
- // approximate error count: 84
- "PhanTypeMismatchReturn",
- // approximate error count: 12
- "PhanTypeObjectUnsetDeclaredProperty",
- // approximate error count: 22
+ // approximate error count: 36
"PhanUndeclaredConstant",
- // approximate error count: 237
+ // approximate error count: 219
"PhanUndeclaredMethod",
- // approximate error count: 846
+ // approximate error count: 752
"PhanUndeclaredProperty",
- // approximate error count: 55
+ // approximate error count: 53
"PhanUndeclaredVariableDim",
] );
diff --git a/includes/EditPage.php b/includes/EditPage.php
index e51fc52bd763..f066a611a1c3 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -1127,7 +1127,7 @@ class EditPage {
* @return string|null
*/
protected function importContentFormData( &$request ) {
- return; // Don't do anything, EditPage already extracted wpTextbox1
+ return null; // Don't do anything, EditPage already extracted wpTextbox1
}
/**
diff --git a/includes/Title.php b/includes/Title.php
index 96f196fe9bdb..8c5bbdc221f3 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -1250,6 +1250,7 @@ class Title implements LinkTarget, IDBAccessObject {
* @param int|int[] $namespaces,... The namespaces to check for
* @return bool
* @since 1.19
+ * @suppress PhanCommentParamOnEmptyParamList Cannot make variadic due to HHVM bug, T191668#5263929
*/
public function inNamespaces( /* ... */ ) {
$namespaces = func_get_args();
diff --git a/includes/cache/BacklinkCache.php b/includes/cache/BacklinkCache.php
index c2fb52afdc8c..269630276fc0 100644
--- a/includes/cache/BacklinkCache.php
+++ b/includes/cache/BacklinkCache.php
@@ -135,7 +135,7 @@ class BacklinkCache {
$this->partitionCache = [];
$this->fullResultCache = [];
$this->wanCache->touchCheckKey( $this->makeCheckKey() );
- unset( $this->db );
+ $this->db = null;
}
/**
@@ -153,7 +153,7 @@ class BacklinkCache {
* @return IDatabase
*/
protected function getDB() {
- if ( !isset( $this->db ) ) {
+ if ( $this->db === null ) {
$this->db = wfGetDB( DB_REPLICA );
}
diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php
index 5f6a0cbcd7fd..d14e0ded00e6 100644
--- a/includes/filerepo/file/File.php
+++ b/includes/filerepo/file/File.php
@@ -305,7 +305,7 @@ abstract class File implements IDBAccessObject {
* @return string
*/
public function getName() {
- if ( !isset( $this->name ) ) {
+ if ( $this->name === null ) {
$this->assertRepoDefined();
$this->name = $this->repo->getNameFromTitle( $this->title );
}
@@ -1521,7 +1521,7 @@ abstract class File implements IDBAccessObject {
* @return string
*/
function getHashPath() {
- if ( !isset( $this->hashPath ) ) {
+ if ( $this->hashPath === null ) {
$this->assertRepoDefined();
$this->hashPath = $this->repo->getHashPath( $this->getName() );
}
diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php
index 6143c3188e1f..f3116e2d2a39 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1946,8 +1946,8 @@ class LocalFile extends File {
// Now switch the object
$this->title = $target;
// Force regeneration of the name and hashpath
- unset( $this->name );
- unset( $this->hashPath );
+ $this->name = null;
+ $this->hashPath = null;
}
return $status;
diff --git a/includes/filerepo/file/UnregisteredLocalFile.php b/includes/filerepo/file/UnregisteredLocalFile.php
index 2865ce5effe6..4292ea0ace5a 100644
--- a/includes/filerepo/file/UnregisteredLocalFile.php
+++ b/includes/filerepo/file/UnregisteredLocalFile.php
@@ -43,7 +43,7 @@ class UnregisteredLocalFile extends File {
/** @var bool|string */
protected $mime;
- /** @var array Dimension data */
+ /** @var array[]|bool[] Dimension data */
protected $dims;
/** @var bool|string Handler-specific metadata which will be saved in the img_metadata field */
@@ -108,7 +108,7 @@ class UnregisteredLocalFile extends File {
/**
* @param int $page
- * @return bool
+ * @return array|bool
*/
private function cachePageDimensions( $page = 1 ) {
$page = (int)$page;
diff --git a/includes/historyblob/DiffHistoryBlob.php b/includes/historyblob/DiffHistoryBlob.php
index 8d92fe531270..fdb3dc4daa5c 100644
--- a/includes/historyblob/DiffHistoryBlob.php
+++ b/includes/historyblob/DiffHistoryBlob.php
@@ -333,7 +333,7 @@ class DiffHistoryBlob implements HistoryBlob {
// addItem() doesn't work if mItems is partially filled from mDiffs
$this->mFrozen = true;
$info = unserialize( gzinflate( $this->mCompressed ) );
- unset( $this->mCompressed );
+ $this->mCompressed = null;
if ( !$info ) {
// Empty object
diff --git a/includes/language/Message.php b/includes/language/Message.php
index 12007faf87bd..0c1ef1388ddc 100644
--- a/includes/language/Message.php
+++ b/includes/language/Message.php
@@ -158,6 +158,8 @@ use MediaWiki\MediaWikiServices;
* @see https://www.mediawiki.org/wiki/Localisation
*
* @since 1.17
+ * @phan-file-suppress PhanCommentParamOnEmptyParamList Cannot make variadic due to HHVM bug,
+ * T191668#5263929
*/
class Message implements MessageSpecifier, Serializable {
/** Use message text as-is */
diff --git a/includes/libs/mime/MSCompoundFileReader.php b/includes/libs/mime/MSCompoundFileReader.php
index 26e96851669f..34d612abbd9a 100644
--- a/includes/libs/mime/MSCompoundFileReader.php
+++ b/includes/libs/mime/MSCompoundFileReader.php
@@ -178,11 +178,22 @@ class MSCompoundFileReader {
);
}
+ /**
+ * @param int $offset
+ * @param int[] $struct
+ * @return array
+ */
private function unpackOffset( $offset, $struct ) {
$block = $this->readOffset( $offset, array_sum( $struct ) );
return $this->unpack( $block, 0, $struct );
}
+ /**
+ * @param string $block
+ * @param int $offset
+ * @param int[] $struct
+ * @return array
+ */
private function unpack( $block, $offset, $struct ) {
$data = [];
foreach ( $struct as $key => $length ) {
diff --git a/includes/libs/rdbms/database/IDatabase.php b/includes/libs/rdbms/database/IDatabase.php
index b4eb89aff4e2..68735e9d94a0 100644
--- a/includes/libs/rdbms/database/IDatabase.php
+++ b/includes/libs/rdbms/database/IDatabase.php
@@ -959,7 +959,7 @@ interface IDatabase {
* @param array $valuedata
* @param string $valuename
*
- * @return string
+ * @return array|string
* @deprecated Since 1.33
*/
public function aggregateValue( $valuedata, $valuename = 'value' );
diff --git a/includes/libs/stats/SamplingStatsdClient.php b/includes/libs/stats/SamplingStatsdClient.php
index 6494c26302d6..172ead3812c5 100644
--- a/includes/libs/stats/SamplingStatsdClient.php
+++ b/includes/libs/stats/SamplingStatsdClient.php
@@ -84,7 +84,7 @@ class SamplingStatsdClient extends StatsdClient {
$data = [ $data ];
}
if ( !$data ) {
- return;
+ return 0;
}
foreach ( $data as $item ) {
if ( !( $item instanceof StatsdDataInterface ) ) {
@@ -109,7 +109,7 @@ class SamplingStatsdClient extends StatsdClient {
try {
$fp = $this->getSender()->open();
if ( !$fp ) {
- return;
+ return 0;
}
foreach ( $data as $message ) {
$written += $this->getSender()->write( $fp, $message );
diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php
index 8ffe824f79ee..5e99ac9d7013 100644
--- a/includes/objectcache/ObjectCache.php
+++ b/includes/objectcache/ObjectCache.php
@@ -319,6 +319,7 @@ class ObjectCache {
* @param array $params
* @return WANObjectCache
* @throws UnexpectedValueException
+ * @suppress PhanTypeMismatchReturn
*/
public static function newWANCacheFromParams( array $params ) {
global $wgCommandLineMode, $wgSecretKey;
diff --git a/includes/page/ImageHistoryPseudoPager.php b/includes/page/ImageHistoryPseudoPager.php
index 799c33ad902b..17a6d51a0b1e 100644
--- a/includes/page/ImageHistoryPseudoPager.php
+++ b/includes/page/ImageHistoryPseudoPager.php
@@ -77,7 +77,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
}
public function getQueryInfo() {
- return false;
+ return [];
}
/**
diff --git a/includes/parser/PPDPart.php b/includes/parser/PPDPart.php
index 187373052c8a..b56527ac6aa5 100644
--- a/includes/parser/PPDPart.php
+++ b/includes/parser/PPDPart.php
@@ -33,6 +33,9 @@ class PPDPart {
// commentEnd Past-the-end input pointer for the last comment encountered
// visualEnd Past-the-end input pointer for the end of the accumulator minus comments
+ /**
+ * @param string $out
+ */
public function __construct( $out = '' ) {
$this->out = $out;
}
diff --git a/includes/parser/PPDPart_Hash.php b/includes/parser/PPDPart_Hash.php
index 7507f06fe078..327dd77a68c8 100644
--- a/includes/parser/PPDPart_Hash.php
+++ b/includes/parser/PPDPart_Hash.php
@@ -25,6 +25,9 @@
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class PPDPart_Hash extends PPDPart {
+ /**
+ * @param string $out
+ */
public function __construct( $out = '' ) {
if ( $out !== '' ) {
$accum = [ $out ];
diff --git a/includes/parser/PPDStackElement_Hash.php b/includes/parser/PPDStackElement_Hash.php
index 26351b21d344..5de5f479e94a 100644
--- a/includes/parser/PPDStackElement_Hash.php
+++ b/includes/parser/PPDStackElement_Hash.php
@@ -59,6 +59,7 @@ class PPDStackElement_Hash extends PPDStackElement {
} else {
$accum[++$lastIndex] = '|';
}
+ // @phan-suppress-next-line PhanTypeMismatchForeach
foreach ( $part->out as $node ) {
if ( is_string( $node ) && is_string( $accum[$lastIndex] ) ) {
$accum[$lastIndex] .= $node;
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index d7a15aff23e5..130667e7d626 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -411,6 +411,7 @@ class Parser {
*/
public function __destruct() {
if ( isset( $this->mLinkHolders ) ) {
+ // @phan-suppress-next-line PhanTypeObjectUnsetDeclaredProperty
unset( $this->mLinkHolders );
}
// @phan-suppress-next-line PhanTypeSuspiciousNonTraversableForeach
diff --git a/includes/rcfeed/FormattedRCFeed.php b/includes/rcfeed/FormattedRCFeed.php
index d0b7ae32209e..9b5b29e2085a 100644
--- a/includes/rcfeed/FormattedRCFeed.php
+++ b/includes/rcfeed/FormattedRCFeed.php
@@ -61,6 +61,7 @@ abstract class FormattedRCFeed extends RCFeed {
// @codeCoverageIgnoreStart
// T109544 - If a feed formatter returns null, this will otherwise cause an
// error in at least RedisPubSubFeedEngine. Not sure best to handle this.
+ // @phan-suppress-next-line PhanTypeMismatchReturn
return;
// @codeCoverageIgnoreEnd
}
diff --git a/includes/resourceloader/DerivativeResourceLoaderContext.php b/includes/resourceloader/DerivativeResourceLoaderContext.php
index b11bd6fd3385..cf0b3c275a32 100644
--- a/includes/resourceloader/DerivativeResourceLoaderContext.php
+++ b/includes/resourceloader/DerivativeResourceLoaderContext.php
@@ -54,6 +54,7 @@ class DerivativeResourceLoaderContext extends ResourceLoaderContext {
if ( $this->modules === self::INHERIT_VALUE ) {
return $this->context->getModules();
}
+ // @phan-suppress-next-line PhanTypeMismatchReturn
return $this->modules;
}
diff --git a/includes/resourceloader/ResourceLoaderOOUIImageModule.php b/includes/resourceloader/ResourceLoaderOOUIImageModule.php
index 689ae5819420..9c204fc711ed 100644
--- a/includes/resourceloader/ResourceLoaderOOUIImageModule.php
+++ b/includes/resourceloader/ResourceLoaderOOUIImageModule.php
@@ -98,7 +98,7 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule {
if ( $module ) {
$dataPath = $this->getThemeImagesPath( $theme, $module );
if ( !$dataPath ) {
- return false;
+ return [];
}
} else {
// Backwards-compatibility for things that probably shouldn't have used this class...
diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php
index 3893e9209157..0954c4538337 100644
--- a/includes/specialpage/ChangesListSpecialPage.php
+++ b/includes/specialpage/ChangesListSpecialPage.php
@@ -1133,7 +1133,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
*
* There is light processing to simplify core maintenance.
* @param array $definition
- * @phan-param array<int,array{class:string}> $definition
+ * @phan-param array<int,array{class:string,filters:array}> $definition
*/
protected function registerFiltersFromDefinitions( array $definition ) {
$autoFillPriority = -1;
diff --git a/includes/specialpage/LoginSignupSpecialPage.php b/includes/specialpage/LoginSignupSpecialPage.php
index d609d2294d8b..62818a14d666 100644
--- a/includes/specialpage/LoginSignupSpecialPage.php
+++ b/includes/specialpage/LoginSignupSpecialPage.php
@@ -209,6 +209,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
/**
* @param string|null $subPage
+ * @suppress PhanTypeObjectUnsetDeclaredProperty
*/
public function execute( $subPage ) {
if ( $this->mPosted ) {
diff --git a/includes/specials/pagers/AllMessagesTablePager.php b/includes/specials/pagers/AllMessagesTablePager.php
index 45d77cea0100..bd279198199f 100644
--- a/includes/specials/pagers/AllMessagesTablePager.php
+++ b/includes/specials/pagers/AllMessagesTablePager.php
@@ -354,7 +354,7 @@ class AllMessagesTablePager extends TablePager {
}
function getQueryInfo() {
- return '';
+ return [];
}
}
diff --git a/includes/user/User.php b/includes/user/User.php
index b0ee5cbb445b..061c60f3bdeb 100644
--- a/includes/user/User.php
+++ b/includes/user/User.php
@@ -3602,6 +3602,7 @@ class User implements IDBAccessObject, UserIdentity {
*
* @param string $permissions,... Permissions to test
* @return bool True if user is allowed to perform *any* of the given actions
+ * @suppress PhanCommentParamOnEmptyParamList Cannot make variadic due to HHVM bug, T191668#5263929
*/
public function isAllowedAny() {
return MediaWikiServices::getInstance()
@@ -3614,6 +3615,7 @@ class User implements IDBAccessObject, UserIdentity {
* ->getPermissionManager()->userHasAllRights(...) instead
* @param string $permissions,... Permissions to test
* @return bool True if the user is allowed to perform *all* of the given actions
+ * @suppress PhanCommentParamOnEmptyParamList Cannot make variadic due to HHVM bug, T191668#5263929
*/
public function isAllowedAll() {
return MediaWikiServices::getInstance()
diff --git a/includes/utils/AvroValidator.php b/includes/utils/AvroValidator.php
index 153b3135992a..b2d6077c26fb 100644
--- a/includes/utils/AvroValidator.php
+++ b/includes/utils/AvroValidator.php
@@ -124,6 +124,7 @@ class AvroValidator {
$errors[] = $result;
}
if ( $errors ) {
+ // @phan-suppress-next-line PhanTypeMismatchReturn
return [ "Expected any one of these to be true", $errors ];
}
return "No schemas provided to union";
diff --git a/languages/Language.php b/languages/Language.php
index dd5c63265f80..ff66b25815f9 100644
--- a/languages/Language.php
+++ b/languages/Language.php
@@ -525,6 +525,7 @@ class Language {
}
# Sometimes a language will be localised but not actually exist on this wiki.
+ // @phan-suppress-next-line PhanTypeMismatchForeach
foreach ( $this->namespaceNames as $key => $text ) {
if ( !isset( $validNamespaces[$key] ) ) {
unset( $this->namespaceNames[$key] );
diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php
index 61a967dc46d9..d1a5720249ea 100644
--- a/languages/LanguageConverter.php
+++ b/languages/LanguageConverter.php
@@ -996,6 +996,7 @@ class LanguageConverter {
*/
private function reloadTables() {
if ( $this->mTables ) {
+ // @phan-suppress-next-line PhanTypeObjectUnsetDeclaredProperty
unset( $this->mTables );
}
diff --git a/maintenance/includes/TextPassDumper.php b/maintenance/includes/TextPassDumper.php
index 21b92c51c7a3..04767fa900ac 100644
--- a/maintenance/includes/TextPassDumper.php
+++ b/maintenance/includes/TextPassDumper.php
@@ -207,6 +207,7 @@ TEXT
* This function resets $this->lb and closes all connections on it.
*
* @throws MWException
+ * @suppress PhanTypeObjectUnsetDeclaredProperty
*/
function rotateDb() {
// Cleaning up old connections
diff --git a/maintenance/mergeMessageFileList.php b/maintenance/mergeMessageFileList.php
index 80e72fb8b45e..48a66661dab0 100644
--- a/maintenance/mergeMessageFileList.php
+++ b/maintenance/mergeMessageFileList.php
@@ -157,6 +157,7 @@ class MergeMessageFileList extends Maintenance {
require_once RUN_MAINTENANCE_IF_MAIN;
$queue = [];
+'@phan-var string[][] $mmfl';
foreach ( $mmfl['setupFiles'] as $fileName ) {
if ( strval( $fileName ) === '' ) {
continue;