From: Max Semenik Date: Sat, 9 Jun 2018 23:26:32 +0000 (-0700) Subject: Get rid of call_user_func(_array)(), part 3 X-Git-Tag: 1.34.0-rc.0~5130^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=1e680456b4b2f5f2a33df4acceafc03d6c8f75b1 Get rid of call_user_func(_array)(), part 3 Also cleaned up nearby code in a couple places. Change-Id: Ibf44ee7c0ceb739d7e79406e4ff39303c316e285 --- diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php index 6bd179a9da..8e77956e82 100644 --- a/includes/SiteConfiguration.php +++ b/includes/SiteConfiguration.php @@ -432,7 +432,7 @@ class SiteConfiguration { return $default; } - $ret = call_user_func_array( $this->siteParamsCallback, [ $this, $wiki ] ); + $ret = ( $this->siteParamsCallback )( $this, $wiki ); # Validate the returned value if ( !is_array( $ret ) ) { return $default; @@ -606,7 +606,7 @@ class SiteConfiguration { public function loadFullData() { if ( $this->fullLoadCallback && !$this->fullLoadDone ) { - call_user_func( $this->fullLoadCallback, $this ); + ( $this->fullLoadCallback )( $this ); $this->fullLoadDone = true; } } diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php index 005618126c..7dd8b25cef 100644 --- a/includes/filerepo/RepoGroup.php +++ b/includes/filerepo/RepoGroup.php @@ -372,8 +372,7 @@ class RepoGroup { $this->initialiseRepos(); } foreach ( $this->foreignRepos as $repo ) { - $args = array_merge( [ $repo ], $params ); - if ( call_user_func_array( $callback, $args ) ) { + if ( $callback( $repo, ...$params ) ) { return true; } } diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index cd4d4b749f..a70157572a 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -81,12 +81,9 @@ abstract class HTMLFormField { $args = func_get_args(); if ( $this->mParent ) { - $callback = [ $this->mParent, 'msg' ]; - } else { - $callback = 'wfMessage'; + return $this->mParent->msg( ...$args ); } - - return call_user_func_array( $callback, $args ); + return wfMessage( ...$args ); } /** @@ -315,7 +312,7 @@ abstract class HTMLFormField { } if ( isset( $this->mValidationCallback ) ) { - return call_user_func( $this->mValidationCallback, $value, $alldata, $this->mParent ); + return ( $this->mValidationCallback )( $value, $alldata, $this->mParent ); } return true; @@ -323,7 +320,7 @@ abstract class HTMLFormField { public function filter( $value, $alldata ) { if ( isset( $this->mFilterCallback ) ) { - $value = call_user_func( $this->mFilterCallback, $value, $alldata, $this->mParent ); + $value = ( $this->mFilterCallback )( $value, $alldata, $this->mParent ); } return $value; diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 4fc04db12b..1cd76b9565 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -410,9 +410,9 @@ abstract class DatabaseUpdater { foreach ( $updates as $funcList ) { $func = $funcList[0]; - $arg = $funcList[1]; + $args = $funcList[1]; $origParams = $funcList[2]; - call_user_func_array( $func, $arg ); + $func( ...$args ); flush(); $this->updatesSkipped[] = $origParams; } @@ -479,7 +479,7 @@ abstract class DatabaseUpdater { } elseif ( $passSelf ) { array_unshift( $params, $this ); } - $ret = call_user_func_array( $func, $params ); + $ret = $func( ...$params ); flush(); if ( $ret !== false ) { $updatesDone[] = $origParams; diff --git a/includes/libs/ArrayUtils.php b/includes/libs/ArrayUtils.php index 0413ea0d5a..e23888779f 100644 --- a/includes/libs/ArrayUtils.php +++ b/includes/libs/ArrayUtils.php @@ -120,8 +120,8 @@ class ArrayUtils { $max = $valueCount; do { $mid = $min + ( ( $max - $min ) >> 1 ); - $item = call_user_func( $valueCallback, $mid ); - $comparison = call_user_func( $comparisonCallback, $target, $item ); + $item = $valueCallback( $mid ); + $comparison = $comparisonCallback( $target, $item ); if ( $comparison > 0 ) { $min = $mid; } elseif ( $comparison == 0 ) { @@ -133,8 +133,8 @@ class ArrayUtils { } while ( $min < $max - 1 ); if ( $min == 0 ) { - $item = call_user_func( $valueCallback, $min ); - $comparison = call_user_func( $comparisonCallback, $target, $item ); + $item = $valueCallback( $min ); + $comparison = $comparisonCallback( $target, $item ); if ( $comparison < 0 ) { // Before the first item return false; @@ -168,7 +168,7 @@ class ArrayUtils { $args[] = $array[$key]; } } - $valueret = call_user_func_array( __METHOD__, $args ); + $valueret = self::arrayDiffAssocRecursive( ...$args ); if ( count( $valueret ) ) { $ret[$key] = $valueret; } diff --git a/includes/libs/MemoizedCallable.php b/includes/libs/MemoizedCallable.php index 14462f1d9f..e9d1fc1ca3 100644 --- a/includes/libs/MemoizedCallable.php +++ b/includes/libs/MemoizedCallable.php @@ -123,7 +123,7 @@ class MemoizedCallable { $success = false; $result = $this->fetchResult( $key, $success ); if ( !$success ) { - $result = call_user_func_array( $this->callable, $args ); + $result = ( $this->callable )( ...$args ); $this->storeResult( $key, $result ); } diff --git a/includes/libs/StringUtils.php b/includes/libs/StringUtils.php index 7915ccf191..d91ac85adb 100644 --- a/includes/libs/StringUtils.php +++ b/includes/libs/StringUtils.php @@ -206,7 +206,7 @@ class StringUtils { } elseif ( $tokenType == 'end' ) { if ( $foundStart ) { # Found match - $output .= call_user_func( $callback, [ + $output .= $callback( [ substr( $subject, $outputPos, $tokenOffset + $tokenLength - $outputPos ), substr( $subject, $contentPos, $tokenOffset - $contentPos ) ] ); diff --git a/includes/libs/filebackend/SwiftFileBackend.php b/includes/libs/filebackend/SwiftFileBackend.php index 3cd973ea48..2f7bc1ef8f 100644 --- a/includes/libs/filebackend/SwiftFileBackend.php +++ b/includes/libs/filebackend/SwiftFileBackend.php @@ -1103,7 +1103,7 @@ class SwiftFileBackend extends FileBackendStore { if ( empty( $params['allowOB'] ) ) { // Cancel output buffering and gzipping if set - call_user_func( $this->obResetFunc ); + ( $this->obResetFunc )(); } $handle = fopen( 'php://output', 'wb' ); @@ -1317,7 +1317,7 @@ class SwiftFileBackend extends FileBackendStore { foreach ( $httpReqs as $index => $httpReq ) { // Run the callback for each request of this operation $callback = $fileOpHandles[$index]->callback; - call_user_func_array( $callback, [ $httpReq, $statuses[$index] ] ); + $callback( $httpReq, $statuses[$index] ); // On failure, abort all remaining requests for this operation // (e.g. abort the DELETE request if the COPY request fails for a move) if ( !$statuses[$index]->isOK() ) { diff --git a/includes/libs/objectcache/CachedBagOStuff.php b/includes/libs/objectcache/CachedBagOStuff.php index ae434c1738..dbab593915 100644 --- a/includes/libs/objectcache/CachedBagOStuff.php +++ b/includes/libs/objectcache/CachedBagOStuff.php @@ -87,11 +87,11 @@ class CachedBagOStuff extends HashBagOStuff { } public function makeKey( $class, $component = null ) { - return call_user_func_array( [ $this->backend, __FUNCTION__ ], func_get_args() ); + return $this->backend->makeKey( ...func_get_args() ); } public function makeGlobalKey( $class, $component = null ) { - return call_user_func_array( [ $this->backend, __FUNCTION__ ], func_get_args() ); + return $this->backend->makeGlobalKey( ...func_get_args() ); } // These just call the backend (tested elsewhere) diff --git a/includes/libs/objectcache/MultiWriteBagOStuff.php b/includes/libs/objectcache/MultiWriteBagOStuff.php index b03052267a..edd5fbca19 100644 --- a/includes/libs/objectcache/MultiWriteBagOStuff.php +++ b/includes/libs/objectcache/MultiWriteBagOStuff.php @@ -195,16 +195,15 @@ class MultiWriteBagOStuff extends BagOStuff { if ( $i == 0 || !$asyncWrites ) { // First store or in sync mode: write now and get result - if ( !call_user_func_array( [ $cache, $method ], $args ) ) { + if ( !$cache->$method( ...$args ) ) { $ret = false; } } else { // Secondary write in async mode: do not block this HTTP request $logger = $this->logger; - call_user_func( - $this->asyncHandler, + ( $this->asyncHandler )( function () use ( $cache, $method, $args, $logger ) { - if ( !call_user_func_array( [ $cache, $method ], $args ) ) { + if ( !$cache->$method( ...$args ) ) { $logger->warning( "Async $method op failed" ); } } @@ -235,10 +234,10 @@ class MultiWriteBagOStuff extends BagOStuff { } public function makeKey( $class, $component = null ) { - return call_user_func_array( [ $this->caches[0], __FUNCTION__ ], func_get_args() ); + return $this->caches[0]->makeKey( ...func_get_args() ); } public function makeGlobalKey( $class, $component = null ) { - return call_user_func_array( [ $this->caches[0], __FUNCTION__ ], func_get_args() ); + return $this->caches[0]->makeGlobalKey( ...func_get_args() ); } } diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index 97e0456e42..927a1e30b1 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -1603,7 +1603,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @since 1.27 */ public function makeKey( $class, $component = null ) { - return call_user_func_array( [ $this->cache, __FUNCTION__ ], func_get_args() ); + return $this->cache->makeKey( ...func_get_args() ); } /** @@ -1614,7 +1614,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @since 1.27 */ public function makeGlobalKey( $class, $component = null ) { - return call_user_func_array( [ $this->cache, __FUNCTION__ ], func_get_args() ); + return $this->cache->makeGlobalKey( ...func_get_args() ); } /** diff --git a/includes/libs/rdbms/database/DBConnRef.php b/includes/libs/rdbms/database/DBConnRef.php index dedf6eab98..b414a2a02a 100644 --- a/includes/libs/rdbms/database/DBConnRef.php +++ b/includes/libs/rdbms/database/DBConnRef.php @@ -46,7 +46,7 @@ class DBConnRef implements IDatabase { $this->conn = $this->lb->getConnection( $db, $groups, $wiki, $flags ); } - return call_user_func_array( [ $this->conn, $name ], $arguments ); + return $this->conn->$name( ...$arguments ); } public function getServerInfo() { diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index 16e654fe7c..57e5907a52 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -1214,13 +1214,13 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware $startTime = microtime( true ); if ( $this->profiler ) { - call_user_func( [ $this->profiler, 'profileIn' ], $queryProf ); + $this->profiler->profileIn( $queryProf ); } $this->affectedRowCount = null; $ret = $this->doQuery( $commentedSql ); $this->affectedRowCount = $this->affectedRows(); if ( $this->profiler ) { - call_user_func( [ $this->profiler, 'profileOut' ], $queryProf ); + $this->profiler->profileOut( $queryProf ); } $queryRuntime = max( microtime( true ) - $startTime, 0.0 ); @@ -3230,7 +3230,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware $e = null; do { try { - $retVal = call_user_func_array( $function, $args ); + $retVal = $function( ...$args ); break; } catch ( DBQueryError $e ) { if ( $this->wasDeadlock() ) { @@ -3310,7 +3310,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware // No transaction is active nor will start implicitly, so make one for this callback $this->startAtomic( __METHOD__, self::ATOMIC_CANCELABLE ); try { - call_user_func( $callback, $this ); + $callback( $this ); $this->endAtomic( __METHOD__ ); } catch ( Exception $e ) { $this->cancelAtomic( __METHOD__ ); @@ -3486,9 +3486,9 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware try { ++$count; list( $phpCallback ) = $callback; - call_user_func( $phpCallback, $this ); + $phpCallback( $this ); } catch ( Exception $ex ) { - call_user_func( $this->errorLogger, $ex ); + $this->errorLogger( $ex ); $e = $e ?: $ex; } } @@ -3522,7 +3522,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware try { $phpCallback( $trigger, $this ); } catch ( Exception $ex ) { - call_user_func( $this->errorLogger, $ex ); + ( $this->errorLogger )( $ex ); $e = $e ?: $ex; } } @@ -3723,7 +3723,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware ) { $sectionId = $this->startAtomic( $fname, $cancelable ); try { - $res = call_user_func_array( $callback, [ $this, $fname ] ); + $res = $callback( $this, $fname ); } catch ( Exception $e ) { $this->cancelAtomic( $fname, $sectionId ); @@ -4249,7 +4249,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware $cmd = $this->replaceVars( $cmd ); if ( $inputCallback ) { - $callbackResult = call_user_func( $inputCallback, $cmd ); + $callbackResult = $inputCallback( $cmd ); if ( is_string( $callbackResult ) || !$callbackResult ) { $cmd = $callbackResult; @@ -4260,7 +4260,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware $res = $this->query( $cmd, $fname ); if ( $resultCallback ) { - call_user_func( $resultCallback, $res, $this ); + $resultCallback( $res, $this ); } if ( false === $res ) { diff --git a/includes/libs/rdbms/database/DatabaseSqlite.php b/includes/libs/rdbms/database/DatabaseSqlite.php index 2125c70fd5..4b925e6413 100644 --- a/includes/libs/rdbms/database/DatabaseSqlite.php +++ b/includes/libs/rdbms/database/DatabaseSqlite.php @@ -865,7 +865,7 @@ class DatabaseSqlite extends Database { $args = func_get_args(); $function = array_shift( $args ); - return call_user_func_array( $function, $args ); + return $function( ...$args ); } /** diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php index 52c2df7a26..34436fb4a4 100644 --- a/includes/libs/rdbms/lbfactory/LBFactory.php +++ b/includes/libs/rdbms/lbfactory/LBFactory.php @@ -202,7 +202,7 @@ abstract class LBFactory implements ILBFactory { protected function forEachLBCallMethod( $methodName, array $args = [] ) { $this->forEachLB( function ( ILoadBalancer $loadBalancer, $methodName, array $args ) { - call_user_func_array( [ $loadBalancer, $methodName ], $args ); + $loadBalancer->$methodName( ...$args ); }, [ $methodName, $args ] ); diff --git a/includes/libs/rdbms/lbfactory/LBFactoryMulti.php b/includes/libs/rdbms/lbfactory/LBFactoryMulti.php index cfa26479bb..30074eca27 100644 --- a/includes/libs/rdbms/lbfactory/LBFactoryMulti.php +++ b/includes/libs/rdbms/lbfactory/LBFactoryMulti.php @@ -422,10 +422,10 @@ class LBFactoryMulti extends LBFactory { */ public function forEachLB( $callback, array $params = [] ) { foreach ( $this->mainLBs as $lb ) { - call_user_func_array( $callback, array_merge( [ $lb ], $params ) ); + $callback( $lb, ...$params ); } foreach ( $this->extLBs as $lb ) { - call_user_func_array( $callback, array_merge( [ $lb ], $params ) ); + $callback( $lb, ...$params ); } } } diff --git a/includes/libs/rdbms/lbfactory/LBFactorySimple.php b/includes/libs/rdbms/lbfactory/LBFactorySimple.php index 0d7b812da7..6a6bb8d17a 100644 --- a/includes/libs/rdbms/lbfactory/LBFactorySimple.php +++ b/includes/libs/rdbms/lbfactory/LBFactorySimple.php @@ -149,10 +149,10 @@ class LBFactorySimple extends LBFactory { */ public function forEachLB( $callback, array $params = [] ) { if ( isset( $this->mainLB ) ) { - call_user_func_array( $callback, array_merge( [ $this->mainLB ], $params ) ); + $callback( $this->mainLB, ...$params ); } foreach ( $this->extLBs as $lb ) { - call_user_func_array( $callback, array_merge( [ $lb ], $params ) ); + $callback( $lb, ...$params ); } } } diff --git a/includes/libs/rdbms/lbfactory/LBFactorySingle.php b/includes/libs/rdbms/lbfactory/LBFactorySingle.php index 587ab23c02..2c1a782a53 100644 --- a/includes/libs/rdbms/lbfactory/LBFactorySingle.php +++ b/includes/libs/rdbms/lbfactory/LBFactorySingle.php @@ -103,7 +103,7 @@ class LBFactorySingle extends LBFactory { */ public function forEachLB( $callback, array $params = [] ) { if ( isset( $this->lb ) ) { // may not be set during _destruct() - call_user_func_array( $callback, array_merge( [ $this->lb ], $params ) ); + $callback( $this->lb, ...$params ); } } } diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 221bca4269..6b271a7708 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -864,7 +864,7 @@ class LoadBalancer implements ILoadBalancer { $this->connLogger->debug( __METHOD__ . ': calling initLB() before first connection.' ); // Load any "waitFor" positions before connecting so that doWait() is triggered $this->connectionAttempted = true; - call_user_func( $this->chronologyCallback, $this ); + ( $this->chronologyCallback )( $this ); } // Check if an auto-commit connection is being requested. If so, it will not reuse the @@ -1370,7 +1370,7 @@ class LoadBalancer implements ILoadBalancer { try { $conn->commit( $fname, $conn::FLUSHING_ALL_PEERS ); } catch ( DBError $e ) { - call_user_func( $this->errorLogger, $e ); + ( $this->errorLogger )( $e ); $failures[] = "{$conn->getServer()}: {$e->getMessage()}"; } } @@ -1723,8 +1723,7 @@ class LoadBalancer implements ILoadBalancer { foreach ( $this->conns as $connsByServer ) { foreach ( $connsByServer as $serverConns ) { foreach ( $serverConns as $conn ) { - $mergedParams = array_merge( [ $conn ], $params ); - call_user_func_array( $callback, $mergedParams ); + $callback( $conn, ...$params ); } } } @@ -1736,8 +1735,7 @@ class LoadBalancer implements ILoadBalancer { if ( isset( $connsByServer[$masterIndex] ) ) { /** @var IDatabase $conn */ foreach ( $connsByServer[$masterIndex] as $conn ) { - $mergedParams = array_merge( [ $conn ], $params ); - call_user_func_array( $callback, $mergedParams ); + $callback( $conn, ...$params ); } } } @@ -1750,8 +1748,7 @@ class LoadBalancer implements ILoadBalancer { continue; // skip master } foreach ( $serverConns as $conn ) { - $mergedParams = array_merge( [ $conn ], $params ); - call_user_func_array( $callback, $mergedParams ); + $callback( $conn, ...$params ); } } } diff --git a/includes/libs/redis/RedisConnRef.php b/includes/libs/redis/RedisConnRef.php index ede35fa2ee..bbcb267791 100644 --- a/includes/libs/redis/RedisConnRef.php +++ b/includes/libs/redis/RedisConnRef.php @@ -133,10 +133,10 @@ class RedisConnRef implements LoggerAwareInterface { private function tryCall( $method, $arguments ) { $this->conn->clearLastError(); try { - $res = call_user_func_array( [ $this->conn, $method ], $arguments ); + $res = $this->conn->$method( ...$arguments ); $authError = $this->checkAuthentication(); if ( $authError === self::AUTH_ERROR_TEMPORARY ) { - $res = call_user_func_array( [ $this->conn, $method ], $arguments ); + $res = $this->conn->$method( ...$arguments ); } if ( $authError === self::AUTH_ERROR_PERMANENT ) { throw new RedisException( "Failure reauthenticating to Redis." ); diff --git a/includes/media/BitmapHandler.php b/includes/media/BitmapHandler.php index 4cb7c87ec0..e2d32cfbe1 100644 --- a/includes/media/BitmapHandler.php +++ b/includes/media/BitmapHandler.php @@ -449,7 +449,7 @@ class BitmapHandler extends TransformationalImageHandler { return $this->getMediaTransformError( $params, $errMsg ); } - $src_image = call_user_func( $loader, $params['srcPath'] ); + $src_image = $loader( $params['srcPath'] ); $rotation = function_exists( 'imagerotate' ) && !isset( $params['disableRotation'] ) ? $this->getRotation( $image ) : @@ -489,7 +489,7 @@ class BitmapHandler extends TransformationalImageHandler { if ( $useQuality && isset( $params['quality'] ) ) { $funcParams[] = $params['quality']; } - call_user_func_array( $saveType, $funcParams ); + $saveType( ...$funcParams ); imagedestroy( $dst_image ); imagedestroy( $src_image ); diff --git a/includes/media/SvgHandler.php b/includes/media/SvgHandler.php index a589dbf3fb..a9c7b4fe89 100644 --- a/includes/media/SvgHandler.php +++ b/includes/media/SvgHandler.php @@ -291,12 +291,16 @@ class SvgHandler extends ImageHandler { if ( is_array( $wgSVGConverters[$wgSVGConverter] ) ) { // This is a PHP callable $func = $wgSVGConverters[$wgSVGConverter][0]; - $args = array_merge( [ $srcPath, $dstPath, $width, $height, $lang ], - array_slice( $wgSVGConverters[$wgSVGConverter], 1 ) ); if ( !is_callable( $func ) ) { throw new MWException( "$func is not callable" ); } - $err = call_user_func_array( $func, $args ); + $err = $func( $srcPath, + $dstPath, + $width, + $height, + $lang, + ...array_slice( $wgSVGConverters[$wgSVGConverter], 1 ) + ); $retval = (bool)$err; } else { // External command diff --git a/includes/page/Article.php b/includes/page/Article.php index c865d4ed53..1abf97470f 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -279,8 +279,8 @@ class Article implements Page { if ( $this->mRevision !== null ) { // Revision title doesn't match the page title given? if ( $this->mPage->getId() != $this->mRevision->getPage() ) { - $function = [ get_class( $this->mPage ), 'newFromID' ]; - $this->mPage = call_user_func( $function, $this->mRevision->getPage() ); + $function = get_class( $this->mPage ). '::newFromID'; + $this->mPage = $function( $this->mRevision->getPage() ); } } } diff --git a/includes/parser/ParserDiffTest.php b/includes/parser/ParserDiffTest.php index 353825a8fb..93f4246e02 100644 --- a/includes/parser/ParserDiffTest.php +++ b/includes/parser/ParserDiffTest.php @@ -61,12 +61,9 @@ class ParserDiffTest { $results = []; $mismatch = false; $lastResult = null; - $first = true; - foreach ( $this->parsers as $i => $parser ) { - $currentResult = call_user_func_array( [ &$this->parsers[$i], $name ], $args ); - if ( $first ) { - $first = false; - } else { + foreach ( $this->parsers as $parser ) { + $currentResult = $parser->$name( ...$args ); + if ( count( $results ) > 0 ) { if ( is_object( $lastResult ) ) { if ( $lastResult != $currentResult ) { $mismatch = true; @@ -77,7 +74,7 @@ class ParserDiffTest { } } } - $results[$i] = $currentResult; + $results[] = $currentResult; $lastResult = $currentResult; } if ( $mismatch ) { diff --git a/includes/poolcounter/PoolCounterWorkViaCallback.php b/includes/poolcounter/PoolCounterWorkViaCallback.php index 834b8b1f83..aed52d1957 100644 --- a/includes/poolcounter/PoolCounterWorkViaCallback.php +++ b/includes/poolcounter/PoolCounterWorkViaCallback.php @@ -66,26 +66,26 @@ class PoolCounterWorkViaCallback extends PoolCounterWork { } public function doWork() { - return call_user_func_array( $this->doWork, [] ); + return ( $this->doWork )(); } public function getCachedWork() { if ( $this->doCachedWork ) { - return call_user_func_array( $this->doCachedWork, [] ); + return ( $this->doCachedWork )(); } return false; } public function fallback() { if ( $this->fallback ) { - return call_user_func_array( $this->fallback, [] ); + return ( $this->fallback )(); } return false; } public function error( $status ) { if ( $this->error ) { - return call_user_func_array( $this->error, [ $status ] ); + return ( $this->error )( $status ); } return false; } diff --git a/includes/services/ServiceContainer.php b/includes/services/ServiceContainer.php index 4c52693a4a..c98b7da79c 100644 --- a/includes/services/ServiceContainer.php +++ b/includes/services/ServiceContainer.php @@ -355,9 +355,8 @@ class ServiceContainer implements DestructibleService { */ private function createService( $name ) { if ( isset( $this->serviceInstantiators[$name] ) ) { - $service = call_user_func_array( - $this->serviceInstantiators[$name], - array_merge( [ $this ], $this->extraInstantiationParams ) + $service = ( $this->serviceInstantiators[$name] )( + $this, ...$this->extraInstantiationParams ); // NOTE: when adding more wiring logic here, make sure copyWiring() is kept in sync! } else { diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php index 683877439e..c1c856d33d 100644 --- a/includes/skins/BaseTemplate.php +++ b/includes/skins/BaseTemplate.php @@ -597,10 +597,7 @@ abstract class BaseTemplate extends QuickTemplate { if ( $option == 'flat' ) { // fold footerlinks into a single array using a bit of trickery - $validFooterLinks = call_user_func_array( - 'array_merge', - array_values( $validFooterLinks ) - ); + $validFooterLinks = array_merge( ...array_values( $validFooterLinks ) ); } return $validFooterLinks; diff --git a/tests/phpunit/mocks/MockMessageLocalizer.php b/tests/phpunit/mocks/MockMessageLocalizer.php index 143a419f05..4d35930730 100644 --- a/tests/phpunit/mocks/MockMessageLocalizer.php +++ b/tests/phpunit/mocks/MockMessageLocalizer.php @@ -37,7 +37,7 @@ class MockMessageLocalizer implements MessageLocalizer { $args = func_get_args(); /** @var Message $message */ - $message = call_user_func_array( 'wfMessage', $args ); + $message = wfMessage( ...$args ); if ( $this->languageCode !== null ) { $message->inLanguage( $this->languageCode );