From f308135df39c29f3227ecc9c34c1225dc468a90e Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Wed, 20 Mar 2019 21:16:08 -0700 Subject: [PATCH] Use PHP 7's ?? syntax Change-Id: I768782b8acbc1776e29886d330358553675e272b --- includes/common/Base.php | 3 +-- includes/engines/LuaCommon/LuaCommon.php | 8 ++++---- includes/engines/LuaCommon/UstringLibrary.php | 2 +- includes/engines/LuaStandalone/LuaStandaloneEngine.php | 4 +--- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/includes/common/Base.php b/includes/common/Base.php index 871ca59c..26bdba49 100644 --- a/includes/common/Base.php +++ b/includes/common/Base.php @@ -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; } /** diff --git a/includes/engines/LuaCommon/LuaCommon.php b/includes/engines/LuaCommon/LuaCommon.php index a3099d65..0faa1b3d 100644 --- a/includes/engines/LuaCommon/LuaCommon.php +++ b/includes/engines/LuaCommon/LuaCommon.php @@ -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] ?? '', ]; } diff --git a/includes/engines/LuaCommon/UstringLibrary.php b/includes/engines/LuaCommon/UstringLibrary.php index a699ea6b..a053a5a9 100644 --- a/includes/engines/LuaCommon/UstringLibrary.php +++ b/includes/engines/LuaCommon/UstringLibrary.php @@ -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]; } diff --git a/includes/engines/LuaStandalone/LuaStandaloneEngine.php b/includes/engines/LuaStandalone/LuaStandaloneEngine.php index bd8272b2..765312fb 100644 --- a/includes/engines/LuaStandalone/LuaStandaloneEngine.php +++ b/includes/engines/LuaStandalone/LuaStandaloneEngine.php @@ -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(