diff --git a/composer.json b/composer.json index 328a64e..d2497aa 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ "php": ">=5.4.0", "3f/lint": "~1.3", "3f/tool-bag": "~1", - "3f/meta": "~1" + "3f/meta": "~1", + "3f/surfer": "dev-master" }, "require-dev": { "phpunit/phpunit": "5.4.6" diff --git a/src/EoC/Adapter/AbstractAdapter.php b/src/EoC/Adapter/AbstractAdapter.php deleted file mode 100644 index 0b51c64..0000000 --- a/src/EoC/Adapter/AbstractAdapter.php +++ /dev/null @@ -1,99 +0,0 @@ -tcp:\/\/|ssl:\/\/|tls:\/\/)? # Scheme - # Authority - (?P[a-z0-9\-._~%]+ # Named host - | \[[a-f0-9:.]+\] # IPv6 host - | \[v[a-f0-9][a-z0-9\-._~%!$&\'()*+,;=:]+\]) # IPvFuture host - (?P:[0-9]+)? # Port - $/ix'; - - // Used to know if the constructor has been already called. - protected static $initialized = FALSE; - - protected $scheme; - protected $host; - protected $port; - - protected $userName; - protected $password; - - - // URI specifying address of proxy server. (e.g. tcp://proxy.example.com:5100). - //protected $proxy = NULL; - - // When set to TRUE, the entire URI will be used when constructing the request. While this is a non-standard request - // format, some proxy servers require it. - //protected $requestFullUri = FALSE; - - - /** - * @brief Creates a client adapter instance. - * @param[in] string $server Server must be expressed as host:port as defined by RFC 3986. It's also possible specify - * a scheme like tcp://, ssl:// or tls://; if no scheme is present, tcp:// will be used. - * @param[in] string $userName (optional) User name. - * @param[in] string $password (optional) Password. - * @see http://www.ietf.org/rfc/rfc3986.txt - */ - public function __construct($server = self::DEFAULT_SERVER, $userName = "", $password = "") { - - // Parses the URI string '$server' to retrieve scheme, host and port and assigns matches to the relative class members. - if (preg_match(self::SCHEME_HOST_PORT_URI, $server, $matches)) { - $this->scheme = isset($matches['scheme']) ? $matches['scheme'] : "tcp://"; - $this->host = isset($matches['host']) ? $matches['host'] : self::DEFAULT_HOST; - $this->port = isset($matches['port']) ? substr($matches['port'], 1) : self::DEFAULT_PORT; - } - else // Match attempt failed. - throw new \InvalidArgumentException(sprintf("'%s' is not a valid URI.", $server)); - - $this->userName = (string)$userName; - $this->password = (string)$password; - } - - - /** - * @brief Initializes the client. - * @details This method is called just once, when the first object instance is created. It's used to execute one time - * operations due to initialize the client. Even if you create many instance of this client, this method is executed - * just once, keep it in mind. - */ - abstract public function initialize(); - - - /** - * @brief This method is used to send an HTTP Request. - * @details You can also provide an instance of a class that implements the IChunkHook interface, to deal with a chunked - * response. - * @param[in] Request $request The Request object. - * @param[in] IChunkHook $chunkHook (optional) A class instance that implements the IChunkHook interface. - * @retval EoC::Message::Response - */ - abstract public function send(Request $request, Hook\IChunkHook $chunkHook = NULL); - -} \ No newline at end of file diff --git a/src/EoC/Adapter/CurlAdapter.php b/src/EoC/Adapter/CurlAdapter.php deleted file mode 100644 index 9468d69..0000000 --- a/src/EoC/Adapter/CurlAdapter.php +++ /dev/null @@ -1,187 +0,0 @@ -initialize(); - - parent::__construct($server, $userName, $password); - - // Init cURL. - $this->handle = curl_init(); - } - - - /** - * @brief Destroys the cURL handle. - */ - public function __destruct() { - curl_close($this->handle); - } - - - /** - * @copydoc AbstractAdapter::initialize() - */ - public function initialize() { - if (!extension_loaded("curl")) - throw new \RuntimeException("The cURL extension is not loaded."); - } - - - /** - * @copydoc AbstractAdapter::send() - * @bug https://github.com/dedalozzo/eoc-client/issues/2 - */ - public function send(Request $request, Hook\IChunkHook $chunkHook = NULL) { - $opts = []; - - // Resets all the cURL options. The curl_reset() function is available only since PHP 5.5. - if (function_exists('curl_reset')) - curl_reset($this->handle); - - // Sets the methods and its related options. - switch ($request->getMethod()) { - - // GET method. - case Request::GET_METHOD: - $opts[CURLOPT_HTTPGET] = TRUE; - break; - - // POST method. - case Request::POST_METHOD: - $opts[CURLOPT_POST] = TRUE; - - // The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full - // path. This can either be passed as a urlencoded string like 'para1=val1¶2=val2&...' or as an array with - // the field name as key and field data as value. If value is an array, the Content-Type header will be set to - // multipart/form-data. - $opts[CURLOPT_POSTFIELDS] = $request->getBody(); - break; - - // PUT method. - case Request::PUT_METHOD: - $opts[CURLOPT_PUT] = TRUE; - - // Often a request contains data in the form of a JSON object. Since cURL is just able to read data from a file, - // but we can't create a temporary file because it's a too much expensive operation, the code below uses a faster - // and efficient memory stream. - if ($request->hasBody()) { - if ($fd = fopen("php://memory", "r+")) { // Try to create a temporary file in memory. - fputs($fd, $request->getBody()); // Writes the message body. - rewind($fd); // Sets the pointer to the beginning of the file stream. - - $opts[CURLOPT_INFILE] = $fd; - $opts[CURLOPT_INFILESIZE] = $request->getBodyLength(); - } - else - throw new \RuntimeException("Cannot create the stream."); - } - - break; - - // DELETE method. - case Request::DELETE_METHOD: - $opts[CURLOPT_CUSTOMREQUEST] = Request::DELETE_METHOD; - break; - - // COPY or any other custom method. - default: - $opts[CURLOPT_CUSTOMREQUEST] = $request->getMethod(); - - } // switch - - // Sets the request Uniform Resource Locator. - $opts[CURLOPT_URL] = "http://".$this->host.":".$this->port.$request->getPath().$request->getQueryString(); - - // Includes the header in the output. We need this because our Response object will parse them. - // NOTE: we don't include header anymore, because we use the option CURLOPT_HEADERFUNCTION. - //$opts[CURLOPT_HEADER] = TRUE; - - // Returns the transfer as a string of the return value of curl_exec() instead of outputting it out directly. - $opts[CURLOPT_RETURNTRANSFER] = TRUE; - - // Sets the protocol version to be used. cURL constants have different values. - $opts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; - - // Sets basic authentication. - if (!empty($this->userName)) { - $opts[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC; - $opts[CURLOPT_USERPWD] = $this->userName.":".$this->password; - } - - // Sets the previous options. - curl_setopt_array($this->handle, $opts); - - // This fix a known cURL bug: see http://the-stickman.com/web-development/php-and-curl-disabling-100-continue-header/ - // cURL sets the Expect header field automatically, ignoring the fact that a client may not need it for the specific - // request. - if (!$request->hasHeaderField(Request::EXPECT_HF)) - curl_setopt($this->handle, CURLOPT_HTTPHEADER, array("Expect:")); - - // Sets the request header. - // Due to a stupid bug, using curl_setopt_array(), cURL doesn't override the Content-Type header field. So we must - // set the header using, instead, curl_stopt() - // $opts[CURLOPT_HTTPHEADER] = $request->getHeaderAsArray(); - curl_setopt($this->handle, CURLOPT_HTTPHEADER, $request->getHeaderAsArray()); - - // Here we use this option because we might have a response without body. This may happen because we are supporting - // chunk responses, and sometimes we want trigger an hook function to let the user perform operations on coming - // chunks. - $header = ""; - curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, - function($unused, $buffer) use (&$header) { - $header .= $buffer; - return strlen($buffer); - }); - - // When the hook function is provided, we set the CURLOPT_WRITEFUNCTION so cURL will call the hook function for each - // response chunk read. - if (isset($chunkHook)) { - curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, - function($unused, $buffer) use ($chunkHook) { - $chunkHook->process($buffer); - return strlen($buffer); - }); - } - - if ($result = curl_exec($this->handle)) { - $response = new Response($header); - $response->setBody($result); - return $response; - } - else { - $error = curl_error($this->handle); - throw new \RuntimeException($error); - } - } - -} \ No newline at end of file diff --git a/src/EoC/Adapter/IClientAdapter.php b/src/EoC/Adapter/IClientAdapter.php deleted file mode 100644 index 82415ef..0000000 --- a/src/EoC/Adapter/IClientAdapter.php +++ /dev/null @@ -1,38 +0,0 @@ -initialize(); - - parent::__construct($server, $userName, $password); - - $this->timeout = static::$defaultSocketTimeout; - - // Establishes a connection within the server. - if ($persistent) - $this->handle = @pfsockopen($this->scheme.$this->host, $this->port, $errno, $errstr, $this->timeout); - else - $this->handle = @fsockopen($this->scheme.$this->host, $this->port, $errno, $errstr, $this->timeout); - - if (!is_resource($this->handle)) - throw new \ErrorException($errstr, $errno); - } - - - /** - * @brief Closes the file pointer. - */ - public function __destruct() { - //@fclose($this->handle); - } - - - /** - * @copydoc AbstractAdapter::initialize() - */ - public function initialize() { - - if (!static::$initialized) { - static::$initialized = TRUE; - - // If PHP is not properly recognizing the line endings when reading files either on or created by a Macintosh - // computer, enabling the auto_detect_line_endings run-time configuration option may help resolve the problem. - ini_set("auto_detect_line_endings", TRUE); - - // By default the default_socket_timeout php.ini setting is used. - static::$defaultSocketTimeout = ini_get("default_socket_timeout"); - } - } - - - /** - * @brief Writes the entire request over the socket. - * @param[in] Request $request A request. - */ - protected function writeRequest(Request $request) { - $command = $request->getMethod()." ".$request->getPath().$request->getQueryString()." ".self::HTTP_VERSION; - - // Writes the request over the socket. - fputs($this->handle, $command.Message::CRLF); - fputs($this->handle, $request->getHeaderAsString().Message::CRLF); - fputs($this->handle, Message::CRLF); - fputs($this->handle, $request->getBody()); - fputs($this->handle, Message::CRLF); - } - - - /** - * @brief Reads the the status code and the header of the response. - * @return string - */ - protected function readResponseStatusCodeAndHeader() { - $statusCodeAndHeader = ""; - - while (!feof($this->handle)) { - // We use fgets() because it stops reading at first newline or buffer length, depends which one is reached first. - $buffer = fgets($this->handle, self::BUFFER_LENGTH); - - // Adds the buffer to the header. - $statusCodeAndHeader .= $buffer; - - // The header is separated from the body by a newline, so we break when we read it. - if ($buffer == Message::CRLF) - break; - } - - return $statusCodeAndHeader; - } - - /** - * @brief Reads the entity-body of a chunked response. - * @see http://www.jmarshall.com/easy/http/#http1.1c2 - * @param[in] IChunkHook $chunkHook The chunk's hook. - */ - protected function readChunkedResponseBody($chunkHook) { - $body = ""; - - while (!feof($this->handle)) { - // Gets the line which has the length of this chunk. - $line = fgets($this->handle, self::BUFFER_LENGTH); - - // If it's only a newline, this normally means it's read the total amount of data requested minus the newline - // continue to next loop to make sure we're done. - if ($line == Message::CRLF) - continue; - - // The length of the block is expressed in hexadecimal. - $length = hexdec($line); - - if (!is_int($length)) - throw new \RuntimeException("The response doesn't seem chunk encoded."); - - // Zero is sent when at the end of the chunks or the end of the stream. - if ($length < 1) - break; - - // Reads the chunk. - // When reading from network streams or pipes, such as those returned when reading remote files or from popen() - // and proc_open(), reading will stop after a new packet is available. This means that we must collect the data - // together in chunks. So, we can't pass to the fread() the entire length because it could return less data than - // expected. We have to read, instead, the standard buffer length, and concatenate the read chunks. - $buffer = ""; - - while ($length > 0) { - $size = min(self::BUFFER_LENGTH, $length); - $data = fread($this->handle, $size); - - if (strlen($data) == 0) - break; // EOF - - $buffer .= $data; - $length -= strlen($data); - } - - // If a function has been hooked, calls it, else just adds the buffer to the body. - if (is_null($chunkHook)) - $body .= $buffer; - else - $chunkHook->process($buffer); - } - - // A chunk response might have some footer, but CouchDB doesn't use them, so we simply ignore them. - while (!feof($this->handle)) { - // We use fgets() because it stops reading at first newline or buffer length, depends which one is reached first. - $buffer = fgets($this->handle, self::BUFFER_LENGTH); - - // The chunk response ends with a newline, so we break when we read it. - if ($buffer == Message::CRLF) - break; - } - - return $body; - } - - - /** - * @brief Reads the entity-body of a standard response. - * @param[in] Response $response The response. - * @return string - */ - protected function readStandardResponseBody(Response $response) { - $body = ""; - - // Retrieves the body length from the header. - $length = (int)$response->getHeaderFieldValue(Response::CONTENT_LENGTH_HF); - - // The response should have a body, if not we have finished. - if ($length > 0) { - $bytes = 0; - - while (!feof($this->handle)) { - $buffer = fgets($this->handle); - $body .= $buffer; - $bytes += strlen($buffer); - - if ($bytes >= $length) - break; - } - } - - return $body; - } - - - /** - * @brief Reads the entity-body. - * @param[in] Response $response The response. - * @param[in] IChunkHook $chunkHook (optional) The chunk's hook. - * @return string - */ - protected function readResponseBody(Response $response, $chunkHook) { - if ($response->getHeaderFieldValue(Response::TRANSFER_ENCODING_HF) == "chunked") - return $this->readChunkedResponseBody($chunkHook); - else - return $this->readStandardResponseBody($response); - } - - - /** - * @copydoc AbstractAdapter::send() - */ - public function send(Request $request, IChunkHook $chunkHook = NULL) { - $request->setHeaderField(Request::HOST_HF, $this->host.":".$this->port); - - if (!empty($this->userName)) - $request->setBasicAuth($this->userName, $this->password); - - // Sets the Content-Length header only when the given request has a message body. - if ($request->hasBody()) - $request->setHeaderField(Message::CONTENT_LENGTH_HF, $request->getBodyLength()); - - // Writes the request over the socket. - $this->writeRequest($request); - - // Creates the Response object. - $response = new Response($this->readResponseStatusCodeAndHeader()); - - // The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent - // to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had - // the request been a GET. - if ($request->getMethod() != Request::HEAD_METHOD) { - // Assigns the body to the response, if any is present. - $response->setBody($this->readResponseBody($response, $chunkHook)); - } - - return $response; - } - -} \ No newline at end of file diff --git a/src/EoC/Couch.php b/src/EoC/Couch.php index a13ac7f..42b34bd 100644 --- a/src/EoC/Couch.php +++ b/src/EoC/Couch.php @@ -11,19 +11,20 @@ namespace EoC; -use EoC\Adapter\IClientAdapter; -use EoC\Message\Request; -use EoC\Message\Response; +use Surfer\Surfer; +use Surfer\Adapter\IClientAdapter; +use Surfer\Message\Request; +use Surfer\Message\Response; +use Surfer\Hook\IChunkHook; /** * @brief The CouchDB's client. You need an instance of this class to interact with CouchDB. * @nosubgrouping * @todo Add Memcached support. Remember to use Memcached extension, not memcache. - * @todo Add Post File support. * @todo Check ISO-8859-1 because CouchDB uses it, in particular utf8_encode(). */ -final class Couch { +final class Couch extends Surfer { //! The user agent name. const USER_AGENT_NAME = "EoC Client"; @@ -52,14 +53,14 @@ final class Couch { * @param[in] IClientAdapter $adapter An instance of a class that implements the IClientAdapter interface. */ public function __construct(IClientAdapter $adapter) { - $this->client = $adapter; + parent::__construct($adapter); } /** * @brief Returns a CouchDB wild card. * @details A standard object is translated to JSON as `{}` same of a JavaScript empty object. - * @retval [stdClass](http://php.net/manual/en/language.types.object.php) + * @return [stdClass](http://php.net/manual/en/language.types.object.php) */ public static function WildCard() { return new \stdClass(); @@ -89,7 +90,7 @@ private function setDocInfo(Doc\IDoc $doc) { * @details CouchDB doesn't return rows for the keys a match is not found. To make joins having a row for each key is * essential. The algorithm below overrides the rows, adding a new row for every key hasn't been matched. The JSON * encoding is necessary because we might have complex keys. A complex key is no more than an array. - * @param[in] array $keys An array containing the keys. + * @param array $keys An array containing the keys. * @param[out] array $rows An associative array containing the rows. */ private function addMissingRows($keys, &$rows) { @@ -122,7 +123,7 @@ private function addMissingRows($keys, &$rows) { /** * @brief Sets a prefix which is used to compose the database's name. - * @param[in] string $prefix A string prefix. + * @param string $prefix A string prefix. */ public function setDbPrefix($prefix) { $this->prefix = $prefix; @@ -143,11 +144,11 @@ public function getDbPrefix() { * @details If you want call a not supported CouchDB API, you can use this function to send your request.\n * You can also provide an instance of a class that implements the IChunkHook interface, to deal with a chunked * response. - * @param[in] Request $request The Request object. - * @param[in] IChunkHook $chunkHook (optional) A class instance that implements the IChunkHook interface. + * @param Request $request The Request object. + * @param IChunkHook $chunkHook (optional) A class instance that implements the IChunkHook interface. * @return Response */ - public function send(Request $request, Hook\IChunkHook $chunkHook = NULL) { + public function send(Request $request, IChunkHook $chunkHook = NULL) { // Sets user agent information. $request->setHeaderField(Request::USER_AGENT_HF, self::USER_AGENT_NAME." ".Version::getNumber()); @@ -158,33 +159,7 @@ public function send(Request $request, Hook\IChunkHook $chunkHook = NULL) { // NOTE: we don't use anymore the connection header field, because we use the same socket until the end of script. //$request->setHeaderField(Message::CONNECTION_HF, "close"); - $response = $this->client->send($request, $chunkHook); - - // 1xx - Informational Status Codes - // 2xx - Success Status Codes - // 3xx - Redirection Status Codes - // 4xx - Client Error Status Codes - // 5xx - Server Error Status Codes - $statusCode = (int)$response->getStatusCode(); - - switch ($statusCode) { - case ($statusCode >= 200 && $statusCode < 300): - break; - case ($statusCode < 200): - //$this->handleInformational($request, $response); - break; - case ($statusCode < 400): - //$this->handleRedirection($request, $response); - break; - case ($statusCode < 500): - throw new Exception\ClientErrorException($request, $response); - case ($statusCode >= 500): - throw new Exception\ServerErrorException($request, $response); - default: - throw new Exception\UnknownResponseException($request, $response); - } - - return $response; + return parent::send($request, $chunkHook); } @@ -195,8 +170,8 @@ public function send(Request $request, Hook\IChunkHook $chunkHook = NULL) { * @brief This method raise an exception when a user provide an invalid document path. * @details This method is called by any other methods that interacts with CouchDB. You don't need to call, unless * you are making a not supported call to CouchDB. - * @param[in] string $path Document path. - * @param[in] bool $excludeLocal Document path. + * @param string $path Document path. + * @param bool $excludeLocal Document path. */ public function validateDocPath($path, $excludeLocal = FALSE) { if (empty($path)) // STD_DOC_PATH @@ -265,7 +240,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. - * @retval Info::ServerInfo + * @return Info::ServerInfo */ public function getServerInfo() { $response = $this->send(new Request(Request::GET_METHOD, "/")); @@ -276,7 +251,7 @@ public function getServerInfo() { /** * @brief Returns information about the Elephant on Couch client. - * @retval Info::ClientInfo + * @return Info::ClientInfo */ public function getClientInfo() { return new Info\ClientInfo(); @@ -287,7 +262,7 @@ public function getClientInfo() { * @brief Returns the favicon.ico file. * @details The favicon is a part of the admin interface, but the handler for it is special as CouchDB tries to make * sure that the favicon is cached for one year. Returns a string that represents the icon. - * @retval string + * @return string * @see http://docs.couchdb.org/en/latest/api/server/common.html#favicon-ico */ public function getFavicon() { @@ -302,7 +277,7 @@ public function getFavicon() { /** * @brief Returns server statistics. - * @retval array An associative array + * @return array An associative array * @see http://docs.couchdb.org/en/latest/api/server/common.html#stats */ public function getStats() { @@ -312,7 +287,7 @@ public function getStats() { /** * @brief Returns a list of all databases on this server. - * @retval array of string + * @return array of string * @see http://docs.couchdb.org/en/latest/api/server/common.html#all-dbs */ public function getAllDbs() { @@ -322,8 +297,8 @@ public function getAllDbs() { /** * @brief Returns a list of all database events in the CouchDB instance. - * @param[in] DbUpdatesFeedOpts $opts Additional options. - * @retval Response + * @param DbUpdatesFeedOpts $opts Additional options. + * @return Response * @attention Requires admin privileges. * @see http://docs.couchdb.org/en/latest/api/server/common.html#db-updates */ @@ -340,7 +315,7 @@ public function getDbUpdates(Opt\DbUpdatesFeedOpts $opts = NULL) { /** * @brief Returns a list of running tasks. * @attention Requires admin privileges. - * @retval 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() { @@ -351,8 +326,8 @@ public function getActiveTasks() { /** * @brief Returns the tail of the server's log file. * @attention Requires admin privileges. - * @param[in] integer $bytes How many bytes to return from the end of the log file. - * @retval string + * @param integer $bytes How many bytes to return from the end of the log file. + * @return string * @see http://docs.couchdb.org/en/latest/api/server/common.html#log */ public function getLogTail($bytes = 1000) { @@ -368,8 +343,8 @@ public function getLogTail($bytes = 1000) { /** * @brief Returns a list of generated UUIDs. - * @param[in] integer $count Requested UUIDs number. - * @retval string|array If `$count == 1` (default) returns a string else returns an array of strings. + * @param integer $count Requested UUIDs number. + * @return string|array If `$count == 1` (default) returns a string else returns an array of strings. * @see http://docs.couchdb.org/en/latest/api/server/common.html#uuids */ public function getUuids($count = 1) { @@ -396,9 +371,9 @@ public function getUuids($count = 1) { /** * @brief Returns the entire server configuration or a single section or a single configuration value of a section. - * @param[in] string $section Requested section. - * @param[in] string $key Requested key. - * @retval string|array An array with the configuration keys or a simple string in case of a single key. + * @param string $section Requested section. + * @param string $key Requested key. + * @return string|array An array with the configuration keys or a simple string in case of a single key. * @see http://docs.couchdb.org/en/latest/api/server/configuration.html#get--_config * @see http://docs.couchdb.org/en/latest/api/server/configuration.html#get--_config-section * @see http://docs.couchdb.org/en/latest/api/server/configuration.html#config-section-key @@ -419,9 +394,9 @@ public function getConfig($section = "", $key = "") { /** * @brief Sets a single configuration value in a given section to server configuration. - * @param[in] string $section The configuration section. - * @param[in] string $key The key. - * @param[in] string $value The value for the key. + * @param string $section The configuration section. + * @param string $key The key. + * @param string $value The value for the key. * @see http://docs.couchdb.org/en/latest/api/server/configuration.html#put--_config-section-key */ public function setConfigKey($section, $key, $value) { @@ -443,8 +418,8 @@ public function setConfigKey($section, $key, $value) { /** * @brief Deletes a single configuration value from a given section in server configuration. - * @param[in] string $section The configuration section. - * @param[in] string $key The key. + * @param string $section The configuration section. + * @param string $key The key. * @see http://docs.couchdb.org/en/latest/api/configuration.html#delete-config-section-key */ public function deleteConfigKey($section, $key) { @@ -465,7 +440,7 @@ public function deleteConfigKey($section, $key) { /** * @brief Returns cookie based login user information. - * @retval Response + * @return Response * @see http://docs.couchdb.org/en/latest/api/server/authn.html#get--_session */ public function getSession() { @@ -475,7 +450,7 @@ public function getSession() { /** * @brief Makes cookie based user login. - * @retval Response + * @return Response * @see http://docs.couchdb.org/en/latest/api/server/authn.html#post--_session */ public function setSession($userName, $password) { @@ -499,7 +474,7 @@ public function setSession($userName, $password) { /** * @brief Makes user logout. - * @retval Response + * @return Response * @see http://docs.couchdb.org/en/latest/api/server/authn.html#delete--_session */ public function deleteSession() { @@ -553,7 +528,7 @@ public function requestToken() { /** * @brief Creates a new database and selects it. - * @param[in] string $name The database name. A database must be named with all lowercase letters (a-z), + * @param string $name The database name. A database must be named with all lowercase letters (a-z), * digits (0-9), or any of the _$()+-/ characters and must end with a slash in the URL. The name has to start with a * lowercase letter (a-z). * @see http://docs.couchdb.org/en/latest/api/database/common.html#put--db @@ -579,7 +554,7 @@ public function createDb($name) { /** * @brief Deletes an existing database. - * @param[in] string $name The database name. + * @param string $name The database name. * @see http://docs.couchdb.org/en/latest/api/database/common.html#delete--db */ public function deleteDb($name) { @@ -589,8 +564,8 @@ public function deleteDb($name) { /** * @brief Returns information about the selected database. - * @param[in] string $name The database name. - * @retval Info::DbInfo + * @param string $name The database name. + * @return Info::DbInfo * @see http://docs.couchdb.org/en/latest/api/database/common.html#get--db */ public function getDbInfo($name) { @@ -601,9 +576,9 @@ public function getDbInfo($name) { /** * @brief Obtains a list of the changes made to the database. This can be used to monitor for update and modifications * to the database for post processing or synchronization. - * @param[in] string $name The database name. - * @param[in] ChangesFeedOpts $opts Additional options. - * @retval Response + * @param string $name The database name. + * @param ChangesFeedOpts $opts Additional options. + * @return Response * @see http://docs.couchdb.org/en/latest/api/database/changes.html */ public function getDbChanges($name, Opt\ChangesFeedOpts $opts = NULL) { @@ -629,7 +604,7 @@ public function getDbChanges($name, Opt\ChangesFeedOpts $opts = NULL) { * database by obtaining the database meta information, the `compact_running` value of the returned database * structure will be set to true. You can also obtain a list of running processes to determine whether compaction is * currently running, using getActiveTasks(). - * @param[in] string $name The database name. + * @param string $name The database name. * @attention Requires admin privileges. * @see http://docs.couchdb.org/en/latest/api/database/compact.html */ @@ -647,8 +622,8 @@ public function compactDb($name) { * @brief Compacts the specified view. * @details If you have very large views or are tight on space, you might consider compaction as well. To run compact * for a particular view on a particular database, use this method. - * @param[in] string $dbName The database name. - * @param[in] string $designDocName Name of the design document where is stored the view. + * @param string $dbName The database name. + * @param string $designDocName Name of the design document where is stored the view. * @see http://docs.couchdb.org/en/latest/api/database/compact.html#db-compact-design-doc */ public function compactView($dbName, $designDocName) { @@ -666,7 +641,7 @@ public function compactView($dbName, $designDocName) { /** * @brief Removes all outdated view indexes. * @details Old views files remain on disk until you explicitly run cleanup. - * @param[in] string $dbName The database name. + * @param string $dbName The database name. * @attention Requires admin privileges. * @see http://docs.couchdb.org/en/latest/api/database/compact.html#db-view-cleanup */ @@ -688,8 +663,8 @@ public function cleanupViews($dbName) { * deeply limits CouchDB's performance for non-bulk writers.\n * Delayed commit should be left set to true in the configuration settings. Anyway, you can still tell CouchDB to make * an fsync, calling the this method. - * @param[in] string $dbName The database name. - * @retval string The timestamp of the last time the database file was opened. + * @param string $dbName The database name. + * @return string The timestamp of the last time the database file was opened. * @see http://docs.couchdb.org/en/latest/api/database/compact.html#db-ensure-full-commit */ public function ensureFullCommit($dbName) { @@ -732,8 +707,8 @@ public function ensureFullCommit($dbName) { /** * @brief Returns the special security object for the database. - * @param[in] string $dbName The database name. - * @retval string A JSON object. + * @param string $dbName The database name. + * @return string A JSON object. * @see http://docs.couchdb.org/en/latest/api/database/security.html#get--db-_security */ public function getSecurityObj($dbName) { @@ -743,7 +718,7 @@ public function getSecurityObj($dbName) { /** * @brief Sets the special security object for the database. - * @param[in] string $dbName The database name. + * @param string $dbName The database name. * @see http://docs.couchdb.org/en/latest/api/database/security.html#put--db-_security */ public function setSecurityObj($dbName) { @@ -775,21 +750,21 @@ public function setSecurityObj($dbName) { @code startReplication("sourcedbname", "http://example.org/targetdbname", TRUE, TRUE); @endcode - * @param[in] string $sourceDbUrl Source database URL. - * @param[in] string $targetDbUrl Destination database URL. - * @param[in] string $proxy (optional) Specify the optional proxy used to perform the replication. - * @param[in] bool $createTargetDb (optional) The target database has to exist and is not implicitly created. You + * @param string $sourceDbUrl Source database URL. + * @param string $targetDbUrl Destination database URL. + * @param string $proxy (optional) Specify the optional proxy used to perform the replication. + * @param bool $createTargetDb (optional) The target database has to exist and is not implicitly created. You * can force the creation setting `$createTargetDb = true`. - * @param[in] bool $continuous (optional) When `true` CouchDB will not stop after replicating all missing documents + * @param bool $continuous (optional) When `true` CouchDB will not stop after replicating all missing documents * from the source to the target.\n * At the time of writing, CouchDB doesn't remember continuous replications over a server restart. For the time being, * you are required to trigger them again when you restart CouchDB. In the future, CouchDB will allow you to define * permanent continuous replications that survive a server restart without you having to do anything. - * @param[in] string|array $filter (optional) Name of a filter function that can choose which revisions get replicated. + * @param string|array $filter (optional) Name of a filter function that can choose which revisions get replicated. * You can also provide an array of document identifiers; if given, only these documents will be replicated. - * @param[in] ViewQueryOpts $opts (optional) Query options to get additional information, grouping results, include + * @param ViewQueryOpts $opts (optional) Query options to get additional information, grouping results, include * docs, etc. - * @retval Response + * @return Response * @see http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate */ public function startReplication($sourceDbUrl, $targetDbUrl, $proxy = NULL, $createTargetDb = TRUE, @@ -844,8 +819,8 @@ public function startReplication($sourceDbUrl, $targetDbUrl, $proxy = NULL, $cre /** * @brief Cancels replication. - * @param[in] string $replicationId The replication ID. - * @retval Response + * @param string $replicationId The replication ID. + * @return Response * @see http://docs.couchdb.org/en/latest/api/server/common.html#canceling-continuous-replication */ public function stopReplication($replicationId) { @@ -887,14 +862,14 @@ public function getReplicator() { /** * @brief Returns a built-in view of all documents in this database. If keys are specified returns only certain rows. - * @param[in] string $dbName The database name. - * @param[in] array $keys (optional) Used to retrieve just the view rows matching that set of keys. Rows are returned + * @param string $dbName The database name. + * @param array $keys (optional) Used to retrieve just the view rows matching that set of keys. Rows are returned * in the order of the specified keys. Combining this feature with Opt\ViewQueryOpts.includeDocs() results in the so-called * multi-document-fetch feature. - * @param[in] ViewQueryOpts $opts (optional) Query options to get additional information, grouping results, include + * @param ViewQueryOpts $opts (optional) Query options to get additional information, grouping results, include * docs, etc. - * @param[in] ChunkHook $chunkHook (optional) A class instance that implements the IChunkHook interface. - * @retval Result::QueryResult The result of the query. + * @param ChunkHook $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 */ @@ -917,16 +892,16 @@ public function queryAllDocs($dbName, array $keys = NULL, Opt\ViewQueryOpts $opt /** * @brief Executes the given view and returns the result. - * @param[in] string $dbName The database name. - * @param[in] string $designDocName The design document's name. - * @param[in] string $viewName The view's name. - * @param[in] array $keys (optional) Used to retrieve just the view rows matching that set of keys. Rows are returned + * @param string $dbName The database name. + * @param string $designDocName The design document's name. + * @param string $viewName The view's name. + * @param array $keys (optional) Used to retrieve just the view rows matching that set of keys. Rows are returned * in the order of the specified keys. Combining this feature with Opt\ViewQueryOpts.includeDocs() results in the so-called * multi-document-fetch feature. - * @param[in] ViewQueryOpts $opts (optional) Query options to get additional information, grouping results, include + * @param ViewQueryOpts $opts (optional) Query options to get additional information, grouping results, include * docs, etc. - * @param[in] IChunkHook $chunkHook (optional) A class instance that implements the IChunkHook interface. - * @retval 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. * @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`. @@ -969,17 +944,17 @@ public function queryView($dbName, $designDocName, $viewName, array $keys = NULL * @brief Executes the given view, both map and reduce functions, for all documents and returns the result. * @details Map and Reduce functions are provided by the programmer. * @attention Requires admin privileges. - * @param[in] string $dbName The database name. - * @param[in] string $mapFn The map function. - * @param[in] string $reduceFn The reduce function. - * @param[in] array $keys (optional) Used to retrieve just the view rows matching that set of keys. Rows are returned + * @param string $dbName The database name. + * @param string $mapFn The map function. + * @param string $reduceFn The reduce function. + * @param array $keys (optional) Used to retrieve just the view rows matching that set of keys. Rows are returned * in the order of the specified keys. Combining this feature with Opt\ViewQueryOpts.includeDocs() results in the so-called * multi-document-fetch feature. - * @param[in] ViewQueryOpts $opts (optional) Query options to get additional information, grouping results, include + * @param ViewQueryOpts $opts (optional) Query options to get additional information, grouping results, include * docs, etc. - * @param[in] string $language The language used to implement the map and reduce functions. - * @param[in] IChunkHook $chunkHook (optional) A class instance that implements the IChunkHook interface. - * @retval Result::QueryResult The result of the query. + * @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. * @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) { @@ -1022,8 +997,8 @@ public function queryTempView($dbName, $mapFn, $reduceFn = "", array $keys = NUL /** * @brief Given a list of document revisions, returns the document revisions that do not exist in the database. - * @param[in] string $dbName The database name. - * @retval Response + * @param string $dbName The database name. + * @return Response * @see http://docs.couchdb.org/en/latest/api/database/misc.html#db-missing-revs */ public function getMissingRevs($dbName) { @@ -1036,8 +1011,8 @@ public function getMissingRevs($dbName) { /** * @brief Given a list of document revisions, returns differences between the given revisions and ones that are in * the database. - * @param[in] string $dbName The database name. - * @retval Response + * @param string $dbName The database name. + * @return Response * @see http://docs.couchdb.org/en/latest/api/database/misc.html#db-revs-diff */ public function getRevsDiff($dbName) { @@ -1049,8 +1024,8 @@ public function getRevsDiff($dbName) { /** * @brief Gets the limit of historical revisions to store for a single document in the database. - * @param[in] string $dbName The database name. - * @retval integer The maximum number of document revisions that will be tracked by CouchDB. + * @param string $dbName The database name. + * @return integer The maximum number of document revisions that will be tracked by CouchDB. * @see http://docs.couchdb.org/en/latest/api/database/misc.html#get--db-_revs_limit */ public function getRevsLimit($dbName) { @@ -1062,8 +1037,8 @@ public function getRevsLimit($dbName) { /** * @brief Sets the limit of historical revisions for a single document in the database. - * @param[in] string $dbName The database name. - * @param[in] integer $revsLimit (optional) Maximum number historical revisions for a single document in the database. + * @param string $dbName The database name. + * @param integer $revsLimit (optional) Maximum number historical revisions for a single document in the database. * Must be a positive integer. * @see http://docs.couchdb.org/en/latest/api/database/misc.html#put--db-_revs_limit */ @@ -1089,9 +1064,9 @@ public function setRevsLimit($dbName, $revsLimit = self::REVS_LIMIT) { * The ETag Header is simply the document's revision in quotes. * @details This function is not available for special documents. To get information about a design document, use * the special function getDesignDocInfo(). - * @param[in] string $dbName The database name. - * @param[in] string $docId The document's identifier. - * @retval string The document's revision. + * @param string $dbName The database name. + * @param string $docId The document's identifier. + * @return string The document's revision. * @see http://docs.couchdb.org/en/latest/api/document/common.html#db-doc * @bug CouchDB ETag is */ @@ -1111,12 +1086,12 @@ public function getDocEtag($dbName, $docId) { * @brief Returns the latest revision of the document. * @details Since CouchDB uses different paths to store special documents, you must provide the document type for * design and local documents. - * @param[in] string $dbName The database name. - * @param[in] string $docId The document's identifier. - * @param[in] string $path The document's path. - * @param[in] string $rev (optional) The document's revision. - * @param[in] DocOpts $opts Query options to get additional document information, like conflicts, attachments, etc. - * @retval object|Response An instance of Doc, LocalDoc, DesignDoc or any subclass of Doc. + * @param string $dbName The database name. + * @param string $docId The document's identifier. + * @param string $path The document's path. + * @param string $rev (optional) The document's revision. + * @param DocOpts $opts Query options to get additional document information, like conflicts, attachments, etc. + * @return object|Response An instance of Doc, LocalDoc, DesignDoc or any subclass of Doc. * @see http://docs.couchdb.org/en/latest/api/document/common.html#get--db-docid */ public function getDoc($dbName, $path, $docId, $rev = NULL, Opt\DocOpts $opts = NULL) { @@ -1169,9 +1144,9 @@ public function getDoc($dbName, $path, $docId, $rev = NULL, Opt\DocOpts $opts = * @details Whether the `$doc` has an id we use a different HTTP method. Using POST CouchDB generates an id for the doc, * using PUT instead we need to specify one. We can still use the function getUuids() to ask CouchDB for some ids. * This is an internal detail. You have only to know that CouchDB can generate the document id for you. - * @param[in] string $dbName The database name. - * @param[in] Doc $doc The document you want insert or update. - * @param[in] bool $batchMode (optional) You can write documents to the database at a higher rate by using the batch + * @param string $dbName The database name. + * @param Doc $doc The document you want insert or update. + * @param bool $batchMode (optional) You can write documents to the database at a higher rate by using the batch * option. This collects document writes together in memory (on a user-by-user basis) before they are committed to * disk. This increases the risk of the documents not being stored in the event of a failure, since the documents are * not written to disk immediately. @@ -1205,10 +1180,10 @@ public function saveDoc($dbName, Doc\IDoc $doc, $batchMode = FALSE) { /** * @brief Deletes the specified document. * @details To delete a document you must provide the document identifier and the revision number. - * @param[in] string $dbName The database name. - * @param[in] string $docId The document's identifier you want delete. - * @param[in] string $rev The document's revision number you want delete. - * @param[in] string $path The document path. + * @param string $dbName The database name. + * @param string $docId The document's identifier you want delete. + * @param string $rev The document's revision number you want delete. + * @param string $path The document path. * @see http://docs.couchdb.org/en/latest/api/document/common.html#delete--db-docid */ public function deleteDoc($dbName, $path, $docId, $rev) { @@ -1231,11 +1206,11 @@ public function deleteDoc($dbName, $path, $docId, $rev) { * @brief Makes a duplicate of the specified document. If you want to overwrite an existing document, you need to * specify the target document's revision with a `$rev` parameter. * @details If you want copy a special document you must specify his type. - * @param[in] string $dbName The database name. - * @param[in] string $sourceDocId The source document id. - * @param[in] string $targetDocId The destination document id. - * @param[in] string $rev Needed when you want override an existent document. - * @param[in] string $path The document path. + * @param string $dbName The database name. + * @param string $sourceDocId The source document id. + * @param string $targetDocId The destination document id. + * @param string $rev Needed when you want override an existent document. + * @param string $path The document path. * @see http://docs.couchdb.org/en/latest/api/document/common.html#copy--db-docid */ public function copyDoc($dbName, $path, $sourceDocId, $targetDocId, $rev = NULL) { @@ -1268,10 +1243,10 @@ public function copyDoc($dbName, $path, $sourceDocId, $targetDocId, $rev = NULL) * The purging of old documents is not replicated to other databases. If you are replicating between databases and * have deleted a large number of documents you should run purge on each database.\n * Purging documents does not remove the space used by them on disk. To reclaim disk space, you should run compactDb().\n - * @param[in] string $dbName The database name. - * @param[in] array $refs An array of references used to identify documents and revisions to delete. The array must + * @param string $dbName The database name. + * @param array $refs An array of references used to identify documents and revisions to delete. The array must * contains instances of the DocRef class. - * @retval Response + * @return Response * @see http://docs.couchdb.org/en/latest/api/database/misc.html#post--db-_purge * @see http://wiki.apache.org/couchdb/Purge_Documents */ @@ -1295,20 +1270,20 @@ public function purgeDocs($dbName, array $refs) { * @details Documents that are updated or deleted must contain the `rev` number. To delete a document, you should * call delete() method on your document. When creating new documents the document ID is optional. For updating existing * documents, you must provide the document ID and revision. - * @param[in] string $dbName The database name. - * @param[in] array $docs An array of documents you want insert, delete or update. - * @param[in] bool $fullCommit (optional) Makes sure all uncommited database changes are written and synchronized + * @param string $dbName The database name. + * @param array $docs An array of documents you want insert, delete or update. + * @param bool $fullCommit (optional) Makes sure all uncommited database changes are written and synchronized * to the disk immediately. - * @param[in] bool $allOrNothing (optional) In all-or-nothing mode, either all documents are written to the database, + * @param bool $allOrNothing (optional) In all-or-nothing mode, either all documents are written to the database, * or no documents are written to the database, in the event of a system failure during commit.\n * You can ask CouchDB to check that all the documents pass your validation functions. If even one fails, none of the * documents are written. If all documents pass validation, then all documents will be updated, even if that introduces * a conflict for some or all of the documents. - * @param[in] bool $newEdits (optional) When `false` CouchDB pushes existing revisions instead of creating + * @param bool $newEdits (optional) When `false` CouchDB pushes existing revisions instead of creating * new ones. The response will not include entries for any of the successful revisions (since their rev IDs are * already known to the sender), only for the ones that had errors. Also, the conflict error will never appear, * since in this mode conflicts are allowed. - * @retval Response + * @return Response * @see http://docs.couchdb.org/en/latest/api/database/bulk-api.html#db-bulk-docs * @see http://docs.couchdb.org/en/latest/json-structure.html#bulk-documents * @see http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API @@ -1354,12 +1329,12 @@ public function performBulkOperations($dbName, array $docs, $fullCommit = FALSE, /** * @brief Returns the minimal amount of information about the specified attachment. - * @param[in] string $dbName The database name. - * @param[in] string $fileName The attachment's name. - * @param[in] string $docId The document's identifier. - * @param[in] string $path The document's path. - * @param[in] string $rev (optional) The document's revision. - * @retval string The document's revision. + * @param string $dbName The database name. + * @param string $fileName The attachment's name. + * @param string $docId The document's identifier. + * @param string $path The document's path. + * @param string $rev (optional) The document's revision. + * @return string The document's revision. * @see http://docs.couchdb.org/en/latest/api/document/attachments.html#db-doc-attachment */ public function getAttachmentInfo($dbName, $fileName, $path, $docId, $rev = NULL) { @@ -1380,11 +1355,11 @@ public function getAttachmentInfo($dbName, $fileName, $path, $docId, $rev = NULL /** * @brief Retrieves the attachment from the specified document. - * @param[in] string $dbName The database name. - * @param[in] string $fileName The attachment's name. - * @param[in] string $docId The document's identifier. - * @param[in] string $path The document's path. - * @param[in] string $rev (optional) The document's revision. + * @param string $dbName The database name. + * @param string $fileName The attachment's name. + * @param string $docId The document's identifier. + * @param string $path The document's path. + * @param string $rev (optional) The document's revision. * @see http://docs.couchdb.org/en/latest/api/document/attachments.html#get--db-docid-attname * @see http://docs.couchdb.org/en/latest/api/document/attachments.html#http-range-requests * @todo Add support for Range request, using header "Range: bytes=0-12". @@ -1407,11 +1382,11 @@ public function getAttachment($dbName, $fileName, $path, $docId, $rev = NULL) { /** * @brief Inserts or updates an attachment to the specified document. - * @param[in] string $dbName The database name. - * @param[in] string $fileName The attachment's name. - * @param[in] string $docId The document's identifier. - * @param[in] string $path The document's path. - * @param[in] string $rev (optional) The document's revision. + * @param string $dbName The database name. + * @param string $fileName The attachment's name. + * @param string $docId The document's identifier. + * @param string $path The document's path. + * @param string $rev (optional) The document's revision. * @see http://docs.couchdb.org/en/latest/api/document/attachments.html#put--db-docid-attname */ public function putAttachment($dbName, $fileName, $path, $docId, $rev = NULL) { @@ -1437,11 +1412,11 @@ public function putAttachment($dbName, $fileName, $path, $docId, $rev = NULL) { /** * @brief Deletes an attachment from the document. - * @param[in] string $dbName The database name. - * @param[in] string $fileName The attachment's name. - * @param[in] string $docId The document's identifier. - * @param[in] string $path The document's path. - * @param[in] string $rev The document's revision. + * @param string $dbName The database name. + * @param string $fileName The attachment's name. + * @param string $docId The document's identifier. + * @param string $path The document's path. + * @param string $rev The document's revision. * @see http://docs.couchdb.org/en/latest/api/document/attachments.html#delete--db-docid-attname */ public function deleteAttachment($dbName, $fileName, $path, $docId, $rev) { @@ -1465,9 +1440,9 @@ public function deleteAttachment($dbName, $fileName, $path, $docId, $rev) { /** * @brief Returns basic information about the design document and his views. - * @param[in] string $dbName The database name. - * @param[in] string $docName The design document's name. - * @retval array An associative array + * @param string $dbName The database name. + * @param string $docName The design document's name. + * @return array An associative array * @see http://docs.couchdb.org/en/latest/api/ddoc/common.html#get--db-_design-ddoc-_info */ public function getDesignDocInfo($dbName, $docName) { @@ -1480,67 +1455,6 @@ public function getDesignDocInfo($dbName, $docName) { return $this->send($request)->getBodyAsArray(); } - - /** - * @brief - * @details - * @see http://docs.couchdb.org/en/latest/api/ddoc/render.html#get--db-_design-ddoc-_show-func - * @see http://docs.couchdb.org/en/latest/api/ddoc/render.html#post--db-_design-ddoc-_show-func - * @see http://docs.couchdb.org/en/latest/api/ddoc/render.html#get--db-_design-ddoc-_show-func-docid - * @see http://docs.couchdb.org/en/latest/api/ddoc/render.html#post--db-_design-ddoc-_show-func-docid - * @todo To be implemented and documented. - */ - public function showDoc($dbName, $designDocName, $showName, $docId = NULL) { - throw new \BadMethodCallException("The method `showDoc()` is not available."); - // Invokes the show handler without a document - // /db/_design/design-doc/_show/show-name - // Invokes the show handler for the given document - // /db/_design/design-doc/_show/show-name/doc - // GET /db/_design/examples/_show/posts/somedocid - // GET /db/_design/examples/_show/people/otherdocid - // GET /db/_design/examples/_show/people/otherdocid?format=xml&details=true - // public function showDoc($designDocName, $funcName, $docId, $format, $details = FALSE) { - } - - - /** - * @brief - * @details - * @see http://docs.couchdb.org/en/latest/api/ddoc/render.html#get--db-_design-ddoc-_list-func-view - * @see http://docs.couchdb.org/en/latest/api/ddoc/render.html#post--db-_design-ddoc-_list-func-view - * @see http://docs.couchdb.org/en/latest/api/ddoc/render.html#get--db-_design-ddoc-_list-func-other-ddoc-view - * @see http://docs.couchdb.org/en/latest/api/ddoc/render.html#post--db-_design-ddoc-_list-func-other-ddoc-view - * @todo To be implemented and documented. - */ - public function listDocs($dbName, $designDocName, $listName, $docId = NULL) { - throw new \BadMethodCallException("The method `listDocs()` is not available."); - // Invokes the list handler to translate the given view results - // Invokes the list handler to translate the given view results for certain documents - // GET /db/_design/examples/_list/index-posts/posts-by-date?descending=true&limit=10 - // GET /db/_design/examples/_list/index-posts/posts-by-tag?key="howto" - // GET /db/_design/examples/_list/browse-people/people-by-name?startkey=["a"]&limit=10 - // GET /db/_design/examples/_list/index-posts/other_ddoc/posts-by-tag?key="howto" - // public function listDocs($designDocName, $funcName, $viewName, $queryArgs, $keys = "") { - } - - - /** - * @brief - * @details - * @see http://docs.couchdb.org/en/latest/api/ddoc/render.html#post--db-_design-ddoc-_update-func - * @see http://docs.couchdb.org/en/latest/api/ddoc/render.html#put--db-_design-ddoc-_update-func-docid - * @todo To be implemented and documented. - */ - public function callUpdateDocFunc($dbName, $designDocName, $funcName) { - throw new \BadMethodCallException("The method `callUpdateDocFunc()` is not available."); - // Invokes the update handler without a document - // /db/_design/design-doc/_update/update-name - // Invokes the update handler for the given document - // /db/_design/design-doc/_update/update-name/doc - // a PUT request against the handler function with a document id: //_design//_update// - // a POST request against the handler function without a document id: //_design//_update/ - } - //!@} } \ No newline at end of file diff --git a/src/EoC/Doc/DesignDoc.dox b/src/EoC/Doc/DesignDoc.dox index 9ce4df4..e9c193a 100644 --- a/src/EoC/Doc/DesignDoc.dox +++ b/src/EoC/Doc/DesignDoc.dox @@ -10,7 +10,7 @@ class DesignDoc { //!@{ /** - * @brief string The purpose of this property is to specify the programming language used to write the handlers' closures. + * @brief The purpose of this property is to specify the programming language used to write the handlers' closures. * @details CouchDB will automatically use the right interpreter for the various handlers stored into this design * document. */ diff --git a/src/EoC/Doc/DesignDoc.php b/src/EoC/Doc/DesignDoc.php index fe5b241..aa2fded 100644 --- a/src/EoC/Doc/DesignDoc.php +++ b/src/EoC/Doc/DesignDoc.php @@ -33,9 +33,9 @@ public function __construct() { /** * @brief Creates an instance of DesignDoc class. - * @param[in] string $name The design document name. - * @param[in] string $language The programming language used by the design document for his handlers. - * @retval DesignDoc An instance of the class. + * @param string $name The design document name. + * @param string $language The programming language used by the design document for his handlers. + * @return DesignDoc An instance of the class. */ public static function create($name, $language = "php") { $instance = new self(); @@ -82,7 +82,7 @@ public function setType($value) {} /** * @brief Gets the document path: `_design/`. - * @retval string + * @return string */ public function getPath() { return "_design/"; @@ -103,8 +103,8 @@ public function resetHandlers() { /** * @brief Given a design document section (ex. views, updates, filters, etc.) and an optional handler's name (because * the handler couldn't have a name), returns the - * @param[in] string $section The section name. - * @param[in] string $name (optional) The handler name. + * @param string $section The section name. + * @param string $name (optional) The handler name. */ public function getHandlerAttributes($section, $name = "") { if (empty($name)) { // The handler doesn't have a name. @@ -127,7 +127,7 @@ public function getHandlerAttributes($section, $name = "") { * @details This method checks the existence of the property `$name`, in fact a design document can have sections * with multiple handlers, but in some cases there is one and only one handler per section, so that handler doesn't * have a name. - * @param[in] Handler\IHandler $handler An instance of a subclass of the abstract class DesignIHandler. + * @param Handler\IHandler $handler An instance of a subclass of the abstract class DesignIHandler. */ public function addHandler(Handler\IHandler $handler) { $section = $handler->getSection(); @@ -158,8 +158,8 @@ public function addHandler(Handler\IHandler $handler) { * @details Some handlers belong to a section. For example ViewHandler belongs to the 'views' section. To specify * the appropriate section name, you should use the static method `getSection` available for every handler * implementation. - * @param[in] string $section The section's name (views, updates, shows, filters, etc). - * @param[in] string $name (optional) The handler's name. + * @param string $section The section's name (views, updates, shows, filters, etc). + * @param string $name (optional) The handler's name. */ public function removeHandler($section, $name = "") { if (empty($name)) { // The handler doesn't have a name. diff --git a/src/EoC/Doc/Doc.dox b/src/EoC/Doc/Doc.dox index 8b60b48..7bbf008 100644 --- a/src/EoC/Doc/Doc.dox +++ b/src/EoC/Doc/Doc.dox @@ -9,6 +9,11 @@ class Doc { /** @name Properties */ //!@{ + /** + * @brief Document’s update sequence in current database. + * @details Available if requested with `local_seq=true` query parameter. + */ + string $localSequence; //!@} diff --git a/src/EoC/Doc/Doc.php b/src/EoC/Doc/Doc.php index 61b9dd2..4975c6d 100644 --- a/src/EoC/Doc/Doc.php +++ b/src/EoC/Doc/Doc.php @@ -23,16 +23,7 @@ class Doc extends AbstractDoc { const REVS_INFO = "_revs_info"; const CONFLICTS = "_conflicts"; const DELETED_CONFLICTS = "_deleted_conflicts"; - - //! If the document has attachments, holds a meta-data structure. - private $attachments = []; // array of attachments - - //! A list of revisions of the document, and their availability. - private $revsInfo = []; - - private $conflicts = []; - - private $deletedConflicts = []; + const LOCAL_SEQUENCE = "_local_seq"; protected function fixDocId() {} @@ -62,8 +53,7 @@ public function getAttachments() { /** - * @brief - * @todo To be documented. + * @brief Adds an attachment. */ public function addAttachment(Attachment $attachment) { $this->meta[self::ATTACHMENTS][$attachment->getName()] = $attachment->asArray(); @@ -71,8 +61,7 @@ public function addAttachment(Attachment $attachment) { /** - * @brief - * @todo To be documented. + * @brief Removes an attachment. */ public function removeAttachment($name) { if ($this->isMetadataPresent(self::ATTACHMENTS)) @@ -85,21 +74,23 @@ public function removeAttachment($name) { } + //! @cond HIDDEN_SYMBOLS + /** - * @brief - * @todo To be documented. + * @brief Returns the `_local_seq` number. */ public function getLocalSequence() { - return $this->meta['_local_sequence']; + return $this->meta[self::LOCAL_SEQUENCE]; } /** - * @brief - * @todo To be documented. + * @brief Returns `true` is the `_local_sequence` number is present, `false` otherwise. */ public function issetLocalSequence() { - return $this->isMetadataPresent('_local_sequence'); + return $this->isMetadataPresent(self::LOCAL_SEQUENCE); } + //! @endcond + } \ No newline at end of file diff --git a/src/EoC/Doc/DocRef.php b/src/EoC/Doc/DocRef.php index ed3aa9a..4c23a16 100644 --- a/src/EoC/Doc/DocRef.php +++ b/src/EoC/Doc/DocRef.php @@ -28,7 +28,7 @@ final class DocRefsArray { /** * @brief Adds a document revision reference. - * @param[in] string $value A document revision. + * @param string $value A document revision. */ public function addRev($value) { $this->revs[] = $value; diff --git a/src/EoC/Doc/IDoc.php b/src/EoC/Doc/IDoc.php index b51229c..ae85e54 100644 --- a/src/EoC/Doc/IDoc.php +++ b/src/EoC/Doc/IDoc.php @@ -25,14 +25,14 @@ interface IDoc { * @brief Sets the full name space class name into the the provided metadata into the metadata array. * @details The method Couch.getDoc will use this to create an object of the same class you previously stored using * Couch::saveDoc() method. - * @param[in] string $value The full namespace class name, like returned from get_class() function. + * @param string $value The full namespace class name, like returned from get_class() function. */ function setClass($value); /** * @brief Sets the object type. - * @param[in] string $value Usually the class name purged of his namespace. + * @param string $value Usually the class name purged of his namespace. */ function setType($value); @@ -42,7 +42,7 @@ function setType($value); * @details Sometime happens you have two classes with the same name but located under different namespaces. In case, * you should provide a type yourself for at least one of these classes, to avoid Couch::saveDoc() using the same type * for both. Default implementation should return `false`. - * @retval bool + * @return bool */ function hasType(); @@ -51,35 +51,35 @@ function hasType(); * @brief Gets the document path. * @details Returns an empty string for standard document, `_local/` for local document and `_design/` for * design document. - * @retval string + * @return string */ function getPath(); /** * @brief Returns the document representation as a JSON object. - * @retval JSON object + * @return JSON object */ function asJson(); /** * @brief Returns the document representation as an associative array. - * @retval array An associative array + * @return array An associative array */ public function asArray(); /** * @brief Gets the document identifier. - * @retval string + * @return string */ function getId(); /** * @brief Returns `true` if the document has an identifier, `false` otherwise. - * @retval bool + * @return bool */ function issetId(); diff --git a/src/EoC/Doc/LocalDoc.php b/src/EoC/Doc/LocalDoc.php index 3fee8d7..460295b 100644 --- a/src/EoC/Doc/LocalDoc.php +++ b/src/EoC/Doc/LocalDoc.php @@ -32,7 +32,7 @@ protected function fixDocId() { /** * @brief Gets the document path: `_local/`. - * @retval string + * @return string */ public function getPath() { return "_local/"; diff --git a/src/EoC/Exception/BadResponseException.php b/src/EoC/Exception/BadResponseException.php deleted file mode 100644 index bb40219..0000000 --- a/src/EoC/Exception/BadResponseException.php +++ /dev/null @@ -1,100 +0,0 @@ -request = $request; - $this->response = $response; - - $this->humanReadableError = $response->getSupportedStatusCodes()[$response->getStatusCode()]; - - parent::__construct($this->humanReadableError, $response->getStatusCode()); - } - - - /** - * @brief Returns the request. - * @retval EoC::Message::Request - */ - public final function getRequest() { - return $this->request; - } - - - /** - * @brief Returns the response. - * @retval EoC::Message::Response - */ - public final function getResponse() { - return $this->response; - } - - - /** - * @brief Overrides the magic method to get all the information about the error. - */ - public function __toString() { - $error = $this->response->getBodyAsArray(); - - $this->info[] = "[CouchDB Error Code] ".$error["error"]; - $this->info[] = "[CouchDB Error Reason] ".$error["reason"]; - - $statusCode = (int)$this->response->getStatusCode(); - - // 4xx - Client Error Status Codes - // 5xx - Server Error Status Codes - // 6xx - Unknown Error Status Codes - switch ($statusCode) { - case ($statusCode < 500): - $this->info[] = "[Error Type] Client Error"; - break; - case ($statusCode >= 500): - $this->info[] = "[Error Type] Server Error"; - break; - default: - $this->info[] = "[Error Type] Unknown Error"; - break; - } - - $this->info[] = "[Error Code] ".$this->response->getStatusCode(); - $this->info[] = "[Error Message] ".$this->humanReadableError; - $this->info[] = "[Request]"; - $this->info[] = sprintf('%s', $this->request); - $this->info[] = "[Response]"; - $this->info[] = sprintf('%s', $this->response); - - return implode(PHP_EOL, $this->info); - } - -} \ No newline at end of file diff --git a/src/EoC/Exception/ClientErrorException.php b/src/EoC/Exception/ClientErrorException.php deleted file mode 100644 index 9a4ac38..0000000 --- a/src/EoC/Exception/ClientErrorException.php +++ /dev/null @@ -1,17 +0,0 @@ - 600 codes) - */ -class UnknownResponseException extends BadResponseException {} \ No newline at end of file diff --git a/src/EoC/Handler/FilterHandler.php b/src/EoC/Handler/FilterHandler.php deleted file mode 100644 index 98e0349..0000000 --- a/src/EoC/Handler/FilterHandler.php +++ /dev/null @@ -1,54 +0,0 @@ -setName($name); - } - - - public function getName() { - return $this->name; - } - - - public function setName($value) { - $this->name = (string)$value; - } - - - public static function getSection() { - return self::FILTERS; - } - - - public function isConsistent() { - } - - - public function asArray() { - } - -} diff --git a/src/EoC/Handler/IHandler.php b/src/EoC/Handler/IHandler.php index b3b1d4c..80485c1 100644 --- a/src/EoC/Handler/IHandler.php +++ b/src/EoC/Handler/IHandler.php @@ -21,7 +21,7 @@ interface IHandler { * @brief Returns the handler's section. * @details Every CouchDB's handler is stored in a particular design document section. Every class that extends the * abstract handler DesignIHandler, must implement this method to return his own section. - * @retval string + * @return string */ static function getSection(); @@ -29,14 +29,14 @@ static function getSection(); /** * @brief Returns `true` if the handler is consistent, `false` otherwise. * @attention You must always check the handler's consistence before every call to asArray() method. - * @retval bool + * @return bool */ function isConsistent(); /** * @brief Returns the handler's attributes. - * @retval string|array + * @return string|array */ function asArray(); diff --git a/src/EoC/Handler/ListHandler.php b/src/EoC/Handler/ListHandler.php deleted file mode 100644 index b249820..0000000 --- a/src/EoC/Handler/ListHandler.php +++ /dev/null @@ -1,57 +0,0 @@ -setName($name); - } - - - public function getName() { - return $this->name; - } - - - public function setName($value) { - $this->name = (string)$value; - } - - - public static function getSection() { - return self::LISTS; - } - - - public function isConsistent() { - // todo Implement isConsistent() method. - } - - - public function asArray() { - // todo Implement getAttributes() method. - } - -} diff --git a/src/EoC/Handler/RewriteHandler.php b/src/EoC/Handler/RewriteHandler.php deleted file mode 100644 index b3ed468..0000000 --- a/src/EoC/Handler/RewriteHandler.php +++ /dev/null @@ -1,57 +0,0 @@ -setName($name); - } - - - public function getName() { - return $this->name; - } - - - public function setName($value) { - $this->name = (string)$value; - } - - - public static function getSection() { - return self::REWRITES; - } - - - public function isConsistent() { - // todo Implement isConsistent() method. - } - - - public function asArray() { - // todo Implement getAttributes() method. - } - -} diff --git a/src/EoC/Handler/ShowHandler.php b/src/EoC/Handler/ShowHandler.php deleted file mode 100644 index b562d69..0000000 --- a/src/EoC/Handler/ShowHandler.php +++ /dev/null @@ -1,57 +0,0 @@ -setName($name); - } - - - public function getName() { - return $this->name; - } - - - public function setName($value) { - $this->name = (string)$value; - } - - - public static function getSection() { - return self::SHOWS; - } - - - public function isConsistent() { - // todo Implement isConsistent() method. - } - - - public function asArray() { - // todo Implement getAttributes() method. - } - -} \ No newline at end of file diff --git a/src/EoC/Handler/UpdateHandler.php b/src/EoC/Handler/UpdateHandler.php deleted file mode 100644 index 926311a..0000000 --- a/src/EoC/Handler/UpdateHandler.php +++ /dev/null @@ -1,57 +0,0 @@ -setName($name); - } - - - public function getName() { - return $this->name; - } - - - public function setName($value) { - $this->name = (string)$value; - } - - - public static function getSection() { - return self::UPDATES; - } - - - public function isConsistent() { - // todo Implement isConsistent() method. - } - - - public function asArray() { - // todo Implement getAttributes() method. - } - -} diff --git a/src/EoC/Handler/ValidateDocUpdateHandler.php b/src/EoC/Handler/ValidateDocUpdateHandler.php deleted file mode 100644 index 6cd9f8f..0000000 --- a/src/EoC/Handler/ValidateDocUpdateHandler.php +++ /dev/null @@ -1,64 +0,0 @@ -issetValidateDocUpdate(); - } - - - public function asArray() { - return $this->validateDocUpdate; - } - - - public function getValidateDocUpdate() { - return $this->validateDocUpdate; - } - - - public function issetValidateDocUpdate() { - return (!empty($this->validateDocUpdate)) ? TRUE : FALSE; - } - - - public function setValidateDocUpdate($value) { - $this->validateDocUpdate = (string)$value; - } - - - public function unsetValidateDocUpdate() { - $this->validateDocUpdate = ""; - } - -} \ No newline at end of file diff --git a/src/EoC/Hook/IChunkHook.php b/src/EoC/Hook/IChunkHook.php deleted file mode 100644 index a786c95..0000000 --- a/src/EoC/Hook/IChunkHook.php +++ /dev/null @@ -1,29 +0,0 @@ -response->hasHeaderFile(Response::ACCEPT_RANGES_HF); + return $this->response->hasHeaderField(Response::ACCEPT_RANGES_HF); } /** * @brief Codec used to compress the attachment. * @details Only available if attachment’s `content_type` is in list of compressible types. - * @retval string|bool The codec name or `false` if the attachment is not compressed. + * @return string|bool The codec name or `false` if the attachment is not compressed. */ public function getContentEncoding() { if ($this->response->hasHeaderField(Response::CONTENT_ENCODING_HF)) @@ -55,7 +60,7 @@ public function getContentEncoding() { /** * @brief Attachment size. * @details If a codec was used to compress the file, the method returns the compressed size. - * @retval integer + * @return integer */ public function getSize() { return $this->response->getHeaderFieldValue(Response::CONTENT_LENGTH_HF); @@ -64,7 +69,7 @@ public function getSize() { /** * @brief Base64 encoded MD5 binary digest. - * @retval integer + * @return integer */ public function getMD5() { return $this->response->getHeaderFieldValue(Response::CONTENT_MD5_HF); @@ -73,7 +78,7 @@ public function getMD5() { /** * @brief Double quoted base64 encoded MD5 binary digest - * @retval integer + * @return integer */ public function getDoubleQuotedMD5() { return $this->response->getHeaderFieldValue(Response::ETAG_HF); diff --git a/src/EoC/Message/Message.php b/src/EoC/Message/Message.php deleted file mode 100644 index ae3cc66..0000000 --- a/src/EoC/Message/Message.php +++ /dev/null @@ -1,361 +0,0 @@ - NULL, - self::CONNECTION_HF => NULL, - self::DATE_HF => NULL, - self::PRAGMA_HF => NULL, - self::TRAILER_HF => NULL, - self::TRANSFER_ENCODING_HF => NULL, - self::UPGRADE_HF => NULL, - self::VIA_HF => NULL, - self::WARNING_HF => NULL, - self::ALLOW_HF => NULL, - self::CONTENT_ENCODING_HF => NULL, - self::CONTENT_LANGUAGE_HF => NULL, - self::CONTENT_LENGTH_HF => NULL, - self::CONTENT_LOCATION_HF => NULL, - self::CONTENT_MD5_HF => NULL, - self::CONTENT_RANGE_HF => NULL, - self::CONTENT_TYPE_HF => NULL, - self::EXPIRES_HF => NULL, - self::LAST_MODIFIED_HF => NULL - ); - - // Stores the message header fields. - protected $header = []; - - // Stores the entity body. - protected $body = ""; - - - /** - * @brief Creates a Message object. - * @details I wanted declare it abstract, but since PHP sucks, I can't define a constructor, in a derived class, with - * a different number of parameters, not when the parent's class constructor is abstract. - */ - public function __construct() { - } - - - /** - * @brief Returns an array of well-formed header fields. Ex: Content-Type: application/json. - * @retval array of strings - */ - public function getHeaderAsArray() { - $wellformedHeader = []; - foreach ($this->header as $name => $value) - $wellformedHeader[] = $name.": ".$value; - - return $wellformedHeader; - } - - - /** - * @brief Returns the header string. - * @retval string - */ - public function getHeaderAsString() { - return implode(self::CRLF, $this->getHeaderAsArray()); - } - - - /** - * @brief Returns `TRUE` in case exist the specified header field or `FALSE` in case it doesn't exist. - * @param[in] string $name Header field name. - * @retval bool - */ - public function hasHeaderField($name) { - return (array_key_exists($name, $this->header)) ? TRUE : FALSE; - } - - - /** - * @brief Returns the value for the header identified by the specified name or `FALSE` in case it doesn't exist. - * @param[in] string $name Header field name. - * @retval string - */ - public function getHeaderFieldValue($name) { - if ($this->hasHeaderField($name)) - return $this->header[$name]; - else - return FALSE; - } - - - /** - * @brief Adds to the headers associative array, the provided header's name and value. - * @param[in] string $name The header field name. - * @param[in] string $value The header field value. - */ - public function setHeaderField($name, $value) { - if (array_key_exists($name, static::$supportedHeaderFields)) - $this->header[$name] = $value; - else - throw new \Exception("$name header field is not supported."); - } - - - /** - * @brief Removes the header field from the headers associative array. - * @param[in] string $name The header field name. - */ - public function removeHeaderField($name) { - if (array_key_exists($name, static::$supportedHeaderFields)) - unset($this->header[$name]); - } - - - /** - * @brief Used to set many header fields at once. - * @param[in] array $headerFields An associative array of header fields. - */ - public function setMultipleHeaderFieldsAtOnce(array $headerFields) { - if (Helper\ArrayHelper::isAssociative($headerFields)) - foreach ($headerFields as $name => $value) - $this->setHeaderField($name, $value); - else - throw new \Exception("\$headerFields must be an associative array."); - } - - - /** - * @brief Adds a non standard HTTP header. - * @param[in] string $name Header field name. - */ - public static function addCustomHeaderField($name) { - if (array_key_exists($name, static::$supportedHeaderFields)) - throw new \Exception("$name header field is supported but already exists."); - else - static::$supportedHeaderFields[] = $name; - } - - - /** - * @brief Returns a list of all supported header fields. - * @retval array An associative array - */ - public function getSupportedHeaderFields() { - return static::$supportedHeaderFields; - } - - - /** - * @brief Returns the Message entity-body as raw string. The string can be in JSON, XML or a proprietary format, - * depends by the server implementation. - * @retval string - */ - public function getBody() { - return $this->body; - } - - - /** - * @brief Returns the Message entity-body JSON as an array. - * @param[in] bool $assoc When `true`, returned objects will be converted into associative arrays. - * @retval array An associative array - */ - public function getBodyAsArray($assoc = TRUE) { - return Helper\ArrayHelper::fromJson($this->body, $assoc); - } - - - /** - * @brief Returns the Message entity-body JSON as an object. - * @retval object - */ - public function getBodyAsObject() { - return Helper\ArrayHelper::toObject($this->getBodyAsArray(FALSE)); - } - - - /** - * @brief Sets the Message entity-body. - * @param[in] string $body - */ - public function setBody($body) { - $this->body = (string)$body; - } - - - /** - * @brief Checks if the Message has a body. - * @retval bool - */ - public function hasBody() { - return (empty($this->body)) ? FALSE : TRUE; - } - - - /** - * @brief Returns the body length. - * @retval integer - */ - public function getBodyLength() { - return strlen($this->body); - } - -} \ No newline at end of file diff --git a/src/EoC/Message/Request.php b/src/EoC/Message/Request.php deleted file mode 100644 index 64f969c..0000000 --- a/src/EoC/Message/Request.php +++ /dev/null @@ -1,436 +0,0 @@ - NULL, - self::ACCEPT_CHARSET_HF => NULL, - self::ACCEPT_ENCODING_HF => NULL, - self::ACCEPT_LANGUAGE_HF => NULL, - self::AUTHORIZATION_HF => NULL, - self::EXPECT_HF => NULL, - self::FROM_HF => NULL, - self::HOST_HF => NULL, - self::IF_MATCH_HF => NULL, - self::IF_MODIFIED_SINCE_HF => NULL, - self::IF_NONE_MATCH_HF => NULL, - self::IF_RANGE_HF => NULL, - self::IF_UNMODIFIED_SINCE_HF => NULL, - self::MAX_FORWARDS_HF => NULL, - self::PROXY_AUTHORIZATION_HF => NULL, - self::RANGE_HF => NULL, - self::REFERER_HF => NULL, - self::TE_HF => NULL, - self::UPGRADE_HF => NULL, - self::USER_AGENT_HF => NULL, - self::COOKIE_HF => NULL, - self::X_REQUESTED_WITH_HF => NULL, - self::X_DO_NOT_TRACK_HF => NULL, - self::DNT_HF => NULL, - self::X_FORWARDED_FOR_HF => NULL, - self::DESTINATION_HF => NULL, - self::X_COUCHDB_WWW_AUTHENTICATE_HF => NULL, - self::X_COUCHDB_FULL_COMMIT_HF => NULL, - ); - - /** @name Request Methods */ - //!@{ - const GET_METHOD = "GET"; - const HEAD_METHOD = "HEAD"; - const POST_METHOD = "POST"; - const PUT_METHOD = "PUT"; - const DELETE_METHOD = "DELETE"; - const COPY_METHOD = "COPY"; //!< This method is not supported by HTTP 1.1. It's a special method used by CouchDB. - //!@} - - // Stores the request methods supported by HTTP 1.1 protocol. - private static $supportedMethods = array( // Cannot use [] syntax otherwise Doxygen generates a warning. - self::GET_METHOD => NULL, - self::HEAD_METHOD => NULL, - self::POST_METHOD => NULL, - self::PUT_METHOD => NULL, - self::DELETE_METHOD => NULL, - self::COPY_METHOD => NULL - ); - - // Used to know if the constructor has been already called. - private static $initialized = FALSE; - - // Stores the request method. - private $method; - - // Stores the request method. - private $path; - - // Stores the request query's parameters. - private $queryParams = []; - - - /** - * @brief Creates an instance of Request class. - * @param[in] string $method The HTTP method for the request. - * @param[in] string $path The absolute path of the request. - * @param[in] string $queryParams (optional) Associative array of query parameters. - * @param[in] string $headerFields (optional) Associative array of header fields. - */ - public function __construct($method, $path, array $queryParams = NULL, array $headerFields = NULL) { - parent::__construct(); - - // We can avoid to call the following code every time a Request instance is created, testing a static property. - // Because the static nature of self::$initialized, this code will be executed only one time, even multiple Request - // instances are created. - if (!self::$initialized) { - self::$initialized = TRUE; - self::$supportedHeaderFields += parent::$supportedHeaderFields; - } - - $this->setMethod($method); - $this->setPath($path); - - if (isset($queryParams)) - $this->setMultipleQueryParamsAtOnce($queryParams); - - if (isset($headerFields)) - $this->setMultipleHeaderFieldsAtOnce($headerFields); - } - - - /** - * Returns a comprehensible representation of the HTTP Request to be used for debugging purpose. - * @retval string - */ - public function __toString() { - $request = [ - $this->getMethod()." ".$this->getPath().$this->getQueryString(), - $this->getHeaderAsString(), - $this->getBody() - ]; - - return implode(PHP_EOL.PHP_EOL, $request); - } - - - /** - * @brief Retrieves the HTTP method used by the current request. - * @retval string - */ - public function getMethod() { - return $this->method; - } - - - /** - * @brief Sets the HTTP method used by the current request. - * @param[in] string $method The HTTP method for the request. You should use one of the public constants, like GET_METHOD. - */ - public function setMethod($method) { - if (array_key_exists($method, self::$supportedMethods)) - $this->method = $method; - else - throw new \UnexpectedValueException("$method method not supported. Use addCustomMethod() to add an unsupported method."); - } - - - /** - * @brief Adds a non standard HTTP method. - * @param[in] string $method The HTTP custom method. - */ - public static function addCustomMethod($method) { - if (array_key_exists($method, self::$supportedMethods)) - throw new \UnexpectedValueException("$method method is supported and already exists."); - else - self::$supportedMethods[] = $method; - } - - - /** - * @brief Gets the absolute path for the current request. - * @retval string - */ - public function getPath() { - return $this->path; - } - - - /** - * @brief Sets the request absolute path. - * @param[in] string $path The absolute path of the request. - */ - public function setPath($path) { - if (is_string($path)) - $this->path = addslashes($path); - else - throw new \InvalidArgumentException("\$path must be a string."); - } - - - /** - * @brief Used to set a query parameter. You can set many query parameters you want. - * @param[in] string $name Parameter name. - * @param[in] string $value Parameter value. - */ - public function setQueryParam($name, $value) { - if (preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $name)) - $this->queryParams[$name] = $value; - else - throw new \InvalidArgumentException("\$name must start with a letter or underscore, followed by any number of - letters, numbers, or underscores."); - } - - - /** - * @brief Used to set many parameters at once. - * @param[in] array $params An associative array of parameters. - */ - public function setMultipleQueryParamsAtOnce(array $params) { - if (Helper\ArrayHelper::isAssociative($params)) - foreach ($params as $name => $value) - $this->setQueryParam($name, $value); - else - throw new \InvalidArgumentException("\$params must be an associative array."); - } - - - /** - * @brief Generates URL-encoded query string. - * @retval string - */ - public function getQueryString() { - if (empty($this->queryParams)) - return ""; - else - // Encoding is based on RFC 3986. - return "?".http_build_query($this->queryParams, NULL, "&", PHP_QUERY_RFC3986); - } - - - /** - * @brief Parses the given query string and sets every single parameter contained into it. - */ - public function setQueryString($value) { - if (!empty($value)) { - $query = ltrim($value, "?"); - - $params = explode('&', $query); - - foreach ($params as $param) { - @list($name, $value) = explode('=', $param, 2); - $this->setQueryParam($name, $value); - } - } - } - - - /** - * @brief This helper forces request to use the Authorization Basic mode. - * @param[in] string $userName User name. - * @param[in] string $password Password. - */ - public function setBasicAuth($userName, $password) { - $this->setHeaderField(self::AUTHORIZATION_HF, "Basic ".base64_encode("$userName:$password")); - } - - - /** - * @brief Returns a list of all supported methods. - * @retval array An associative array - */ - public function getSupportedMethods() { - return self::$supportedMethods; - } - -} \ No newline at end of file diff --git a/src/EoC/Message/Response.php b/src/EoC/Message/Response.php deleted file mode 100644 index 79e8df5..0000000 --- a/src/EoC/Message/Response.php +++ /dev/null @@ -1,540 +0,0 @@ - NULL, - self::AGE_HF => NULL, - self::CONTENT_DISPOSITION_HF => NULL, - self::ETAG_HF => NULL, - self::LINK_HF => NULL, - self::LOCATION_HF => NULL, - self::P3P_HF => NULL, - self::PROXY_AUTHENTICATE_HF => NULL, - self::REFRESH_HF => NULL, - self::RETRY_AFTER_HF => NULL, - self::SERVER_HF => NULL, - self::SET_COOKIE_HF => NULL, - self::STRICT_TRANSPORT_SECURITY_HF => NULL, - self::VARY_HF => NULL, - self::WWW_AUTHENTICATE_HF => NULL, - self::X_FRAME_OPTIONS_HF => NULL, - self::X_XSS_PROTECTION_HF => NULL, - self::X_CONTENT_TYPE_OPTIONS_HF => NULL, - self::X_FORWARDED_PROTO_HF => NULL, - self::X_POWERED_BY_HF => NULL, - self::X_UA_COMPATIBLE_HF => NULL - ); - - /** @name Informational Status Codes */ - //!@{ - - /** - * @brief Indicates that an initial part of the request was received and the client should continue. - * @details After sending this, the server must respond after receiving the body request. - */ - const CONTINUE_SC = 100; - - //!@} - - /** @name Success Status Codes - //!@{ - - /** - * @brief Request is OK, entity body contains requested resource. - */ - const OK_SC = 200; - - /** - * @brief For requests that create server objects (e.g., PUT). - * @details The entity body of the response should contain the various URLs for referencing the created resource, - * with the Location header containing the most specific reference. - */ - const CREATED_SC = 201; - - /** - * @brief The request was accepted, but the server has not yet performed any action with it. - * @details There are no guarantees that the server will complete the request; this just means that the request - * looked valid when accepted. - */ - const ACCEPTED_SC = 202; - - /** - * @brief The response message contains headers and a status line, but no entity body. - * @details Primarily used to update browsers without having them move to a new document. - */ - const NO_CONTENT_SC = 204; - - /** - * @brief A partial or range request was successful. - * @details A 206 response must include a Content-Range, Date, and either ETag or Content-Location header. - */ - const PARTIAL_CONTENT_SC = 206; - - //!@} - - /** @name Redirection Status Codes */ - //!@{ - - /** - * @brief Used when the requested URL has been moved. - * @details The response should contain in the Location header the URL where the resource now resides. - */ - const MOVED_PERMANENTLY_SC = 301; - - /** - * @brief Like the 301 status code. - * @details However, the client should use the URL given in the Location header to locate the resource temporarily. - * Future requests should use the old URL. - */ - const FOUND_SC = 302; - - /** - * @brief Clients can make their requests conditional by the request headers they include. - * @details If a client makes a conditional request, such as a GET if the resource has not been changed recently, - * this code is used to indicate that the resource has not changed. Responses with this status code should not - * contain an entity body. - */ - const NOT_MODIFIED_SC = 304; - - //!@} - - /** @name Client Error Status Codes */ - //!@{ - - /** - * @brief Used to tell the client that it has sent a malformed request. - */ - const BAD_REQUEST_SC = 400; - - /** - * @brief Returned along with appropriate headers that ask the client to authenticate itself before it can gain access - * to the resource. - */ - const UNAUTHORIZED_SC = 401; - - /** - * @brief Used to indicate that the request was refused by the server. - * @details If the server wants to indicate why the request was denied, it can include an entity body describing the - * reason. However, this code usually is used when the server does not want to reveal the reason for the refusal. - */ - const FORBIDDEN_SC = 403; - - /** - * @brief Used to indicate that the server cannot find the requested URL. - * @details Often, an entity is included for the client application to display to the user. - */ - const NOT_FOUND_SC = 404; - - /** - * @brief Used when a request is made with a method that is not supported for the requested URL. - * @details The Allow header should be included in the response to tell the client what methods are allowed on the - * requested resource. - */ - const METHOD_NOT_ALLOWED_SC = 405; - - /** - * @brief Clients can specify parameters about what types of entities they are willing to accept. - * @details This code is used when the server has no resource matching the URL that is acceptable for the client. - * Often, servers include headers that allow the client to figure out why the request could not be satisfied. - */ - const NOT_ACCEPTABLE_SC = 406; - - /** - * @brief Used to indicate some conflict that the request may be causing on a resource. - * @details Servers might send this code when they fear that a request could cause a conflict. The response should - * contain a body describing the conflict. - */ - const CONFLICT_SC = 409; - - /** - * @brief Used if a client makes a conditional request and one of the conditions fails. - * @details Conditional requests occur when a client includes an unexpected header. - */ - const PRECONDITION_FAILED_SC = 412; - - /** - * @brief Used when a client sends an entity body that is larger than the server can or wants to process. - */ - const REQUEST_ENTITY_TOO_LARGE_SC = 413; - - /** - * @brief Used when a client sends an entity of a content type that the server does not understand or support. - */ - const UNSUPPORTED_MEDIA_TYPE_SC = 415; - - /** - * @brief Used when the request message requested a range of a given resource and that range either was invalid or - * could not be met. - */ - const REQUESTED_RANGE_NOT_SATISFIABLE_SC = 416; - - /** - * @brief Used when the request contained an expectation in the request header that the server could not satisfy. - */ - const EXPECTATION_FAILED_SC = 417; - - //!@} - - /** @name Server Error Status Codes */ - //!@{ - - /** - * @brief Used when the server encounters an error that prevents it from servicing the request. - */ - const INTERNAL_SERVER_ERROR_SC = 500; - - //!@} - - // Array of HTTP Status Codes - private static $supportedStatusCodes = array( // Cannot use [] syntax otherwise Doxygen generates a warning. - // Informational Status Codes - self::CONTINUE_SC => "Continue", - // Success Status Codes - self::OK_SC => "OK", - self::CREATED_SC => "Created", - self::ACCEPTED_SC => "Accepted", - self::NO_CONTENT_SC => "No Content", - self::PARTIAL_CONTENT_SC => "Partial Content", - // Redirection Status Codes - self::MOVED_PERMANENTLY_SC => "Moved Permanently", - self::FOUND_SC => "Found", - self::NOT_MODIFIED_SC => "Not Modified", - // Client Error Status Codes - self::BAD_REQUEST_SC => "Bad Request", - self::UNAUTHORIZED_SC => "Unauthorized", - self::FORBIDDEN_SC => "Forbidden", - self::NOT_FOUND_SC => "Not Found", - self::METHOD_NOT_ALLOWED_SC => "Method Not Allowed", - self::NOT_ACCEPTABLE_SC => "Not Acceptable", - self::CONFLICT_SC => "Conflict", - self::PRECONDITION_FAILED_SC => "Precondition Failed", - self::REQUEST_ENTITY_TOO_LARGE_SC => "Request Entity Too Large", - self::UNSUPPORTED_MEDIA_TYPE_SC => "Unsupported Media Type", - self::REQUESTED_RANGE_NOT_SATISFIABLE_SC => "Requested Range Not Satisfiable", - self::EXPECTATION_FAILED_SC => "Expectation Failed", - // Server Error Status Codes - self::INTERNAL_SERVER_ERROR_SC => "Internal Server Error", - ); - - private $statusCode; - - // Used to know if the constructor has been already called. - private static $initialized = FALSE; - - - /** - * @brief Creates a new Response object. - * @param[in] string $message The complete Response string. - */ - public function __construct($message) { - parent::__construct(); - - // We can avoid to call the following code every time a Response instance is created, testing a static property. - // Because the static nature of self::$initialized, this code will be executed only one time, even multiple Response - // instances are created. - if (!self::$initialized) { - self::$initialized = TRUE; - self::$supportedHeaderFields += parent::$supportedHeaderFields; - } - - $this->parseStatusCodeAndHeader($message); - } - - - /** - * @brief Returns a comprehensible representation of the HTTP Response to be used for debugging purpose. - * @retval string - */ - public function __toString() { - $response = [ - $this->getStatusCode()." ".$this->getSupportedStatusCodes()[$this->getStatusCode()], - $this->getHeaderAsString(), - $this->getBody() - ]; - - return implode(PHP_EOL.PHP_EOL, $response); - } - - - /** - * @brief Parses the response's status code. - * @param[in] string $rawMessage The raw message. - */ - protected function parseStatusCode($rawMessage) { - $matches = []; - if (preg_match('%HTTP/1\.[0-1] (\d\d\d) %', $rawMessage, $matches)) - $this->statusCode = $matches[1]; - else - throw new \UnexpectedValueException("HTTP Status Code undefined."); - - if (!array_key_exists($this->statusCode, self::$supportedStatusCodes)) - throw new \UnexpectedValueException("HTTP Status Code unknown."); - } - - - /** - * @brief Parses the response's header fields. - * @param[in] string $rawHeader The raw header. - */ - protected function parseHeaderFields($rawHeader) { - $fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $rawHeader)); - - foreach ($fields as $field) { - if (preg_match('/([^:]+): (.+)/m', $field, $matches)) { - // With the advent of PHP 5.5, the /e modifier is deprecated, so we use preg_replace_callback(). - $matches[1] = preg_replace_callback('/(?<=^|[\x09\x20\x2D])./', - function($matches) { - return strtoupper($matches[0]); - }, - strtolower(trim($matches[1]))); - - if (isset($this->header[$matches[1]])) - $this->header[$matches[1]] = array($this->header[$matches[1]], $matches[2]); - else - $this->header[$matches[1]] = trim($matches[2]); - } - } - } - - - /** - * @brief Parses the response's status code and header. - * @param[in] string $rawMessage The raw message. - */ - protected function parseStatusCodeAndHeader($rawMessage) { - if (!is_string($rawMessage)) - throw new \InvalidArgumentException("\$rawMessage must be a string."); - - if (empty($rawMessage)) - throw new \UnexpectedValueException("\$rawMessage is null."); - - $this->parseStatusCode($rawMessage); - - // In case server sends a "100 Continue" response, we must parse the message twice. This happens when a client uses - // the "Expect: 100-continue" header field. - // @see http://www.jmarshall.com/easy/http/#http1.1s5 - if ($this->statusCode == self::CONTINUE_SC) { - $rawMessage = preg_split('/\r\n\r\n/', $rawMessage, 2)[1]; - $this->parseStatusCodeAndHeader($rawMessage); - } - - $rawMessage = preg_split('/\r\n\r\n/', $rawMessage, 2); - - if (empty($rawMessage)) - throw new \RuntimeException("The server didn't return a valid Response for the Request."); - - // $rawMessage[0] contains header fields. - $this->parseHeaderFields($rawMessage[0]); - - // $rawMessage[1] contains the entity-body. - $this->body = $rawMessage[1]; - } - - - /** - * @brief Returns the HTTP Status Code for the current response. - * @retval string - */ - public function getStatusCode() { - return $this->statusCode; - } - - - /** - * @brief Sets the Response status code. - * @param[in] int $value The status code. - */ - public function setStatusCode($value) { - if (array_key_exists($value, self::$supportedStatusCodes)) { - $this->statusCode = $value; - } - else - throw new \UnexpectedValueException("Status Code $value is not supported."); - } - - - /** - * @brief Returns a list of all supported status codes. - * @retval array An associative array - */ - public function getSupportedStatusCodes() { - return self::$supportedStatusCodes; - } - - - /** - * @brief Adds a non standard HTTP Status Code. - * @param[in] string $code The Status Code. - * @param[in] string $description A description for the Status Code. - */ - public static function addCustomStatusCode($code, $description) { - if (in_array($code, self::$supportedStatusCodes)) - throw new \UnexpectedValueException("Status Code $code is supported and already exists."); - elseif (is_int($code) and $code > 0) - self::$supportedStatusCodes[$code] = $description; - else - throw new \InvalidArgumentException("\$code must be a positive integer."); - } - -} \ No newline at end of file diff --git a/src/EoC/Opt/AbstractOpts.php b/src/EoC/Opt/AbstractOpts.php index 37e63ae..f479f99 100644 --- a/src/EoC/Opt/AbstractOpts.php +++ b/src/EoC/Opt/AbstractOpts.php @@ -32,7 +32,7 @@ public function reset() { /** * @brief Returns an associative array of the chosen options. - * @retval array An associative array + * @return array An associative array. */ public function asArray() { return $this->options; diff --git a/src/EoC/Opt/ChangesFeedOpts.php b/src/EoC/Opt/ChangesFeedOpts.php index 64e3172..3e66c6c 100644 --- a/src/EoC/Opt/ChangesFeedOpts.php +++ b/src/EoC/Opt/ChangesFeedOpts.php @@ -78,7 +78,7 @@ class ChangesFeedOpts extends AbstractOpts { /** * @brief Starts the results from the change immediately after the given sequence number. - * @param[in] integer $since Sequence number to start results. Allowed values: positive integers | 'now'. + * @param integer $since Sequence number to start results. Allowed values: positive integers | 'now'. */ public function setSince($since = 0) { if (($since == "now") or (is_int($since) and ($since >= 0))) @@ -92,7 +92,7 @@ public function setSince($since = 0) { /** * @brief Limits number of result rows to the specified value. - * @param[in] integer $limit Maximum number of rows to return. Must be a positive integer. + * @param integer $limit Maximum number of rows to return. Must be a positive integer. */ public function setLimit($limit) { if (is_int($limit) and ($limit > 0)) @@ -114,7 +114,7 @@ public function reverseOrderOfResults() { /** * @brief Sets the type of feed. - * @param[in] string $type Type of feed. + * @param string $type Type of feed. */ public function setFeedType($type) { if (array_key_exists($type, self::$supportedTypes)) @@ -127,7 +127,7 @@ public function setFeedType($type) { /** * @brief Specifies how many revisions are returned in the changes array. The default, `main_only`, will only * return the winning revision; `all_docs` will return all the conflicting revisions. - * @param[in] bool $style The feed style. + * @param bool $style The feed style. */ public function setStyle($style) { if (array_key_exists($style, self::$supportedStyles)) @@ -140,7 +140,7 @@ public function setStyle($style) { /** * @brief Period in milliseconds after which an empty line is sent in the results. Overrides any timeout to keep the * feed alive indefinitely. - * @param[in] integer $heartbeat Period in milliseconds after which an empty line is sent in the results. + * @param integer $heartbeat Period in milliseconds after which an empty line is sent in the results. * @warning Only applicable for `longpoll` or `continuous` feeds. */ public function setHeartbeat($heartbeat = self::DEFAULT_HEARTBEAT) { @@ -157,7 +157,7 @@ public function setHeartbeat($heartbeat = self::DEFAULT_HEARTBEAT) { /** * @brief Maximum period in milliseconds to wait for a change before the response is sent, even if there are no results. * @details Note that 60000 is also the default maximum timeout to prevent undetected dead connections. - * @param[in] integer $timeout Maximum period to wait before the response is sent. Must be a positive integer. + * @param integer $timeout Maximum period to wait before the response is sent. Must be a positive integer. * @warning Only applicable for `longpoll` or `continuous` feeds. */ public function setTimeout($timeout = self::DEFAULT_TIMEOUT) { @@ -181,8 +181,8 @@ public function includeDocs() { /** * @brief Sets a filter function. - * @param[in] string $designDocName The design document's name. - * @param[in] string $filterName Filter function from a design document to get updates. + * @param string $designDocName The design document's name. + * @param string $filterName Filter function from a design document to get updates. * @todo Implement the setFilter() method. */ public function setFilter($designDocName, $filterName) { diff --git a/src/EoC/Opt/DbUpdatesFeedOpts.php b/src/EoC/Opt/DbUpdatesFeedOpts.php index c922966..4033ac2 100644 --- a/src/EoC/Opt/DbUpdatesFeedOpts.php +++ b/src/EoC/Opt/DbUpdatesFeedOpts.php @@ -60,7 +60,7 @@ class DbUpdatesFeedOpts extends AbstractOpts { /** * @brief Sets the type of feed. - * @param[in] string $type Type of feed. + * @param string $type Type of feed. */ public function setFeedType($type) { if (array_key_exists($type, self::$supportedTypes)) @@ -75,7 +75,7 @@ public function setFeedType($type) { /** * @brief Maximum period in seconds to wait for a change before the response is sent, even if there are no results. * @details Note that 60 is also the default maximum timeout to prevent undetected dead connections. - * @param[in] integer $timeout Maximum period to wait before the response is sent. Must be a positive integer. + * @param integer $timeout Maximum period to wait before the response is sent. Must be a positive integer. * @warning Only applicable for `continuous` feeds. */ public function setTimeout($timeout = self::DEFAULT_TIMEOUT) { diff --git a/src/EoC/Opt/DocOpts.php b/src/EoC/Opt/DocOpts.php index d7b0233..b3b8ffe 100644 --- a/src/EoC/Opt/DocOpts.php +++ b/src/EoC/Opt/DocOpts.php @@ -51,7 +51,7 @@ public function includeAttachments() { * to fetch only the attachments that have changed since a particular revision. You can specify one or more revision IDs. * In the last case you must use an array of string. The response will include the content of only those attachments * that changed since the given revision(s). - * @param[in] string|array $revs The revision(s) identifier(s). + * @param string|array $revs The revision(s) identifier(s). */ public function includeAttsSince($revs) { $this->options['atts_since'] = json_encode($revs); @@ -140,7 +140,7 @@ public function includeRevsInfo() { * with an "ok" key pointing to the document, or a "missing" key pointing to the rev string. * @details CouchDB will return something like this: * [{"missing":"1-fbd8a6da4d669ae4b909fcdb42bb2bfd"},{"ok":{"_id":"test","_rev":"2-5bc3c6319edf62d4c624277fdd0ae191","hello":"foo"}}] - * @param[in] string|array $revs The revision(s) identifier(s). + * @param string|array $revs The revision(s) identifier(s). */ public function includeOpenRevs($revs = 'all') { if (is_array($revs)) diff --git a/src/EoC/Result/QueryResult.php b/src/EoC/Result/QueryResult.php index 89e66eb..12dcb44 100644 --- a/src/EoC/Result/QueryResult.php +++ b/src/EoC/Result/QueryResult.php @@ -24,7 +24,7 @@ class QueryResult implements \IteratorAggregate, \Countable, \ArrayAccess { /** * @brief Creates an instance of the class - * @param[in] array $result The result of a CouchDB's query converted from JSON to array. + * @param array $result The result of a CouchDB's query converted from JSON to array. */ public function __construct($result) { $this->result = &$result; @@ -33,7 +33,7 @@ public function __construct($result) { /** * @brief Gets the number of total rows in the view. - * @retval integer Number of the view rows. + * @return integer Number of the view rows. */ public function getTotalRows() { return $this->result['total_rows']; @@ -42,7 +42,7 @@ public function getTotalRows() { /** * @brief Returns count or sum in case this is the result of a reduce function. - * @retval integer The result of the reduce function. + * @return integer The result of the reduce function. */ public function getReducedValue() { return empty($this->result['rows']) ? 0 : $this->result['rows'][0]['value']; @@ -52,7 +52,7 @@ public function getReducedValue() { /** * @brief Returns the result as a real array of rows to be used with `array_column()` or other functions operating on * arrays. - * @retval array An array of rows. + * @return array An array of rows. */ public function asArray() { return $this->result['rows']; @@ -63,7 +63,7 @@ public function asArray() { * @brief Returns `true` in case there aren't rows, `false` otherwise. * @details Since the PHP core developers are noobs, `empty()` cannot be used on any class that implements ArrayAccess. * @attention This method must be used in place of `empty()`. - * @retval bool + * @return bool */ public function isEmpty() { return empty($this->result['rows']) ? TRUE : FALSE; @@ -72,7 +72,7 @@ public function isEmpty() { /** * @brief Returns an external iterator. - * @retval [ArrayIterator](http://php.net/manual/en/class.arrayiterator.php). + * @return [ArrayIterator](http://php.net/manual/en/class.arrayiterator.php). */ public function getIterator() { return new \ArrayIterator($this->result['rows']); @@ -81,7 +81,7 @@ public function getIterator() { /** * @brief Returns the number of documents found. - * @retval integer Number of documents. + * @return integer Number of documents. */ public function count() { return count($this->result['rows']); @@ -91,8 +91,8 @@ public function count() { /** * @brief Whether or not an offset exists. * @details This method is executed when using `isset()` or `empty()` on objects implementing ArrayAccess. - * @param[in] integer $offset An offset to check for. - * @retval bool Returns `true` on success or `false` on failure. + * @param integer $offset An offset to check for. + * @return bool Returns `true` on success or `false` on failure. */ public function offsetExists($offset) { return isset($this->result['rows'][$offset]); @@ -102,8 +102,8 @@ public function offsetExists($offset) { /** * @brief Returns the value at specified offset. * @details This method is executed when checking if offset is `empty()`. - * @param[in] integer $offset The offset to retrieve. - * @retval mixed Can return all value types. + * @param integer $offset The offset to retrieve. + * @return mixed Can return all value types. */ public function offsetGet($offset) { return $this->result['rows'][$offset]; diff --git a/src/EoC/Version.php b/src/EoC/Version.php index 62e90f8..81d9654 100644 --- a/src/EoC/Version.php +++ b/src/EoC/Version.php @@ -19,13 +19,13 @@ class Version { const MAJOR = '0'; //!< Major release number. - const MINOR = '8'; //!< Minor release number. - const MAINTENANCE = '2'; //!< Maintenance release number (bug fixes only). + const MINOR = '9'; //!< Minor release number. + const MAINTENANCE = '0'; //!< Maintenance release number (bug fixes only). /** * @brief Returns the version number as string. - * @retval string The version number. + * @return string The version number. */ public static function getNumber() { return static::MAJOR.".".static::MINOR.".".static::MAINTENANCE;