mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-09-23 02:09:36 +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 = [
|
$val = [
|
||||||
'prefix' => $prefix,
|
'prefix' => $prefix,
|
||||||
'url' => $urlUtils->expand( $row['iw_url'], PROTO_RELATIVE ) ?? false,
|
'url' => $urlUtils->expand( $row['iw_url'], PROTO_RELATIVE ) ?? false,
|
||||||
'isProtocolRelative' => substr( $row['iw_url'], 0, 2 ) === '//',
|
'isProtocolRelative' => str_starts_with( $row['iw_url'], '//' ),
|
||||||
'isLocal' => isset( $row['iw_local'] ) && $row['iw_local'] == '1',
|
'isLocal' => (bool)( $row['iw_local'] ?? false ),
|
||||||
'isTranscludable' => isset( $row['iw_trans'] ) && $row['iw_trans'] == '1',
|
'isTranscludable' => (bool)( $row['iw_trans'] ?? false ),
|
||||||
'isCurrentWiki' => in_array( $prefix, $localInterwikis ),
|
'isCurrentWiki' => in_array( $prefix, $localInterwikis ),
|
||||||
'isExtraLanguageLink' => in_array( $prefix, $extraInterlanguageLinkPrefixes ),
|
'isExtraLanguageLink' => in_array( $prefix, $extraInterlanguageLinkPrefixes ),
|
||||||
];
|
];
|
||||||
|
|
|
@ -106,9 +106,7 @@ foreach ( $pats as $k => $pp ) {
|
||||||
$rstart = null;
|
$rstart = null;
|
||||||
foreach ( $chars as $i => $c ) {
|
foreach ( $chars as $i => $c ) {
|
||||||
if ( preg_match( "/^$re$/u", $c ) && !preg_match( "/^$re2$/u", $c ) ) {
|
if ( preg_match( "/^$re$/u", $c ) && !preg_match( "/^$re2$/u", $c ) ) {
|
||||||
if ( $rstart === null ) {
|
$rstart ??= $i;
|
||||||
$rstart = $i;
|
|
||||||
}
|
|
||||||
} elseif ( $rstart !== null ) {
|
} elseif ( $rstart !== null ) {
|
||||||
addRange( $k, $rstart, $i );
|
addRange( $k, $rstart, $i );
|
||||||
$rstart = null;
|
$rstart = null;
|
||||||
|
|
|
@ -103,10 +103,7 @@ abstract class LuaEngineTestBase extends MediaWikiLangTestCase {
|
||||||
public function toString(): string {
|
public function toString(): string {
|
||||||
// When running tests written in Lua, return a nicer representation in
|
// When running tests written in Lua, return a nicer representation in
|
||||||
// the failure message.
|
// the failure message.
|
||||||
if ( $this->luaTestName ) {
|
return $this->engineName . ': ' . ( $this->luaTestName ?: parent::toString() );
|
||||||
return $this->engineName . ': ' . $this->luaTestName;
|
|
||||||
}
|
|
||||||
return $this->engineName . ': ' . parent::toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -91,10 +91,7 @@ abstract class LuaEngineUnitTestBase extends TestCase {
|
||||||
public function toString(): string {
|
public function toString(): string {
|
||||||
// When running tests written in Lua, return a nicer representation in
|
// When running tests written in Lua, return a nicer representation in
|
||||||
// the failure message.
|
// the failure message.
|
||||||
if ( $this->luaTestName ) {
|
return $this->engineName . ': ' . ( $this->luaTestName ?: parent::toString() );
|
||||||
return $this->engineName . ': ' . $this->luaTestName;
|
|
||||||
}
|
|
||||||
return $this->engineName . ': ' . parent::toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue