From: Thiemo Kreuz Date: Tue, 28 May 2019 14:07:50 +0000 (+0200) Subject: Inline trivial …_internal() methods in Title/UserArray classes X-Git-Tag: 1.34.0-rc.0~1548^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=faffad7cf802ac4d4344b9fb1b8e9d1258bf6871;p=lhc%2Fweb%2Fwiklou.git Inline trivial …_internal() methods in Title/UserArray classes This code is quite old. I can't tell why it was written this way. But I can see these methods are never used anywhere else. We can as well inline them. Change-Id: I252f4d2b2b2da822c8d43ffc1f088f5848034c5e --- diff --git a/includes/TitleArray.php b/includes/TitleArray.php index a1eabe5b25..f6969851d5 100644 --- a/includes/TitleArray.php +++ b/includes/TitleArray.php @@ -42,18 +42,6 @@ abstract class TitleArray implements Iterator { if ( !Hooks::run( 'TitleArrayFromResult', [ &$array, $res ] ) ) { return null; } - if ( $array === null ) { - $array = self::newFromResult_internal( $res ); - } - return $array; - } - - /** - * @param IResultWrapper $res - * @return TitleArrayFromResult - */ - protected static function newFromResult_internal( $res ) { - $array = new TitleArrayFromResult( $res ); - return $array; + return $array ?? new TitleArrayFromResult( $res ); } } diff --git a/includes/user/UserArray.php b/includes/user/UserArray.php index 66d9c7a1f8..c398e4904e 100644 --- a/includes/user/UserArray.php +++ b/includes/user/UserArray.php @@ -32,10 +32,7 @@ abstract class UserArray implements Iterator { if ( !Hooks::run( 'UserArrayFromResult', [ &$userArray, $res ] ) ) { return null; } - if ( $userArray === null ) { - $userArray = self::newFromResult_internal( $res ); - } - return $userArray; + return $userArray ?? new UserArrayFromResult( $res ); } /** @@ -84,12 +81,4 @@ abstract class UserArray implements Iterator { ); return self::newFromResult( $res ); } - - /** - * @param IResultWrapper $res - * @return UserArrayFromResult - */ - protected static function newFromResult_internal( $res ) { - return new UserArrayFromResult( $res ); - } }