From dbb23e39520efa16941f0988ead2bbbd3bc75654 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Mon, 6 Apr 2020 09:23:35 +0000 Subject: [PATCH] Upgrade phan to 0.10.2 Amongst other things, this version of phan bundles taint-check, which is however disabled in the config file because there are lots of issues to be fixed. Upgrading phan alone now means that we can have a clean baseline for the taint-check upgrade. Bug: T248630 Change-Id: I8ab7ef9a9e73952098664176aad6c2b3b88095ee --- .phan/config.php | 1 + composer.json | 2 +- includes/htmlform/fields/HTMLFormFieldCloner.php | 1 + includes/libs/rdbms/database/Database.php | 1 - includes/parser/Preprocessor.php | 4 ++-- includes/resourceloader/ResourceLoaderOOUIIconPackModule.php | 1 + includes/resourceloader/ResourceLoaderOOUIImageModule.php | 1 + includes/skins/BaseTemplate.php | 1 + languages/LanguageConverter.php | 3 ++- 9 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.phan/config.php b/.phan/config.php index a1e36bb8eda..d9eca55dd7a 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -18,6 +18,7 @@ * @file */ +$disableTaintCheck = true; $cfg = require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php'; $cfg['file_list'] = array_merge( diff --git a/composer.json b/composer.json index 89e0409c946..15b7cf0ac73 100644 --- a/composer.json +++ b/composer.json @@ -73,7 +73,7 @@ "johnkary/phpunit-speedtrap": "^3.1", "justinrainbow/json-schema": "~5.2", "mediawiki/mediawiki-codesniffer": "30.0.0", - "mediawiki/mediawiki-phan-config": "0.9.2", + "mediawiki/mediawiki-phan-config": "0.10.2", "monolog/monolog": "~1.25.3", "nikic/php-parser": "4.3.0", "nmred/kafka-php": "0.1.5", diff --git a/includes/htmlform/fields/HTMLFormFieldCloner.php b/includes/htmlform/fields/HTMLFormFieldCloner.php index 92621161ecf..daa4fc59b1a 100644 --- a/includes/htmlform/fields/HTMLFormFieldCloner.php +++ b/includes/htmlform/fields/HTMLFormFieldCloner.php @@ -54,6 +54,7 @@ class HTMLFormFieldCloner extends HTMLFormField { } // Make sure the delete button, if explicitly specified, is sane + // @phan-suppress-next-line PhanTypeMismatchDimFetch Phan is very confused if ( isset( $this->mParams['fields']['delete'] ) ) { $class = 'mw-htmlform-cloner-delete-button'; $info = $this->mParams['fields']['delete'] + [ diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index bfbcbd8f80f..7bf1466257e 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -2341,7 +2341,6 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware $opts = $this->makeUpdateOptions( $options ); $sql = "UPDATE $opts $table SET " . $this->makeList( $set, self::LIST_SET ); - // @phan-suppress-next-line PhanTypeComparisonFromArray if ( $conds !== [] && $conds !== '*' ) { $sql .= " WHERE " . $this->makeList( $conds, self::LIST_AND ); } diff --git a/includes/parser/Preprocessor.php b/includes/parser/Preprocessor.php index 19dd96e8856..38308c6b7ca 100644 --- a/includes/parser/Preprocessor.php +++ b/includes/parser/Preprocessor.php @@ -81,7 +81,7 @@ abstract class Preprocessor { $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); $key = $cache->makeKey( - // @phan-suppress-next-line PhanUndeclaredConstant + // @phan-suppress-next-line PhanUndeclaredConstantOfClass defined( 'static::CACHE_PREFIX' ) ? static::CACHE_PREFIX : static::class, md5( $text ), $flags @@ -114,7 +114,7 @@ abstract class Preprocessor { $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); $key = $cache->makeKey( - // @phan-suppress-next-line PhanUndeclaredConstant + // @phan-suppress-next-line PhanUndeclaredConstantOfClass defined( 'static::CACHE_PREFIX' ) ? static::CACHE_PREFIX : static::class, md5( $text ), $flags diff --git a/includes/resourceloader/ResourceLoaderOOUIIconPackModule.php b/includes/resourceloader/ResourceLoaderOOUIIconPackModule.php index 95f37f25fc5..1459f20802e 100644 --- a/includes/resourceloader/ResourceLoaderOOUIIconPackModule.php +++ b/includes/resourceloader/ResourceLoaderOOUIIconPackModule.php @@ -38,6 +38,7 @@ class ResourceLoaderOOUIIconPackModule extends ResourceLoaderOOUIImageModule { } private function getIcons() { + // @phan-suppress-next-line PhanTypeArraySuspiciousNullable Checked in the constructor return $this->definition['icons']; } diff --git a/includes/resourceloader/ResourceLoaderOOUIImageModule.php b/includes/resourceloader/ResourceLoaderOOUIImageModule.php index 5500f497d76..fe611e1012b 100644 --- a/includes/resourceloader/ResourceLoaderOOUIImageModule.php +++ b/includes/resourceloader/ResourceLoaderOOUIImageModule.php @@ -92,6 +92,7 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule { * @param string $theme * @param string $module * @return array + * @suppress PhanTypeArraySuspiciousNullable */ protected function loadOOUIDefinition( $theme, $module ) { // Find the path to the JSON file which contains the actual image definitions for this theme diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php index 2868bd9a27f..be229a5a31f 100644 --- a/includes/skins/BaseTemplate.php +++ b/includes/skins/BaseTemplate.php @@ -566,6 +566,7 @@ abstract class BaseTemplate extends QuickTemplate { unset( $buttonAttrs['width'] ); unset( $buttonAttrs['height'] ); $imgAttrs = [ + // @phan-suppress-next-line PhanTypeInvalidDimOffset 'src' => $attrs['src'], 'alt' => $attrs['alt'] ?? wfMessage( 'searchbutton' )->text(), 'width' => $attrs['width'] ?? null, diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index fdd949376df..001f83511eb 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -977,7 +977,8 @@ abstract class LanguageConverter implements ILanguageConverter { } $this->mTablesLoaded = true; - $this->mTables = null; + // Do not use null as starting value, as that would confuse phan a lot. + $this->mTables = []; $cache = ObjectCache::getInstance( $wgLanguageConverterCacheType ); $cacheKey = $cache->makeKey( 'conversiontables', $this->mMainLanguageCode ); if ( $fromCache ) {