Browse Source

Merge branch 'v1.0/phpdocs'

Daniele Alessandri 10 years ago
parent
commit
87aba18002

+ 4 - 0
CHANGELOG.md

@@ -86,6 +86,10 @@ v1.0.0 (201x-xx-xx)
   shorter `Predis\Command\Processor\ProcessorInterface`. Also removed interface
   for chain processors since it is basically useless.
 
+- Renamed `Predis\ExecutableContextInterface` to `Predis\ClientContextInterface`
+  and augmented it with a couple of required methods since this interface is no
+  more comparable to a basic client as it could be misleading.
+
 - The `Predis\Option` namespace is now known as `Predis\Configuration` and have
   a fully-reworked `Options` class with the ability to lazily initialize values
   using objects that responds to `__invoke()` (not all the kinds of callables)

+ 2 - 0
src/Client.php

@@ -36,6 +36,8 @@ use Predis\Transaction\MultiExec as MultiExecTransaction;
  * abstractions are built. Internally it aggregates various other classes each
  * one with its own responsibility and scope.
  *
+ * {@inheritdoc}
+ *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
 class Client implements ClientInterface

+ 186 - 0
src/ClientContextInterface.php

@@ -0,0 +1,186 @@
+<?php
+
+/*
+ * This file is part of the Predis package.
+ *
+ * (c) Daniele Alessandri <suppakilla@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Predis;
+
+use Predis\Command\CommandInterface;
+
+/**
+ * Interface defining a client-side context such as a pipeline or transaction.
+ *
+ * @method $this del(array $keys)
+ * @method $this dump($key)
+ * @method $this exists($key)
+ * @method $this expire($key, $seconds)
+ * @method $this expireat($key, $timestamp)
+ * @method $this keys($pattern)
+ * @method $this move($key, $db)
+ * @method $this object($subcommand, $key)
+ * @method $this persist($key)
+ * @method $this pexpire($key, $milliseconds)
+ * @method $this pexpireat($key, $timestamp)
+ * @method $this pttl($key)
+ * @method $this randomkey()
+ * @method $this rename($key, $target)
+ * @method $this renamenx($key, $target)
+ * @method $this scan($cursor, array $options = null)
+ * @method $this sort($key, array $options = null)
+ * @method $this ttl($key)
+ * @method $this type($key)
+ * @method $this append($key, $value)
+ * @method $this bitcount($key, $start = null, $end = null)
+ * @method $this bitop($operation, $destkey, $key)
+ * @method $this decr($key)
+ * @method $this decrby($key, $decrement)
+ * @method $this get($key)
+ * @method $this getbit($key, $offset)
+ * @method $this getrange($key, $start, $end)
+ * @method $this getset($key, $value)
+ * @method $this incr($key)
+ * @method $this incrby($key, $increment)
+ * @method $this incrbyfloat($key, $increment)
+ * @method $this mget(array $keys)
+ * @method $this mset(array $dictionary)
+ * @method $this msetnx(array $dictionary)
+ * @method $this psetex($key, $milliseconds, $value)
+ * @method $this set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
+ * @method $this setbit($key, $offset, $value)
+ * @method $this setex($key, $seconds, $value)
+ * @method $this setnx($key, $value)
+ * @method $this setrange($key, $offset, $value)
+ * @method $this strlen($key)
+ * @method $this hdel($key, array $fields)
+ * @method $this hexists($key, $field)
+ * @method $this hget($key, $field)
+ * @method $this hgetall($key)
+ * @method $this hincrby($key, $field, $increment)
+ * @method $this hincrbyfloat($key, $field, $increment)
+ * @method $this hkeys($key)
+ * @method $this hlen($key)
+ * @method $this hmget($key, array $fields)
+ * @method $this hmset($key, array $dictionary)
+ * @method $this hscan($key, $cursor, array $options = null)
+ * @method $this hset($key, $field, $value)
+ * @method $this hsetnx($key, $field, $value)
+ * @method $this hvals($key)
+ * @method $this blpop(array $keys, $timeout)
+ * @method $this brpop(array $keys, $timeout)
+ * @method $this brpoplpush($source, $destination, $timeout)
+ * @method $this lindex($key, $index)
+ * @method $this linsert($key, $whence, $pivot, $value)
+ * @method $this llen($key)
+ * @method $this lpop($key)
+ * @method $this lpush($key, array $values)
+ * @method $this lpushx($key, $value)
+ * @method $this lrange($key, $start, $stop)
+ * @method $this lrem($key, $count, $value)
+ * @method $this lset($key, $index, $value)
+ * @method $this ltrim($key, $start, $stop)
+ * @method $this rpop($key)
+ * @method $this rpoplpush($source, $destination)
+ * @method $this rpush($key, array $values)
+ * @method $this rpushx($key, $value)
+ * @method $this sadd($key, array $members)
+ * @method $this scard($key)
+ * @method $this sdiff(array $keys)
+ * @method $this sdiffstore($destination, array $keys)
+ * @method $this sinter(array $keys)
+ * @method $this sinterstore($destination, array $keys)
+ * @method $this sismember($key, $member)
+ * @method $this smembers($key)
+ * @method $this smove($source, $destination, $member)
+ * @method $this spop($key)
+ * @method $this srandmember($key, $count = null)
+ * @method $this srem($key, $member)
+ * @method $this sscan($key, $cursor, array $options = null)
+ * @method $this sunion(array $keys)
+ * @method $this sunionstore($destination, array $keys)
+ * @method $this zadd($key, array $membersAndScoresDictionary)
+ * @method $this zcard($key)
+ * @method $this zcount($key, $min, $max)
+ * @method $this zinterstore($destination, array $keys, array $options = null)
+ * @method $this zrange($key, $start, $stop, array $options = null)
+ * @method $this zrangebyscore($key, $min, $max, array $options = null)
+ * @method $this zrank($key, $member)
+ * @method $this zrem($key, $member)
+ * @method $this zremrangebyrank($key, $start, $stop)
+ * @method $this zremrangebyscore($key, $min, $max)
+ * @method $this zrevrange($key, $start, $stop, array $options = null)
+ * @method $this zrevrangebyscore($key, $min, $max, array $options = null)
+ * @method $this zrevrank($key, $member)
+ * @method $this zunionstore($destination, array $keys, array $options = null)
+ * @method $this zscore($key, $member)
+ * @method $this zscan($key, $cursor, array $options = null)
+ * @method $this zrangebylex($key, $start, $stop, array $options = null)
+ * @method $this zremrangebylex($key, $min, $max)
+ * @method $this zlexcount($key, $min, $max)
+ * @method $this pfadd($key, array $elements)
+ * @method $this pfmerge($destinationKey, array $sourceKeys)
+ * @method $this pfcount(array $keys)
+ * @method $this pubsub($subcommand, $argument)
+ * @method $this publish($channel, $message)
+ * @method $this discard()
+ * @method $this exec()
+ * @method $this multi()
+ * @method $this unwatch()
+ * @method $this watch($key)
+ * @method $this eval($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null)
+ * @method $this evalsha($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null)
+ * @method $this script($subcommand, $argument = null)
+ * @method $this auth($password)
+ * @method $this echo($message)
+ * @method $this ping($message = null)
+ * @method $this select($database)
+ * @method $this bgrewriteaof()
+ * @method $this bgsave()
+ * @method $this client($subcommand, $argument = null)
+ * @method $this config($subcommand, $argument = null)
+ * @method $this dbsize()
+ * @method $this flushall()
+ * @method $this flushdb()
+ * @method $this info($section = null)
+ * @method $this lastsave()
+ * @method $this save()
+ * @method $this slaveof($host, $port)
+ * @method $this slowlog($subcommand, $argument = null)
+ * @method $this time()
+ * @method $this command()
+ *
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
+interface ClientContextInterface
+{
+
+    /**
+     * Sends the specified command instance to Redis.
+     *
+     * @param  CommandInterface $command Command instance.
+     * @return mixed
+     */
+    public function executeCommand(CommandInterface $command);
+
+    /**
+     * Sends the specified command with its arguments to Redis.
+     *
+     * @param  string $commandID Command ID.
+     * @param  array  $arguments Arguments for the command.
+     * @return mixed
+     */
+    public function __call($method, $arguments);
+
+    /**
+     * Starts the execution of the context.
+     *
+     * @param  mixed $callable Optional callback for execution.
+     * @return array
+     */
+    public function execute($callable = null);
+}

+ 144 - 2
src/ClientInterface.php

@@ -17,8 +17,150 @@ use Predis\Connection\ConnectionInterface;
 use Predis\Profile\ProfileInterface;
 
 /**
- * Interface defining an high-level Redis client that can interact with other
- * building blocks of Predis.
+ * Interface defining a client able to execute commands against Redis.
+ *
+ * All the commands exposed by the client generally have the same signature as
+ * described by the Redis documentation, but some of them offer an additional
+ * and more friendly interface to ease programming which is described in the
+ * following list of methods:
+ *
+ * @method int    del(array $keys)
+ * @method string dump($key)
+ * @method int    exists($key)
+ * @method int    expire($key, $seconds)
+ * @method int    expireat($key, $timestamp)
+ * @method array  keys($pattern)
+ * @method int    move($key, $db)
+ * @method mixed  object($subcommand, $key)
+ * @method int    persist($key)
+ * @method int    pexpire($key, $milliseconds)
+ * @method int    pexpireat($key, $timestamp)
+ * @method int    pttl($key)
+ * @method string randomkey()
+ * @method mixed  rename($key, $target)
+ * @method int    renamenx($key, $target)
+ * @method array  scan($cursor, array $options = null)
+ * @method array  sort($key, array $options = null)
+ * @method int    ttl($key)
+ * @method mixed  type($key)
+ * @method int    append($key, $value)
+ * @method int    bitcount($key, $start = null, $end = null)
+ * @method int    bitop($operation, $destkey, $key)
+ * @method int    decr($key)
+ * @method int    decrby($key, $decrement)
+ * @method string get($key)
+ * @method int    getbit($key, $offset)
+ * @method string getrange($key, $start, $end)
+ * @method string getset($key, $value)
+ * @method int    incr($key)
+ * @method int    incrby($key, $increment)
+ * @method string incrbyfloat($key, $increment)
+ * @method array  mget(array $keys)
+ * @method mixed  mset(array $dictionary)
+ * @method int    msetnx(array $dictionary)
+ * @method mixed  psetex($key, $milliseconds, $value)
+ * @method mixed  set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
+ * @method int    setbit($key, $offset, $value)
+ * @method int    setex($key, $seconds, $value)
+ * @method int    setnx($key, $value)
+ * @method int    setrange($key, $offset, $value)
+ * @method int    strlen($key)
+ * @method int    hdel($key, array $fields)
+ * @method int    hexists($key, $field)
+ * @method string hget($key, $field)
+ * @method array  hgetall($key)
+ * @method int    hincrby($key, $field, $increment)
+ * @method string hincrbyfloat($key, $field, $increment)
+ * @method array  hkeys($key)
+ * @method int    hlen($key)
+ * @method array  hmget($key, array $fields)
+ * @method mixed  hmset($key, array $dictionary)
+ * @method array  hscan($key, $cursor, array $options = null)
+ * @method int    hset($key, $field, $value)
+ * @method int    hsetnx($key, $field, $value)
+ * @method array  hvals($key)
+ * @method array  blpop(array $keys, $timeout)
+ * @method array  brpop(array $keys, $timeout)
+ * @method array  brpoplpush($source, $destination, $timeout)
+ * @method string lindex($key, $index)
+ * @method int    linsert($key, $whence, $pivot, $value)
+ * @method int    llen($key)
+ * @method string lpop($key)
+ * @method int    lpush($key, array $values)
+ * @method int    lpushx($key, $value)
+ * @method array  lrange($key, $start, $stop)
+ * @method int    lrem($key, $count, $value)
+ * @method mixed  lset($key, $index, $value)
+ * @method mixed  ltrim($key, $start, $stop)
+ * @method string rpop($key)
+ * @method string rpoplpush($source, $destination)
+ * @method int    rpush($key, array $values)
+ * @method int    rpushx($key, $value)
+ * @method int    sadd($key, array $members)
+ * @method int    scard($key)
+ * @method array  sdiff(array $keys)
+ * @method int    sdiffstore($destination, array $keys)
+ * @method array  sinter(array $keys)
+ * @method int    sinterstore($destination, array $keys)
+ * @method int    sismember($key, $member)
+ * @method array  smembers($key)
+ * @method int    smove($source, $destination, $member)
+ * @method string spop($key)
+ * @method string srandmember($key, $count = null)
+ * @method int    srem($key, $member)
+ * @method array  sscan($key, $cursor, array $options = null)
+ * @method array  sunion(array $keys)
+ * @method int    sunionstore($destination, array $keys)
+ * @method int    zadd($key, array $membersAndScoresDictionary)
+ * @method int    zcard($key)
+ * @method string zcount($key, $min, $max)
+ * @method int    zinterstore($destination, array $keys, array $options = null)
+ * @method array  zrange($key, $start, $stop, array $options = null)
+ * @method array  zrangebyscore($key, $min, $max, array $options = null)
+ * @method int    zrank($key, $member)
+ * @method int    zrem($key, $member)
+ * @method int    zremrangebyrank($key, $start, $stop)
+ * @method int    zremrangebyscore($key, $min, $max)
+ * @method array  zrevrange($key, $start, $stop, array $options = null)
+ * @method array  zrevrangebyscore($key, $min, $max, array $options = null)
+ * @method int    zrevrank($key, $member)
+ * @method int    zunionstore($destination, array $keys, array $options = null)
+ * @method string zscore($key, $member)
+ * @method array  zscan($key, $cursor, array $options = null)
+ * @method array  zrangebylex($key, $start, $stop, array $options = null)
+ * @method int    zremrangebylex($key, $min, $max)
+ * @method int    zlexcount($key, $min, $max)
+ * @method int    pfadd($key, array $elements)
+ * @method mixed  pfmerge($destinationKey, array $sourceKeys)
+ * @method int    pfcount(array $keys)
+ * @method mixed  pubsub($subcommand, $argument)
+ * @method int    publish($channel, $message)
+ * @method mixed  discard()
+ * @method array  exec()
+ * @method mixed  multi()
+ * @method mixed  unwatch()
+ * @method mixed  watch($key)
+ * @method mixed  eval($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null)
+ * @method mixed  evalsha($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null)
+ * @method mixed  script($subcommand, $argument = null)
+ * @method mixed  auth($password)
+ * @method string echo($message)
+ * @method mixed  ping($message = null)
+ * @method mixed  select($database)
+ * @method mixed  bgrewriteaof()
+ * @method mixed  bgsave()
+ * @method mixed  client($subcommand, $argument = null)
+ * @method mixed  config($subcommand, $argument = null)
+ * @method int    dbsize()
+ * @method mixed  flushall()
+ * @method mixed  flushdb()
+ * @method array  info($section = null)
+ * @method int    lastsave()
+ * @method mixed  save()
+ * @method mixed  slaveof($host, $port)
+ * @method mixed  slowlog($subcommand, $argument = null)
+ * @method array  time()
+ * @method array  command()
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */

+ 2 - 0
src/Configuration/Options.php

@@ -15,6 +15,8 @@ namespace Predis\Configuration;
  * Manages Predis options with filtering, conversion and lazy initialization of
  * values using a mini-DI container approach.
  *
+ * {@inheritdoc}
+ *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
 class Options implements OptionsInterface

+ 1 - 1
src/Configuration/OptionsInterface.php

@@ -12,7 +12,7 @@
 namespace Predis\Configuration;
 
 /**
- * Defines an options container class.
+ * Interface defining a container for client options.
  *
  * @property-read mixed aggregate   Custom connection aggregator.
  * @property-read mixed cluster     Aggregate connection for clustering.

+ 3 - 1
src/Connection/Parameters.php

@@ -14,7 +14,9 @@ namespace Predis\Connection;
 use InvalidArgumentException;
 
 /**
- * Connection parameters used to initialize connections to Redis.
+ * Container for connection parameters used to initialize connections to Redis.
+ *
+ * {@inheritdoc}
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */

+ 1 - 1
src/Connection/ParametersInterface.php

@@ -12,7 +12,7 @@
 namespace Predis\Connection;
 
 /**
- * Interface for classes providing their own logic for connection parameters.
+ * Interface defining a container for connection parameters.
  *
  * The actual list of connection parameters depends on the features supported by
  * each connection backend class (please refer to their specific documentation),

+ 0 - 29
src/ExecutableContextInterface.php

@@ -1,29 +0,0 @@
-<?php
-
-/*
- * This file is part of the Predis package.
- *
- * (c) Daniele Alessandri <suppakilla@gmail.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Predis;
-
-/**
- * Defines the interface of a basic client object or abstraction that can send
- * commands to Redis.
- *
- * @author Daniele Alessandri <suppakilla@gmail.com>
- */
-interface ExecutableContextInterface
-{
-    /**
-     * Starts the execution of the context.
-     *
-     * @param  mixed $callable Optional callback for execution.
-     * @return array
-     */
-    public function execute($callable = null);
-}

+ 4 - 2
src/Pipeline/Pipeline.php

@@ -14,9 +14,9 @@ namespace Predis\Pipeline;
 use Exception;
 use InvalidArgumentException;
 use SplQueue;
+use Predis\ClientContextInterface;
 use Predis\ClientException;
 use Predis\ClientInterface;
-use Predis\ExecutableContextInterface;
 use Predis\Command\CommandInterface;
 use Predis\Connection\ConnectionInterface;
 use Predis\Connection\Aggregate\ReplicationInterface;
@@ -28,9 +28,11 @@ use Predis\Response\ServerException;
  * Implementation of a command pipeline in which write and read operations of
  * Redis commands are pipelined to alleviate the effects of network round-trips.
  *
+ * {@inheritdoc}
+ *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class Pipeline implements ExecutableContextInterface
+class Pipeline implements ClientContextInterface
 {
     private $client;
     private $pipeline;

+ 4 - 2
src/Transaction/MultiExec.php

@@ -14,10 +14,10 @@ namespace Predis\Transaction;
 use Exception;
 use InvalidArgumentException;
 use SplQueue;
+use Predis\ClientContextInterface;
 use Predis\ClientException;
 use Predis\ClientInterface;
 use Predis\CommunicationException;
-use Predis\ExecutableContextInterface;
 use Predis\NotSupportedException;
 use Predis\Response\ErrorInterface as ErrorResponseInterface;
 use Predis\Response\ServerException;
@@ -29,9 +29,11 @@ use Predis\Protocol\ProtocolException;
 /**
  * Client-side abstraction of a Redis transaction based on MULTI / EXEC.
  *
+ * {@inheritdoc}
+ *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class MultiExec implements ExecutableContextInterface
+class MultiExec implements ClientContextInterface
 {
     private $state;