mediawiki-extensions-Scribunto/includes/engines/LuaSandbox/LuaSandboxCallback.php
Brad Jorsch 3a19bb8b0c Document a lot of methods
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
2020-01-17 23:03:03 +00:00

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() );
}
}
}