3 namespace Wikimedia\Rdbms
;
8 * Overloads the relevant methods of the real ResultsWrapper so it
9 * doesn't go anywhere near an actual database.
11 class FakeResultWrapper
implements IResultWrapper
{
12 /** @var stdClass[]|array[] */
19 * @param stdClass[]|array[]|FakeResultWrapper $result
21 public function __construct( $result ) {
22 if ( $result instanceof self
) {
23 $this->result
= $result->result
;
25 $this->result
= $result;
29 public function numRows() {
30 return count( $this->result
);
33 public function fetchObject() {
34 $current = $this->current();
41 public function fetchRow() {
42 $row = $this->valid() ?
$this->result
[$this->pos
] : false;
46 return is_object( $row ) ?
get_object_vars( $row ) : $row;
49 public function seek( $pos ) {
53 public function free() {
57 public function rewind() {
61 public function current() {
62 $row = $this->valid() ?
$this->result
[$this->pos
] : false;
64 return is_array( $row ) ?
(object)$row : $row;
67 public function key() {
71 public function next() {
74 return $this->current();
77 public function valid() {
78 return array_key_exists( $this->pos
, $this->result
);
83 * @deprecated since 1.29
85 class_alias( FakeResultWrapper
::class, 'FakeResultWrapper' );