mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-04 20:58:13 +00:00
3a19bb8b0c
Clear up a bunch of phpcs ignores by documenting many methods. Also remove Scribunto_LuaError::setLineMap(), which has apparently never been used since it was added in Ia51f439e. Change-Id: I763bcdbc7edbbb8e4600495a03acca3439fc0ec9
32 lines
638 B
PHP
32 lines
638 B
PHP
<?php
|
|
|
|
class Scribunto_LuaSandboxCallback {
|
|
|
|
/**
|
|
* @var callable
|
|
*/
|
|
protected $callback;
|
|
|
|
/**
|
|
* @param callable $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() );
|
|
}
|
|
}
|
|
}
|