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

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

Change subject: Private by default in ChangeOpFactory based API modules
......................................................................

Private by default in ChangeOpFactory based API modules

Change-Id: Ib690b8a2408c36ad0005c40c4c17b2ad14b04e03
---
M repo/includes/api/CreateClaim.php
M repo/includes/api/RemoveClaims.php
M repo/includes/api/SetClaim.php
M repo/includes/api/SetClaimValue.php
M repo/includes/api/SetDescription.php
M repo/includes/api/SetLabel.php
M repo/includes/api/SetQualifier.php
M repo/includes/api/SetReference.php
M repo/includes/api/SetSiteLink.php
9 files changed, 32 insertions(+), 64 deletions(-)


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

diff --git a/repo/includes/api/CreateClaim.php 
b/repo/includes/api/CreateClaim.php
index 8ffdb91..90b562e 100644
--- a/repo/includes/api/CreateClaim.php
+++ b/repo/includes/api/CreateClaim.php
@@ -25,7 +25,7 @@
        /**
         * @var ClaimChangeOpFactory
         */
-       protected $claimChangeOpFactory;
+       private $claimChangeOpFactory;
 
        /**
         * @param ApiMain $mainModule
@@ -86,11 +86,9 @@
         * Checks if the required parameters are set and the ones that make no 
sense given the
         * snaktype value are not set.
         *
-        * @since 0.2
-        *
         * @params array $params
         */
-       protected function validateParameters( array $params ) {
+       private function validateParameters( array $params ) {
                if ( $params['snaktype'] == 'value' XOR isset( $params['value'] 
) ) {
                        if ( $params['snaktype'] == 'value' ) {
                                $this->dieError( 'A value needs to be provided 
when creating a claim with PropertyValueSnak snak', 'param-missing' );
diff --git a/repo/includes/api/RemoveClaims.php 
b/repo/includes/api/RemoveClaims.php
index aa86dc1..ae48f98 100644
--- a/repo/includes/api/RemoveClaims.php
+++ b/repo/includes/api/RemoveClaims.php
@@ -27,7 +27,7 @@
        /**
         * @var ClaimChangeOpFactory
         */
-       protected $claimChangeOpFactory;
+       private $claimChangeOpFactory;
 
        /**
         * @param ApiMain $mainModule
@@ -77,13 +77,11 @@
        /**
         * Validates the parameters and returns the EntityId to act upon on 
success
         *
-        * @since 0.4
-        *
         * @param array $params
         *
         * @return EntityId
         */
-       protected function getEntityId( array $params ) {
+       private function getEntityId( array $params ) {
                $entityId = null;
 
                foreach ( $params['claim'] as $guid ) {
@@ -110,12 +108,10 @@
        /**
         * Checks whether the claims can be found
         *
-        * @since 0.4
-        *
         * @param Entity $entity
         * @param array $guids
         */
-       protected function checkClaims( Entity $entity, array $guids ) {
+       private function checkClaims( Entity $entity, array $guids ) {
                $claims = new Claims( $entity->getClaims() );
 
                foreach ( $guids as $guid) {
@@ -126,13 +122,11 @@
        }
 
        /**
-        * @since 0.4
-        *
         * @param array $params
         *
         * @return ChangeOp[]
         */
-       protected function getChangeOps( array $params ) {
+       private function getChangeOps( array $params ) {
                $changeOps = array();
 
                foreach ( $params['claim'] as $guid ) {
diff --git a/repo/includes/api/SetClaim.php b/repo/includes/api/SetClaim.php
index a836044..874e6b9 100644
--- a/repo/includes/api/SetClaim.php
+++ b/repo/includes/api/SetClaim.php
@@ -36,7 +36,7 @@
        /**
         * @var ClaimChangeOpFactory
         */
-       protected $claimChangeOpFactory;
+       private $claimChangeOpFactory;
 
        /**
         * @param ApiMain $mainModule
@@ -94,7 +94,7 @@
         *
         * @todo this summary builder is ugly and summary stuff needs to be 
refactored
         */
-       protected function getSummary( array $params, Claim $claim, Entity 
$entity ){
+       private function getSummary( array $params, Claim $claim, Entity 
$entity ){
                $claimSummaryBuilder = new ClaimSummaryBuilder(
                        $this->getModuleName(),
                        new ClaimDiffer( new OrderedListDiffer( new 
ComparableComparer() ) )
@@ -112,8 +112,6 @@
        }
 
        /**
-        * @since 0.4
-        *
         * @param array $params
         *
         * @throws IllegalValueException
@@ -121,7 +119,7 @@
         * @throws LogicException
         * @return Claim
         */
-       protected function getClaimFromParams( array $params ) {
+       private function getClaimFromParams( array $params ) {
                $serializerFactory = new SerializerFactory();
                $unserializer = $serializerFactory->newUnserializerForClass( 
'Wikibase\DataModel\Claim\Claim' );
 
diff --git a/repo/includes/api/SetClaimValue.php 
b/repo/includes/api/SetClaimValue.php
index e69256c..ca5f5a0 100644
--- a/repo/includes/api/SetClaimValue.php
+++ b/repo/includes/api/SetClaimValue.php
@@ -21,7 +21,7 @@
        /**
         * @var ClaimChangeOpFactory
         */
-       protected $claimChangeOpFactory;
+       private $claimChangeOpFactory;
 
        /**
         * @param ApiMain $mainModule
@@ -73,11 +73,9 @@
        }
 
        /**
-        * @since 0.4
-        *
         * @param array $params
         */
-       protected function validateParameters( array $params ) {
+       private function validateParameters( array $params ) {
                if ( !( $this->claimModificationHelper->validateClaimGuid( 
$params['claim'] ) ) ) {
                        $this->dieError( 'Invalid claim guid' , 'invalid-guid' 
);
                }
diff --git a/repo/includes/api/SetDescription.php 
b/repo/includes/api/SetDescription.php
index e79146f..41752f0 100644
--- a/repo/includes/api/SetDescription.php
+++ b/repo/includes/api/SetDescription.php
@@ -24,7 +24,7 @@
        /**
         * @var FingerprintChangeOpFactory
         */
-       protected $termChangeOpFactory;
+       private $termChangeOpFactory;
 
        /**
         * @param ApiMain $mainModule
@@ -58,12 +58,11 @@
        }
 
        /**
-        * @since 0.4
-        *
         * @param array $params
+        *
         * @return ChangeOpDescription
         */
-       protected function getChangeOp( array $params ) {
+       private function getChangeOp( array $params ) {
                wfProfileIn( __METHOD__ );
                $description = "";
                $language = $params['language'];
diff --git a/repo/includes/api/SetLabel.php b/repo/includes/api/SetLabel.php
index 0a0ab58..f5930e1 100644
--- a/repo/includes/api/SetLabel.php
+++ b/repo/includes/api/SetLabel.php
@@ -24,7 +24,7 @@
        /**
         * @var FingerprintChangeOpFactory
         */
-       protected $termChangeOpFactory;
+       private $termChangeOpFactory;
 
        /**
         * @param ApiMain $mainModule
@@ -58,12 +58,11 @@
        }
 
        /**
-        * @since 0.4
-        *
         * @param array $params
+        *
         * @return ChangeOpLabel
         */
-       protected function getChangeOp( array $params ) {
+       private function getChangeOp( array $params ) {
                wfProfileIn( __METHOD__ );
                $label = "";
                $language = $params['language'];
diff --git a/repo/includes/api/SetQualifier.php 
b/repo/includes/api/SetQualifier.php
index b4a07f9..820fbbf 100644
--- a/repo/includes/api/SetQualifier.php
+++ b/repo/includes/api/SetQualifier.php
@@ -25,7 +25,7 @@
        /**
         * @var ClaimChangeOpFactory
         */
-       protected $claimChangeOpFactory;
+       private $claimChangeOpFactory;
 
        /**
         * @param ApiMain $mainModule
@@ -76,10 +76,8 @@
        /**
         * Checks if the required parameters are set and the ones that make no 
sense given the
         * snaktype value are not set.
-        *
-        * @since 0.2
         */
-       protected function validateParameters( array $params ) {
+       private function validateParameters( array $params ) {
                if ( !( $this->claimModificationHelper->validateClaimGuid( 
$params['claim'] ) ) ) {
                        $this->dieError( 'Invalid claim guid' , 'invalid-guid' 
);
                }
@@ -100,23 +98,19 @@
        }
 
        /**
-        * @since 0.4
-        *
         * @param Claim $claim
         * @param string $qualifierHash
         */
-       protected function validateQualifierHash( Claim $claim, $qualifierHash 
) {
+       private function validateQualifierHash( Claim $claim, $qualifierHash ) {
                if ( !$claim->getQualifiers()->hasSnakHash( $qualifierHash ) ) {
                        $this->dieError( "Claim does not have a qualifier with 
the given hash" , 'no-such-qualifier' );
                }
        }
 
        /**
-        * @since 0.4
-        *
         * @return ChangeOpQualifier
         */
-       protected function getChangeOp() {
+       private function getChangeOp() {
                $params = $this->extractRequestParams();
 
                $claimGuid = $params['claim'];
diff --git a/repo/includes/api/SetReference.php 
b/repo/includes/api/SetReference.php
index 17fb5ae..4ed727f 100644
--- a/repo/includes/api/SetReference.php
+++ b/repo/includes/api/SetReference.php
@@ -29,7 +29,7 @@
        /**
         * @var StatementChangeOpFactory
         */
-       protected $statementChangeOpFactory;
+       private $statementChangeOpFactory;
 
        /**
         * @param ApiMain $mainModule
@@ -96,35 +96,29 @@
 
        /**
         * Check the provided parameters
-        *
-        * @since 0.4
         */
-       protected function validateParameters( array $params ) {
+       private function validateParameters( array $params ) {
                if ( !( $this->claimModificationHelper->validateClaimGuid( 
$params['statement'] ) ) ) {
                        $this->dieError( 'Invalid claim guid' , 'invalid-guid' 
);
                }
        }
 
        /**
-        * @since 0.4
-        *
         * @param Statement $claim
         * @param string $referenceHash
         */
-       protected function validateReferenceHash( Statement $claim, 
$referenceHash ) {
+       private function validateReferenceHash( Statement $claim, 
$referenceHash ) {
                if ( !$claim->getReferences()->hasReferenceHash( $referenceHash 
) ) {
                        $this->dieError( "Claim does not have a reference with 
the given hash" , 'no-such-reference' );
                }
        }
 
        /**
-        * @since 0.5
-        *
         * @param string $arrayParam
         *
         * @return array
         */
-       protected function getArrayFromParam( $arrayParam ) {
+       private function getArrayFromParam( $arrayParam ) {
                $rawArray = FormatJson::decode( $arrayParam, true );
 
                if ( !is_array( $rawArray ) || !count( $rawArray ) ) {
@@ -135,8 +129,6 @@
        }
 
        /**
-        * @since 0.3
-        *
         * @param array $rawSnaks array of snaks
         * @param array $snakOrder array of property ids the snaks are supposed 
to be ordered by.
         *
@@ -144,7 +136,7 @@
         *
         * @return SnakList
         */
-       protected function getSnaks( array $rawSnaks, array $snakOrder = 
array() ) {
+       private function getSnaks( array $rawSnaks, array $snakOrder = array() 
) {
                $snaks = new SnakList();
 
                $serializerFactory = new SerializerFactory();
@@ -185,13 +177,11 @@
        }
 
        /**
-        * @since 0.4
-        *
         * @param Reference $reference
         *
         * @return ChangeOpReference
         */
-       protected function getChangeOp( Reference $reference ) {
+       private function getChangeOp( Reference $reference ) {
                $params = $this->extractRequestParams();
 
                $claimGuid = $params['statement'];
diff --git a/repo/includes/api/SetSiteLink.php 
b/repo/includes/api/SetSiteLink.php
index a09e113..67eb3b6 100644
--- a/repo/includes/api/SetSiteLink.php
+++ b/repo/includes/api/SetSiteLink.php
@@ -29,7 +29,7 @@
        /**
         * @var SiteLinkChangeOpFactory
         */
-       protected $siteLinkChangeOpFactory;
+       private $siteLinkChangeOpFactory;
 
        /**
         * @param ApiMain $mainModule
@@ -44,14 +44,13 @@
        }
 
        /**
-        * @since 0.5
-        *
         * Checks whether the link should be removed based on params
         *
         * @param array $params
+        *
         * @return bool
         */
-       protected function shouldRemove( array $params ) {
+       private function shouldRemove( array $params ) {
                if ( $params['linktitle'] === '' || ( !isset( 
$params['linktitle'] ) && !isset( $params['badges'] ) ) ) {
                        return true;
                } else {
@@ -115,12 +114,11 @@
        }
 
        /**
-        * @since 0.4
-        *
         * @param array $params
+        *
         * @return ChangeOpSiteLink
         */
-       protected function getChangeOp( array $params ) {
+       private function getChangeOp( array $params ) {
                wfProfileIn( __METHOD__ );
                if ( $this->shouldRemove( $params ) ) {
                        $linksite = $this->stringNormalizer->trimToNFC( 
$params['linksite'] );

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

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