mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-12 08:25:10 +00:00
9c6f6f905a
Move autoload entries for test to TestAutoloadClasses key Change-Id: Ie705db0e7225600b7b498cfa134733a65f1ae1c9
29 lines
598 B
PHP
29 lines
598 B
PHP
<?php
|
|
|
|
class Scribunto_LuaSandboxCallback {
|
|
|
|
/**
|
|
* @var callable
|
|
*/
|
|
protected $callback;
|
|
|
|
public function __construct( $callback ) {
|
|
$this->callback = $callback;
|
|
}
|
|
|
|
/**
|
|
* We use __call with a variable function name so that LuaSandbox will be
|
|
* able to return a meaningful function name in profiling data.
|
|
* @param string $funcName
|
|
* @param array $args
|
|
* @return mixed
|
|
*/
|
|
public function __call( $funcName, $args ) {
|
|
try {
|
|
return ( $this->callback )( ...$args );
|
|
} catch ( Scribunto_LuaError $e ) {
|
|
throw new LuaSandboxRuntimeError( $e->getLuaMessage() );
|
|
}
|
|
}
|
|
}
|