From: Thiemo Kreuz Date: Sun, 24 Mar 2019 21:40:49 +0000 (+0100) Subject: Use the ?? feature instead of isset() where it makes sense X-Git-Tag: 1.34.0-rc.0~2385^2 X-Git-Url: http://git.cyclocoop.org/%22.htmlspecialchars%28%24url_syndic%29.%22?a=commitdiff_plain;h=2540c29b207494d771bd8e5b0ab43f0a056b5283;p=lhc%2Fweb%2Fwiklou.git Use the ?? feature instead of isset() where it makes sense Change-Id: I3a54f36b33d99ef3ff4c63e32e7dfcbcfc296135 --- diff --git a/includes/ActorMigration.php b/includes/ActorMigration.php index 0c33eb9bfc..597b8e76e7 100644 --- a/includes/ActorMigration.php +++ b/includes/ActorMigration.php @@ -136,11 +136,7 @@ class ActorMigration { * @return string[] [ $text, $actor ] */ private static function getFieldNames( $key ) { - if ( isset( self::$specialFields[$key] ) ) { - return self::$specialFields[$key]; - } - - return [ $key . '_text', substr( $key, 0, -5 ) . '_actor' ]; + return self::$specialFields[$key] ?? [ $key . '_text', substr( $key, 0, -5 ) . '_actor' ]; } /** diff --git a/includes/MagicWordArray.php b/includes/MagicWordArray.php index fde32ce4fd..707c644a8d 100644 --- a/includes/MagicWordArray.php +++ b/includes/MagicWordArray.php @@ -268,10 +268,7 @@ class MagicWordArray { return $hash[1][$text]; } $lc = $this->factory->getContentLanguage()->lc( $text ); - if ( isset( $hash[0][$lc] ) ) { - return $hash[0][$lc]; - } - return false; + return $hash[0][$lc] ?? false; } /** diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index e03352554b..bff9fd0095 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -158,11 +158,9 @@ abstract class ApiFormatBase extends ApiBase { if ( !is_array( $paramSettings ) ) { return $paramSettings; - } elseif ( isset( $paramSettings[self::PARAM_DFLT] ) ) { - return $paramSettings[self::PARAM_DFLT]; - } else { - return null; } + + return $paramSettings[self::PARAM_DFLT] ?? null; } /** diff --git a/includes/config/ConfigRepository.php b/includes/config/ConfigRepository.php index 96dc51c118..2874c334f4 100644 --- a/includes/config/ConfigRepository.php +++ b/includes/config/ConfigRepository.php @@ -71,10 +71,8 @@ class ConfigRepository implements SalvageableService { if ( !$this->has( $name, true ) ) { throw new \ConfigException( 'The configuration option ' . $name . ' does not exist.' ); } - if ( isset( $this->configItems['public'][$name] ) ) { - return $this->configItems['public'][$name]; - } - return $this->configItems['private'][$name]; + + return $this->configItems['public'][$name] ?? $this->configItems['private'][$name]; } /** diff --git a/includes/filerepo/file/ForeignAPIFile.php b/includes/filerepo/file/ForeignAPIFile.php index c49810cfeb..3a75720cdf 100644 --- a/includes/filerepo/file/ForeignAPIFile.php +++ b/includes/filerepo/file/ForeignAPIFile.php @@ -184,11 +184,7 @@ class ForeignAPIFile extends File { * null on error */ public function getExtendedMetadata() { - if ( isset( $this->mInfo['extmetadata'] ) ) { - return $this->mInfo['extmetadata']; - } - - return null; + return $this->mInfo['extmetadata'] ?? null; } /** diff --git a/includes/media/MediaHandlerFactory.php b/includes/media/MediaHandlerFactory.php index 543dc80dfd..82e8d1ffc2 100644 --- a/includes/media/MediaHandlerFactory.php +++ b/includes/media/MediaHandlerFactory.php @@ -66,11 +66,7 @@ class MediaHandlerFactory { } protected function getHandlerClass( $type ) { - if ( isset( $this->registry[$type] ) ) { - return $this->registry[$type]; - } else { - return false; - } + return $this->registry[$type] ?? false; } /** diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 699de951b6..1c93261a86 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -938,12 +938,7 @@ class ParserTestRunner { */ private static function getOptionValue( $key, $opts, $default ) { $key = strtolower( $key ); - - if ( isset( $opts[$key] ) ) { - return $opts[$key]; - } else { - return $default; - } + return $opts[$key] ?? $default; } /**