Ejegg has uploaded a new change for review.

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

Change subject: More type hints in extras, no passing objects by ref
......................................................................

More type hints in extras, no passing objects by ref

&$this should never be necessary

Change-Id: I920dee6bf1e9286b4f83e361e67073366d595fad
---
M extras/banner_history/BannerHistoryLogIdProcessor.php
M extras/conversion_log/conversion_log.body.php
M extras/custom_filters/custom_filters.body.php
M extras/custom_filters/filters/functions/functions.body.php
M extras/custom_filters/filters/ip_velocity/ip_velocity.body.php
M extras/custom_filters/filters/minfraud/minfraud.body.php
M extras/custom_filters/filters/referrer/referrer.body.php
M extras/custom_filters/filters/source/source.body.php
M extras/extras.body.php
M extras/session_velocity/session_velocity.body.php
M gateway_common/gateway.adapter.php
11 files changed, 100 insertions(+), 44 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/87/277687/1

diff --git a/extras/banner_history/BannerHistoryLogIdProcessor.php 
b/extras/banner_history/BannerHistoryLogIdProcessor.php
index 9f620c9..20fa9a5 100644
--- a/extras/banner_history/BannerHistoryLogIdProcessor.php
+++ b/extras/banner_history/BannerHistoryLogIdProcessor.php
@@ -22,7 +22,7 @@
         */
        protected $gatewayAdapter;
 
-       protected static function singleton( $gatewayAdapter ) {
+       protected static function singleton( GatewayType $gatewayAdapter ) {
                static $instance;
 
                if ( !$instance ) {
@@ -31,7 +31,7 @@
                return $instance;
        }
 
-       protected function __construct( $gatewayAdapter ) {
+       protected function __construct( GatewayType $gatewayAdapter ) {
                $this->gatewayAdapter = $gatewayAdapter;
 
                $this->logger = DonationLoggerFactory::getLogger(
@@ -80,9 +80,9 @@
         * Handler for the GatewayReady hook. This is the class's entry point.
         *
         * @param GatewayType $gatewayAdapter
-        * @param DonationData $donationData
+        * @return bool always true
         */
-       public static function onGatewayReady( $gatewayAdapter ) {
+       public static function onGatewayReady( GatewayType $gatewayAdapter ) {
 
                self::singleton( $gatewayAdapter )
                        ->queueAssociationOfIds();
diff --git a/extras/conversion_log/conversion_log.body.php 
b/extras/conversion_log/conversion_log.body.php
index a41fdf8..585dfaa 100644
--- a/extras/conversion_log/conversion_log.body.php
+++ b/extras/conversion_log/conversion_log.body.php
@@ -33,7 +33,7 @@
                return true;
        }
 
-       static function onPostProcess( GatewayType &$gateway_adapter ) {
+       static function onPostProcess( GatewayType $gateway_adapter ) {
                if ( !$gateway_adapter->getGlobal( 'EnableConversionLog' ) ) {
                        return true;
                }
@@ -41,7 +41,7 @@
                return self::singleton( $gateway_adapter )->post_process();
        }
 
-       static function singleton( GatewayType &$gateway_adapter ) {
+       static function singleton( GatewayType $gateway_adapter ) {
                if ( !self::$instance ) {
                        self::$instance = new self( $gateway_adapter );
                }
diff --git a/extras/custom_filters/custom_filters.body.php 
b/extras/custom_filters/custom_filters.body.php
index 6ee5f71..86855b1 100644
--- a/extras/custom_filters/custom_filters.body.php
+++ b/extras/custom_filters/custom_filters.body.php
@@ -33,7 +33,7 @@
         */
        protected $fraud_logger;
 
-       public function __construct( GatewayType &$gateway_adapter ) {
+       public function __construct( GatewayType $gateway_adapter ) {
                parent::__construct( $gateway_adapter ); //gateway_adapter is 
set in there. 
                // load user action ranges and risk score               
                $this->action_ranges = $this->gateway_adapter->getGlobal( 
'CustomFiltersActionRanges' );
@@ -110,7 +110,7 @@
         */
        public function validate() {
                // expose a hook for custom filters
-               WmfFramework::runHooks( 'GatewayCustomFilter', array( 
&$this->gateway_adapter, &$this ) );
+               WmfFramework::runHooks( 'GatewayCustomFilter', array( 
$this->gateway_adapter, $this ) );
                $localAction = $this->determineAction();
                $this->gateway_adapter->setValidationAction( $localAction );
 
@@ -153,7 +153,7 @@
                return TRUE;
        }
 
-       static function onValidate( &$gateway_adapter ) {
+       static function onValidate( GatewayType $gateway_adapter ) {
                if ( !$gateway_adapter->getGlobal( 'EnableCustomFilters' ) ){
                        return true;
                }
@@ -161,7 +161,7 @@
                return self::singleton( $gateway_adapter )->validate();
        }
 
-       static function singleton( &$gateway_adapter ) {
+       static function singleton( GatewayType $gateway_adapter ) {
                if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter );
                }
diff --git a/extras/custom_filters/filters/functions/functions.body.php 
b/extras/custom_filters/filters/functions/functions.body.php
index ba80abd..ce95614 100644
--- a/extras/custom_filters/filters/functions/functions.body.php
+++ b/extras/custom_filters/filters/functions/functions.body.php
@@ -14,9 +14,13 @@
         */
        public $cfo;
 
-       public function __construct( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
+       public function __construct(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                parent::__construct( $gateway_adapter );
-               $this->cfo = & $custom_filter_object;
+               $this->cfo = $custom_filter_object;
        }
 
        /**
@@ -47,7 +51,11 @@
                return TRUE;
        }
 
-       static function onFilter( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
+       static function onFilter(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                if ( !$gateway_adapter->getGlobal( 'EnableFunctionsFilter' ) ||
                        !count( $gateway_adapter->getGlobal( 
'CustomFiltersFunctions' ) ) ){
                        return true;
@@ -56,7 +64,11 @@
                return self::singleton( $gateway_adapter, $custom_filter_object 
)->filter();
        }
 
-       static function singleton( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
+       static function singleton(
+               GatewayType $gateway_adapter,
+               $custom_filter_object
+       ) {
+
                if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter, 
$custom_filter_object );
                }
diff --git a/extras/custom_filters/filters/ip_velocity/ip_velocity.body.php 
b/extras/custom_filters/filters/ip_velocity/ip_velocity.body.php
index a65de70..dbaa524 100644
--- a/extras/custom_filters/filters/ip_velocity/ip_velocity.body.php
+++ b/extras/custom_filters/filters/ip_velocity/ip_velocity.body.php
@@ -20,9 +20,13 @@
         */
        protected $cache_obj;
 
-       public function __construct( GatewayType &$gateway_adapter, 
&$custom_filter_object = null ) {
+       public function __construct(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                parent::__construct( $gateway_adapter );
-               $this->cfo = & $custom_filter_object;
+               $this->cfo = $custom_filter_object;
        }
 
        public function filter() {
@@ -152,7 +156,7 @@
        }
        
 
-       static function onFilter( &$gateway_adapter, &$custom_filter_object ) {
+       static function onFilter( $gateway_adapter, $custom_filter_object ) {
                if ( !$gateway_adapter->getGlobal( 'EnableIPVelocityFilter' ) ){
                        return true;
                }
@@ -160,7 +164,7 @@
                return self::singleton( $gateway_adapter, $custom_filter_object 
)->filter();
        }
        
-       static function onPostProcess( GatewayType &$gateway_adapter ) {
+       static function onPostProcess( GatewayType $gateway_adapter ) {
                if ( !$gateway_adapter->getGlobal( 'EnableIPVelocityFilter' ) ){
                        return true;
                }
@@ -169,7 +173,11 @@
                return self::singleton( $gateway_adapter, $dummy 
)->postProcess();
        }
 
-       static function singleton( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
+       static function singleton(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter, 
$custom_filter_object );
                }
@@ -180,8 +188,9 @@
         * Add a hit to this IP's history for a toxic card.  This is designed 
to be
         * called outside of the usual filter callbacks so we record nasty 
attempts
         * even when the filters aren't called.
+        * @param GatewayType $gateway adapter instance with user_ip set
         */
-       public static function penalize( GatewayType &$gateway ) {
+       public static function penalize( GatewayType $gateway ) {
                $logger = DonationLoggerFactory::getLogger( $gateway );
                $logger->info( 'IPVelocityFilter penalizing IP address '
                        . $gateway->getData_Unstaged_Escaped( 'user_ip' )
diff --git a/extras/custom_filters/filters/minfraud/minfraud.body.php 
b/extras/custom_filters/filters/minfraud/minfraud.body.php
index f3307a3..31d724e 100644
--- a/extras/custom_filters/filters/minfraud/minfraud.body.php
+++ b/extras/custom_filters/filters/minfraud/minfraud.body.php
@@ -98,12 +98,16 @@
         * @param string            $license_key        The license key. May 
also be set in $wgMinFraudLicenseKey
         * @throws RuntimeException
         */
-       public function __construct( GatewayType &$gateway_adapter, 
&$custom_filter_object, $license_key = NULL ) {
+       public function __construct(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object,
+               $license_key = NULL
+       ) {
 
                parent::__construct( $gateway_adapter );
                $this->fraud_logger = DonationLoggerFactory::getLogger( 
$gateway_adapter, '_fraud' );
 
-               $this->cfo = &$custom_filter_object;
+               $this->cfo = $custom_filter_object;
 
                global $wgMinFraudLicenseKey;
 
@@ -337,8 +341,11 @@
         *
         * @return true
         */
-       public static function onFilter( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
-               
+       public static function onFilter(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                if ( !$gateway_adapter->getGlobal( 'EnableMinfraud' ) ){
                        return true;
                }
@@ -375,7 +382,11 @@
         *
         * @return Gateway_Extras_CustomFilters_MinFraud
         */
-       public static function singleton( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
+       public static function singleton(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter, 
$custom_filter_object );
                }
@@ -388,7 +399,7 @@
         * Right now this only checks the number of queries remaining.
         */
        protected function health_check() {
-               global $wgEmergencyContact, $wgServerName, $wgMemc;
+               global $wgEmergencyContact, $wgMemc;
 
                if ( array_key_exists( 'queriesRemaining', 
$this->minfraudResponse ) ) {
                        $queries = intval( 
$this->minfraudResponse['queriesRemaining'] );
diff --git a/extras/custom_filters/filters/referrer/referrer.body.php 
b/extras/custom_filters/filters/referrer/referrer.body.php
index 48f804b..c30425c 100644
--- a/extras/custom_filters/filters/referrer/referrer.body.php
+++ b/extras/custom_filters/filters/referrer/referrer.body.php
@@ -14,9 +14,13 @@
         */
        public $cfo;
 
-       public function __construct( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
+       public function __construct(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                parent::__construct( $gateway_adapter );
-               $this->cfo = & $custom_filter_object;
+               $this->cfo = $custom_filter_object;
        }
 
        public function filter() {
@@ -47,7 +51,11 @@
                return TRUE;
        }
 
-       static function onFilter( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
+       static function onFilter(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                if ( !$gateway_adapter->getGlobal( 'EnableReferrerFilter' ) ||
                        !count( $gateway_adapter->getGlobal( 
'CustomFiltersRefRules' ) ) ){
                        return true;
@@ -56,7 +64,11 @@
                return self::singleton( $gateway_adapter, $custom_filter_object 
)->filter();
        }
 
-       static function singleton( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
+       static function singleton(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter, 
$custom_filter_object );
                }
diff --git a/extras/custom_filters/filters/source/source.body.php 
b/extras/custom_filters/filters/source/source.body.php
index 7567e5e..56feeec 100644
--- a/extras/custom_filters/filters/source/source.body.php
+++ b/extras/custom_filters/filters/source/source.body.php
@@ -14,9 +14,13 @@
         */
        public $cfo;
 
-       public function __construct( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
+       public function __construct(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                parent::__construct( $gateway_adapter );
-               $this->cfo = & $custom_filter_object;
+               $this->cfo = $custom_filter_object;
        }
 
        public function filter() {
@@ -46,7 +50,11 @@
                return TRUE;
        }
 
-       static function onFilter( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
+       static function onFilter(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                if ( !$gateway_adapter->getGlobal( 'EnableSourceFilter' ) ||
                        !count( $gateway_adapter->getGlobal( 
'CustomFiltersSrcRules' ) ) ){
                        return true;
@@ -55,7 +63,11 @@
                return self::singleton( $gateway_adapter, $custom_filter_object 
)->filter();
        }
 
-       static function singleton( GatewayType &$gateway_adapter, 
&$custom_filter_object ) {
+       static function singleton(
+               GatewayType $gateway_adapter,
+               Gateway_Extras_CustomFilters $custom_filter_object
+       ) {
+
                if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter, 
$custom_filter_object );
                }
diff --git a/extras/extras.body.php b/extras/extras.body.php
index 4ae9f17..1736532 100644
--- a/extras/extras.body.php
+++ b/extras/extras.body.php
@@ -23,8 +23,8 @@
         */
        protected $gateway_logger;
 
-       public function __construct( GatewayType &$gateway_adapter ) {
-               $this->gateway_adapter = &$gateway_adapter;
+       public function __construct( GatewayType $gateway_adapter ) {
+               $this->gateway_adapter = $gateway_adapter;
                $this->transaction_logger = DonationLoggerFactory::getLogger( 
$this->gateway_adapter, '_trxn' );
                $this->gateway_logger = DonationLoggerFactory::getLogger( 
$this->gateway_adapter );
        }
diff --git a/extras/session_velocity/session_velocity.body.php 
b/extras/session_velocity/session_velocity.body.php
index ca288ad..7c09276 100644
--- a/extras/session_velocity/session_velocity.body.php
+++ b/extras/session_velocity/session_velocity.body.php
@@ -40,7 +40,7 @@
         *
         * @return Gateway_Extras_SessionVelocityFilter
         */
-       private static function singleton( GatewayType &$gateway_adapter ) {
+       private static function singleton( GatewayType $gateway_adapter ) {
                if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter );
                }
@@ -55,7 +55,7 @@
         * @return bool Filter chain termination on FALSE. Also indicates that 
the cURL transaction
         *  should not be performed.
         */
-       public static function onCurlInit( GatewayType &$gateway_adapter ) {
+       public static function onCurlInit( GatewayType $gateway_adapter ) {
                if ( !$gateway_adapter->getGlobal( 
'EnableSessionVelocityFilter' ) ){
                        return true;
                }
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index b1f70a8..bf3ecef 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -1187,7 +1187,7 @@
                // Initialize cURL and construct operation (also run hook)
                $ch = curl_init();
 
-               $hookResult = WmfFramework::runHooks( 
'DonationInterfaceCurlInit', array( &$this ) );
+               $hookResult = WmfFramework::runHooks( 
'DonationInterfaceCurlInit', array( $this ) );
                if ( $hookResult == false ) {
                        $this->logger->info( 'cURL transaction aborted on hook 
DonationInterfaceCurlInit' );
                        $this->setValidationAction( 'reject' );
@@ -2184,7 +2184,7 @@
                }
                // allow any external validators to have their way with the data
                $this->logger->info( 'Preparing to run custom filters' );
-               WmfFramework::runHooks( 'GatewayValidate', array( &$this ) );
+               WmfFramework::runHooks( 'GatewayValidate', array( $this ) );
                $this->logger->info( 'Finished running custom filters' );
 
                //DO NOT set some variable as getValidationAction() here, and 
keep
@@ -2193,19 +2193,19 @@
                // if the transaction was flagged for review
                if ( $this->getValidationAction() == 'review' ) {
                        // expose a hook for external handling of trxns flagged 
for review
-                       WmfFramework::runHooks( 'GatewayReview', array( &$this 
) );
+                       WmfFramework::runHooks( 'GatewayReview', array( $this ) 
);
                }
 
                // if the transaction was flagged to be 'challenged'
                if ( $this->getValidationAction() == 'challenge' ) {
                        // expose a hook for external handling of trxns flagged 
for challenge (eg captcha)
-                       WmfFramework::runHooks( 'GatewayChallenge', array( 
&$this ) );
+                       WmfFramework::runHooks( 'GatewayChallenge', array( 
$this ) );
                }
 
                // if the transaction was flagged for rejection
                if ( $this->getValidationAction() == 'reject' ) {
                        // expose a hook for external handling of trxns flagged 
for rejection
-                       WmfFramework::runHooks( 'GatewayReject', array( &$this 
) );
+                       WmfFramework::runHooks( 'GatewayReject', array( $this ) 
);
                }
        }
 
@@ -2218,7 +2218,7 @@
         */
        protected function runPostProcessHooks() {
                // expose a hook for any post processing
-               WmfFramework::runHooks( 'GatewayPostProcess', array( &$this ) );
+               WmfFramework::runHooks( 'GatewayPostProcess', array( $this ) );
 
                try {
                        $this->doStompTransaction();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I920dee6bf1e9286b4f83e361e67073366d595fad
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>

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

Reply via email to