Skip to content

Commit

Permalink
a lot of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dedalozzo committed Nov 30, 2017
1 parent 2cb1617 commit 6e1af5f
Showing 3 changed files with 18 additions and 25 deletions.
32 changes: 17 additions & 15 deletions src/EoC/Couch.php
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@
use Surfer\Message\Response;
use Surfer\Hook\IChunkHook;

use stdClass;


/**
* @brief The CouchDB's client. You need an instance of this class to interact with CouchDB.
@@ -57,10 +59,10 @@ public function __construct(IClientAdapter $adapter) {
/**
* @brief Returns a CouchDB wild card.
* @details A standard object is translated to JSON as `{}` same of a JavaScript empty object.
* @return [stdClass](http://php.net/manual/en/language.types.object.php)
* @return stdClass
*/
public static function WildCard() {
return new \stdClass();
return new stdClass();
}


@@ -90,7 +92,7 @@ private function setDocInfo(Doc\IDoc $doc) {
* @param array $keys An array containing the keys.
* @param[out] array $rows An associative array containing the rows.
*/
private function addMissingRows($keys, &$rows) {
private function addMissingRows(array $keys, &$rows) {

if (!empty($keys) && isset($rows)) {

@@ -237,7 +239,7 @@ public function restartServer() {
* @brief Returns an object that contains MOTD, server and client and PHP versions.
* @details The MOTD can be specified in CouchDB configuration files. This function returns more information
* compared to the CouchDB standard REST call.
* @return Info::ServerInfo
* @return Info\ServerInfo
*/
public function getServerInfo() {
$response = $this->send(new Request(Request::GET_METHOD, "/"));
@@ -248,7 +250,7 @@ public function getServerInfo() {

/**
* @brief Returns information about the Elephant on Couch client.
* @return Info::ClientInfo
* @return Info\ClientInfo
*/
public function getClientInfo() {
return new Info\ClientInfo();
@@ -295,7 +297,7 @@ public function getAllDbs() {
/**
* @brief Returns a list of all database events in the CouchDB instance.
* @param DbUpdatesFeedOpts $opts Additional options.
* @return Response
* @return array An associative array.
* @attention Requires admin privileges.
* @see http://docs.couchdb.org/en/latest/api/server/common.html#db-updates
*/
@@ -312,7 +314,7 @@ public function getDbUpdates(Opt\DbUpdatesFeedOpts $opts = NULL) {
/**
* @brief Returns a list of running tasks.
* @attention Requires admin privileges.
* @return array An associative array
* @return array An associative array.
* @see http://docs.couchdb.org/en/latest/api/server/common.html#active-tasks
*/
public function getActiveTasks() {
@@ -562,7 +564,7 @@ public function deleteDb($name) {
/**
* @brief Returns information about the selected database.
* @param string $name The database name.
* @return Info::DbInfo
* @return array An associative array.
* @see http://docs.couchdb.org/en/latest/api/database/common.html#get--db
*/
public function getDbInfo($name) {
@@ -865,12 +867,12 @@ public function getReplicator() {
* multi-document-fetch feature.
* @param ViewQueryOpts $opts (optional) Query options to get additional information, grouping results, include
* docs, etc.
* @param ChunkHook $chunkHook (optional) A class instance that implements the IChunkHook interface.
* @return Result::QueryResult The result of the query.
* @param IChunkHook $chunkHook (optional) A class instance that implements the IChunkHook interface.
* @return Result\QueryResult The result of the query.
* @see http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs
* @see http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs
*/
public function queryAllDocs($dbName, array $keys = NULL, Opt\ViewQueryOpts $opts = NULL, Hook\IChunkHook $chunkHook = NULL) {
public function queryAllDocs($dbName, array $keys = NULL, Opt\ViewQueryOpts $opts = NULL, IChunkHook $chunkHook = NULL) {
if (is_null($keys))
$request = new Request(Request::GET_METHOD, "/".rawurlencode($this->prefix.$dbName)."/_all_docs");
else {
@@ -898,14 +900,14 @@ public function queryAllDocs($dbName, array $keys = NULL, Opt\ViewQueryOpts $opt
* @param ViewQueryOpts $opts (optional) Query options to get additional information, grouping results, include
* docs, etc.
* @param IChunkHook $chunkHook (optional) A class instance that implements the IChunkHook interface.
* @return Result::QueryResult The result of the query.
* @return Result\QueryResult The result of the query.
* @attention Multiple keys request to a reduce function only supports `group=true` (identical to `group-level=exact`,
* but it doesn't support `group_level` > 0.
* CouchDB raises "Multi-key fetchs for reduce view must include `group=true`" error, in case you use `group_level`.
* @see http://docs.couchdb.org/en/latest/api/ddoc/views.html#get--db-_design-ddoc-_view-view
* @see http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view
*/
public function queryView($dbName, $designDocName, $viewName, array $keys = NULL, Opt\ViewQueryOpts $opts = NULL, Hook\IChunkHook $chunkHook = NULL) {
public function queryView($dbName, $designDocName, $viewName, array $keys = NULL, Opt\ViewQueryOpts $opts = NULL, IChunkHook $chunkHook = NULL) {
$this->validateAndEncodeDocId($designDocName);

if (empty($viewName))
@@ -951,10 +953,10 @@ public function queryView($dbName, $designDocName, $viewName, array $keys = NULL
* docs, etc.
* @param string $language The language used to implement the map and reduce functions.
* @param IChunkHook $chunkHook (optional) A class instance that implements the IChunkHook interface.
* @return Result::QueryResult The result of the query.
* @return Result\QueryResult The result of the query.
* @see http://docs.couchdb.org/en/latest/api/database/temp-views.html#post--db-_temp_view
*/
public function queryTempView($dbName, $mapFn, $reduceFn = "", array $keys = NULL, Opt\ViewQueryOpts $opts = NULL, $language = 'php', Hook\IChunkHook $chunkHook = NULL) {
public function queryTempView($dbName, $mapFn, $reduceFn = "", array $keys = NULL, Opt\ViewQueryOpts $opts = NULL, $language = 'php', IChunkHook $chunkHook = NULL) {
$handler = new Handler\ViewHandler('temp');
$handler->language = $language;
$handler->mapFn = $mapFn;
9 changes: 0 additions & 9 deletions src/EoC/Doc/AbstractDoc.php
Original file line number Diff line number Diff line change
@@ -80,27 +80,18 @@ public function hasType() {
abstract public function getPath();


/**
* @copydoc MetaClass::assignJson()
*/
public function assignJson($json) {
parent::assignJson($json);
$this->fixDocId();
}


/**
* @copydoc MetaClass::assignArray()
*/
public function assignArray(array $array) {
parent::assignArray($array);
$this->fixDocId();
}


/**
* @copydoc MetaClass::assignObject()
*/
public function assignObject(\stdClass $object) {
parent::assignObject($object);
$this->fixDocId();
2 changes: 1 addition & 1 deletion src/EoC/Version.php
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ class Version {

const MAJOR = '0'; //!< Major release number.
const MINOR = '9'; //!< Minor release number.
const MAINTENANCE = '0'; //!< Maintenance release number (bug fixes only).
const MAINTENANCE = '1'; //!< Maintenance release number (bug fixes only).


/**

0 comments on commit 6e1af5f

Please sign in to comment.