HHVM does not support variadic arguments with type hints. This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases). As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User. If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args(). Some of the changes are definitely safe, like
functions and test classes.
In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:
* Forwarding all arguments to another function. It's useful to keep
func_get_args() here where we want to keep the list of expected
arguments and their meanings in the function signature line for
documentation purposes, but don't want to copy-paste a long line of
argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
arguments individually but want to use them as an array as well for
some reason.
Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
31 files changed:
* subsequent arguments to $msg2 will be passed as parameters only for replacing in $msg2
* @param string $msg1
* @param string $msg2
* subsequent arguments to $msg2 will be passed as parameters only for replacing in $msg2
* @param string $msg1
* @param string $msg2
+ * @param mixed ...$args To pass as params to wfMessage() with $msg2. Either variadic, or a single
+ * array argument.
-function wfForbidden( $msg1, $msg2 ) {
+function wfForbidden( $msg1, $msg2, ...$args ) {
global $wgImgAuthDetails;
global $wgImgAuthDetails;
- $args = func_get_args();
- array_shift( $args );
- array_shift( $args );
$args = ( isset( $args[0] ) && is_array( $args[0] ) ) ? $args[0] : $args;
$msgHdr = wfMessage( $msg1 )->escaped();
$args = ( isset( $args[0] ) && is_array( $args[0] ) ) ? $args[0] : $args;
$msgHdr = wfMessage( $msg1 )->escaped();
* which is not fun
*
* @param array $array1
* which is not fun
*
* @param array $array1
+ * @param array ...$arrays
- static function arrayMerge( $array1/* ... */ ) {
+ static function arrayMerge( array $array1, ...$arrays ) {
- $argsCount = func_num_args();
- for ( $i = 1; $i < $argsCount; $i++ ) {
- foreach ( func_get_arg( $i ) as $key => $value ) {
+ foreach ( $arrays as $array ) {
+ foreach ( $array as $key => $value ) {
if ( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) {
$out[$key] = self::arrayMerge( $out[$key], $value );
} elseif ( !isset( $out[$key] ) || !$out[$key] && !is_numeric( $key ) ) {
if ( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) {
$out[$key] = self::arrayMerge( $out[$key], $value );
} elseif ( !isset( $out[$key] ) || !$out[$key] && !is_numeric( $key ) ) {
/**
* Fetch the standard parameters this helper recognizes
* @param string $action AuthManager action
/**
* Fetch the standard parameters this helper recognizes
* @param string $action AuthManager action
- * @param string $param,... Parameters to use
+ * @param string ...$wantedParams Parameters to use
- public static function getStandardParams( $action, $param /* ... */ ) {
+ public static function getStandardParams( $action, ...$wantedParams ) {
$params = [
'requests' => [
ApiBase::PARAM_TYPE => 'string',
$params = [
'requests' => [
ApiBase::PARAM_TYPE => 'string',
- $wantedParams = func_get_args();
- array_shift( $wantedParams );
foreach ( $wantedParams as $name ) {
if ( isset( $params[$name] ) ) {
$ret[$name] = $params[$name];
foreach ( $wantedParams as $name ) {
if ( isset( $params[$name] ) ) {
$ret[$name] = $params[$name];
* @param string $key Message name
* @param string $fallback Default message if the message cache can't be
* called by the exception
* @param string $key Message name
* @param string $fallback Default message if the message cache can't be
* called by the exception
- * The function also has other parameters that are arguments for the message
+ * @param mixed ...$params To pass to wfMessage()
* @return string Message with arguments replaced
*/
* @return string Message with arguments replaced
*/
- public function msg( $key, $fallback /*[, params...] */ ) {
+ public function msg( $key, $fallback, ...$params ) {
- $args = array_slice( func_get_args(), 2 );
// FIXME: Keep logic in sync with MWExceptionRenderer::msg.
$res = false;
if ( $this->useMessageCache() ) {
try {
// FIXME: Keep logic in sync with MWExceptionRenderer::msg.
$res = false;
if ( $this->useMessageCache() ) {
try {
- $res = wfMessage( $key, $args )->text();
+ $res = wfMessage( $key, $params )->text();
} catch ( Exception $e ) {
}
}
if ( $res === false ) {
} catch ( Exception $e ) {
}
}
if ( $res === false ) {
- $res = wfMsgReplaceArgs( $fallback, $args );
+ $res = wfMsgReplaceArgs( $fallback, $params );
// If an exception happens inside message rendering,
// {{SITENAME}} sometimes won't be replaced.
$res = strtr( $res, [
// If an exception happens inside message rendering,
// {{SITENAME}} sometimes won't be replaced.
$res = strtr( $res, [
* @param string $key Message name
* @param string $fallback Default message if the message cache can't be
* called by the exception
* @param string $key Message name
* @param string $fallback Default message if the message cache can't be
* called by the exception
- * The function also has other parameters that are arguments for the message
+ * @param mixed ...$params To pass to wfMessage()
* @return string Message with arguments replaced
*/
* @return string Message with arguments replaced
*/
- private static function msg( $key, $fallback /*[, params...] */ ) {
+ private static function msg( $key, $fallback, ...$params ) {
- $args = array_slice( func_get_args(), 2 );
// FIXME: Keep logic in sync with MWException::msg.
try {
// FIXME: Keep logic in sync with MWException::msg.
try {
- $res = wfMessage( $key, $args )->text();
+ $res = wfMessage( $key, $params )->text();
} catch ( Exception $e ) {
} catch ( Exception $e ) {
- $res = wfMsgReplaceArgs( $fallback, $args );
+ $res = wfMsgReplaceArgs( $fallback, $params );
// If an exception happens inside message rendering,
// {{SITENAME}} sometimes won't be replaced.
$res = strtr( $res, [
// If an exception happens inside message rendering,
// {{SITENAME}} sometimes won't be replaced.
$res = strtr( $res, [
- public function msg() {
- $args = func_get_args();
-
+ public function msg( ...$args ) {
if ( $this->mParent ) {
return $this->mParent->msg( ...$args );
}
if ( $this->mParent ) {
return $this->mParent->msg( ...$args );
}
wfDebug( "IMPORT: $data\n" );
}
wfDebug( "IMPORT: $data\n" );
}
- public function notice( $msg /*, $param, ...*/ ) {
- $params = func_get_args();
- array_shift( $params );
-
+ public function notice( $msg, ...$params ) {
if ( is_callable( $this->mNoticeCallback ) ) {
call_user_func( $this->mNoticeCallback, $msg, $params );
} else { # No ImportReporter -> CLI
if ( is_callable( $this->mNoticeCallback ) ) {
call_user_func( $this->mNoticeCallback, $msg, $params );
} else { # No ImportReporter -> CLI
- $args = func_get_args();
- return Hooks::run( 'AfterImportPage', $args );
+ return Hooks::run( 'AfterImportPage', func_get_args() );
private function pageOutCallback( $title, $foreignTitle, $revCount,
$sucCount, $pageInfo ) {
if ( isset( $this->mPageOutCallback ) ) {
private function pageOutCallback( $title, $foreignTitle, $revCount,
$sucCount, $pageInfo ) {
if ( isset( $this->mPageOutCallback ) ) {
- $args = func_get_args();
- call_user_func_array( $this->mPageOutCallback, $args );
+ call_user_func_array( $this->mPageOutCallback, func_get_args() );
$this->showMessage( 'config-install-step-done' );
}
$this->showMessage( 'config-install-step-done' );
}
- public function showMessage( $msg /*, ... */ ) {
- echo $this->getMessageText( func_get_args() ) . "\n";
+ public function showMessage( $msg, ...$params ) {
+ echo $this->getMessageText( $msg, $params ) . "\n";
- public function showError( $msg /*, ... */ ) {
- echo "***{$this->getMessageText( func_get_args() )}***\n";
+ public function showError( $msg, ...$params ) {
+ echo "***{$this->getMessageText( $msg, $params )}***\n";
* @param array $params
*
* @return string
*/
* @param array $params
*
* @return string
*/
- protected function getMessageText( $params ) {
- $msg = array_shift( $params );
-
+ protected function getMessageText( $msg, $params ) {
$text = wfMessage( $msg, $params )->parse();
$text = preg_replace( '/<a href="(.*?)".*?>(.*?)<\/a>/', '$2 <$1>', $text );
$text = wfMessage( $msg, $params )->parse();
$text = preg_replace( '/<a href="(.*?)".*?>(.*?)<\/a>/', '$2 <$1>', $text );
* The messages will be in wikitext format, which will be converted to an
* output format such as HTML or text before being sent to the user.
* @param string $msg
* The messages will be in wikitext format, which will be converted to an
* output format such as HTML or text before being sent to the user.
* @param string $msg
+ * @param mixed ...$params
- abstract public function showMessage( $msg /*, ... */ );
+ abstract public function showMessage( $msg, ...$params );
/**
* Same as showMessage(), but for displaying errors
* @param string $msg
/**
* Same as showMessage(), but for displaying errors
* @param string $msg
+ * @param mixed ...$params
- abstract public function showError( $msg /*, ... */ );
+ abstract public function showError( $msg, ...$params );
/**
* Show a message to the installing user by using a Status object
/**
* Show a message to the installing user by using a Status object
* Show an error message in a box. Parameters are like wfMessage(), or
* alternatively, pass a Message object in.
* @param string|Message $msg
* Show an error message in a box. Parameters are like wfMessage(), or
* alternatively, pass a Message object in.
* @param string|Message $msg
+ * @param mixed ...$params
- public function showError( $msg /*...*/ ) {
+ public function showError( $msg, ...$params ) {
if ( !( $msg instanceof Message ) ) {
if ( !( $msg instanceof Message ) ) {
- $args = func_get_args();
- array_shift( $args );
- $args = array_map( 'htmlspecialchars', $args );
- $msg = wfMessage( $msg, $args );
+ $msg = wfMessage(
+ $msg,
+ array_map( 'htmlspecialchars', $params )
+ );
}
$text = $msg->useDatabase( false )->plain();
$this->output->addHTML( $this->getErrorBox( $text ) );
}
$text = $msg->useDatabase( false )->plain();
$this->output->addHTML( $this->getErrorBox( $text ) );
* @param string $msg
* @return string
*/
* @param string $msg
* @return string
*/
- public function getHelpBox( $msg /*, ... */ ) {
- $args = func_get_args();
- array_shift( $args );
+ public function getHelpBox( $msg, ...$args ) {
$args = array_map( 'htmlspecialchars', $args );
$text = wfMessage( $msg, $args )->useDatabase( false )->plain();
$html = $this->parse( $text, true );
$args = array_map( 'htmlspecialchars', $args );
$text = wfMessage( $msg, $args )->useDatabase( false )->plain();
$html = $this->parse( $text, true );
/**
* Output a help box.
* @param string $msg Key for wfMessage()
/**
* Output a help box.
* @param string $msg Key for wfMessage()
+ * @param mixed ...$params
- public function showHelpBox( $msg /*, ... */ ) {
- $args = func_get_args();
- $html = $this->getHelpBox( ...$args );
+ public function showHelpBox( $msg, ...$params ) {
+ $html = $this->getHelpBox( $msg, ...$params );
$this->output->addHTML( $html );
}
$this->output->addHTML( $html );
}
* Output looks like a list.
*
* @param string $msg
* Output looks like a list.
*
* @param string $msg
+ * @param mixed ...$params
- public function showMessage( $msg /*, ... */ ) {
- $args = func_get_args();
- array_shift( $args );
+ public function showMessage( $msg, ...$params ) {
$html = '<div class="config-message">' .
$html = '<div class="config-message">' .
- $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
+ $this->parse( wfMessage( $msg, $params )->useDatabase( false )->plain() ) .
"</div>\n";
$this->output->addHTML( $html );
}
"</div>\n";
$this->output->addHTML( $html );
}
* @since 1.23
*
* @param array $array1 The array to compare from
* @since 1.23
*
* @param array $array1 The array to compare from
- * @param array $array2,... More arrays to compare against
+ * @param array ...$arrays More arrays to compare against
* @return array An array containing all the values from array1
* that are not present in any of the other arrays.
*/
* @return array An array containing all the values from array1
* that are not present in any of the other arrays.
*/
- public static function arrayDiffAssocRecursive( $array1 ) {
- $arrays = func_get_args();
- array_shift( $arrays );
+ public static function arrayDiffAssocRecursive( $array1, ...$arrays ) {
$ret = [];
foreach ( $array1 as $key => $value ) {
$ret = [];
foreach ( $array1 as $key => $value ) {
/**
* @param callable $callback Callback that gets called by __toString
/**
* @param callable $callback Callback that gets called by __toString
- * @param mixed $param,... Parameters to the callback
+ * @param mixed ...$params Parameters to the callback
- public function __construct( $callback /*...*/ ) {
- $this->params = func_get_args();
- array_shift( $this->params );
+ public function __construct( $callback, ...$params ) {
$this->callback = $callback;
$this->callback = $callback;
+ $this->params = $params;
*
* Like MemoizedCallable::invokeArgs(), but variadic.
*
*
* Like MemoizedCallable::invokeArgs(), but variadic.
*
- * @param mixed $params,... Parameters for memoized function or method.
+ * @param mixed ...$params Parameters for memoized function or method.
* @return mixed The memoized callable's return value.
*/
* @return mixed The memoized callable's return value.
*/
- public function invoke() {
- return $this->invokeArgs( func_get_args() );
+ public function invoke( ...$params ) {
+ return $this->invokeArgs( $params );
* - StatusValue::newGood() if this method is called without parameters
* - StatusValue::newFatal() with all parameters to this method if passed in
*
* - StatusValue::newGood() if this method is called without parameters
* - StatusValue::newFatal() with all parameters to this method if passed in
*
- * @param string $args,...
+ * @param string ...$args
- final protected function newStatus() {
- $args = func_get_args();
+ final protected function newStatus( ...$args ) {
if ( count( $args ) ) {
$sv = StatusValue::newFatal( ...$args );
} else {
if ( count( $args ) ) {
$sv = StatusValue::newFatal( ...$args );
} else {
public $funDecls = array();
public $varDecls = array();
public $funDecls = array();
public $varDecls = array();
- public function __construct($t, $type=0)
+ public function __construct($t, $type=0, ...$nodes)
{
if ($token = $t->currentToken())
{
{
if ($token = $t->currentToken())
{
$this->lineno = $t->lineno;
}
$this->lineno = $t->lineno;
}
- if (($numargs = func_num_args()) > 2)
+ foreach($nodes as $node)
- $args = func_get_args();
- for ($i = 2; $i < $numargs; $i++)
- $this->addNode($args[$i]);
/** @var Message */
private $msg;
/** @var Message */
private $msg;
- function __construct( $msg, $width, $height /*, ... */ ) {
- $args = array_slice( func_get_args(), 3 );
+ function __construct( $msg, $width, $height, ...$args ) {
$this->msg = wfMessage( $msg )->params( $args );
$this->width = intval( $width );
$this->height = intval( $height );
$this->msg = wfMessage( $msg )->params( $args );
$this->width = intval( $width );
$this->height = intval( $height );
function toHtml( $options = [] ) {
global $wgPriorityHints, $wgElementTiming;
function toHtml( $options = [] ) {
global $wgPriorityHints, $wgElementTiming;
- if ( count( func_get_args() ) == 2 ) {
+ if ( func_num_args() == 2 ) {
throw new MWException( __METHOD__ . ' called in the old style' );
}
throw new MWException( __METHOD__ . ' called in the old style' );
}
/**
* @param Parser $parser
/**
* @param Parser $parser
+ * @param string $part1 Message key
+ * @param mixed ...$params To pass to wfMessage()
- public static function intFunction( $parser, $part1 = '' /*, ... */ ) {
+ public static function intFunction( $parser, $part1 = '', ...$params ) {
if ( strval( $part1 ) !== '' ) {
if ( strval( $part1 ) !== '' ) {
- $args = array_slice( func_get_args(), 2 );
- $message = wfMessage( $part1, $args )
+ $message = wfMessage( $part1, $params )
->inLanguage( $parser->getOptions()->getUserLangObj() );
return [ $message->plain(), 'noparse' => false ];
} else {
->inLanguage( $parser->getOptions()->getUserLangObj() );
return [ $message->plain(), 'noparse' => false ];
} else {
/**
* @param Parser $parser
* @param string $username
/**
* @param Parser $parser
* @param string $username
+ * @param string ...$forms What to output for each gender
- public static function gender( $parser, $username ) {
- $forms = array_slice( func_get_args(), 2 );
-
+ public static function gender( $parser, $username, ...$forms ) {
// Some shortcuts to avoid loading user data unnecessarily
if ( count( $forms ) === 0 ) {
return '';
// Some shortcuts to avoid loading user data unnecessarily
if ( count( $forms ) === 0 ) {
return '';
/**
* @param Parser $parser
* @param string $text
/**
* @param Parser $parser
* @param string $text
+ * @param string ...$forms What to output for each number (singular, dual, plural, etc.)
- public static function plural( $parser, $text = '' ) {
- $forms = array_slice( func_get_args(), 2 );
+ public static function plural( $parser, $text = '', ...$forms ) {
$text = $parser->getFunctionLang()->parseFormattedNumber( $text );
settype( $text, ctype_digit( $text ) ? 'int' : 'float' );
return $parser->getFunctionLang()->convertPlural( $text, $forms );
$text = $parser->getFunctionLang()->parseFormattedNumber( $text );
settype( $text, ctype_digit( $text ) ? 'int' : 'float' );
return $parser->getFunctionLang()->convertPlural( $text, $forms );
/**
* @param string $sep
* @param int $flags
/**
* @param string $sep
* @param int $flags
- * @param string|PPNode_DOM|DOMDocument $args,...
+ * @param string|PPNode_DOM|DOMDocument ...$args
- public function implodeWithFlags( $sep, $flags /*, ... */ ) {
- $args = array_slice( func_get_args(), 2 );
-
+ public function implodeWithFlags( $sep, $flags, ...$args ) {
$first = true;
$s = '';
foreach ( $args as $root ) {
$first = true;
$s = '';
foreach ( $args as $root ) {
* This previously called implodeWithFlags but has now been inlined to reduce stack depth
*
* @param string $sep
* This previously called implodeWithFlags but has now been inlined to reduce stack depth
*
* @param string $sep
- * @param string|PPNode_DOM|DOMDocument $args,...
+ * @param string|PPNode_DOM|DOMDocument ...$args
- public function implode( $sep /*, ... */ ) {
- $args = array_slice( func_get_args(), 1 );
-
+ public function implode( $sep, ...$args ) {
$first = true;
$s = '';
foreach ( $args as $root ) {
$first = true;
$s = '';
foreach ( $args as $root ) {
* with implode()
*
* @param string $sep
* with implode()
*
* @param string $sep
- * @param string|PPNode_DOM|DOMDocument $args,...
+ * @param string|PPNode_DOM|DOMDocument ...$args
- public function virtualImplode( $sep /*, ... */ ) {
- $args = array_slice( func_get_args(), 1 );
+ public function virtualImplode( $sep, ...$args ) {
$out = [];
$first = true;
$out = [];
$first = true;
* @param string $start
* @param string $sep
* @param string $end
* @param string $start
* @param string $sep
* @param string $end
- * @param string|PPNode_DOM|DOMDocument $args,...
+ * @param string|PPNode_DOM|DOMDocument ...$args
- public function virtualBracketedImplode( $start, $sep, $end /*, ... */ ) {
- $args = array_slice( func_get_args(), 3 );
+ public function virtualBracketedImplode( $start, $sep, $end, ...$args ) {
$out = [ $start ];
$first = true;
$out = [ $start ];
$first = true;
/**
* @param string $sep
* @param int $flags
/**
* @param string $sep
* @param int $flags
- * @param string|PPNode $args,...
+ * @param string|PPNode ...$args
- public function implodeWithFlags( $sep, $flags /*, ... */ ) {
- $args = array_slice( func_get_args(), 2 );
-
+ public function implodeWithFlags( $sep, $flags, ...$args ) {
$first = true;
$s = '';
foreach ( $args as $root ) {
$first = true;
$s = '';
foreach ( $args as $root ) {
* Implode with no flags specified
* This previously called implodeWithFlags but has now been inlined to reduce stack depth
* @param string $sep
* Implode with no flags specified
* This previously called implodeWithFlags but has now been inlined to reduce stack depth
* @param string $sep
- * @param string|PPNode $args,...
+ * @param string|PPNode ...$args
- public function implode( $sep /*, ... */ ) {
- $args = array_slice( func_get_args(), 1 );
-
+ public function implode( $sep, ...$args ) {
$first = true;
$s = '';
foreach ( $args as $root ) {
$first = true;
$s = '';
foreach ( $args as $root ) {
* with implode()
*
* @param string $sep
* with implode()
*
* @param string $sep
- * @param string|PPNode $args,...
+ * @param string|PPNode ...$args
* @return PPNode_Hash_Array
*/
* @return PPNode_Hash_Array
*/
- public function virtualImplode( $sep /*, ... */ ) {
- $args = array_slice( func_get_args(), 1 );
+ public function virtualImplode( $sep, ...$args ) {
$out = [];
$first = true;
$out = [];
$first = true;
* @param string $start
* @param string $sep
* @param string $end
* @param string $start
* @param string $sep
* @param string $end
- * @param string|PPNode $args,...
+ * @param string|PPNode ...$args
* @return PPNode_Hash_Array
*/
* @return PPNode_Hash_Array
*/
- public function virtualBracketedImplode( $start, $sep, $end /*, ... */ ) {
- $args = array_slice( func_get_args(), 3 );
+ public function virtualBracketedImplode( $start, $sep, $end, ...$args ) {
$out = [ $start ];
$first = true;
$out = [ $start ];
$first = true;
* Adds parameters to the command. All parameters are sanitized via Shell::escape().
* Null values are ignored.
*
* Adds parameters to the command. All parameters are sanitized via Shell::escape().
* Null values are ignored.
*
- * @param string|string[] $args,...
+ * @param string|string[] ...$args
- public function params( /* ... */ ) {
- $args = func_get_args();
+ public function params( ...$args ) {
if ( count( $args ) === 1 && is_array( reset( $args ) ) ) {
// If only one argument has been passed, and that argument is an array,
// treat it as a list of arguments
if ( count( $args ) === 1 && is_array( reset( $args ) ) ) {
// If only one argument has been passed, and that argument is an array,
// treat it as a list of arguments
* Adds unsafe parameters to the command. These parameters are NOT sanitized in any way.
* Null values are ignored.
*
* Adds unsafe parameters to the command. These parameters are NOT sanitized in any way.
* Null values are ignored.
*
- * @param string|string[] $args,...
+ * @param string|string[] ...$args
- public function unsafeParams( /* ... */ ) {
- $args = func_get_args();
+ public function unsafeParams( ...$args ) {
if ( count( $args ) === 1 && is_array( reset( $args ) ) ) {
// If only one argument has been passed, and that argument is an array,
// treat it as a list of arguments
if ( count( $args ) === 1 && is_array( reset( $args ) ) ) {
// If only one argument has been passed, and that argument is an array,
// treat it as a list of arguments
- function reportLogItem( /* ... */ ) {
+ function reportLogItem( ...$args ) {
$this->mLogItemCount++;
if ( is_callable( $this->mOriginalLogCallback ) ) {
$this->mLogItemCount++;
if ( is_callable( $this->mOriginalLogCallback ) ) {
- call_user_func_array( $this->mOriginalLogCallback, func_get_args() );
+ call_user_func_array( $this->mOriginalLogCallback, $args );
*/
public function reportPage( $title, $foreignTitle, $revisionCount,
$successCount, $pageInfo ) {
*/
public function reportPage( $title, $foreignTitle, $revisionCount,
$successCount, $pageInfo ) {
- $args = func_get_args();
- call_user_func_array( $this->mOriginalPageOutCallback, $args );
+ call_user_func_array( $this->mOriginalPageOutCallback, func_get_args() );
if ( $title === null ) {
# Invalid or non-importable title; a notice is already displayed
if ( $title === null ) {
# Invalid or non-importable title; a notice is already displayed
* Dispatch a command to the next available replica DB.
* This may block until a replica DB finishes its work and becomes available.
*/
* Dispatch a command to the next available replica DB.
* This may block until a replica DB finishes its work and becomes available.
*/
- function dispatch( /*...*/ ) {
- $args = func_get_args();
+ function dispatch( ...$args ) {
$pipes = $this->replicaPipes;
$x = [];
$y = [];
$pipes = $this->replicaPipes;
$x = [];
$y = [];
->getMock();
$mock->expects( $this->exactly( $insertCalls ) )
->method( 'insert' )
->getMock();
$mock->expects( $this->exactly( $insertCalls ) )
->method( 'insert' )
- ->willReturnCallback( function () {
- return call_user_func_array( [ $this->db, 'insert' ], func_get_args() );
+ ->willReturnCallback( function ( ...$args ) {
+ return call_user_func_array( [ $this->db, 'insert' ], $args );
} );
$mock->expects( $this->exactly( $selectCalls ) )
->method( 'select' )
} );
$mock->expects( $this->exactly( $selectCalls ) )
->method( 'select' )
- ->willReturnCallback( function () {
- return call_user_func_array( [ $this->db, 'select' ], func_get_args() );
+ ->willReturnCallback( function ( ...$args ) {
+ return call_user_func_array( [ $this->db, 'select' ], $args );
} );
$mock->expects( $this->exactly( $insertCalls ) )
->method( 'affectedRows' )
} );
$mock->expects( $this->exactly( $insertCalls ) )
->method( 'affectedRows' )
- ->willReturnCallback( function () {
- return call_user_func_array( [ $this->db, 'affectedRows' ], func_get_args() );
+ ->willReturnCallback( function ( ...$args ) {
+ return call_user_func_array( [ $this->db, 'affectedRows' ], $args );
} );
$mock->expects( $this->any() )
->method( 'insertId' )
} );
$mock->expects( $this->any() )
->method( 'insertId' )
- ->willReturnCallback( function () {
- return call_user_func_array( [ $this->db, 'insertId' ], func_get_args() );
+ ->willReturnCallback( function ( ...$args ) {
+ return call_user_func_array( [ $this->db, 'insertId' ], $args );
/**
* Merges all requests parameter + expected values into one
/**
* Merges all requests parameter + expected values into one
- * @param array $v,... List of arrays, each of which contains exactly two
+ * @param array ...$arrays List of arrays, each of which contains exactly two
- protected function merge( /*...*/ ) {
+ protected function merge( ...$arrays ) {
$request = [];
$expected = [];
$request = [];
$expected = [];
- foreach ( func_get_args() as $v ) {
- list( $req, $exp ) = $this->validateRequestExpectedPair( $v );
+ foreach ( $arrays as $array ) {
+ list( $req, $exp ) = $this->validateRequestExpectedPair( $array );
$request = array_merge_recursive( $request, $req );
$this->mergeExpected( $expected, $exp );
}
$request = array_merge_recursive( $request, $req );
$this->mergeExpected( $expected, $exp );
}
* @dataProvider provideLoadFromSubmission
*/
public function testLoadFromSubmission(
* @dataProvider provideLoadFromSubmission
*/
public function testLoadFromSubmission(
- array $args, array $data, $expectState /* $hiddenPref, $enableEmail */
+ array $args, array $data, $expectState, $hiddenPref = null, $enableEmail = null
- list( $args, $data, $expectState, $hiddenPref, $enableEmail ) = func_get_args();
$this->setMwGlobals( 'wgHiddenPrefs', $hiddenPref );
$this->setMwGlobals( 'wgEnableEmail', $enableEmail );
parent::testLoadFromSubmission( $args, $data, $expectState );
$this->setMwGlobals( 'wgHiddenPrefs', $hiddenPref );
$this->setMwGlobals( 'wgEnableEmail', $enableEmail );
parent::testLoadFromSubmission( $args, $data, $expectState );
*/
private static $pageName = 'CategoryMembershipChangeTestPage';
*/
private static $pageName = 'CategoryMembershipChangeTestPage';
- public static function newForCategorizationCallback() {
- self::$lastNotifyArgs = func_get_args();
+ public static function newForCategorizationCallback( ...$args ) {
+ self::$lastNotifyArgs = $args;
self::$notifyCallCounter += 1;
return self::$mockRecentChange;
}
self::$notifyCallCounter += 1;
return self::$mockRecentChange;
}
* @covers ArrayUtils::arrayDiffAssocRecursive
* @dataProvider provideArrayDiffAssocRecursive
*/
* @covers ArrayUtils::arrayDiffAssocRecursive
* @dataProvider provideArrayDiffAssocRecursive
*/
- function testArrayDiffAssocRecursive( $expected ) {
- $args = func_get_args();
- array_shift( $args );
+ function testArrayDiffAssocRecursive( $expected, ...$args ) {
$this->assertEquals( call_user_func_array(
'ArrayUtils::arrayDiffAssocRecursive', $args
), $expected );
$this->assertEquals( call_user_func_array(
'ArrayUtils::arrayDiffAssocRecursive', $args
), $expected );
// That call will die if the contructor is not public, unless we use disableOriginalConstructor(),
// in which case we could not test the constructor.
abstract class PoolCounterAbstractMock extends PoolCounter {
// That call will die if the contructor is not public, unless we use disableOriginalConstructor(),
// in which case we could not test the constructor.
abstract class PoolCounterAbstractMock extends PoolCounter {
- public function __construct() {
- call_user_func_array( 'parent::__construct', func_get_args() );
+ public function __construct( ...$args ) {
+ call_user_func_array( 'parent::__construct', $args );
} ) );
$mock->expects( $this->any() )
->method( 'isAllowedAny' )
} ) );
$mock->expects( $this->any() )
->method( 'isAllowedAny' )
- ->will( $this->returnCallback( function () use ( $notAllowedAction ) {
- $actions = func_get_args();
+ ->will( $this->returnCallback( function ( ...$actions ) use ( $notAllowedAction ) {
return !in_array( $notAllowedAction, $actions );
} ) );
return !in_array( $notAllowedAction, $actions );
} ) );
->getMock();
$mock->expects( $this->any() )
->method( 'makeKey' )
->getMock();
$mock->expects( $this->any() )
->method( 'makeKey' )
- ->will( $this->returnCallback( function () {
- return implode( ':', func_get_args() );
+ ->will( $this->returnCallback( function ( ...$args ) {
+ return implode( ':', $args );