Drop compatibility with PHP 5.3
authorMatěj Suchánek <matejsuchanek97@gmail.com>
Sat, 2 Sep 2017 18:01:44 +0000 (20:01 +0200)
committerMatěj Suchánek <matejsuchanek97@gmail.com>
Sat, 2 Sep 2017 18:39:13 +0000 (20:39 +0200)
Since 5.4, $this works inside closures.

Change-Id: I6987f76a1e33d6d7ab020a57186e5477186bbf2e

includes/filerepo/LocalRepo.php
includes/filerepo/file/File.php
includes/page/WikiPage.php
includes/skins/Skin.php
tests/phpunit/includes/changes/ChangesListStringOptionsFilterGroupTest.php

index 20d51c2..ed00793 100644 (file)
@@ -274,14 +274,13 @@ class LocalRepo extends FileRepo {
                        );
                };
 
                        );
                };
 
-               $that = $this;
                $applyMatchingFiles = function ( ResultWrapper $res, &$searchSet, &$finalFiles )
                $applyMatchingFiles = function ( ResultWrapper $res, &$searchSet, &$finalFiles )
-                       use ( $that, $fileMatchesSearch, $flags )
+                       use ( $fileMatchesSearch, $flags )
                {
                        global $wgContLang;
                {
                        global $wgContLang;
-                       $info = $that->getInfo();
+                       $info = $this->getInfo();
                        foreach ( $res as $row ) {
                        foreach ( $res as $row ) {
-                               $file = $that->newFileFromRow( $row );
+                               $file = $this->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 = [ strtr( $file->getName(), ' ', '_' ) ];
                                // 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 = [ strtr( $file->getName(), ' ', '_' ) ];
index 460fe51..4ea0973 100644 (file)
@@ -1282,11 +1282,10 @@ abstract class File implements IDBAccessObject {
                // Thumbnailing a very large file could result in network saturation if
                // everyone does it at once.
                if ( $this->getSize() >= 1e7 ) { // 10MB
                // Thumbnailing a very large file could result in network saturation if
                // everyone does it at once.
                if ( $this->getSize() >= 1e7 ) { // 10MB
-                       $that = $this;
                        $work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $this->getName() ),
                                [
                        $work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $this->getName() ),
                                [
-                                       'doWork' => function () use ( $that ) {
-                                               return $that->getLocalRefPath();
+                                       'doWork' => function () {
+                                               return $this->getLocalRefPath();
                                        }
                                ]
                        );
                                        }
                                ]
                        );
index 5f6e455..5a0670c 100644 (file)
@@ -878,11 +878,10 @@ class WikiPage implements Page, IDBAccessObject {
                }
 
                // Update the DB post-send if the page has not cached since now
                }
 
                // Update the DB post-send if the page has not cached since now
-               $that = $this;
                $latest = $this->getLatest();
                DeferredUpdates::addCallableUpdate(
                $latest = $this->getLatest();
                DeferredUpdates::addCallableUpdate(
-                       function () use ( $that, $retval, $latest ) {
-                               $that->insertRedirectEntry( $retval, $latest );
+                       function () use ( $retval, $latest ) {
+                               $this->insertRedirectEntry( $retval, $latest );
                        },
                        DeferredUpdates::POSTSEND,
                        wfGetDB( DB_MASTER )
                        },
                        DeferredUpdates::POSTSEND,
                        wfGetDB( DB_MASTER )
index e1d0034..df7a9ed 100644 (file)
@@ -1251,11 +1251,10 @@ abstract class Skin extends ContextSource {
        function buildSidebar() {
                global $wgEnableSidebarCache, $wgSidebarCacheExpiry;
 
        function buildSidebar() {
                global $wgEnableSidebarCache, $wgSidebarCacheExpiry;
 
-               $that = $this;
-               $callback = function () use ( $that ) {
+               $callback = function () {
                        $bar = [];
                        $bar = [];
-                       $that->addToSidebar( $bar, 'sidebar' );
-                       Hooks::run( 'SkinBuildSidebar', [ $that, &$bar ] );
+                       $this->addToSidebar( $bar, 'sidebar' );
+                       Hooks::run( 'SkinBuildSidebar', [ $this, &$bar ] );
 
                        return $bar;
                };
 
                        return $bar;
                };
index 04b7ee0..4f917e9 100644 (file)
@@ -40,8 +40,6 @@ class ChangesListStringOptionsFilterGroupTest extends MediaWikiTestCase {
         * @dataProvider provideModifyQuery
         */
        public function testModifyQuery( $filterDefinitions, $expectedValues, $input ) {
         * @dataProvider provideModifyQuery
         */
        public function testModifyQuery( $filterDefinitions, $expectedValues, $input ) {
-               $self = $this;
-
                $queryCallable = function (
                        $className,
                        $ctx,
                $queryCallable = function (
                        $className,
                        $ctx,
@@ -52,8 +50,8 @@ class ChangesListStringOptionsFilterGroupTest extends MediaWikiTestCase {
                        &$query_options,
                        &$join_conds,
                        $actualSelectedValues
                        &$query_options,
                        &$join_conds,
                        $actualSelectedValues
-               ) use ( $self, $expectedValues ) {
-                       $self->assertSame(
+               ) use ( $expectedValues ) {
+                       $this->assertSame(
                                $expectedValues,
                                $actualSelectedValues
                        );
                                $expectedValues,
                                $actualSelectedValues
                        );