Rename IP::isValidBlock to isValidRange, deprecating the former
[lhc/web/wiklou.git] / includes / user / UserArray.php
index 31bd601..ab6683b 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use Wikimedia\Rdbms\ResultWrapper;
+
 abstract class UserArray implements Iterator {
        /**
         * @param ResultWrapper $res
@@ -27,7 +29,7 @@ abstract class UserArray implements Iterator {
         */
        static function newFromResult( $res ) {
                $userArray = null;
-               if ( !Hooks::run( 'UserArrayFromResult', array( &$userArray, $res ) ) ) {
+               if ( !Hooks::run( 'UserArrayFromResult', [ &$userArray, $res ] ) ) {
                        return null;
                }
                if ( $userArray === null ) {
@@ -38,19 +40,19 @@ abstract class UserArray implements Iterator {
 
        /**
         * @param array $ids
-        * @return UserArrayFromResult
+        * @return UserArrayFromResult|ArrayIterator
         */
        static function newFromIDs( $ids ) {
                $ids = array_map( 'intval', (array)$ids ); // paranoia
                if ( !$ids ) {
                        // Database::select() doesn't like empty arrays
-                       return new ArrayIterator( array() );
+                       return new ArrayIterator( [] );
                }
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
                $res = $dbr->select(
                        'user',
                        User::selectFields(),
-                       array( 'user_id' => array_unique( $ids ) ),
+                       [ 'user_id' => array_unique( $ids ) ],
                        __METHOD__
                );
                return self::newFromResult( $res );
@@ -59,19 +61,19 @@ abstract class UserArray implements Iterator {
        /**
         * @since 1.25
         * @param array $names
-        * @return UserArrayFromResult
+        * @return UserArrayFromResult|ArrayIterator
         */
        static function newFromNames( $names ) {
                $names = array_map( 'strval', (array)$names ); // paranoia
                if ( !$names ) {
                        // Database::select() doesn't like empty arrays
-                       return new ArrayIterator( array() );
+                       return new ArrayIterator( [] );
                }
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
                $res = $dbr->select(
                        'user',
                        User::selectFields(),
-                       array( 'user_name' => array_unique( $names ) ),
+                       [ 'user_name' => array_unique( $names ) ],
                        __METHOD__
                );
                return self::newFromResult( $res );