wiki.techinc.nl/includes/libs/rdbms/database/resultwrapper/FakeResultWrapper.php
Umherirrender be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00

65 lines
1.1 KiB
PHP

<?php
namespace Wikimedia\Rdbms;
use stdClass;
/**
* Overloads the relevant methods of the real ResultsWrapper so it
* doesn't go anywhere near an actual database.
*/
class FakeResultWrapper extends ResultWrapper {
/** @var $result stdClass[] */
/**
* @param stdClass[] $rows
*/
function __construct( array $rows ) {
parent::__construct( null, $rows );
}
function numRows() {
return count( $this->result );
}
function fetchRow() {
if ( $this->pos < count( $this->result ) ) {
$this->currentRow = $this->result[$this->pos];
} else {
$this->currentRow = false;
}
$this->pos++;
if ( is_object( $this->currentRow ) ) {
return get_object_vars( $this->currentRow );
} else {
return $this->currentRow;
}
}
function seek( $row ) {
$this->pos = $row;
}
function free() {
}
function fetchObject() {
$this->fetchRow();
if ( $this->currentRow ) {
return (object)$this->currentRow;
} else {
return false;
}
}
function rewind() {
$this->pos = 0;
$this->currentRow = null;
}
function next() {
return $this->fetchObject();
}
}
class_alias( FakeResultWrapper::class, 'FakeResultWrapper' );