aboutsummaryrefslogtreecommitdiffstats
path: root/includes/user/UserArrayFromResult.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/user/UserArrayFromResult.php')
-rw-r--r--includes/user/UserArrayFromResult.php32
1 files changed, 10 insertions, 22 deletions
diff --git a/includes/user/UserArrayFromResult.php b/includes/user/UserArrayFromResult.php
index febb61135b6f..611449152dbf 100644
--- a/includes/user/UserArrayFromResult.php
+++ b/includes/user/UserArrayFromResult.php
@@ -27,34 +27,23 @@ use Wikimedia\Rdbms\IResultWrapper;
* @internal Call and type against UserArray instead.
*/
class UserArrayFromResult extends UserArray {
- /** @var IResultWrapper */
- public $res;
- /** @var int */
- public $key;
+ private IResultWrapper $res;
+ private int $key = 0;
+ /** FIXME not private because CentralAuth is extending this class when it shouldn't. See T387148 */
+ protected ?User $current = null;
- /** @var User|false */
- public $current;
-
- /**
- * @param IResultWrapper $res
- */
- public function __construct( $res ) {
+ public function __construct( IResultWrapper $res ) {
$this->res = $res;
- $this->key = 0;
- $this->setCurrent( $this->res->current() );
+ $this->rewind();
}
/**
- * @param stdClass|false $row
+ * @param stdClass|null|false $row
* @return void
*/
protected function setCurrent( $row ) {
- if ( $row === false ) {
- $this->current = false;
- } else {
- $this->current = User::newFromRow( $row );
- }
+ $this->current = $row instanceof stdClass ? User::newFromRow( $row ) : null;
}
public function count(): int {
@@ -70,8 +59,7 @@ class UserArrayFromResult extends UserArray {
}
public function next(): void {
- $row = $this->res->fetchObject();
- $this->setCurrent( $row );
+ $this->setCurrent( $this->res->fetchObject() );
$this->key++;
}
@@ -82,7 +70,7 @@ class UserArrayFromResult extends UserArray {
}
public function valid(): bool {
- return $this->current !== false;
+ return (bool)$this->current;
}
}