mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-23 15:56:55 +00:00
Make use of ??=, ?: and similar operators where possible
The main benefit of these operators is that they avoid repeating parts of the code. Change-Id: I86ea0eb02715ad5b7c62a71849309ed7095c5972
This commit is contained in:
parent
b1cc0225a9
commit
a630e3d129
|
@ -228,9 +228,9 @@ class SiteLibrary extends LibraryBase {
|
|||
$val = [
|
||||
'prefix' => $prefix,
|
||||
'url' => $urlUtils->expand( $row['iw_url'], PROTO_RELATIVE ) ?? false,
|
||||
'isProtocolRelative' => substr( $row['iw_url'], 0, 2 ) === '//',
|
||||
'isLocal' => isset( $row['iw_local'] ) && $row['iw_local'] == '1',
|
||||
'isTranscludable' => isset( $row['iw_trans'] ) && $row['iw_trans'] == '1',
|
||||
'isProtocolRelative' => str_starts_with( $row['iw_url'], '//' ),
|
||||
'isLocal' => (bool)( $row['iw_local'] ?? false ),
|
||||
'isTranscludable' => (bool)( $row['iw_trans'] ?? false ),
|
||||
'isCurrentWiki' => in_array( $prefix, $localInterwikis ),
|
||||
'isExtraLanguageLink' => in_array( $prefix, $extraInterlanguageLinkPrefixes ),
|
||||
];
|
||||
|
|
|
@ -106,9 +106,7 @@ foreach ( $pats as $k => $pp ) {
|
|||
$rstart = null;
|
||||
foreach ( $chars as $i => $c ) {
|
||||
if ( preg_match( "/^$re$/u", $c ) && !preg_match( "/^$re2$/u", $c ) ) {
|
||||
if ( $rstart === null ) {
|
||||
$rstart = $i;
|
||||
}
|
||||
$rstart ??= $i;
|
||||
} elseif ( $rstart !== null ) {
|
||||
addRange( $k, $rstart, $i );
|
||||
$rstart = null;
|
||||
|
|
|
@ -103,10 +103,7 @@ abstract class LuaEngineTestBase extends MediaWikiLangTestCase {
|
|||
public function toString(): string {
|
||||
// When running tests written in Lua, return a nicer representation in
|
||||
// the failure message.
|
||||
if ( $this->luaTestName ) {
|
||||
return $this->engineName . ': ' . $this->luaTestName;
|
||||
}
|
||||
return $this->engineName . ': ' . parent::toString();
|
||||
return $this->engineName . ': ' . ( $this->luaTestName ?: parent::toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -91,10 +91,7 @@ abstract class LuaEngineUnitTestBase extends TestCase {
|
|||
public function toString(): string {
|
||||
// When running tests written in Lua, return a nicer representation in
|
||||
// the failure message.
|
||||
if ( $this->luaTestName ) {
|
||||
return $this->engineName . ': ' . $this->luaTestName;
|
||||
}
|
||||
return $this->engineName . ': ' . parent::toString();
|
||||
return $this->engineName . ': ' . ( $this->luaTestName ?: parent::toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue