Use the ?? feature instead of isset() where it makes sense

Change-Id: I3a54f36b33d99ef3ff4c63e32e7dfcbcfc296135
This commit is contained in:
Thiemo Kreuz 2019-03-24 22:40:49 +01:00
parent 0449f653c7
commit 2540c29b20
7 changed files with 9 additions and 33 deletions

View file

@ -136,11 +136,7 @@ class ActorMigration {
* @return string[] [ $text, $actor ] * @return string[] [ $text, $actor ]
*/ */
private static function getFieldNames( $key ) { private static function getFieldNames( $key ) {
if ( isset( self::$specialFields[$key] ) ) { return self::$specialFields[$key] ?? [ $key . '_text', substr( $key, 0, -5 ) . '_actor' ];
return self::$specialFields[$key];
}
return [ $key . '_text', substr( $key, 0, -5 ) . '_actor' ];
} }
/** /**

View file

@ -268,10 +268,7 @@ class MagicWordArray {
return $hash[1][$text]; return $hash[1][$text];
} }
$lc = $this->factory->getContentLanguage()->lc( $text ); $lc = $this->factory->getContentLanguage()->lc( $text );
if ( isset( $hash[0][$lc] ) ) { return $hash[0][$lc] ?? false;
return $hash[0][$lc];
}
return false;
} }
/** /**

View file

@ -158,11 +158,9 @@ abstract class ApiFormatBase extends ApiBase {
if ( !is_array( $paramSettings ) ) { if ( !is_array( $paramSettings ) ) {
return $paramSettings; return $paramSettings;
} elseif ( isset( $paramSettings[self::PARAM_DFLT] ) ) {
return $paramSettings[self::PARAM_DFLT];
} else {
return null;
} }
return $paramSettings[self::PARAM_DFLT] ?? null;
} }
/** /**

View file

@ -71,10 +71,8 @@ class ConfigRepository implements SalvageableService {
if ( !$this->has( $name, true ) ) { if ( !$this->has( $name, true ) ) {
throw new \ConfigException( 'The configuration option ' . $name . ' does not exist.' ); throw new \ConfigException( 'The configuration option ' . $name . ' does not exist.' );
} }
if ( isset( $this->configItems['public'][$name] ) ) {
return $this->configItems['public'][$name]; return $this->configItems['public'][$name] ?? $this->configItems['private'][$name];
}
return $this->configItems['private'][$name];
} }
/** /**

View file

@ -184,11 +184,7 @@ class ForeignAPIFile extends File {
* null on error * null on error
*/ */
public function getExtendedMetadata() { public function getExtendedMetadata() {
if ( isset( $this->mInfo['extmetadata'] ) ) { return $this->mInfo['extmetadata'] ?? null;
return $this->mInfo['extmetadata'];
}
return null;
} }
/** /**

View file

@ -66,11 +66,7 @@ class MediaHandlerFactory {
} }
protected function getHandlerClass( $type ) { protected function getHandlerClass( $type ) {
if ( isset( $this->registry[$type] ) ) { return $this->registry[$type] ?? false;
return $this->registry[$type];
} else {
return false;
}
} }
/** /**

View file

@ -938,12 +938,7 @@ class ParserTestRunner {
*/ */
private static function getOptionValue( $key, $opts, $default ) { private static function getOptionValue( $key, $opts, $default ) {
$key = strtolower( $key ); $key = strtolower( $key );
return $opts[$key] ?? $default;
if ( isset( $opts[$key] ) ) {
return $opts[$key];
} else {
return $default;
}
} }
/** /**