Also cleaned up nearby code in a couple places.
Change-Id: Ibf44ee7c0ceb739d7e79406e4ff39303c316e285
28 files changed:
- $ret = call_user_func_array( $this->siteParamsCallback, [ $this, $wiki ] );
+ $ret = ( $this->siteParamsCallback )( $this, $wiki );
# Validate the returned value
if ( !is_array( $ret ) ) {
return $default;
# Validate the returned value
if ( !is_array( $ret ) ) {
return $default;
public function loadFullData() {
if ( $this->fullLoadCallback && !$this->fullLoadDone ) {
public function loadFullData() {
if ( $this->fullLoadCallback && !$this->fullLoadDone ) {
- call_user_func( $this->fullLoadCallback, $this );
+ ( $this->fullLoadCallback )( $this );
$this->fullLoadDone = true;
}
}
$this->fullLoadDone = true;
}
}
$this->initialiseRepos();
}
foreach ( $this->foreignRepos as $repo ) {
$this->initialiseRepos();
}
foreach ( $this->foreignRepos as $repo ) {
- $args = array_merge( [ $repo ], $params );
- if ( call_user_func_array( $callback, $args ) ) {
+ if ( $callback( $repo, ...$params ) ) {
$args = func_get_args();
if ( $this->mParent ) {
$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 );
}
if ( isset( $this->mValidationCallback ) ) {
}
if ( isset( $this->mValidationCallback ) ) {
- return call_user_func( $this->mValidationCallback, $value, $alldata, $this->mParent );
+ return ( $this->mValidationCallback )( $value, $alldata, $this->mParent );
public function filter( $value, $alldata ) {
if ( isset( $this->mFilterCallback ) ) {
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 );
foreach ( $updates as $funcList ) {
$func = $funcList[0];
foreach ( $updates as $funcList ) {
$func = $funcList[0];
$origParams = $funcList[2];
$origParams = $funcList[2];
- call_user_func_array( $func, $arg );
flush();
$this->updatesSkipped[] = $origParams;
}
flush();
$this->updatesSkipped[] = $origParams;
}
} elseif ( $passSelf ) {
array_unshift( $params, $this );
}
} elseif ( $passSelf ) {
array_unshift( $params, $this );
}
- $ret = call_user_func_array( $func, $params );
+ $ret = $func( ...$params );
flush();
if ( $ret !== false ) {
$updatesDone[] = $origParams;
flush();
if ( $ret !== false ) {
$updatesDone[] = $origParams;
$max = $valueCount;
do {
$mid = $min + ( ( $max - $min ) >> 1 );
$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 ) {
if ( $comparison > 0 ) {
$min = $mid;
} elseif ( $comparison == 0 ) {
} while ( $min < $max - 1 );
if ( $min == 0 ) {
} 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;
if ( $comparison < 0 ) {
// Before the first item
return false;
$args[] = $array[$key];
}
}
$args[] = $array[$key];
}
}
- $valueret = call_user_func_array( __METHOD__, $args );
+ $valueret = self::arrayDiffAssocRecursive( ...$args );
if ( count( $valueret ) ) {
$ret[$key] = $valueret;
}
if ( count( $valueret ) ) {
$ret[$key] = $valueret;
}
$success = false;
$result = $this->fetchResult( $key, $success );
if ( !$success ) {
$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 );
}
$this->storeResult( $key, $result );
}
} elseif ( $tokenType == 'end' ) {
if ( $foundStart ) {
# Found match
} 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 )
] );
substr( $subject, $outputPos, $tokenOffset + $tokenLength - $outputPos ),
substr( $subject, $contentPos, $tokenOffset - $contentPos )
] );
if ( empty( $params['allowOB'] ) ) {
// Cancel output buffering and gzipping if set
if ( empty( $params['allowOB'] ) ) {
// Cancel output buffering and gzipping if set
- call_user_func( $this->obResetFunc );
+ ( $this->obResetFunc )();
}
$handle = fopen( 'php://output', 'wb' );
}
$handle = fopen( 'php://output', 'wb' );
foreach ( $httpReqs as $index => $httpReq ) {
// Run the callback for each request of this operation
$callback = $fileOpHandles[$index]->callback;
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() ) {
// 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() ) {
}
public function makeKey( $class, $component = null ) {
}
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 ) {
}
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)
}
// These just call the backend (tested elsewhere)
if ( $i == 0 || !$asyncWrites ) {
// First store or in sync mode: write now and get result
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;
$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 ) {
function () use ( $cache, $method, $args, $logger ) {
- if ( !call_user_func_array( [ $cache, $method ], $args ) ) {
+ if ( !$cache->$method( ...$args ) ) {
$logger->warning( "Async $method op failed" );
}
}
$logger->warning( "Async $method op failed" );
}
}
}
public function makeKey( $class, $component = null ) {
}
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 ) {
}
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() );
* @since 1.27
*/
public function makeKey( $class, $component = null ) {
* @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() );
* @since 1.27
*/
public function makeGlobalKey( $class, $component = null ) {
* @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() );
$this->conn = $this->lb->getConnection( $db, $groups, $wiki, $flags );
}
$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() {
}
public function getServerInfo() {
$startTime = microtime( true );
if ( $this->profiler ) {
$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 ) {
}
$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 );
}
$queryRuntime = max( microtime( true ) - $startTime, 0.0 );
- $retVal = call_user_func_array( $function, $args );
+ $retVal = $function( ...$args );
break;
} catch ( DBQueryError $e ) {
if ( $this->wasDeadlock() ) {
break;
} catch ( DBQueryError $e ) {
if ( $this->wasDeadlock() ) {
// No transaction is active nor will start implicitly, so make one for this callback
$this->startAtomic( __METHOD__, self::ATOMIC_CANCELABLE );
try {
// 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 );
$this->endAtomic( __METHOD__ );
} catch ( Exception $e ) {
$this->cancelAtomic( __METHOD__ );
$this->endAtomic( __METHOD__ );
} catch ( Exception $e ) {
$this->cancelAtomic( __METHOD__ );
try {
++$count;
list( $phpCallback ) = $callback;
try {
++$count;
list( $phpCallback ) = $callback;
- call_user_func( $phpCallback, $this );
} catch ( Exception $ex ) {
} catch ( Exception $ex ) {
- call_user_func( $this->errorLogger, $ex );
+ $this->errorLogger( $ex );
try {
$phpCallback( $trigger, $this );
} catch ( Exception $ex ) {
try {
$phpCallback( $trigger, $this );
} catch ( Exception $ex ) {
- call_user_func( $this->errorLogger, $ex );
+ ( $this->errorLogger )( $ex );
) {
$sectionId = $this->startAtomic( $fname, $cancelable );
try {
) {
$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 );
} catch ( Exception $e ) {
$this->cancelAtomic( $fname, $sectionId );
$cmd = $this->replaceVars( $cmd );
if ( $inputCallback ) {
$cmd = $this->replaceVars( $cmd );
if ( $inputCallback ) {
- $callbackResult = call_user_func( $inputCallback, $cmd );
+ $callbackResult = $inputCallback( $cmd );
if ( is_string( $callbackResult ) || !$callbackResult ) {
$cmd = $callbackResult;
if ( is_string( $callbackResult ) || !$callbackResult ) {
$cmd = $callbackResult;
$res = $this->query( $cmd, $fname );
if ( $resultCallback ) {
$res = $this->query( $cmd, $fname );
if ( $resultCallback ) {
- call_user_func( $resultCallback, $res, $this );
+ $resultCallback( $res, $this );
}
if ( false === $res ) {
}
if ( false === $res ) {
$args = func_get_args();
$function = array_shift( $args );
$args = func_get_args();
$function = array_shift( $args );
- return call_user_func_array( $function, $args );
+ return $function( ...$args );
protected function forEachLBCallMethod( $methodName, array $args = [] ) {
$this->forEachLB(
function ( ILoadBalancer $loadBalancer, $methodName, array $args ) {
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 ]
);
},
[ $methodName, $args ]
);
*/
public function forEachLB( $callback, array $params = [] ) {
foreach ( $this->mainLBs as $lb ) {
*/
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 ) {
}
foreach ( $this->extLBs as $lb ) {
- call_user_func_array( $callback, array_merge( [ $lb ], $params ) );
+ $callback( $lb, ...$params );
*/
public function forEachLB( $callback, array $params = [] ) {
if ( isset( $this->mainLB ) ) {
*/
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 ) {
}
foreach ( $this->extLBs as $lb ) {
- call_user_func_array( $callback, array_merge( [ $lb ], $params ) );
+ $callback( $lb, ...$params );
*/
public function forEachLB( $callback, array $params = [] ) {
if ( isset( $this->lb ) ) { // may not be set during _destruct()
*/
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 );
$this->connLogger->debug( __METHOD__ . ': calling initLB() before first connection.' );
// Load any "waitFor" positions before connecting so that doWait() is triggered
$this->connectionAttempted = true;
$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
}
// Check if an auto-commit connection is being requested. If so, it will not reuse the
try {
$conn->commit( $fname, $conn::FLUSHING_ALL_PEERS );
} catch ( DBError $e ) {
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()}";
}
}
$failures[] = "{$conn->getServer()}: {$e->getMessage()}";
}
}
foreach ( $this->conns as $connsByServer ) {
foreach ( $connsByServer as $serverConns ) {
foreach ( $serverConns as $conn ) {
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 );
if ( isset( $connsByServer[$masterIndex] ) ) {
/** @var IDatabase $conn */
foreach ( $connsByServer[$masterIndex] as $conn ) {
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 );
continue; // skip master
}
foreach ( $serverConns as $conn ) {
continue; // skip master
}
foreach ( $serverConns as $conn ) {
- $mergedParams = array_merge( [ $conn ], $params );
- call_user_func_array( $callback, $mergedParams );
+ $callback( $conn, ...$params );
private function tryCall( $method, $arguments ) {
$this->conn->clearLastError();
try {
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 ) {
$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." );
}
if ( $authError === self::AUTH_ERROR_PERMANENT ) {
throw new RedisException( "Failure reauthenticating to Redis." );
return $this->getMediaTransformError( $params, $errMsg );
}
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 ) :
$rotation = function_exists( 'imagerotate' ) && !isset( $params['disableRotation'] ) ?
$this->getRotation( $image ) :
if ( $useQuality && isset( $params['quality'] ) ) {
$funcParams[] = $params['quality'];
}
if ( $useQuality && isset( $params['quality'] ) ) {
$funcParams[] = $params['quality'];
}
- call_user_func_array( $saveType, $funcParams );
+ $saveType( ...$funcParams );
imagedestroy( $dst_image );
imagedestroy( $src_image );
imagedestroy( $dst_image );
imagedestroy( $src_image );
if ( is_array( $wgSVGConverters[$wgSVGConverter] ) ) {
// This is a PHP callable
$func = $wgSVGConverters[$wgSVGConverter][0];
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" );
}
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
$retval = (bool)$err;
} else {
// External command
if ( $this->mRevision !== null ) {
// Revision title doesn't match the page title given?
if ( $this->mPage->getId() != $this->mRevision->getPage() ) {
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() );
$results = [];
$mismatch = false;
$lastResult = null;
$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;
if ( is_object( $lastResult ) ) {
if ( $lastResult != $currentResult ) {
$mismatch = true;
- $results[$i] = $currentResult;
+ $results[] = $currentResult;
$lastResult = $currentResult;
}
if ( $mismatch ) {
$lastResult = $currentResult;
}
if ( $mismatch ) {
}
public function doWork() {
}
public function doWork() {
- return call_user_func_array( $this->doWork, [] );
+ return ( $this->doWork )();
}
public function getCachedWork() {
if ( $this->doCachedWork ) {
}
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 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 false;
}
public function error( $status ) {
if ( $this->error ) {
- return call_user_func_array( $this->error, [ $status ] );
+ return ( $this->error )( $status );
*/
private function createService( $name ) {
if ( isset( $this->serviceInstantiators[$name] ) ) {
*/
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 {
);
// NOTE: when adding more wiring logic here, make sure copyWiring() is kept in sync!
} else {
if ( $option == 'flat' ) {
// fold footerlinks into a single array using a bit of trickery
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;
}
return $validFooterLinks;
$args = func_get_args();
/** @var Message $message */
$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 );
if ( $this->languageCode !== null ) {
$message->inLanguage( $this->languageCode );