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

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

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 patch only touches private functions. Making these more restricted
should be much safer.

Change-Id: Id55fec7332d206c57c084007da2af3cbaa2b5fb9
---
M client/includes/Hooks/SpecialWatchlistQueryHandler.php
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/Interactors/TermIndexSearchInteractor.php
M repo/includes/Localizer/MessageParameterFormatter.php
M repo/includes/api/ResultBuilder.php
9 files changed, 22 insertions(+), 22 deletions(-)


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

diff --git a/client/includes/Hooks/SpecialWatchlistQueryHandler.php 
b/client/includes/Hooks/SpecialWatchlistQueryHandler.php
index 77337e1..1253beb 100644
--- a/client/includes/Hooks/SpecialWatchlistQueryHandler.php
+++ b/client/includes/Hooks/SpecialWatchlistQueryHandler.php
@@ -71,7 +71,7 @@
         *
         * @return boolean
         */
-       private function shouldHideWikibaseChanges( WebRequest $request, $opts 
) {
+       private function shouldHideWikibaseChanges( WebRequest $request, 
FormOptions $opts = null ) {
                if ( !$this->showExternalChanges || 
$this->isEnhancedChangesEnabled( $request ) === true ) {
                        return true;
                }
diff --git a/client/includes/LangLinkHandler.php 
b/client/includes/LangLinkHandler.php
index 7f2f122..171701b 100644
--- a/client/includes/LangLinkHandler.php
+++ b/client/includes/LangLinkHandler.php
@@ -137,7 +137,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 ) {
@@ -153,7 +153,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..2cea2a5 100644
--- a/client/includes/Usage/SiteLinkUsageLookup.php
+++ b/client/includes/Usage/SiteLinkUsageLookup.php
@@ -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 fbfd5b1..c61bd36 100644
--- a/client/includes/recentchanges/ExternalChangeFactory.php
+++ b/client/includes/recentchanges/ExternalChangeFactory.php
@@ -92,7 +92,7 @@
         * @throws UnexpectedValueException
         * @return bool
         */
-       private function validateChangeData( $changeParams ) {
+       private function validateChangeData( array $changeParams ) {
                if ( !is_array( $changeParams ) ) {
                        throw new UnexpectedValueException( 'Invalid Wikibase 
change' );
                }
@@ -177,7 +177,7 @@
         *
         * @return string
         */
-       private function extractComment( $changeParams ) {
+       private function extractComment( array $changeParams ) {
                $comment = array(
                        'key' => 'wikibase-comment-update'
                );
@@ -202,7 +202,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 b7ee5f7..3145482 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/Interactors/TermIndexSearchInteractor.php 
b/repo/includes/Interactors/TermIndexSearchInteractor.php
index ef9890a..10ff0c5 100644
--- a/repo/includes/Interactors/TermIndexSearchInteractor.php
+++ b/repo/includes/Interactors/TermIndexSearchInteractor.php
@@ -347,7 +347,7 @@
         *
         * @returns TermIndexEntry[]
         */
-       private function makeTermIndexEntryTemplates( $text, $languageCodes, 
$termTypes ) {
+       private function makeTermIndexEntryTemplates( $text, array 
$languageCodes, array $termTypes ) {
                $terms = array();
                foreach ( $languageCodes as $languageCode ) {
                        foreach ( $termTypes as $termType ) {
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 d08c5c6..636fc1b 100644
--- a/repo/includes/api/ResultBuilder.php
+++ b/repo/includes/api/ResultBuilder.php
@@ -283,9 +283,9 @@
                $sourceEntityIdSerialization,
                EntityRevision $entityRevision,
                $props = 'all',
-               $filterSiteIds = array(),
-               $filterLangCodes = array(),
-               $fallbackChains = array()
+               array $filterSiteIds = array(),
+               array $filterLangCodes = array(),
+               array $fallbackChains = array()
        ) {
                $entity = $entityRevision->getEntity();
                $entityId = $entity->getId();
@@ -344,9 +344,9 @@
        private function getEntityArray(
                Entity $entity,
                $props,
-               $filterSiteIds,
-               $filterLangCodes,
-               $fallbackChains
+               array $filterSiteIds,
+               array $filterLangCodes,
+               array $fallbackChains
        ) {
                $entitySerializer = 
$this->serializerFactory->newEntitySerializer();
                $serialization = $entitySerializer->serialize( $entity );
@@ -454,7 +454,7 @@
                return $serialization;
        }
 
-       private function filterEntitySerializationUsingSiteIds( array 
$serialization, $siteIds ) {
+       private function filterEntitySerializationUsingSiteIds( array 
$serialization, array $siteIds ) {
                if ( !empty( $siteIds ) && array_key_exists( 'sitelinks', 
$serialization ) ) {
                        foreach ( $serialization['sitelinks'] as $siteId => 
$siteLink ) {
                                if ( is_array( $siteLink ) && !in_array( 
$siteLink['site'], $siteIds ) ) {
@@ -521,7 +521,7 @@
                return $newSerialization;
        }
 
-       private function filterEntitySerializationUsingLangCodes( array 
$serialization, $langCodes ) {
+       private function filterEntitySerializationUsingLangCodes( array 
$serialization, array $langCodes ) {
                if ( !empty( $langCodes ) ) {
                        if ( array_key_exists( 'labels', $serialization ) ) {
                                foreach ( $serialization['labels'] as $langCode 
=> $languageArray ) {
@@ -548,7 +548,7 @@
                return $serialization;
        }
 
-       private function getRawModeEntitySerialization( $serialization ) {
+       private function getRawModeEntitySerialization( array $serialization ) {
                // In raw mode aliases are not currently grouped by language
                $serialization = $this->modifier->modifyUsingCallback(
                        $serialization,
@@ -1007,7 +1007,7 @@
                );
        }
 
-       private function getRawModeReferenceArray( $array ) {
+       private function getRawModeReferenceArray( array $array ) {
                $array = $this->modifier->modifyUsingCallback( $array, 
'snaks-order', function ( $array ) {
                        ApiResult::setIndexedTagName( $array, 'property' );
                        return $array;
@@ -1034,7 +1034,7 @@
         *
         * @since 0.5
         */
-       public function addMissingEntity( $key, $missingDetails ) {
+       public function addMissingEntity( $key, array $missingDetails ) {
                if ( $key === null && isset( $missingDetails['id'] ) ) {
                        $key = $missingDetails['id'];
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id55fec7332d206c57c084007da2af3cbaa2b5fb9
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