mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-14 19:30:57 +00:00
Use PHP 7 variadic params for LuaInterpreter::callFunction()
Change-Id: I3b32e73dcee6a92d91f29915a76dd4e83c080ada
This commit is contained in:
parent
f308135df3
commit
c3d93b61e2
|
@ -16,8 +16,9 @@ abstract class Scribunto_LuaInterpreter {
|
|||
* at zero. If an error occurs, a Scribunto_LuaError will be thrown.
|
||||
*
|
||||
* @param mixed $func The function object
|
||||
* @param mixed ...$args Arguments to the function
|
||||
*/
|
||||
abstract public function callFunction( $func /*...*/ );
|
||||
abstract public function callFunction( $func, ...$args );
|
||||
|
||||
/**
|
||||
* Wrap a PHP callable as a Lua function, which can be passed back into
|
||||
|
|
|
@ -309,9 +309,7 @@ class Scribunto_LuaSandboxInterpreter extends Scribunto_LuaInterpreter {
|
|||
# $name, [ $this, 'callback' ], $functions );
|
||||
}
|
||||
|
||||
public function callFunction( $func /*, ... */ ) {
|
||||
$args = func_get_args();
|
||||
$func = array_shift( $args );
|
||||
public function callFunction( $func, ...$args ) {
|
||||
try {
|
||||
$ret = $func->call( ...$args );
|
||||
if ( $ret === false ) {
|
||||
|
|
|
@ -354,7 +354,7 @@ class Scribunto_LuaStandaloneInterpreter extends Scribunto_LuaInterpreter {
|
|||
return new Scribunto_LuaStandaloneInterpreterFunction( $this->id, $result[1] );
|
||||
}
|
||||
|
||||
public function callFunction( $func /* ... */ ) {
|
||||
public function callFunction( $func, ...$args ) {
|
||||
if ( !( $func instanceof Scribunto_LuaStandaloneInterpreterFunction ) ) {
|
||||
throw new MWException( __METHOD__ . ': invalid function type' );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue