From: Timo Tijhof Date: Sat, 25 Apr 2015 03:27:13 +0000 (+0100) Subject: Consistently name the $this callback variable "$that" X-Git-Tag: 1.31.0-rc.0~11414 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/%22%24ccApp/ecrire?a=commitdiff_plain;h=19bff2537ed3344a763300f51d713b8e2e3a362c;p=lhc%2Fweb%2Fwiklou.git Consistently name the $this callback variable "$that" 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 --- diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index 5f406c9be0..d6d7e9e77a 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -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 ); } }; diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index 591d684ab9..ef402ea984 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -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() ) ); diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index e26f739402..fe42c2d81c 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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 ); } diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index c2cd8122d6..6b918e9594 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -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(); diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index 9e4bbbe532..387c174a82 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -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(); diff --git a/tests/phpunit/includes/libs/ArrayUtilsTest.php b/tests/phpunit/includes/libs/ArrayUtilsTest.php index b5ea7b7259..a91cc950d6 100644 --- a/tests/phpunit/includes/libs/ArrayUtilsTest.php +++ b/tests/phpunit/includes/libs/ArrayUtilsTest.php @@ -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; }; }; diff --git a/tests/phpunit/includes/site/CachingSiteStoreTest.php b/tests/phpunit/includes/site/CachingSiteStoreTest.php index d0a798032d..4305ceb94c 100644 --- a/tests/phpunit/includes/site/CachingSiteStoreTest.php +++ b/tests/phpunit/includes/site/CachingSiteStoreTest.php @@ -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; } ) ); diff --git a/tests/phpunit/includes/site/SiteImporterTest.php b/tests/phpunit/includes/site/SiteImporterTest.php index cb0316ab25..64b195d823 100644 --- a/tests/phpunit/includes/site/SiteImporterTest.php +++ b/tests/phpunit/includes/site/SiteImporterTest.php @@ -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() )