Inline trivial …_internal() methods in Title/UserArray classes
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Tue, 28 May 2019 14:07:50 +0000 (16:07 +0200)
committerThiemo Kreuz (WMDE) <thiemo.kreuz@wikimedia.de>
Wed, 29 May 2019 19:22:03 +0000 (19:22 +0000)
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

includes/TitleArray.php
includes/user/UserArray.php

index a1eabe5..f696985 100644 (file)
@@ -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 );
        }
 }
index 66d9c7a..c398e49 100644 (file)
@@ -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 );
-       }
 }