Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/236741

Change subject: Add array type hints to private functions
......................................................................

Add array type hints to private functions

I found these candidates by doing a regex search for untyped function
parameters that end with a plural "s".

This is the (hopefully) non-controversial part of Id55fec7 that (for
real) exclusively touches private functions.

Change-Id: I307193a61f641c5fdec6287f12840249cacb6ec9
---
M client/includes/LangLinkHandler.php
M client/includes/Usage/SiteLinkUsageLookup.php
M client/includes/recentchanges/ExternalChangeFactory.php
M repo/includes/ChangeOp/ChangeOpValidationException.php
M repo/includes/Diff/DiffOpValueFormatter.php
M repo/includes/Localizer/MessageParameterFormatter.php
M repo/includes/api/ResultBuilder.php
7 files changed, 25 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/41/236741/1

diff --git a/client/includes/LangLinkHandler.php 
b/client/includes/LangLinkHandler.php
index 1bebff2..ca4112d 100644
--- a/client/includes/LangLinkHandler.php
+++ b/client/includes/LangLinkHandler.php
@@ -65,7 +65,7 @@
         * @param NamespaceChecker $namespaceChecker determines which 
namespaces wikibase is enabled on
         * @param SiteLinkLookup $siteLinkLookup A site link lookup service
         * @param EntityLookup $entityLookup An entity lookup service
-        * @param SiteStore $sites
+        * @param SiteStore $siteStore
         * @param string $siteId The global site ID for the local wiki
         * @param string $siteGroup The ID of the site group to use for showing 
language links.
         */
@@ -128,7 +128,7 @@
         *
         * @return SiteLink[] The SiteLinks in $links, indexed by site ID
         */
-       private function indexLinksBySiteId( $links ) {
+       private function indexLinksBySiteId( array $links ) {
                $indexed = array();
 
                foreach ( $links as $link ) {
@@ -144,7 +144,7 @@
         *
         * @return SiteLink[] The SiteLinks in $links, indexed by interwiki 
prefix.
         */
-       private function indexLinksByInterwiki( $links ) {
+       private function indexLinksByInterwiki( array $links ) {
                $indexed = array();
 
                foreach ( $links as $link ) {
diff --git a/client/includes/Usage/SiteLinkUsageLookup.php 
b/client/includes/Usage/SiteLinkUsageLookup.php
index afe3582..0f7d012 100644
--- a/client/includes/Usage/SiteLinkUsageLookup.php
+++ b/client/includes/Usage/SiteLinkUsageLookup.php
@@ -42,7 +42,7 @@
         * @param SiteLinkLookup $siteLinkLookup
         * @param TitleFactory $titleFactory
         *
-        * @throws \InvalidArgumentException
+        * @throws InvalidArgumentException
         */
        public function __construct( $clientSiteId, SiteLinkLookup 
$siteLinkLookup, TitleFactory $titleFactory ) {
                if ( !is_string( $clientSiteId ) ) {
@@ -175,7 +175,7 @@
         *
         * @return ItemId[]
         */
-       private function makeItemIds( $numericIds ) {
+       private function makeItemIds( array $numericIds ) {
                return array_map(
                        function ( $numericId ) {
                                return ItemId::newFromNumber( $numericId );
diff --git a/client/includes/recentchanges/ExternalChangeFactory.php 
b/client/includes/recentchanges/ExternalChangeFactory.php
index cddd1f9..43f1d9d 100644
--- a/client/includes/recentchanges/ExternalChangeFactory.php
+++ b/client/includes/recentchanges/ExternalChangeFactory.php
@@ -87,7 +87,7 @@
        }
 
        /**
-        * @param array $changeParams
+        * @param mixed $changeParams
         *
         * @throws UnexpectedValueException
         * @return bool
@@ -198,7 +198,7 @@
         *
         * @return string
         */
-       private function extractComment( $changeParams ) {
+       private function extractComment( array $changeParams ) {
                $comment = array(
                        'key' => 'wikibase-comment-update'
                );
@@ -223,7 +223,7 @@
         *
         * @return int
         */
-       private function countCompositeComments( $comments ) {
+       private function countCompositeComments( array $comments ) {
                $compositeComments = array_filter( $comments );
 
                return count( $compositeComments );
diff --git a/repo/includes/ChangeOp/ChangeOpValidationException.php 
b/repo/includes/ChangeOp/ChangeOpValidationException.php
index 17ded97..db0ad4b 100644
--- a/repo/includes/ChangeOp/ChangeOpValidationException.php
+++ b/repo/includes/ChangeOp/ChangeOpValidationException.php
@@ -48,7 +48,7 @@
         *
         * @return string
         */
-       private function composeErrorMessage( $errors ) {
+       private function composeErrorMessage( array $errors ) {
                $text = implode( '; ', array_map( function( Error $error ) {
                        return $error->getText();
                }, $errors ) );
diff --git a/repo/includes/Diff/DiffOpValueFormatter.php 
b/repo/includes/Diff/DiffOpValueFormatter.php
index a4e8017..c26529b 100644
--- a/repo/includes/Diff/DiffOpValueFormatter.php
+++ b/repo/includes/Diff/DiffOpValueFormatter.php
@@ -135,7 +135,7 @@
         *
         * @return string HTML
         */
-       private function generateValueHtml( $values ) {
+       private function generateValueHtml( array $values ) {
                $html = '';
 
                foreach ( $values as $value ) {
diff --git a/repo/includes/Localizer/MessageParameterFormatter.php 
b/repo/includes/Localizer/MessageParameterFormatter.php
index ee4d66d..ae38d64 100644
--- a/repo/includes/Localizer/MessageParameterFormatter.php
+++ b/repo/includes/Localizer/MessageParameterFormatter.php
@@ -96,7 +96,7 @@
         *
         * @return string[]
         */
-       private function formatValueList( $values ) {
+       private function formatValueList( array $values ) {
                $formatted = array();
 
                foreach ( $values as $key => $value ) {
diff --git a/repo/includes/api/ResultBuilder.php 
b/repo/includes/api/ResultBuilder.php
index 707aa8b..ccd9c0e 100644
--- a/repo/includes/api/ResultBuilder.php
+++ b/repo/includes/api/ResultBuilder.php
@@ -85,7 +85,7 @@
         * @param SerializerFactory $serializerFactory
         * @param SiteStore $siteStore
         * @param PropertyDataTypeLookup $dataTypeLookup
-        * @param bool $addMetaData when special elements such as '_element' 
are needed
+        * @param bool|null $addMetaData when special elements such as 
'_element' are needed
         */
        public function __construct(
                ApiResult $result,
@@ -101,6 +101,7 @@
                $this->siteStore = $siteStore;
                $this->dataTypeLookup = $dataTypeLookup;
                $this->addMetaData = $addMetaData;
+
                $this->modifier = new SerializationModifier();
                $this->callbackFactory = new CallbackFactory();
        }
@@ -483,7 +484,16 @@
                return $newSerialization;
        }
 
-       private function filterEntitySerializationUsingLangCodes( array 
$serialization, $langCodes ) {
+       /**
+        * @param array $serialization
+        * @param string[] $langCodes
+        *
+        * @return array
+        */
+       private function filterEntitySerializationUsingLangCodes(
+               array $serialization,
+               array $langCodes
+       ) {
                if ( !empty( $langCodes ) ) {
                        if ( array_key_exists( 'labels', $serialization ) ) {
                                foreach ( $serialization['labels'] as $langCode 
=> $languageArray ) {
@@ -510,7 +520,7 @@
                return $serialization;
        }
 
-       private function getEntitySerializationWithMetaData( $serialization ) {
+       private function getEntitySerializationWithMetaData( array 
$serialization ) {
                $arrayTypes = array(
                        'aliases' => 'id',
                        'claims/*/*/references/*/snaks' => 'id',
@@ -981,7 +991,7 @@
                );
        }
 
-       private function getReferenceArrayWithMetaData( $array ) {
+       private function getReferenceArrayWithMetaData( array $array ) {
                $array = $this->modifier->modifyUsingCallback( $array, 
'snaks-order', function ( $array ) {
                        ApiResult::setIndexedTagName( $array, 'property' );
                        return $array;

-- 
To view, visit https://gerrit.wikimedia.org/r/236741
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I307193a61f641c5fdec6287f12840249cacb6ec9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to