jenkins-bot has submitted this change and it was merged.

Change subject: Use callable type-hint in a few places
......................................................................


Use callable type-hint in a few places

Mostly places which immediately had a:
 if ( !is_callable( $callback ) ) {
  throw new Exception(...);
 }
check at the beginning of the function.

Change-Id: Ia78663b2231629010816bd1cda8814b996968d1d
---
M includes/db/DBConnRef.php
M includes/db/Database.php
M includes/db/IDatabase.php
M includes/libs/objectcache/BagOStuff.php
M includes/libs/objectcache/EmptyBagOStuff.php
M includes/libs/objectcache/MemcachedBagOStuff.php
M includes/libs/objectcache/ReplicatedBagOStuff.php
M includes/libs/objectcache/WinCacheBagOStuff.php
M includes/objectcache/SqlBagOStuff.php
9 files changed, 9 insertions(+), 29 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/db/DBConnRef.php b/includes/db/DBConnRef.php
index d73ba85..af5f8f9 100644
--- a/includes/db/DBConnRef.php
+++ b/includes/db/DBConnRef.php
@@ -433,7 +433,7 @@
                return $this->__call( __FUNCTION__, func_get_args() );
        }
 
-       public function doAtomicSection( $fname, $callback ) {
+       public function doAtomicSection( $fname, callable $callback ) {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
 
diff --git a/includes/db/Database.php b/includes/db/Database.php
index 92e89b0..6bdcb24 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -2561,11 +2561,7 @@
                }
        }
 
-       final public function doAtomicSection( $fname, $callback ) {
-               if ( !is_callable( $callback ) ) {
-                       throw new UnexpectedValueException( "Invalid callback." 
);
-               };
-
+       final public function doAtomicSection( $fname, callable $callback ) {
                $this->startAtomic( $fname );
                try {
                        call_user_func_array( $callback, [ $this, $fname ] );
diff --git a/includes/db/IDatabase.php b/includes/db/IDatabase.php
index 710efb2..0a71df2 100644
--- a/includes/db/IDatabase.php
+++ b/includes/db/IDatabase.php
@@ -1313,7 +1313,7 @@
         * @throws UnexpectedValueException
         * @since 1.27
         */
-       public function doAtomicSection( $fname, $callback );
+       public function doAtomicSection( $fname, callable $callback );
 
        /**
         * Begin a transaction. If a transaction is already in progress,
diff --git a/includes/libs/objectcache/BagOStuff.php 
b/includes/libs/objectcache/BagOStuff.php
index dd22d91..1a2711a 100644
--- a/includes/libs/objectcache/BagOStuff.php
+++ b/includes/libs/objectcache/BagOStuff.php
@@ -267,11 +267,7 @@
         * @return bool Success
         * @throws InvalidArgumentException
         */
-       public function merge( $key, $callback, $exptime = 0, $attempts = 10, 
$flags = 0 ) {
-               if ( !is_callable( $callback ) ) {
-                       throw new InvalidArgumentException( "Got invalid 
callback." );
-               }
-
+       public function merge( $key, callable $callback, $exptime = 0, 
$attempts = 10, $flags = 0 ) {
                return $this->mergeViaLock( $key, $callback, $exptime, 
$attempts, $flags );
        }
 
diff --git a/includes/libs/objectcache/EmptyBagOStuff.php 
b/includes/libs/objectcache/EmptyBagOStuff.php
index 4321b25..408212a 100644
--- a/includes/libs/objectcache/EmptyBagOStuff.php
+++ b/includes/libs/objectcache/EmptyBagOStuff.php
@@ -39,7 +39,7 @@
                return true;
        }
 
-       public function merge( $key, $callback, $exptime = 0, $attempts = 10, 
$flags = 0 ) {
+       public function merge( $key, callable $callback, $exptime = 0, 
$attempts = 10, $flags = 0 ) {
                return true; // faster
        }
 }
diff --git a/includes/libs/objectcache/MemcachedBagOStuff.php 
b/includes/libs/objectcache/MemcachedBagOStuff.php
index 7a36214..ba8c736 100644
--- a/includes/libs/objectcache/MemcachedBagOStuff.php
+++ b/includes/libs/objectcache/MemcachedBagOStuff.php
@@ -75,11 +75,7 @@
                        $this->fixExpiry( $exptime ) );
        }
 
-       public function merge( $key, $callback, $exptime = 0, $attempts = 10, 
$flags = 0 ) {
-               if ( !is_callable( $callback ) ) {
-                       throw new Exception( "Got invalid callback." );
-               }
-
+       public function merge( $key, callable $callback, $exptime = 0, 
$attempts = 10, $flags = 0 ) {
                return $this->mergeViaCas( $key, $callback, $exptime, $attempts 
);
        }
 
diff --git a/includes/libs/objectcache/ReplicatedBagOStuff.php 
b/includes/libs/objectcache/ReplicatedBagOStuff.php
index 40ac1bb..5f2c509 100644
--- a/includes/libs/objectcache/ReplicatedBagOStuff.php
+++ b/includes/libs/objectcache/ReplicatedBagOStuff.php
@@ -112,7 +112,7 @@
                return $this->writeStore->unlock( $key );
        }
 
-       public function merge( $key, $callback, $exptime = 0, $attempts = 10, 
$flags = 0 ) {
+       public function merge( $key, callable $callback, $exptime = 0, 
$attempts = 10, $flags = 0 ) {
                return $this->writeStore->merge( $key, $callback, $exptime, 
$attempts, $flags );
        }
 
diff --git a/includes/libs/objectcache/WinCacheBagOStuff.php 
b/includes/libs/objectcache/WinCacheBagOStuff.php
index 3d72abe..19cc66a 100644
--- a/includes/libs/objectcache/WinCacheBagOStuff.php
+++ b/includes/libs/objectcache/WinCacheBagOStuff.php
@@ -64,11 +64,7 @@
                return true;
        }
 
-       public function merge( $key, $callback, $exptime = 0, $attempts = 10, 
$flags = 0 ) {
-               if ( !is_callable( $callback ) ) {
-                       throw new Exception( "Got invalid callback." );
-               }
-
+       public function merge( $key, callable $callback, $exptime = 0, 
$attempts = 10, $flags = 0 ) {
                return $this->mergeViaCas( $key, $callback, $exptime, $attempts 
);
        }
 }
diff --git a/includes/objectcache/SqlBagOStuff.php 
b/includes/objectcache/SqlBagOStuff.php
index a1394c1..98b6eb9 100644
--- a/includes/objectcache/SqlBagOStuff.php
+++ b/includes/objectcache/SqlBagOStuff.php
@@ -459,11 +459,7 @@
                return $newValue;
        }
 
-       public function merge( $key, $callback, $exptime = 0, $attempts = 10, 
$flags = 0 ) {
-               if ( !is_callable( $callback ) ) {
-                       throw new Exception( "Got invalid callback." );
-               }
-
+       public function merge( $key, callable $callback, $exptime = 0, 
$attempts = 10, $flags = 0 ) {
                $ok = $this->mergeViaCas( $key, $callback, $exptime, $attempts 
);
                if ( ( $flags & self::WRITE_SYNC ) == self::WRITE_SYNC ) {
                        $ok = $ok && $this->waitForSlaves();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia78663b2231629010816bd1cda8814b996968d1d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to