Removed Closure type hints where not needed.
authorTyler Anthony Romeo <tylerromeo@gmail.com>
Fri, 15 Mar 2013 02:09:14 +0000 (22:09 -0400)
committerAlex Monk <krenair@gmail.com>
Sun, 19 May 2013 17:09:52 +0000 (17:09 +0000)
Closures are not the only types of callable objects in PHP.
Specifically, any string referencing a valid function, any object with a __call(),
or any class with a __callStatic() can all be called.
Therefore, removed type hinting for Closures in places where a callable is expected.
(Unfortunately, the callable type-hint only comes in PHP 5.4.)

Change-Id: I6bff7e4a95716ef63aa7e07d3d9fef6d20eb65a6

includes/MappedIterator.php
includes/ScopedCallback.php
includes/db/Database.php

index b4376f4..14495f2 100644 (file)
@@ -29,7 +29,7 @@
 class MappedIterator implements Iterator {
        /** @var Iterator */
        protected $baseIterator;
-       /** @var Closure */
+       /** @var callable */
        protected $vCallback;
 
        /**
@@ -39,10 +39,10 @@ class MappedIterator implements Iterator {
         * The keys of the base iterator are reused verbatim.
         *
         * @param Iterator|Array $iter
-        * @param Closure $vCallback
+        * @param callable $vCallback
         * @throws MWException
         */
-    public function __construct( $iter, Closure $vCallback ) {
+       public function __construct( $iter, $vCallback ) {
                if ( is_array( $iter ) ) {
                        $this->baseIterator = new ArrayIterator( $iter );
                } elseif ( $iter instanceof Iterator ) {
@@ -51,7 +51,7 @@ class MappedIterator implements Iterator {
                        throw new MWException( "Invalid base iterator provided." );
                }
                $this->vCallback = $vCallback;
-    }
+       }
 
        /**
         * @return void
index 8ecd874..fa88c0e 100644 (file)
  * @since 1.21
  */
 class ScopedCallback {
-       /** @var Closure */
+       /** @var callable */
        protected $callback;
 
        /**
-        * @param $callback Closure
+        * @param callable $callback
         */
-       public function __construct( Closure $callback ) {
+       public function __construct( $callback ) {
                $this->callback = $callback;
        }
 
index 09866dc..799e168 100644 (file)
@@ -229,9 +229,9 @@ abstract class DatabaseBase implements DatabaseType {
        protected $mConn = null;
        protected $mOpened = false;
 
-       /** @var array of Closure */
+       /** @var callable[] */
        protected $mTrxIdleCallbacks = array();
-       /** @var array of Closure */
+       /** @var callable[] */
        protected $mTrxPreCommitCallbacks = array();
 
        protected $mTablePrefix;
@@ -2966,10 +2966,10 @@ abstract class DatabaseBase implements DatabaseType {
         * after the database is updated so that the jobs will see the data when they actually run.
         * It can also be used for updates that easily cause deadlocks if locks are held too long.
         *
-        * @param Closure $callback
+        * @param callable $callback
         * @since 1.20
         */
-       final public function onTransactionIdle( Closure $callback ) {
+       final public function onTransactionIdle( $callback ) {
                $this->mTrxIdleCallbacks[] = $callback;
                if ( !$this->mTrxLevel ) {
                        $this->runOnTransactionIdleCallbacks();
@@ -2984,10 +2984,10 @@ abstract class DatabaseBase implements DatabaseType {
         * This is useful for updates that easily cause deadlocks if locks are held too long
         * but where atomicity is strongly desired for these updates and some related updates.
         *
-        * @param Closure $callback
+        * @param callable $callback
         * @since 1.22
         */
-       final public function onTransactionPreCommitOrIdle( Closure $callback ) {
+       final public function onTransactionPreCommitOrIdle( $callback ) {
                if ( $this->mTrxLevel ) {
                        $this->mTrxPreCommitCallbacks[] = $callback;
                } else {