mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Add strict "array" type hints to code expecting arrays
I found candidates for this by looking for parameters names that end with a plural "s". Change-Id: I61c706eb4dfbdadceb0129afd724e6ce1eb4f4a8
This commit is contained in:
parent
79b82ea45a
commit
0efef4faf3
|
@ -18,7 +18,7 @@ interface Bundleable {
|
|||
/**
|
||||
* @param Bundleable[] $bundleables other object that have been bundled with this one
|
||||
*/
|
||||
public function setBundledElements( $bundleables );
|
||||
public function setBundledElements( array $bundleables );
|
||||
|
||||
/**
|
||||
* @return mixed the key by which this object should be sorted during the bundling process
|
||||
|
|
|
@ -20,7 +20,7 @@ class Bundler {
|
|||
* @param Bundleable[] $bundleables
|
||||
* @return Bundleable[] Grouped notifications sorted by timestamp DESC
|
||||
*/
|
||||
public function bundle( $bundleables ) {
|
||||
public function bundle( array $bundleables ) {
|
||||
$groups = [];
|
||||
$bundled = [];
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ abstract class EchoDiscussionParser {
|
|||
*/
|
||||
public static function generateMentionEvents(
|
||||
$header,
|
||||
$userLinks,
|
||||
array $userLinks,
|
||||
$content,
|
||||
RevisionRecord $revision,
|
||||
User $agent
|
||||
|
@ -308,7 +308,7 @@ abstract class EchoDiscussionParser {
|
|||
}
|
||||
}
|
||||
|
||||
private static function getOverallUserMentionsCount( $userMentions ) {
|
||||
private static function getOverallUserMentionsCount( array $userMentions ) {
|
||||
return count( $userMentions, COUNT_RECURSIVE ) - count( $userMentions );
|
||||
}
|
||||
|
||||
|
@ -524,7 +524,7 @@ abstract class EchoDiscussionParser {
|
|||
* but it contains multiple signatures.
|
||||
* - unknown: Unrecognised change type.
|
||||
*/
|
||||
public static function interpretDiff( $changes, $username, Title $title = null ) {
|
||||
public static function interpretDiff( array $changes, $username, Title $title = null ) {
|
||||
// One extra item in $changes for _info
|
||||
$actions = [];
|
||||
$signedSections = [];
|
||||
|
@ -708,7 +708,7 @@ abstract class EchoDiscussionParser {
|
|||
* @param string[] $lines
|
||||
* @return int[] Tuple [$firstLine, $lastLine]
|
||||
*/
|
||||
private static function getSectionSpan( $offset, $lines ) {
|
||||
private static function getSectionSpan( $offset, array $lines ) {
|
||||
return [
|
||||
self::getSectionStartIndex( $offset, $lines ),
|
||||
self::getSectionEndIndex( $offset, $lines )
|
||||
|
|
|
@ -81,19 +81,19 @@ class MWEchoDbFactory {
|
|||
/**
|
||||
* Get the database connection for Echo
|
||||
* @param int $db Index of the connection to get
|
||||
* @param mixed $groups Query groups.
|
||||
* @param string[] $groups Query groups.
|
||||
* @return \Wikimedia\Rdbms\IDatabase
|
||||
*/
|
||||
public function getEchoDb( $db, $groups = [] ) {
|
||||
public function getEchoDb( $db, array $groups = [] ) {
|
||||
return $this->getLB()->getConnection( $db, $groups );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $db Index of the connection to get
|
||||
* @param array $groups Query groups
|
||||
* @param string[] $groups Query groups
|
||||
* @return bool|\Wikimedia\Rdbms\IDatabase false if no shared db is configured
|
||||
*/
|
||||
public function getSharedDb( $db, $groups = [] ) {
|
||||
public function getSharedDb( $db, array $groups = [] ) {
|
||||
if ( !$this->shared ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -109,11 +109,11 @@ class MWEchoDbFactory {
|
|||
*
|
||||
* @deprecated Use newFromDefault() instead to create a db factory
|
||||
* @param int $db Index of the connection to get
|
||||
* @param mixed $groups Query groups.
|
||||
* @param string[] $groups Query groups.
|
||||
* @param string|bool $wiki The wiki ID, or false for the current wiki
|
||||
* @return \Wikimedia\Rdbms\IDatabase
|
||||
*/
|
||||
public static function getDB( $db, $groups = [], $wiki = false ) {
|
||||
public static function getDB( $db, array $groups = [], $wiki = false ) {
|
||||
global $wgEchoCluster;
|
||||
|
||||
$services = MediaWikiServices::getInstance();
|
||||
|
|
|
@ -23,7 +23,7 @@ trait ApiCrossWiki {
|
|||
* @return array[]
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function getFromForeign( $wikis = null, array $paramOverrides = [] ) {
|
||||
protected function getFromForeign( array $wikis = null, array $paramOverrides = [] ) {
|
||||
$wikis = $wikis ?? $this->getRequestedForeignWikis();
|
||||
if ( $wikis === [] ) {
|
||||
return [];
|
||||
|
|
|
@ -14,7 +14,7 @@ class EchoModerationController {
|
|||
* @param bool $moderate Whether to moderate or unmoderate the events
|
||||
* @throws MWException
|
||||
*/
|
||||
public static function moderate( $eventIds, $moderate ) {
|
||||
public static function moderate( array $eventIds, $moderate ) {
|
||||
if ( !$eventIds ) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ EOF;
|
|||
* @param EchoEventPresentationModel[] $models
|
||||
* @return array [ 'category name' => EchoEventPresentationModel[] ]
|
||||
*/
|
||||
private function groupByCategory( $models ) {
|
||||
private function groupByCategory( array $models ) {
|
||||
$eventsByCategory = [];
|
||||
foreach ( $models as $model ) {
|
||||
$eventsByCategory[$model->getCategory()][] = $model;
|
||||
|
|
|
@ -65,7 +65,7 @@ class EchoUserRightsPresentationModel extends EchoEventPresentationModel {
|
|||
return false;
|
||||
}
|
||||
|
||||
private function getLocalizedGroupNames( $names ) {
|
||||
private function getLocalizedGroupNames( array $names ) {
|
||||
return array_map( function ( $name ) {
|
||||
$msg = $this->msg( 'group-' . $name );
|
||||
return $msg->isBlank() ? $name : $msg->text();
|
||||
|
|
|
@ -23,7 +23,7 @@ class EchoNotificationDeleteJob extends Job {
|
|||
* @param Title $title
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct( $title, $params ) {
|
||||
public function __construct( Title $title, array $params ) {
|
||||
parent::__construct( __CLASS__, $title, $params );
|
||||
$this->userIds = $params['userIds'];
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class EchoNotificationJob extends Job {
|
||||
|
||||
public function __construct( $title, $params ) {
|
||||
public function __construct( Title $title, array $params ) {
|
||||
parent::__construct( 'EchoNotificationJob', $title, $params );
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ class EchoEventMapper extends EchoAbstractMapper {
|
|||
* @param bool $deleted
|
||||
* @return bool|IResultWrapper
|
||||
*/
|
||||
public function toggleDeleted( $eventIds, $deleted ) {
|
||||
public function toggleDeleted( array $eventIds, $deleted ) {
|
||||
$dbw = $this->dbFactory->getEchoDb( DB_MASTER );
|
||||
|
||||
$selectDeleted = $deleted ? 0 : 1;
|
||||
|
|
|
@ -264,7 +264,7 @@ class EchoNotificationMapper extends EchoAbstractMapper {
|
|||
* @param int[] $eventIds
|
||||
* @return EchoNotification[]|false
|
||||
*/
|
||||
public function fetchByUserEvents( User $user, $eventIds ) {
|
||||
public function fetchByUserEvents( User $user, array $eventIds ) {
|
||||
$dbr = $this->dbFactory->getEchoDb( DB_REPLICA );
|
||||
|
||||
$result = $dbr->select(
|
||||
|
@ -383,7 +383,7 @@ class EchoNotificationMapper extends EchoAbstractMapper {
|
|||
* @param int[] $eventIds
|
||||
* @return int[]|false
|
||||
*/
|
||||
public function fetchUsersWithNotificationsForEvents( $eventIds ) {
|
||||
public function fetchUsersWithNotificationsForEvents( array $eventIds ) {
|
||||
$dbr = $this->dbFactory->getEchoDb( DB_REPLICA );
|
||||
|
||||
$res = $dbr->select(
|
||||
|
|
|
@ -667,7 +667,7 @@ class EchoEvent extends EchoAbstractEntity implements Bundleable {
|
|||
return $this->deleted === 1;
|
||||
}
|
||||
|
||||
public function setBundledEvents( $events ) {
|
||||
public function setBundledEvents( array $events ) {
|
||||
$this->bundledEvents = $events;
|
||||
}
|
||||
|
||||
|
@ -692,7 +692,7 @@ class EchoEvent extends EchoAbstractEntity implements Bundleable {
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setBundledElements( $bundleables ) {
|
||||
public function setBundledElements( array $bundleables ) {
|
||||
$this->setBundledEvents( $bundleables );
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ class EchoNotification extends EchoAbstractEntity implements Bundleable {
|
|||
* @param EchoTargetPage[]|null $targetPages An array of EchoTargetPage instances, or null if not loaded.
|
||||
* @return EchoNotification|false False if failed to load/unserialize
|
||||
*/
|
||||
public static function newFromRow( $row, $targetPages = null ) {
|
||||
public static function newFromRow( $row, array $targetPages = null ) {
|
||||
$notification = new EchoNotification();
|
||||
|
||||
if ( property_exists( $row, 'event_type' ) ) {
|
||||
|
@ -226,7 +226,7 @@ class EchoNotification extends EchoAbstractEntity implements Bundleable {
|
|||
return $this->targetPages;
|
||||
}
|
||||
|
||||
public function setBundledNotifications( $notifications ) {
|
||||
public function setBundledNotifications( array $notifications ) {
|
||||
$this->bundledNotifications = $notifications;
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ class EchoNotification extends EchoAbstractEntity implements Bundleable {
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setBundledElements( $bundleables ) {
|
||||
public function setBundledElements( array $bundleables ) {
|
||||
$this->setBundledNotifications( $bundleables );
|
||||
}
|
||||
|
||||
|
|
|
@ -421,7 +421,7 @@ class GenerateSampleNotifications extends Maintenance {
|
|||
] );
|
||||
}
|
||||
|
||||
private function shouldGenerate( $type, $types ) {
|
||||
private function shouldGenerate( $type, array $types ) {
|
||||
return array_search( $type, $types ) !== false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue