Merge "Fix new phan errors, part 6"

This commit is contained in:
jenkins-bot 2019-10-20 18:05:18 +00:00 committed by Gerrit Code Review
commit c3c45ff689
16 changed files with 43 additions and 25 deletions

View file

@ -211,6 +211,10 @@ class HTMLFormFieldCloner extends HTMLFormField {
return $ret;
}
/**
* @inheritDoc
* @phan-param array[] $values
*/
public function cancelSubmit( $values, $alldata ) {
if ( isset( $values['nonjs'] ) ) {
return true;
@ -231,6 +235,10 @@ class HTMLFormFieldCloner extends HTMLFormField {
return parent::cancelSubmit( $values, $alldata );
}
/**
* @inheritDoc
* @phan-param array[] $values
*/
public function validate( $values, $alldata ) {
if ( isset( $this->mParams['required'] )
&& $this->mParams['required'] !== false

View file

@ -162,6 +162,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
$optionsOouiSections
);
}
'@phan-var array[] $optionsOouiSections';
$out = [];
foreach ( $optionsOouiSections as $sectionLabel => $optionsOoui ) {

View file

@ -80,6 +80,7 @@ class InterwikiLookupAdapter implements InterwikiLookup {
return false;
}
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
return $this->interwikiMap[$prefix];
}

View file

@ -85,7 +85,7 @@ class DnsSrvDiscoverer {
/**
* @param array $server
* @param array $servers
* @param array[] $servers
* @return array[]
*/
public function removeServer( $server, array $servers ) {

View file

@ -42,7 +42,7 @@ class XhprofData {
/**
* Per-function inclusive data.
* @var array[] $inclusive
* @var array[][] $inclusive
*/
protected $inclusive;
@ -152,7 +152,7 @@ class XhprofData {
* - max: Maximum value
* - variance: Variance (spread) of the values
*
* @return array[]
* @return array[][]
* @see getRawData()
* @see getCompleteMetrics()
*/
@ -163,40 +163,40 @@ class XhprofData {
$hasMu = isset( $main['mu'] );
$hasAlloc = isset( $main['alloc'] );
$this->inclusive = [];
$inclusive = [];
foreach ( $this->hieraData as $key => $stats ) {
list( $parent, $child ) = self::splitKey( $key );
if ( !isset( $this->inclusive[$child] ) ) {
$this->inclusive[$child] = [
if ( !isset( $inclusive[$child] ) ) {
$inclusive[$child] = [
'ct' => 0,
'wt' => new RunningStat(),
];
if ( $hasCpu ) {
$this->inclusive[$child]['cpu'] = new RunningStat();
$inclusive[$child]['cpu'] = new RunningStat();
}
if ( $hasMu ) {
$this->inclusive[$child]['mu'] = new RunningStat();
$this->inclusive[$child]['pmu'] = new RunningStat();
$inclusive[$child]['mu'] = new RunningStat();
$inclusive[$child]['pmu'] = new RunningStat();
}
if ( $hasAlloc ) {
$this->inclusive[$child]['alloc'] = new RunningStat();
$this->inclusive[$child]['free'] = new RunningStat();
$inclusive[$child]['alloc'] = new RunningStat();
$inclusive[$child]['free'] = new RunningStat();
}
}
$this->inclusive[$child]['ct'] += $stats['ct'];
$inclusive[$child]['ct'] += $stats['ct'];
foreach ( $stats as $stat => $value ) {
if ( $stat === 'ct' ) {
continue;
}
if ( !isset( $this->inclusive[$child][$stat] ) ) {
if ( !isset( $inclusive[$child][$stat] ) ) {
// Ignore unknown stats
continue;
}
for ( $i = 0; $i < $stats['ct']; $i++ ) {
$this->inclusive[$child][$stat]->addObservation(
$inclusive[$child][$stat]->addObservation(
$value / $stats['ct']
);
}
@ -205,14 +205,14 @@ class XhprofData {
// Convert RunningStat instances to static arrays and add
// percentage stats.
foreach ( $this->inclusive as $func => $stats ) {
foreach ( $inclusive as $func => $stats ) {
foreach ( $stats as $name => $value ) {
if ( $value instanceof RunningStat ) {
$total = $value->getMean() * $value->getCount();
$percent = ( isset( $main[$name] ) && $main[$name] )
? 100 * $total / $main[$name]
: 0;
$this->inclusive[$func][$name] = [
$inclusive[$func][$name] = [
'total' => $total,
'min' => $value->min,
'mean' => $value->getMean(),
@ -224,9 +224,10 @@ class XhprofData {
}
}
uasort( $this->inclusive, self::makeSortFunction(
uasort( $inclusive, self::makeSortFunction(
$this->config['sort'], 'total'
) );
$this->inclusive = $inclusive;
}
return $this->inclusive;
}

View file

@ -399,6 +399,7 @@ class FileBackendMultiWrite extends FileBackend {
if (
$resyncMode === 'conservative' &&
$cloneStat &&
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
$cloneStat['mtime'] > $masterStat['mtime']
) {
// Do not replace files with older ones; reduces the risk of data loss
@ -527,7 +528,7 @@ class FileBackendMultiWrite extends FileBackend {
}
/**
* @param array $ops File operations for FileBackend::doOperations()
* @param array[] $ops File operations for FileBackend::doOperations()
* @return bool Whether there are file path sources with outside lifetime/ownership
*/
protected function hasVolatileSources( array $ops ) {

View file

@ -1182,7 +1182,7 @@ abstract class FileBackendStore extends FileBackend {
* The result must have the same number of items as the input.
* An exception is thrown if an unsupported operation is requested.
*
* @param array $ops Same format as doOperations()
* @param array[] $ops Same format as doOperations()
* @return FileOp[] List of FileOp objects
* @throws FileBackendError
*/

View file

@ -142,13 +142,12 @@ class FileOpBatch {
* within any given sub-batch do not depend on each other.
* This will abort remaining ops on failure.
*
* @param array $pPerformOps Batches of file ops (batches use original indexes)
* @param FileOp[][] $pPerformOps Batches of file ops (batches use original indexes)
* @param StatusValue $status
*/
protected static function runParallelBatches( array $pPerformOps, StatusValue $status ) {
$aborted = false; // set to true on unexpected errors
foreach ( $pPerformOps as $performOpsBatch ) {
/** @var FileOp[] $performOpsBatch */
if ( $aborted ) { // check batch op abort flag...
// We can't continue (even with $ignoreErrors) as $predicates is wrong.
// Log the remaining ops as failed for recovery...

View file

@ -158,7 +158,7 @@ class MultiHttpClient implements LoggerAwareInterface {
* - reqTimeout : post-connection timeout per request (seconds)
* - usePipelining : whether to use HTTP pipelining if possible (for all hosts)
* - maxConnsPerHost : maximum number of concurrent connections (per host)
* @return array $reqs With response array populated for each
* @return array[] $reqs With response array populated for each
* @throws Exception
*/
public function runMulti( array $reqs, array $opts = [] ) {

View file

@ -1327,8 +1327,10 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt
// Get the current key value and its metadata
$curTTL = self::PASS_BY_REF;
$curInfo = self::PASS_BY_REF; /** @var array $curInfo */
$curInfo = self::PASS_BY_REF;
$curValue = $this->get( $key, $curTTL, $checkKeys, $curInfo );
/** @var array $curInfo */
'@phan-var array $curInfo';
// Apply any $touchedCb invalidation timestamp to get the "last purge timestamp"
list( $curTTL, $LPT ) = $this->resolveCTL( $curValue, $curTTL, $curInfo, $touchedCb );
// Use the cached value if it exists and is not due for synchronous regeneration

View file

@ -31,7 +31,7 @@ class DBConnRef implements IDatabase {
private $lb;
/** @var Database|null Live connection handle */
private $conn;
/** @var array|null N-tuple of (server index, group, DatabaseDomain|string) */
/** @var array N-tuple of (server index, group, DatabaseDomain|string) */
private $params;
/** @var int One of DB_MASTER/DB_REPLICA */
private $role;

View file

@ -2963,6 +2963,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
if ( !is_array( reset( $rows ) ) ) {
$rows = [ $rows ];
}
'@phan-var array[] $rows';
if ( count( $uniqueIndexes ) ) {
$clauses = []; // list WHERE clauses that each identify a single row

View file

@ -904,6 +904,7 @@ abstract class DatabaseMysqlBase extends Database {
} else {
// Wait on the binlog coordinates
$encFile = $this->addQuotes( $pos->getLogFile() );
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
$encPos = intval( $pos->getLogPosition()[$pos::CORD_EVENT] );
$sql = "SELECT MASTER_POS_WAIT($encFile, $encPos, $timeout)";
$waitPos = $pos->__toString();

View file

@ -178,6 +178,7 @@ class MySQLMasterPos implements DBMasterPos {
* @since 1.31
*/
public function getLogFile() {
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
return $this->gtids ? null : "{$this->binLog}.{$this->logPos[self::CORD_INDEX]}";
}
@ -351,6 +352,7 @@ class MySQLMasterPos implements DBMasterPos {
public function __toString() {
return $this->gtids
? implode( ',', $this->gtids )
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
: $this->getLogFile() . "/{$this->logPos[self::CORD_EVENT]}";
}
}

View file

@ -59,6 +59,7 @@ class FakeResultWrapper implements IResultWrapper {
}
public function current() {
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
$row = $this->valid() ? $this->result[$this->pos] : false;
return is_array( $row ) ? (object)$row : $row;

View file

@ -156,7 +156,7 @@ class VirtualRESTServiceClient {
* list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $responses[0];
* @endcode
*
* @param array $reqs Map of Virtual HTTP request maps
* @param array[] $reqs Map of Virtual HTTP request maps
* @return array $reqs Map of corresponding response values with the same keys/order
* @throws Exception
*/