Consistently name the $this callback variable "$that"
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 25 Apr 2015 03:27:13 +0000 (04:27 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Wed, 13 May 2015 22:05:07 +0000 (23:05 +0100)
Most are already, but some had differnet names. In PHP 5.4+ this is
redundant as they inherit automatically, but we need these for PHP 5.3
compatibility. Settle on "$that" to make these easier to find.

Change-Id: I0b68b2c550fde9c2da53d844421e34b8df0c42ed

includes/filebackend/SwiftFileBackend.php
includes/filerepo/LocalRepo.php
includes/filerepo/file/LocalFile.php
includes/specials/SpecialContributions.php
includes/specials/SpecialDeletedContributions.php
tests/phpunit/includes/libs/ArrayUtilsTest.php
tests/phpunit/includes/site/CachingSiteStoreTest.php
tests/phpunit/includes/site/SiteImporterTest.php

index 5f406c9..d6d7e9e 100644 (file)
@@ -235,16 +235,16 @@ class SwiftFileBackend extends FileBackendStore {
                        'body' => $params['content']
                ) );
 
-               $be = $this;
+               $that = $this;
                $method = __METHOD__;
-               $handler = function ( array $request, Status $status ) use ( $be, $method, $params ) {
+               $handler = function ( array $request, Status $status ) use ( $that, $method, $params ) {
                        list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $request['response'];
                        if ( $rcode === 201 ) {
                                // good
                        } elseif ( $rcode === 412 ) {
                                $status->fatal( 'backend-fail-contenttype', $params['dst'] );
                        } else {
-                               $be->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
+                               $that->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
                        }
                };
 
@@ -298,16 +298,16 @@ class SwiftFileBackend extends FileBackendStore {
                        'body' => $handle // resource
                ) );
 
-               $be = $this;
+               $that = $this;
                $method = __METHOD__;
-               $handler = function ( array $request, Status $status ) use ( $be, $method, $params ) {
+               $handler = function ( array $request, Status $status ) use ( $that, $method, $params ) {
                        list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $request['response'];
                        if ( $rcode === 201 ) {
                                // good
                        } elseif ( $rcode === 412 ) {
                                $status->fatal( 'backend-fail-contenttype', $params['dst'] );
                        } else {
-                               $be->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
+                               $that->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
                        }
                };
 
@@ -347,16 +347,16 @@ class SwiftFileBackend extends FileBackendStore {
                        ) + $this->sanitizeHdrs( $params ), // extra headers merged into object
                ) );
 
-               $be = $this;
+               $that = $this;
                $method = __METHOD__;
-               $handler = function ( array $request, Status $status ) use ( $be, $method, $params ) {
+               $handler = function ( array $request, Status $status ) use ( $that, $method, $params ) {
                        list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $request['response'];
                        if ( $rcode === 201 ) {
                                // good
                        } elseif ( $rcode === 404 ) {
                                $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] );
                        } else {
-                               $be->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
+                               $that->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
                        }
                };
 
@@ -405,9 +405,9 @@ class SwiftFileBackend extends FileBackendStore {
                        );
                }
 
-               $be = $this;
+               $that = $this;
                $method = __METHOD__;
-               $handler = function ( array $request, Status $status ) use ( $be, $method, $params ) {
+               $handler = function ( array $request, Status $status ) use ( $that, $method, $params ) {
                        list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $request['response'];
                        if ( $request['method'] === 'PUT' && $rcode === 201 ) {
                                // good
@@ -416,7 +416,7 @@ class SwiftFileBackend extends FileBackendStore {
                        } elseif ( $rcode === 404 ) {
                                $status->fatal( 'backend-fail-move', $params['src'], $params['dst'] );
                        } else {
-                               $be->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
+                               $that->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
                        }
                };
 
@@ -446,9 +446,9 @@ class SwiftFileBackend extends FileBackendStore {
                        'headers' => array()
                ) );
 
-               $be = $this;
+               $that = $this;
                $method = __METHOD__;
-               $handler = function ( array $request, Status $status ) use ( $be, $method, $params ) {
+               $handler = function ( array $request, Status $status ) use ( $that, $method, $params ) {
                        list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $request['response'];
                        if ( $rcode === 204 ) {
                                // good
@@ -457,7 +457,7 @@ class SwiftFileBackend extends FileBackendStore {
                                        $status->fatal( 'backend-fail-delete', $params['src'] );
                                }
                        } else {
-                               $be->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
+                               $that->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
                        }
                };
 
@@ -505,16 +505,16 @@ class SwiftFileBackend extends FileBackendStore {
                        'headers' => $metaHdrs + $customHdrs
                ) );
 
-               $be = $this;
+               $that = $this;
                $method = __METHOD__;
-               $handler = function ( array $request, Status $status ) use ( $be, $method, $params ) {
+               $handler = function ( array $request, Status $status ) use ( $that, $method, $params ) {
                        list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $request['response'];
                        if ( $rcode === 202 ) {
                                // good
                        } elseif ( $rcode === 404 ) {
                                $status->fatal( 'backend-fail-describe', $params['src'] );
                        } else {
-                               $be->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
+                               $that->onError( $status, $method, $params, $rerr, $rcode, $rdesc );
                        }
                };
 
index 591d684..ef402ea 100644 (file)
@@ -275,14 +275,14 @@ class LocalRepo extends FileRepo {
                        );
                };
 
-               $repo = $this;
+               $that = $this;
                $applyMatchingFiles = function ( ResultWrapper $res, &$searchSet, &$finalFiles )
-                       use ( $repo, $fileMatchesSearch, $flags )
+                       use ( $that, $fileMatchesSearch, $flags )
                {
                        global $wgContLang;
-                       $info = $repo->getInfo();
+                       $info = $that->getInfo();
                        foreach ( $res as $row ) {
-                               $file = $repo->newFileFromRow( $row );
+                               $file = $that->newFileFromRow( $row );
                                // There must have been a search for this DB key, but this has to handle the
                                // cases were title capitalization is different on the client and repo wikis.
                                $dbKeysLook = array( str_replace( ' ', '_', $file->getName() ) );
index e26f739..fe42c2d 100644 (file)
@@ -1603,21 +1603,21 @@ class LocalFile extends File {
 
                // Hack: the lock()/unlock() pair is nested in a transaction so the locking is not
                // tied to BEGIN/COMMIT. To avoid slow purges in the transaction, move them outside.
-               $file = $this;
+               $that = $this;
                $this->getRepo()->getMasterDB()->onTransactionIdle(
-                       function () use ( $file, $archiveNames ) {
+                       function () use ( $that, $archiveNames ) {
                                global $wgUseSquid;
 
-                               $file->purgeEverything();
+                               $that->purgeEverything();
                                foreach ( $archiveNames as $archiveName ) {
-                                       $file->purgeOldThumbnails( $archiveName );
+                                       $that->purgeOldThumbnails( $archiveName );
                                }
 
                                if ( $wgUseSquid ) {
                                        // Purge the squid
                                        $purgeUrls = array();
                                        foreach ( $archiveNames as $archiveName ) {
-                                               $purgeUrls[] = $file->getArchiveUrl( $archiveName );
+                                               $purgeUrls[] = $that->getArchiveUrl( $archiveName );
                                        }
                                        SquidUpdate::purge( $purgeUrls );
                                }
index c2cd812..6b918e9 100644 (file)
@@ -724,7 +724,6 @@ class ContribsPager extends ReverseChronologicalPager {
                        $limit,
                        $descending
                );
-               $pager = $this;
 
                /*
                 * This hook will allow extensions to add in additional queries, so they can get their data
@@ -749,7 +748,7 @@ class ContribsPager extends ReverseChronologicalPager {
                ) );
                Hooks::run(
                        'ContribsPager::reallyDoQuery',
-                       array( &$data, $pager, $offset, $limit, $descending )
+                       array( &$data, $this, $offset, $limit, $descending )
                );
 
                $result = array();
index 9e4bbbe..387c174 100644 (file)
@@ -88,15 +88,13 @@ class DeletedContribsPager extends IndexPager {
         * @return ResultWrapper
         */
        function reallyDoQuery( $offset, $limit, $descending ) {
-               $pager = $this;
-
                $data = array( parent::reallyDoQuery( $offset, $limit, $descending ) );
 
                // This hook will allow extensions to add in additional queries, nearly
                // identical to ContribsPager::reallyDoQuery.
                Hooks::run(
                        'DeletedContribsPager::reallyDoQuery',
-                       array( &$data, $pager, $offset, $limit, $descending )
+                       array( &$data, $this, $offset, $limit, $descending )
                );
 
                $result = array();
index b5ea7b7..a91cc95 100644 (file)
@@ -23,11 +23,11 @@ class ArrayUtilsTest extends PHPUnit_Framework_TestCase {
        }
 
        function provideFindLowerBound() {
-               $self = $this;
-               $indexValueCallback = function ( $size ) use ( $self ) {
-                       return function ( $val ) use ( $self, $size ) {
-                               $self->assertTrue( $val >= 0 );
-                               $self->assertTrue( $val < $size );
+               $that = $this;
+               $indexValueCallback = function ( $size ) use ( $that ) {
+                       return function ( $val ) use ( $that, $size ) {
+                               $that->assertTrue( $val >= 0 );
+                               $that->assertTrue( $val < $size );
                                return $val;
                        };
                };
index d0a7980..4305ceb 100644 (file)
@@ -96,17 +96,17 @@ class CachingSiteStoreTest extends MediaWikiTestCase {
                        ->getMock();
 
                // php 5.3 compatibility!
-               $self = $this;
+               $that = $this;
 
                $dbSiteStore->expects( $this->any() )
                        ->method( 'getSite' )
-                       ->will( $this->returnValue( $self->getTestSite() ) );
+                       ->will( $this->returnValue( $that->getTestSite() ) );
 
                $dbSiteStore->expects( $this->any() )
                        ->method( 'getSites' )
-                       ->will( $this->returnCallback( function() use( $self ) {
+                       ->will( $this->returnCallback( function() use ( $that ) {
                                $siteList = new SiteList();
-                               $siteList->setSite( $self->getTestSite() );
+                               $siteList->setSite( $that->getTestSite() );
 
                                return $siteList;
                        } ) );
index cb0316a..64b195d 100644 (file)
@@ -34,11 +34,11 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase {
        private function newSiteImporter( array $expectedSites, $errorCount ) {
                $store = $this->getMock( 'SiteStore' );
 
-               $self = $this;
+               $that = $this;
                $store->expects( $this->once() )
                        ->method( 'saveSites' )
-                       ->will( $this->returnCallback( function ( $sites ) use ( $expectedSites, $self ) {
-                               $self->assertSitesEqual( $expectedSites, $sites );
+                       ->will( $this->returnCallback( function ( $sites ) use ( $expectedSites, $that ) {
+                               $that->assertSitesEqual( $expectedSites, $sites );
                        } ) );
 
                $store->expects( $this->any() )