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

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

Change subject: Private by default in all Repo API modules
......................................................................

Private by default in all Repo API modules

The idea is simple: If a class does not have any subclasses, protected
means nothing and can be replaced with private. I double checked
everything if it is used anywhere, just to be sure.

Change-Id: I1e228f21ce6c4e456dda7c0dabdaae44e424dfa0
---
M repo/includes/api/ApiErrorReporter.php
M repo/includes/api/ClaimModificationHelper.php
M repo/includes/api/FormatSnakValue.php
M repo/includes/api/GetClaims.php
M repo/includes/api/GetEntities.php
M repo/includes/api/ItemByTitleHelper.php
M repo/includes/api/LinkTitles.php
M repo/includes/api/ParseValue.php
M repo/includes/api/ResultBuilder.php
M repo/includes/api/SearchEntities.php
10 files changed, 56 insertions(+), 76 deletions(-)


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

diff --git a/repo/includes/api/ApiErrorReporter.php 
b/repo/includes/api/ApiErrorReporter.php
index cef3011..c7387b6 100644
--- a/repo/includes/api/ApiErrorReporter.php
+++ b/repo/includes/api/ApiErrorReporter.php
@@ -26,17 +26,17 @@
        /**
         * @var ApiBase
         */
-       protected $apiModule;
+       private $apiModule;
 
        /**
         * @var ExceptionLocalizer
         */
-       protected $localizer;
+       private $localizer;
 
        /**
         * @var Language
         */
-       protected $language;
+       private $language;
 
        /**
         * @param ApiBase $apiModule the API module for collaboration
@@ -97,7 +97,7 @@
         * @param string $key
         * @param string|array $warningData Warning message
         */
-       protected function setWarning( $key, $warningData ) {
+       private function setWarning( $key, $warningData ) {
                $result = $this->apiModule->getResult();
                $moduleName = $this->apiModule->getModuleName();
 
@@ -283,7 +283,7 @@
         *
         * @throws LogicException
         */
-       protected function throwUsageException( $description, $errorCode, 
$httpRespCode = 0, $extradata = null ) {
+       private function throwUsageException( $description, $errorCode, 
$httpRespCode = 0, $extradata = null ) {
                $this->apiModule->getMain()->dieUsage( $description, 
$errorCode, $httpRespCode, $extradata );
 
                throw new LogicException( 'UsageException not thrown' );
@@ -363,7 +363,7 @@
         * @return array a result structure containing the messages from 
$errors as well as what
         *         was already present in the $messages parameter.
         */
-       protected function convertMessagesToResult( array $messageSpecs ) {
+       private function convertMessagesToResult( array $messageSpecs ) {
                $result = array();
                $res = $this->apiModule->getResult();
 
@@ -407,7 +407,7 @@
         * @return array a result structure containing the messages from 
$errors as well as what
         *         was already present in the $messages parameter.
         */
-       protected function convertToMessageList( array $messageSpecs ) {
+       private function convertToMessageList( array $messageSpecs ) {
                $messages = array();
 
                foreach ( $messageSpecs as $message ) {
@@ -432,7 +432,7 @@
         *
         * @return array
         */
-       protected function convertMessageToResult( Message $message ) {
+       private function convertMessageToResult( Message $message ) {
                $res = $this->apiModule->getResult();
 
                $name = $message->getKey();
@@ -474,7 +474,7 @@
         *
         * @return Message|null
         */
-       protected function convertToMessage( $messageSpec ) {
+       private function convertToMessage( $messageSpec ) {
                $name = null;
                $params = null;
 
diff --git a/repo/includes/api/ClaimModificationHelper.php 
b/repo/includes/api/ClaimModificationHelper.php
index 2d55f80..6ed4c16 100644
--- a/repo/includes/api/ClaimModificationHelper.php
+++ b/repo/includes/api/ClaimModificationHelper.php
@@ -39,25 +39,19 @@
 class ClaimModificationHelper {
 
        /**
-        * @since 0.4
-        *
         * @var SnakConstructionService
         */
-       protected $snakConstructionService;
+       private $snakConstructionService;
 
        /**
-        * @since 0.4
-        *
         * @var EntityIdParser
         */
-       protected $entityIdParser;
+       private $entityIdParser;
 
        /**
-        * @since 0.4
-        *
         * @var ClaimGuidValidator
         */
-       protected $claimGuidValidator;
+       private $claimGuidValidator;
 
        /**
         * @since 0.4
diff --git a/repo/includes/api/FormatSnakValue.php 
b/repo/includes/api/FormatSnakValue.php
index a6386e1..ea1de13 100644
--- a/repo/includes/api/FormatSnakValue.php
+++ b/repo/includes/api/FormatSnakValue.php
@@ -29,17 +29,17 @@
        /**
         * @var null|OutputFormatValueFormatterFactory
         */
-       protected $formatterFactory = null;
+       private $formatterFactory = null;
 
        /**
         * @var null|DataValueFactory
         */
-       protected $valueFactory = null;
+       private $valueFactory = null;
 
        /**
         * @return OutputFormatValueFormatterFactory
         */
-       protected function getFormatterFactory() {
+       private function getFormatterFactory() {
                if ( $this->formatterFactory === null ) {
                        $this->formatterFactory = 
WikibaseRepo::getDefaultInstance()->getValueFormatterFactory();
                }
@@ -50,7 +50,7 @@
        /**
         * @return DataValueFactory
         */
-       protected function getValueFactory() {
+       private function getValueFactory() {
                if ( $this->valueFactory === null ) {
                        $this->valueFactory = 
WikibaseRepo::getDefaultInstance()->getDataValueFactory();
                }
@@ -105,15 +105,13 @@
        }
 
        /**
-        * @since 0.1
-        *
         * @param string $json A JSON-encoded DataValue
         *
         * @throws UsageException
         * @throws LogicException
         * @return DataValue
         */
-       protected function decodeDataValue( $json ) {
+       private function decodeDataValue( $json ) {
                $data = \FormatJson::decode( $json, true );
 
                if ( !is_array( $data ) ) {
@@ -131,13 +129,11 @@
        }
 
        /**
-        * @since 0.1
-        *
         * @param string $optionsParam
         *
         * @return FormatterOptions
         */
-       protected function getOptionsObject( $optionsParam ) {
+       private function getOptionsObject( $optionsParam ) {
                $formatterOptions = new FormatterOptions();
                $formatterOptions->setOption( ValueFormatter::OPT_LANG, 
$this->getLanguage()->getCode() );
 
@@ -156,9 +152,10 @@
         * Returns the data type ID specified by the parameters.
         *
         * @param array $params
+        *
         * @return string|null
         */
-       protected function getDataTypeId( array $params ) {
+       private function getDataTypeId( array $params ) {
                //TODO: could be looked up based on a property ID
                return $params['datatype'];
        }
diff --git a/repo/includes/api/GetClaims.php b/repo/includes/api/GetClaims.php
index c0cf852..a455228 100644
--- a/repo/includes/api/GetClaims.php
+++ b/repo/includes/api/GetClaims.php
@@ -30,12 +30,12 @@
        /**
         * @var ClaimGuidValidator
         */
-       protected $claimGuidValidator;
+       private $claimGuidValidator;
 
        /**
         * @var ClaimGuidParser
         */
-       protected $claimGuidParser;
+       private $claimGuidParser;
 
        /**
         * @param ApiMain $mainModule
@@ -88,7 +88,7 @@
                wfProfileOut( __METHOD__ );
        }
 
-       protected function validateParameters( array $params ) {
+       private function validateParameters( array $params ) {
                if ( !isset( $params['entity'] ) && !isset( $params['claim'] ) 
) {
                        $this->dieError( 'Either the entity parameter or the 
claim parameter need to be set', 'param-missing' );
                }
@@ -102,7 +102,7 @@
         *
         * @return Claim[]
         */
-       protected function getClaims( Entity $entity, $claimGuid ) {
+       private function getClaims( Entity $entity, $claimGuid ) {
                $claimsList = new Claims( $entity->getClaims() );
 
                if ( $claimGuid !== null ) {
@@ -122,12 +122,12 @@
                return $claims;
        }
 
-       protected function claimMatchesFilters( Claim $claim ) {
+       private function claimMatchesFilters( Claim $claim ) {
                return $this->rankMatchesFilter( $claim->getRank() )
                        && $this->propertyMatchesFilter( 
$claim->getPropertyId() );
        }
 
-       protected function rankMatchesFilter( $rank ) {
+       private function rankMatchesFilter( $rank ) {
                if ( $rank === null ) {
                        return true;
                }
@@ -142,7 +142,7 @@
                return true;
        }
 
-       protected function propertyMatchesFilter( EntityId $propertyId ) {
+       private function propertyMatchesFilter( EntityId $propertyId ) {
                $params = $this->extractRequestParams();
 
                if ( isset( $params['property'] ) ){
@@ -170,7 +170,7 @@
         * First element is a prefixed entity id
         * Second element is either null or a claim GUID
         */
-       protected function getIdentifiers( $params ) {
+       private function getIdentifiers( $params ) {
                if ( isset( $params['claim'] ) ) {
                        $claimGuid = $params['claim'];
                        $entityId = $this->getEntityIdFromClaimGuid( 
$params['claim'] );
@@ -186,7 +186,7 @@
                return array( $entityId, $claimGuid );
        }
 
-       protected function getEntityIdFromClaimGuid( $claimGuid ) {
+       private function getEntityIdFromClaimGuid( $claimGuid ) {
                if ( $this->claimGuidValidator->validateFormat( $claimGuid ) 
=== false ) {
                        $this->dieError( 'Invalid claim guid' , 'invalid-guid' 
);
                }
diff --git a/repo/includes/api/GetEntities.php 
b/repo/includes/api/GetEntities.php
index 2814e2e..4b2e487 100644
--- a/repo/includes/api/GetEntities.php
+++ b/repo/includes/api/GetEntities.php
@@ -32,12 +32,12 @@
        /**
         * @var StringNormalizer
         */
-       protected $stringNormalizer;
+       private $stringNormalizer;
 
        /**
         * @var LanguageFallbackChainFactory
         */
-       protected $languageFallbackChainFactory;
+       private $languageFallbackChainFactory;
 
        /**
         * @var SiteLinkTargetProvider
@@ -45,11 +45,9 @@
        private $siteLinkTargetProvider;
 
        /**
-        * @since 0.5
-        *
-        * @var array
+        * @var string[]
         */
-       protected $siteLinkGroups;
+       private $siteLinkGroups;
 
        /**
         * @param ApiMain $mainModule
@@ -114,7 +112,7 @@
         *
         * @return EntityId[]
         */
-       protected function getEntityIdsFromParams( array $params ) {
+       private function getEntityIdsFromParams( array $params ) {
                $fromIds = $this->getEntityIdsFromIdParam( $params );
                $fromSiteTitleCombinations = 
$this->getItemIdsFromSiteTitleParams( $params );
                $ids = array_merge( $fromIds, $fromSiteTitleCombinations );
@@ -180,13 +178,11 @@
        /**
         * Returns props based on request parameters
         *
-        * @since 0.5
-        *
         * @param array $params
         *
         * @return array
         */
-       protected function getPropsFromParams( $params ) {
+       private function getPropsFromParams( $params ) {
                if ( in_array( 'sitelinks/urls', $params['props'] ) ) {
                        $params['props'][] = 'sitelinks';
                }
@@ -200,7 +196,7 @@
         *
         * @return EntityRevision[]
         */
-       protected function getEntityRevisionsFromEntityIds( $entityIds, 
$resolveRedirects = false ) {
+       private function getEntityRevisionsFromEntityIds( $entityIds, 
$resolveRedirects = false ) {
                $revisionArray = array();
 
                foreach ( $entityIds as $entityId ) {
@@ -241,7 +237,7 @@
         * @param EntityRevision|null $entityRevision
         * @param array $params
         */
-       protected function handleEntity( $key, EntityRevision $entityRevision = 
null, array $params = array() ) {
+       private function handleEntity( $key, EntityRevision $entityRevision = 
null, array $params = array() ) {
                wfProfileIn( __METHOD__ );
 
                if ( $entityRevision === null ) {
diff --git a/repo/includes/api/ItemByTitleHelper.php 
b/repo/includes/api/ItemByTitleHelper.php
index 928d6b3..d004fc9 100644
--- a/repo/includes/api/ItemByTitleHelper.php
+++ b/repo/includes/api/ItemByTitleHelper.php
@@ -19,25 +19,26 @@
  * @author Adam Shorland
  */
 class ItemByTitleHelper {
+
        /**
         * @var ResultBuilder
         */
-       protected $resultBuilder;
+       private $resultBuilder;
 
        /**
         * @var SiteLinkCache
         */
-       protected $siteLinkCache;
+       private $siteLinkCache;
 
        /**
         * @var SiteStore
         */
-       protected $siteStore;
+       private $siteStore;
 
        /**
         * @var StringNormalizer
         */
-       protected $stringNormalizer;
+       private $stringNormalizer;
 
        /**
         * @param ResultBuilder $resultBuilder
diff --git a/repo/includes/api/LinkTitles.php b/repo/includes/api/LinkTitles.php
index bfea635..fc41d55 100644
--- a/repo/includes/api/LinkTitles.php
+++ b/repo/includes/api/LinkTitles.php
@@ -31,11 +31,9 @@
        private $siteLinkTargetProvider;
 
        /**
-        * @since 0.5
-        *
-        * @var array
+        * @var string[]
         */
-       protected $siteLinkGroups;
+       private $siteLinkGroups;
 
        /**
         * @param ApiMain $mainModule
diff --git a/repo/includes/api/ParseValue.php b/repo/includes/api/ParseValue.php
index 474fe67..b642182 100644
--- a/repo/includes/api/ParseValue.php
+++ b/repo/includes/api/ParseValue.php
@@ -25,14 +25,12 @@
        /**
         * @var null|ValueParserFactory
         */
-       protected $factory = null;
+       private $factory = null;
 
        /**
-        * @since 0.1
-        *
         * @return ValueParserFactory
         */
-       protected function getFactory() {
+       private function getFactory() {
                if ( $this->factory === null ) {
                        $this->factory = new ValueParserFactory( 
$GLOBALS['wgValueParsers'] );
                }
@@ -101,7 +99,7 @@
                return $result;
        }
 
-       protected function addParseErrorToResult( &$result, ParseException 
$parseError ) {
+       private function addParseErrorToResult( &$result, ParseException 
$parseError ) {
                $result['error'] = get_class( $parseError );
 
                $result['error-info'] = $parseError->getMessage();
@@ -122,13 +120,11 @@
        }
 
        /**
-        * @since 0.1
-        *
         * @param string $optionsParam
         *
         * @return ParserOptions
         */
-       protected function getOptionsObject( $optionsParam ) {
+       private function getOptionsObject( $optionsParam ) {
                $parserOptions = new ParserOptions();
                $parserOptions->setOption( ValueParser::OPT_LANG, 
$this->getLanguage()->getCode() );
 
diff --git a/repo/includes/api/ResultBuilder.php 
b/repo/includes/api/ResultBuilder.php
index 540d591..a6425ea 100644
--- a/repo/includes/api/ResultBuilder.php
+++ b/repo/includes/api/ResultBuilder.php
@@ -30,27 +30,27 @@
        /**
         * @var ApiResult
         */
-       protected $result;
+       private $result;
 
        /**
         * @var int
         */
-       protected $missingEntityCounter;
+       private $missingEntityCounter;
 
        /**
         * @var SerializerFactory
         */
-       protected $serializerFactory;
+       private $serializerFactory;
 
        /**
         * @var EntityTitleLookup
         */
-       protected $entityTitleLookup;
+       private $entityTitleLookup;
 
        /**
         * @var SerializationOptions
         */
-       protected $options;
+       private $options;
 
        /**
         * @param ApiResult $result
diff --git a/repo/includes/api/SearchEntities.php 
b/repo/includes/api/SearchEntities.php
index 45e3d84..fc2f8ab 100644
--- a/repo/includes/api/SearchEntities.php
+++ b/repo/includes/api/SearchEntities.php
@@ -35,12 +35,12 @@
        /**
         * @var EntityTitleLookup
         */
-       protected $titleLookup;
+       private $titleLookup;
 
        /**
         * @var EntityIdParser
         */
-       protected $idParser;
+       private $idParser;
 
        /**
         * @param ApiMain $mainModule
@@ -61,8 +61,6 @@
         * Get the entities corresponding to the provided language and term 
pair.
         * Term means it is either a label or an alias.
         *
-        * @since 0.2
-        *
         * @param string $term
         * @param string|null $entityType
         * @param string $language
@@ -71,7 +69,7 @@
         *
         * @return EntityId[]
         */
-       protected function searchEntities( $term, $entityType, $language, 
$limit, $prefixSearch ) {
+       private function searchEntities( $term, $entityType, $language, $limit, 
$prefixSearch ) {
                wfProfileIn( __METHOD__ );
 
                $ids = 
WikibaseRepo::getDefaultInstance()->getStore()->getTermIndex()->getMatchingIDs(

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

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