Use PHP 7's ?? syntax

Change-Id: I768782b8acbc1776e29886d330358553675e272b
This commit is contained in:
Kunal Mehta 2019-03-20 21:16:08 -07:00
parent 822d34c2a3
commit f308135df3
4 changed files with 7 additions and 10 deletions

View file

@ -128,8 +128,7 @@ abstract class ScribuntoEngineBase {
* @return mixed
*/
public function getOption( $optionName ) {
return isset( $this->options[$optionName] )
? $this->options[$optionName] : null;
return $this->options[$optionName] ?? null;
}
/**

View file

@ -241,7 +241,7 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase {
$oldExpandCache = $this->expandCache;
$this->currentFrames = [
'current' => $frame,
'parent' => isset( $frame->parent ) ? $frame->parent : null,
'parent' => $frame->parent ?? null,
];
$this->expandCache = [];
@ -374,7 +374,7 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase {
# Prepending an "@" to the chunk name makes Lua think it is a filename
$module = $this->getInterpreter()->loadString( $code, '@' . basename( $fileName ) );
$ret = $this->getInterpreter()->callFunction( $module );
return isset( $ret[0] ) ? $ret[0] : null;
return $ret[0] ?? null;
}
public function getGeSHiLanguage() {
@ -441,8 +441,8 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase {
$ret = $this->getInterpreter()->callFunction( $func, $contentInit, $contentExe );
return [
'return' => isset( $ret[0] ) ? $ret[0] : null,
'print' => isset( $ret[1] ) ? $ret[1] : '',
'return' => $ret[0] ?? null,
'print' => $ret[1] ?? '',
];
}

View file

@ -803,7 +803,7 @@ class Scribunto_LuaUstringLibrary extends Scribunto_LuaLibraryBase {
if ( $anypos ) {
$m = array_shift( $captures );
}
$x = isset( $m['m1'] ) ? $m['m1'] : $m[0];
$x = $m['m1'] ?? $m[0];
if ( !isset( $repl[$x] ) || $repl[$x] === null ) {
return $m[0];
}

View file

@ -213,9 +213,7 @@ class Scribunto_LuaStandaloneInterpreter extends Scribunto_LuaInterpreter {
$this->engine = $engine;
$this->enableDebug = !empty( $options['debug'] );
$this->logger = isset( $options['logger'] )
? $options['logger']
: new NullLogger();
$this->logger = $options['logger'] ?? new NullLogger();
$pipes = null;
$cmd = wfEscapeShellArg(