3 namespace Wikimedia\Rdbms
;
9 * Overloads the relevant methods of the real ResultWrapper so it
10 * doesn't go anywhere near an actual database.
12 class FakeResultWrapper
extends ResultWrapper
{
13 /** @var stdClass[]|array[]|null */
17 * @param stdClass[]|array[]|FakeResultWrapper $result
19 public function __construct( $result ) {
20 if ( $result instanceof self
) {
21 $this->result
= $result->result
;
23 $this->result
= $result;
27 protected function doNumRows() {
28 return count( $this->result
);
31 protected function doFetchObject() {
32 $value = $this->result
[$this->currentPos
] ??
false;
33 return is_array( $value ) ?
(object)$value : $value;
36 protected function doFetchRow() {
37 $row = $this->doFetchObject();
38 return is_object( $row ) ?
get_object_vars( $row ) : $row;
41 protected function doSeek( $pos ) {
44 protected function doFree() {
48 protected function doGetFieldNames() {
49 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
50 throw new RuntimeException( __METHOD__
. ' is unimplemented' );