Merge "build: Upgrade mediawiki-phan-config to 0.8.0"

This commit is contained in:
jenkins-bot 2019-10-19 20:04:47 +00:00 committed by Gerrit Code Review
commit af86fe62a4
9 changed files with 26 additions and 24 deletions

View file

@ -13,7 +13,7 @@
"mediawiki/mediawiki-codesniffer": "28.0.0",
"jakub-onderka/php-console-highlighter": "0.3.2",
"mediawiki/minus-x": "0.3.2",
"mediawiki/mediawiki-phan-config": "0.7.1"
"mediawiki/mediawiki-phan-config": "0.8.0"
},
"scripts": {
"fix": [

View file

@ -584,7 +584,8 @@ class AbuseFilter {
/**
* @param string[] $filters
* @return array[][]
* @return (string|array)[][][]
* @phan-return array<string,array<string,array{action:string,parameters:string[]}>>
*/
public static function getConsequencesForFilters( $filters ) {
$globalFilters = [];
@ -624,7 +625,8 @@ class AbuseFilter {
* @param IDatabase $dbr
* @param string[] $filters
* @param string $prefix
* @return array[][]
* @return (string|array)[][][]
* @phan-return array<string,array<string,array{action:string,parameters:string[]}>>
*/
public static function loadConsequencesFromDB( IDatabase $dbr, $filters, $prefix = '' ) {
$actionsByFilter = [];

View file

@ -34,10 +34,8 @@ class AbuseFilterRunner {
/**
* @var array Data from per-filter profiling. Shape:
*
* [
* filterID => [ 'time' => timeTaken, 'conds' => condsUsed, 'result' => result ]
* ]
* [ filterName => [ 'time' => float, 'conds' => int, 'result' => bool ] ]
* @phan-var array<string,array{time:float,conds:int,result:bool}>
*
* Where 'timeTaken' is in seconds, 'result' is a boolean indicating whether the filter matched
* the action, and 'filterID' is "{prefix}-{ID}" ; Prefix should be empty for local
@ -465,6 +463,7 @@ class AbuseFilterRunner {
* Record per-filter profiling, for all filters
*
* @param array $data Profiling data, as stored in $this->profilingData
* @phan-param array<string,array{time:float,conds:int,result:bool}> $data
*/
protected function recordPerFilterProfiling( array $data ) {
global $wgAbuseFilterSlowFilterRuntimeLimit;

View file

@ -1,12 +1,14 @@
<?php
/**
* @phan-file-suppress PhanTypeArraySuspiciousNullable Some confusion with class members
*/
class AbuseFilterViewDiff extends AbuseFilterView {
/**
* @var array|null The old version of the filter
* @var (string|array)[]|null The old version of the filter
*/
public $mOldVersion = null;
/**
* @var array|null The new version of the filter
* @var (string|array)[]|null The new version of the filter
*/
public $mNewVersion = null;
/**
@ -112,7 +114,7 @@ class AbuseFilterViewDiff extends AbuseFilterView {
$this->mOldVersion = $this->loadSpec( $oldSpec, $newSpec );
$this->mNewVersion = $this->loadSpec( $newSpec, $oldSpec );
if ( is_null( $this->mOldVersion ) || is_null( $this->mNewVersion ) ) {
if ( $this->mOldVersion === null || $this->mNewVersion === null ) {
$this->getOutput()->addWikiMsg( 'abusefilter-diff-invalid' );
return false;
}
@ -151,7 +153,7 @@ class AbuseFilterViewDiff extends AbuseFilterView {
/**
* @param string $spec
* @param string $otherSpec
* @return array|null
* @return (string|array)[]|null
*/
public function loadSpec( $spec, $otherSpec ) {
static $dependentSpecs = [ 'prev', 'next' ];
@ -229,7 +231,7 @@ class AbuseFilterViewDiff extends AbuseFilterView {
/**
* @param stdClass $row
* @return array
* @return (string|array)[]
*/
public function loadFromHistoryRow( $row ) {
return [

View file

@ -479,9 +479,10 @@ class AbuseFilterViewEdit extends AbuseFilterView {
$output = '';
foreach ( $enabledActions as $action => $_ ) {
$params = $actions[$action] ?? null;
$output .= $this->buildConsequenceSelector(
$action, $setActions[$action], $row, $params );
if ( array_key_exists( $action, $actions ) ) {
$output .= $this->buildConsequenceSelector(
$action, $setActions[$action], $row, $actions[$action] );
}
}
return $output;
@ -491,16 +492,12 @@ class AbuseFilterViewEdit extends AbuseFilterView {
* @param string $action The action to build an editor for
* @param bool $set Whether or not the action is activated
* @param stdClass $row abuse_filter row object
* @param array|null $parameters Action parameters
* @param array $parameters Action parameters
* @return string|\OOUI\FieldLayout
*/
private function buildConsequenceSelector( $action, $set, $row, array $parameters = null ) {
private function buildConsequenceSelector( $action, $set, $row, array $parameters ) {
$config = $this->getConfig();
$user = $this->getUser();
$actions = $config->get( 'AbuseFilterActions' );
if ( empty( $actions[$action] ) ) {
return '';
}
$readOnly = !AbuseFilter::canEditFilter( $user, $row );

View file

@ -171,7 +171,7 @@ class AbuseFilterViewRevert extends AbuseFilterView {
}
/**
* @return array
* @return array[]
*/
public function doLookup() {
$periodStart = $this->mPeriodStart;

View file

@ -123,7 +123,7 @@ class AFPData {
} elseif ( $target === self::DFLOAT ) {
return new AFPData( self::DFLOAT, floatval( count( $orig->data ) ) );
} elseif ( $target === self::DINT ) {
return new AFPData( self::DINT, intval( count( $orig->data ) ) );
return new AFPData( self::DINT, count( $orig->data ) );
} elseif ( $target === self::DSTRING ) {
$s = '';
foreach ( $orig->data as $item ) {

View file

@ -5,6 +5,7 @@
* evaluating it into different passes, allowing the parse tree to be cached.
*
* @file
* @phan-file-suppress PhanPossiblyInfiniteRecursionSameParams Recursion controlled by class props
*/
use Psr\Log\LoggerInterface;

View file

@ -906,6 +906,7 @@ class AbuseFilterParser {
throw new AFPUserVisibleException( 'outofbounds', $this->mCur->pos,
[ $idx, count( $result->getData() ) ] );
}
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable Guaranteed to be array
$result = $result->getData()[$idx];
} elseif ( $result->getType() === AFPData::DUNDEFINED ) {
$result = new AFPData( AFPData::DUNDEFINED );