mediawiki-extensions-Parser.../ParserFunctions.library.php
Umherirrender 04e4c1b300 Add phpcs and make pass
Change-Id: I8f985ca83223f1a2fdb4365294701f3b1d9b019b
2017-06-06 19:51:28 +00:00

24 lines
578 B
PHP

<?php
class Scribunto_LuaParserFunctionsLibrary extends Scribunto_LuaLibraryBase {
public function register() {
$lib = [
'expr' => [ $this, 'expr' ],
];
return $this->getEngine()->registerInterface(
__DIR__ . '/mw.ext.ParserFunctions.lua', $lib, []
);
}
public function expr( $expression = null ) {
$this->checkType( 'mw.ext.ParserFunctions.expr', 1, $expression, 'string' );
try {
return [ ExtParserFunctions::getExprParser()->doExpression( $expression ) ];
} catch ( ExprError $e ) {
throw new Scribunto_LuaError( $e->getMessage() );
}
}
}