Merge "build: Upgrade phan to 0.9.0"

This commit is contained in:
jenkins-bot 2019-12-09 16:15:27 +00:00 committed by Gerrit Code Review
commit 9d8954a372
42 changed files with 36 additions and 36 deletions

View file

@ -92,6 +92,11 @@ $cfg['exclude_analysis_directory_list'] = [
// @todo Enable when the issue above is resolved and we update our config!
$cfg['redundant_condition_detection'] = false;
// These are too spammy for now. TODO enable
$cfg['null_casts_as_any_type'] = true;
$cfg['scalar_implicit_cast'] = true;
$cfg['suppress_issue_types'][] = 'PhanTypePossiblyInvalidDimOffset';
// Do not use aliases in core.
// Use the correct name, because we don't need backward compatibility
$cfg['enable_class_alias_support'] = false;

View file

@ -77,7 +77,7 @@
"wikimedia/avro": "1.9.0",
"wikimedia/testing-access-wrapper": "~1.0",
"wmde/hamcrest-html-matchers": "^0.1.0",
"mediawiki/mediawiki-phan-config": "0.8.0",
"mediawiki/mediawiki-phan-config": "0.9.0",
"symfony/yaml": "~3.4 | 4.3.4",
"johnkary/phpunit-speedtrap": "^3.1",
"phpunit/php-invoker": "^2.0"

View file

@ -2343,7 +2343,7 @@ function wfDiff( $before, $after, $params = '-u' ) {
if ( !$h ) {
unlink( $oldtextName );
unlink( $newtextName );
throw new Exception( __METHOD__ . '(): popen() failed' );
throw new Exception( __FUNCTION__ . '(): popen() failed' );
}
$diff = '';
@ -2530,7 +2530,7 @@ function wfForeignMemcKey( $db, $prefix, ...$args ) {
* @return string
*/
function wfGlobalCacheKey( ...$args ) {
wfDeprecated( __METHOD__, '1.30' );
wfDeprecated( __FUNCTION__, '1.30' );
return ObjectCache::getLocalClusterInstance()->makeGlobalKey( ...$args );
}
@ -2929,7 +2929,7 @@ function wfUnpack( $format, $data, $length = false ) {
function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) {
$services = MediaWikiServices::getInstance();
if ( $blacklist !== null ) {
wfDeprecated( __METHOD__ . ' with $blacklist parameter', '1.34' );
wfDeprecated( __FUNCTION__ . ' with $blacklist parameter', '1.34' );
return ( new BadFileLookup(
function () use ( $blacklist ) {
return $blacklist;

View file

@ -4051,7 +4051,6 @@ class OutputPage extends ContextSource {
* @param mixed ...$msgSpecs
*/
public function wrapWikiMsg( $wrap, ...$msgSpecs ) {
$msgSpecs = array_values( $msgSpecs );
$s = $wrap;
foreach ( $msgSpecs as $n => $spec ) {
if ( is_array( $spec ) ) {

View file

@ -49,11 +49,9 @@ class EntryPoint {
$responseFactory = new ResponseFactory( self::getTextFormatters( $services ) );
// @phan-suppress-next-line PhanAccessMethodInternal
$authorizer = new MWBasicAuthorizer( $context->getUser(),
$services->getPermissionManager() );
// @phan-suppress-next-line PhanAccessMethodInternal
$restValidator = new Validator( $objectFactory,
$services->getPermissionManager(),
$request,

View file

@ -296,7 +296,6 @@ class Router {
*/
private function executeHandler( $handler ): ResponseInterface {
// Check for basic authorization, to avoid leaking data from private wikis
// @phan-suppress-next-line PhanAccessMethodInternal
$authResult = $this->basicAuth->authorize( $handler->getRequest(), $handler );
if ( $authResult ) {
return $this->responseFactory->createHttpError( 403, [ 'error' => $authResult ] );

View file

@ -90,7 +90,6 @@ class Revision implements IDBAccessObject {
* @return SqlBlobStore
*/
protected static function getBlobStore( $wiki = false ) {
// @phan-suppress-next-line PhanAccessMethodInternal
$store = MediaWikiServices::getInstance()
->getBlobStoreFactory()
->newSqlBlobStore( $wiki );

View file

@ -125,7 +125,6 @@ class RevisionStoreFactory {
$store = new RevisionStore(
$this->dbLoadBalancerFactory->getMainLB( $dbDomain ),
// @phan-suppress-next-line PhanAccessMethodInternal
$this->blobStoreFactory->newSqlBlobStore( $dbDomain ),
$this->cache, // Pass local cache instance; Leave cache sharing to RevisionStore.
$this->commentStore,

View file

@ -506,7 +506,6 @@ return [
'MessageFormatterFactory' =>
function ( MediaWikiServices $services ) : IMessageFormatterFactory {
// @phan-suppress-next-line PhanAccessMethodInternal
return new MessageFormatterFactory();
},
@ -1017,7 +1016,6 @@ return [
},
'_SqlBlobStore' => function ( MediaWikiServices $services ) : SqlBlobStore {
// @phan-suppress-next-line PhanAccessMethodInternal
return $services->getBlobStoreFactory()->newSqlBlobStore();
},

View file

@ -81,11 +81,12 @@ class ApiAuthManagerHelper {
break;
case 'raw':
$params = $message->getParams();
$res[$key] = [
'key' => $message->getKey(),
'params' => $message->getParams(),
'params' => $params,
];
ApiResult::setIndexedTagName( $res[$key]['params'], 'param' );
ApiResult::setIndexedTagName( $params, 'param' );
break;
}
}

View file

@ -912,7 +912,7 @@ abstract class ApiBase extends ContextSource {
function ( $p ) {
return '<var>' . $this->encodeParamName( $p ) . '</var>';
},
array_values( $required )
$required
) ),
count( $required ),
], 'missingparam' );
@ -963,7 +963,7 @@ abstract class ApiBase extends ContextSource {
function ( $p ) {
return '<var>' . $this->encodeParamName( $p ) . '</var>';
},
array_values( $required )
$required
) ),
count( $required ),
], 'missingparam' );

View file

@ -29,6 +29,7 @@ class ApiContinuationManager {
private $allModules = [];
private $generatedModules = [];
/** @var array[] */
private $continuationData = [];
private $generatorContinuationData = [];
private $generatorNonContinuationData = [];
@ -217,8 +218,6 @@ class ApiContinuationManager {
// Some modules are unfinished: include those params, and copy
// the generator params.
foreach ( $continuationData as $module => $kvp ) {
// XXX: Not sure why phan is complaining here...
// @phan-suppress-next-line PhanTypeInvalidLeftOperand
$data += $kvp;
}
$generatorParams = [];
@ -226,6 +225,7 @@ class ApiContinuationManager {
$generatorParams += $kvp;
}
$generatorParams += $this->generatorParams;
// @phan-suppress-next-line PhanTypeInvalidLeftOperand
$data += $generatorParams;
$generatorKeys = implode( '|', array_keys( $generatorParams ) );
} elseif ( $this->generatorContinuationData ) {

View file

@ -337,6 +337,7 @@ class ApiErrorFormatter {
break;
case 'wikitext':
// @phan-suppress-next-line PhanUselessBinaryAddRight
$value += [
'text' => $msg->text(),
ApiResult::META_CONTENT => 'text',

View file

@ -62,6 +62,7 @@ class ApiQueryAuthManagerInfo extends ApiQueryBase {
'preservedusername' => (string)$preservedReq->username,
];
} else {
// @phan-suppress-next-line PhanUselessBinaryAddRight
$ret += [
'haspreservedstate' => false,
'hasprimarypreservedstate' => false,

View file

@ -329,7 +329,6 @@ class ApiQueryUsers extends ApiQueryBase {
}
}
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
$fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $data[$u] );
if ( !$fit ) {
if ( $useNames ) {

View file

@ -304,7 +304,6 @@ abstract class AuthenticationRequest {
* @param AuthenticationRequest[] $reqs
* @return array
* @throws \UnexpectedValueException If fields cannot be merged
* @suppress PhanTypeInvalidDimOffset
*/
public static function mergeFieldInfo( array $reqs ) {
$merged = [];

View file

@ -67,6 +67,7 @@ class ChangesFeed {
* Generate the feed items given a row from the database.
* @param object $rows IDatabase resource with recentchanges rows
* @return array
* @suppress PhanTypeInvalidDimOffset False positives in the foreach
*/
public static function buildItems( $rows ) {
$items = [];

View file

@ -112,7 +112,6 @@ use Wikimedia\ObjectFactory;
* @see https://github.com/Seldaek/monolog
* @since 1.25
* @copyright © 2014 Wikimedia Foundation and contributors
* @phan-file-suppress PhanTypeArraySuspiciousNullable False positives with $this->config
*/
class MonologSpi implements Spi {

View file

@ -550,6 +550,7 @@ abstract class HTMLFormField {
} else {
$field = Html::rawElement(
'div',
// @phan-suppress-next-line PhanUselessBinaryAddRight
[ 'class' => $outerDivClass ] + $cellAttributes,
$inputHtml . "\n$errors"
);

View file

@ -145,7 +145,6 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
// 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];

View file

@ -1556,6 +1556,7 @@ class SwiftFileBackend extends FileBackendStore {
} elseif ( $rcode === 409 ) { // not empty
$this->onError( $status, __METHOD__, $params, $rerr, $rcode, $rdesc ); // race?
} else {
// @phan-suppress-previous-line PhanPluginDuplicateIfStatements
$this->onError( $status, __METHOD__, $params, $rerr, $rcode, $rdesc );
}

View file

@ -493,7 +493,6 @@ class MultiHttpClient implements LoggerAwareInterface {
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 {

View file

@ -1449,6 +1449,7 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt
$this->setInterimValue( $key, $value, $lockTSE, $version, $walltime );
} else {
$finalSetOpts = [
// @phan-suppress-next-line PhanUselessBinaryAddRight
'since' => $setOpts['since'] ?? $preCallbackTime,
'version' => $version,
'staleTTL' => $staleTTL,

View file

@ -3635,7 +3635,6 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
list( $phpCallback ) = $callback;
$this->clearFlag( self::DBO_TRX ); // make each query its own transaction
try {
// @phan-suppress-next-line PhanParamTooManyCallable
call_user_func( $phpCallback, $trigger, $this );
} catch ( Exception $ex ) {
call_user_func( $this->errorLogger, $ex );

View file

@ -98,7 +98,6 @@ class FormatMetadata extends ContextSource {
* Exif::getFilteredData() or BitmapMetadataHandler )
* @return array
* @since 1.23
* @suppress PhanTypeArraySuspiciousNullable
*/
public function makeFormattedData( $tags ) {
$resolutionunit = !isset( $tags['ResolutionUnit'] ) || $tags['ResolutionUnit'] == 2 ? 2 : 3;

View file

@ -168,6 +168,7 @@ class GIFMetadataExtractor {
$commentCount = count( $comment );
if ( $commentCount === 0
// @phan-suppress-next-line PhanTypeInvalidDimOffset
|| $comment[$commentCount - 1] !== $data
) {
// Some applications repeat the same comment on each

View file

@ -41,8 +41,6 @@ use Wikimedia\Rdbms\LoadBalancer;
*
* Some fields are public only for backwards-compatibility. Use accessors.
* In the past, this class was part of Article.php and everything was public.
*
* @phan-file-suppress PhanAccessMethodInternal Due to the use of DerivedPageDataUpdater
*/
class WikiPage implements Page, IDBAccessObject {
// Constants for $mDataLoadedFrom and related

View file

@ -265,6 +265,7 @@ class BlockLevelPass {
# Close all the prefixes which aren't shared.
while ( $commonPrefixLength < $lastPrefixLength ) {
// @phan-suppress-next-line PhanTypeInvalidDimOffset
$output .= $this->closeList( $lastPrefix[$lastPrefixLength - 1] );
--$lastPrefixLength;
}

View file

@ -4302,11 +4302,13 @@ class Parser {
# Decrease TOC level, find level to jump to
for ( $i = $toclevel; $i > 0; $i-- ) {
// @phan-suppress-next-line PhanTypeInvalidDimOffset
if ( $levelCount[$i] == $level ) {
# Found last matching level
$toclevel = $i;
break;
} elseif ( $levelCount[$i] < $level ) {
// @phan-suppress-previous-line PhanTypeInvalidDimOffset
# Found first matching level below current level
$toclevel = $i + 1;
break;

View file

@ -44,6 +44,7 @@ class TimezoneFilter implements Filter {
if ( count( $data ) === 3 ) {
// Make sure this timezone exists
try {
// @phan-suppress-next-line PhanNoopNew
new DateTimeZone( $data[2] );
// If the constructor didn't throw, we know it's valid
$valid = true;

View file

@ -332,6 +332,7 @@ JAVASCRIPT;
$startupQuery
);
// @phan-suppress-next-line PhanTypeMismatchArgument
return WrappedString::join( "\n", $chunks );
}

View file

@ -228,6 +228,7 @@ class RevDelFileItem extends RevDelItem {
'url' => $file->getUrl(),
];
} elseif ( $this->canViewContent() ) {
// @phan-suppress-next-line PhanUselessBinaryAddRight
$ret += [
'url' => SpecialPage::getTitleFor( 'Revisiondelete' )->getLinkURL(
[

View file

@ -156,7 +156,6 @@ class SessionInfo {
$this->idIsSafe = $data['idIsSafe'];
$this->forceUse = $data['forceUse'] && $this->provider;
} else {
// @phan-suppress-next-line PhanUndeclaredMethod
$this->id = $this->provider->getManager()->generateSessionId();
$this->idIsSafe = true;
$this->forceUse = false;

View file

@ -1793,7 +1793,6 @@ class User implements IDBAccessObject, UserIdentity {
$request = $this->getRequest();
}
// @phan-suppress-next-line PhanAccessMethodInternal It's the only allowed use
$block = MediaWikiServices::getInstance()->getBlockManager()->getUserBlock(
$this,
$request,
@ -2980,7 +2979,6 @@ class User implements IDBAccessObject, UserIdentity {
}
if ( array_key_exists( $oname, $this->mOptions ) ) {
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable Obvious false positive
return $this->mOptions[$oname];
}

View file

@ -148,7 +148,6 @@ class SearchFormWidget {
* @param string $profile The currently selected profile
* @param string $term The user provided search terms
* @return string HTML
* @suppress PhanTypeArraySuspiciousNullable
*/
protected function profileTabsHtml( $profile, $term ) {
$bareterm = $this->startsWithImage( $term )

View file

@ -20,7 +20,6 @@
* @file
* @ingroup Maintenance
* @phan-file-suppress PhanInvalidCommentForDeclarationType False negative about about `@var`
* @phan-file-suppress PhanUnextractableAnnotation False negative about about `@var`
*/
/**

View file

@ -387,6 +387,7 @@ class MigrateActors extends LoggedUpdateMaintenance {
$res = $dbw->select(
[ $table, $newTable ],
[ $primaryKey, $userField, $nameField, 'actor_id' => $actorIdSubquery ] + $extra,
// @phan-suppress-next-line PhanSuspiciousBinaryAddLists
[ $newPrimaryKey => null ] + $next,
__METHOD__,
[

View file

@ -59,7 +59,6 @@ class MigrateArchiveText extends LoggedUpdateMaintenance {
protected function doDBUpdates() {
$replaceMissing = $this->hasOption( 'replace-missing' );
$defaultExternalStore = $this->getConfig()->get( 'DefaultExternalStore' );
// @phan-suppress-next-line PhanAccessMethodInternal
$blobStore = MediaWikiServices::getInstance()
->getBlobStoreFactory()
->newSqlBlobStore();

View file

@ -244,6 +244,7 @@ class MigrateComments extends LoggedUpdateMaintenance {
$res = $dbw->select(
[ $table, $newTable ],
[ $primaryKey, $oldField ],
// @phan-suppress-next-line PhanSuspiciousBinaryAddLists
[ $newPrimaryKey => null ] + $next,
__METHOD__,
[

View file

@ -143,6 +143,7 @@ class CheckStorage {
$id = $row->old_id;
// Create flagStats row if it doesn't exist
// @phan-suppress-next-line PhanSuspiciousBinaryAddLists
$flagStats = $flagStats + [ $flags => 0 ];
// Increment counter
$flagStats[$flags]++;
@ -282,6 +283,7 @@ class CheckStorage {
continue;
}
// @phan-suppress-next-line PhanSuspiciousBinaryAddLists
$objectStats = $objectStats + [ $className => 0 ];
$objectStats[$className]++;
@ -568,7 +570,7 @@ class CheckStorage {
[],
[ 'content' => [ 'INNER JOIN', [ 'content_id = slot_content_id' ] ] ]
);
// @phan-suppress-next-line PhanAccessMethodInternal
$blobStore = MediaWikiServices::getInstance()
->getBlobStoreFactory()
->newSqlBlobStore();

View file

@ -239,7 +239,7 @@ class CompressOld extends Maintenance {
/** @var ExternalStoreDB $storeObj */
$storeObj = $esFactory->getStore( 'DB' );
}
// @phan-suppress-next-line PhanAccessMethodInternal
$blobStore = MediaWikiServices::getInstance()
->getBlobStoreFactory()
->newSqlBlobStore();

View file

@ -123,7 +123,7 @@ class RecompressTracked {
$this->pageBlobClass = function_exists( 'xdiff_string_bdiff' ) ?
DiffHistoryBlob::class : ConcatenatedGzipHistoryBlob::class;
$this->orphanBlobClass = ConcatenatedGzipHistoryBlob::class;
// @phan-suppress-next-line PhanAccessMethodInternal
$this->blobStore = MediaWikiServices::getInstance()
->getBlobStoreFactory()
->newSqlBlobStore();