From 93dcd803f16b6a55582ce4c30407f385647e14b6 Mon Sep 17 00:00:00 2001 From: shixinke Date: Tue, 26 Dec 2017 18:42:04 +0800 Subject: [PATCH 01/34] =?UTF-8?q?swoole=E6=9B=B4=E6=96=B0=E5=88=B02.0.10?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=A8=B3=E5=AE=9A=E7=89=88=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E8=A1=A5=E5=85=A8=E5=A4=A7=E9=83=A8=E5=88=86swoole?= =?UTF-8?q?=E7=94=A8=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Swoole/Async.php | 92 - src/Swoole/Atomic.php | 81 - src/Swoole/Buffer.php | 125 - src/Swoole/Channel.php | 67 - src/Swoole/Client.php | 263 -- src/Swoole/Connection/Iterator.php | 120 - src/Swoole/Coroutine.php | 65 - src/Swoole/Coroutine/Client.php | 169 -- src/Swoole/Coroutine/Http/Client.php | 189 -- src/Swoole/Coroutine/MySQL.php | 158 -- src/Swoole/Coroutine/MySQL/Exception.php | 156 -- src/Swoole/Coroutine/Redis.php | 2359 ----------------- src/Swoole/Event.php | 97 - src/Swoole/Exception.php | 156 -- src/Swoole/Http/Client.php | 230 -- src/Swoole/Http/Request.php | 77 - src/Swoole/Http/Response.php | 128 - src/Swoole/Http/Server.php | 456 ---- src/Swoole/Lock.php | 87 - src/Swoole/Mmap.php | 28 - src/Swoole/Module.php | 27 - src/Swoole/MySQL.php | 95 - src/Swoole/MySQL/Exception.php | 156 -- src/Swoole/Process.php | 242 -- src/Swoole/Redis.php | 82 - src/Swoole/Redis/Server.php | 510 ---- src/Swoole/Server.php | 498 ---- src/Swoole/Server/Port.php | 58 - src/Swoole/Table.php | 209 -- src/Swoole/Timer.php | 62 - src/Swoole/WebSocket/Frame.php | 15 - src/Swoole/WebSocket/Server.php | 488 ---- src/Swoole/swoole.namespace.php | 569 ---- src/Swoole/swoole.php | 569 ---- src/Swoole/swoole_async.php | 91 - src/Swoole/swoole_atomic.php | 80 - src/Swoole/swoole_buffer.php | 124 - src/Swoole/swoole_channel.php | 66 - src/Swoole/swoole_client.php | 262 -- src/Swoole/swoole_client_coro.php | 168 -- src/Swoole/swoole_connection_iterator.php | 119 - src/Swoole/swoole_coroutine.php | 64 - src/Swoole/swoole_event.php | 96 - src/Swoole/swoole_exception.php | 155 -- src/Swoole/swoole_http_client.php | 229 -- src/Swoole/swoole_http_client_coro.php | 188 -- src/Swoole/swoole_http_request.php | 76 - src/Swoole/swoole_http_response.php | 127 - src/Swoole/swoole_http_server.php | 455 ---- src/Swoole/swoole_lock.php | 86 - src/Swoole/swoole_mmap.php | 27 - src/Swoole/swoole_module.php | 26 - src/Swoole/swoole_mysql.php | 94 - src/Swoole/swoole_mysql_coro.php | 157 -- src/Swoole/swoole_mysql_coro_exception.php | 155 -- src/Swoole/swoole_mysql_exception.php | 155 -- src/Swoole/swoole_process.php | 241 -- src/Swoole/swoole_redis.php | 81 - src/Swoole/swoole_redis_coro.php | 2358 ---------------- src/Swoole/swoole_redis_server.php | 509 ---- src/Swoole/swoole_server.php | 497 ---- src/Swoole/swoole_server_port.php | 57 - src/Swoole/swoole_table.php | 208 -- src/Swoole/swoole_timer.php | 61 - src/Swoole/swoole_websocket_frame.php | 14 - src/Swoole/swoole_websocket_server.php | 487 ---- src/swoole/swoole.json | 1 + src/swoole/swoole_async.json | 1 + src/swoole/swoole_atomic.json | 1 + src/swoole/swoole_atomic_long.json | 1 + src/swoole/swoole_buffer.json | 1 + src/swoole/swoole_channel.json | 1 + src/swoole/swoole_client.json | 1 + src/swoole/swoole_client_coro.json | 1 + src/swoole/swoole_connection_iterator.json | 1 + src/swoole/swoole_coroutine.json | 1 + src/swoole/swoole_coroutine_client.json | 1 + src/swoole/swoole_coroutine_http_client.json | 1 + src/swoole/swoole_coroutine_mysql.json | 1 + .../swoole_coroutine_mysql_exception.json | 1 + src/swoole/swoole_event.json | 1 + src/swoole/swoole_exception.json | 1 + src/swoole/swoole_http_client.json | 1 + src/swoole/swoole_http_client_coro.json | 1 + src/swoole/swoole_http_request.json | 1 + src/swoole/swoole_http_response.json | 1 + src/swoole/swoole_http_server.json | 1 + src/swoole/swoole_lock.json | 1 + src/swoole/swoole_mmap.json | 1 + src/swoole/swoole_mysql.json | 1 + src/swoole/swoole_mysql_coro.json | 1 + src/swoole/swoole_mysql_coro_exception.json | 1 + src/swoole/swoole_mysql_exception.json | 1 + src/swoole/swoole_process.json | 1 + src/swoole/swoole_redis.json | 97 + src/swoole/swoole_redis_server.json | 1 + src/swoole/swoole_serialize.json | 1 + src/swoole/swoole_server.json | 1 + src/swoole/swoole_server_port.json | 1 + src/swoole/swoole_table.json | 1 + src/swoole/swoole_table_row.json | 1 + src/swoole/swoole_timer.json | 1 + src/swoole/swoole_websocket_frame.json | 1 + src/swoole/swoole_websocket_server.json | 1 + 104 files changed, 134 insertions(+), 16196 deletions(-) delete mode 100644 src/Swoole/Async.php delete mode 100644 src/Swoole/Atomic.php delete mode 100644 src/Swoole/Buffer.php delete mode 100644 src/Swoole/Channel.php delete mode 100644 src/Swoole/Client.php delete mode 100644 src/Swoole/Connection/Iterator.php delete mode 100644 src/Swoole/Coroutine.php delete mode 100644 src/Swoole/Coroutine/Client.php delete mode 100644 src/Swoole/Coroutine/Http/Client.php delete mode 100644 src/Swoole/Coroutine/MySQL.php delete mode 100644 src/Swoole/Coroutine/MySQL/Exception.php delete mode 100644 src/Swoole/Coroutine/Redis.php delete mode 100644 src/Swoole/Event.php delete mode 100644 src/Swoole/Exception.php delete mode 100644 src/Swoole/Http/Client.php delete mode 100644 src/Swoole/Http/Request.php delete mode 100644 src/Swoole/Http/Response.php delete mode 100644 src/Swoole/Http/Server.php delete mode 100644 src/Swoole/Lock.php delete mode 100644 src/Swoole/Mmap.php delete mode 100644 src/Swoole/Module.php delete mode 100644 src/Swoole/MySQL.php delete mode 100644 src/Swoole/MySQL/Exception.php delete mode 100644 src/Swoole/Process.php delete mode 100644 src/Swoole/Redis.php delete mode 100644 src/Swoole/Redis/Server.php delete mode 100644 src/Swoole/Server.php delete mode 100644 src/Swoole/Server/Port.php delete mode 100644 src/Swoole/Table.php delete mode 100644 src/Swoole/Timer.php delete mode 100644 src/Swoole/WebSocket/Frame.php delete mode 100644 src/Swoole/WebSocket/Server.php delete mode 100644 src/Swoole/swoole.namespace.php delete mode 100644 src/Swoole/swoole.php delete mode 100644 src/Swoole/swoole_async.php delete mode 100644 src/Swoole/swoole_atomic.php delete mode 100644 src/Swoole/swoole_buffer.php delete mode 100644 src/Swoole/swoole_channel.php delete mode 100644 src/Swoole/swoole_client.php delete mode 100644 src/Swoole/swoole_client_coro.php delete mode 100644 src/Swoole/swoole_connection_iterator.php delete mode 100644 src/Swoole/swoole_coroutine.php delete mode 100644 src/Swoole/swoole_event.php delete mode 100644 src/Swoole/swoole_exception.php delete mode 100644 src/Swoole/swoole_http_client.php delete mode 100644 src/Swoole/swoole_http_client_coro.php delete mode 100644 src/Swoole/swoole_http_request.php delete mode 100644 src/Swoole/swoole_http_response.php delete mode 100644 src/Swoole/swoole_http_server.php delete mode 100644 src/Swoole/swoole_lock.php delete mode 100644 src/Swoole/swoole_mmap.php delete mode 100644 src/Swoole/swoole_module.php delete mode 100644 src/Swoole/swoole_mysql.php delete mode 100644 src/Swoole/swoole_mysql_coro.php delete mode 100644 src/Swoole/swoole_mysql_coro_exception.php delete mode 100644 src/Swoole/swoole_mysql_exception.php delete mode 100644 src/Swoole/swoole_process.php delete mode 100644 src/Swoole/swoole_redis.php delete mode 100644 src/Swoole/swoole_redis_coro.php delete mode 100644 src/Swoole/swoole_redis_server.php delete mode 100644 src/Swoole/swoole_server.php delete mode 100644 src/Swoole/swoole_server_port.php delete mode 100644 src/Swoole/swoole_table.php delete mode 100644 src/Swoole/swoole_timer.php delete mode 100644 src/Swoole/swoole_websocket_frame.php delete mode 100644 src/Swoole/swoole_websocket_server.php create mode 100644 src/swoole/swoole.json create mode 100644 src/swoole/swoole_async.json create mode 100644 src/swoole/swoole_atomic.json create mode 100644 src/swoole/swoole_atomic_long.json create mode 100644 src/swoole/swoole_buffer.json create mode 100644 src/swoole/swoole_channel.json create mode 100644 src/swoole/swoole_client.json create mode 100644 src/swoole/swoole_client_coro.json create mode 100644 src/swoole/swoole_connection_iterator.json create mode 100644 src/swoole/swoole_coroutine.json create mode 100644 src/swoole/swoole_coroutine_client.json create mode 100644 src/swoole/swoole_coroutine_http_client.json create mode 100644 src/swoole/swoole_coroutine_mysql.json create mode 100644 src/swoole/swoole_coroutine_mysql_exception.json create mode 100644 src/swoole/swoole_event.json create mode 100644 src/swoole/swoole_exception.json create mode 100644 src/swoole/swoole_http_client.json create mode 100644 src/swoole/swoole_http_client_coro.json create mode 100644 src/swoole/swoole_http_request.json create mode 100644 src/swoole/swoole_http_response.json create mode 100644 src/swoole/swoole_http_server.json create mode 100644 src/swoole/swoole_lock.json create mode 100644 src/swoole/swoole_mmap.json create mode 100644 src/swoole/swoole_mysql.json create mode 100644 src/swoole/swoole_mysql_coro.json create mode 100644 src/swoole/swoole_mysql_coro_exception.json create mode 100644 src/swoole/swoole_mysql_exception.json create mode 100644 src/swoole/swoole_process.json create mode 100644 src/swoole/swoole_redis.json create mode 100644 src/swoole/swoole_redis_server.json create mode 100644 src/swoole/swoole_serialize.json create mode 100644 src/swoole/swoole_server.json create mode 100644 src/swoole/swoole_server_port.json create mode 100644 src/swoole/swoole_table.json create mode 100644 src/swoole/swoole_table_row.json create mode 100644 src/swoole/swoole_timer.json create mode 100644 src/swoole/swoole_websocket_frame.json create mode 100644 src/swoole/swoole_websocket_server.json diff --git a/src/Swoole/Async.php b/src/Swoole/Async.php deleted file mode 100644 index 70abb7c..0000000 --- a/src/Swoole/Async.php +++ /dev/null @@ -1,92 +0,0 @@ -start前创建;在swoole_process中使用原子计数器,必须在swoole_process->start前创建) - * @example - * @param int $value 创建一个原子计数对象(只能操作32位整数,最大支持42亿.在swoole_server中使用原子计数器,必须在swoole_server->start前创建;在swoole_process中使用原子计数器,必须在swoole_process->start前创建) - * @return - */ - public function __construct($value) - { - } - - /** - * - *增加计数 - * @example - * @param int $add_value 增加计数 - * @return - */ - public function add($add_value) - { - } - - /** - * - *减少计数 - * @example - * @param int $sub_value 减少计数 - * @return - */ - public function sub($sub_value) - { - } - - /** - * - *获取当前计数的值 - * @example - * @return - */ - public function get() - { - } - - /** - * - *将当前值设置为指定的数字 - * @example - * @param int $value 将当前值设置为指定的数字 - * @return - */ - public function set($value) - { - } - - /** - * - *如果当前数值等于参数1,则将当前数值设置为参数2($cmp_value,$set_value 必须为小于42亿的整数) - * @example - * @param int $cmp_value 如果当前数值等于参数1,则将当前数值设置为参数2($cmp_value,$set_value 必须为小于42亿的整数) - * @param int $new_value 如果当前数值等于参数1,则将当前数值设置为参数2($cmp_value,$set_value 必须为小于42亿的整数) - * @return - */ - public function cmpset($cmp_value, $new_value) - { - } - -} - diff --git a/src/Swoole/Buffer.php b/src/Swoole/Buffer.php deleted file mode 100644 index c49587d..0000000 --- a/src/Swoole/Buffer.php +++ /dev/null @@ -1,125 +0,0 @@ -recv方法的第二个参数,阻塞等待直到收到指定长度的数据后返回 - */ - const MSG_WAITALL = 256; - - /** - * @var int $errCode - * 错误码。errCode的值等于Linux errno。可使用socket_strerror将错误码转为错误信息 - * @access public - */ - public $errCode = 0; - - /** - * @var int $sock - * sock属性是此socket的文件描述符 - * @access public - */ - public $sock = 0; - - /** - * @var bool $reuse - * 表示此连接是新创建的还是复用已存在的。与SWOOLE_KEEP配合使用 - * @access public - */ - public $reuse = ''; - - /** - * @var int $reuseCount - * - * @access public - */ - public $reuseCount = 0; - - /** - * - *创建tcp/udp客户端 - * @example - * @param int $type 创建tcp/udp客户端 - * @param int $async 创建tcp/udp客户端 - * @return - */ - public function __construct($type, $async) - { - } - - /** - * - *析构函数 - * @example - * @return - */ - public function __destruct() - { - } - - /** - * - *设置客户端参数 - * @example - * @param array $settings 设置客户端参数 - * @return - */ - public function set(Array $settings) - { - } - - /** - * - *连接到远程服务器 - * @example - * @param string $host 连接到远程服务器 - * @param int $port 连接到远程服务器 - * @param float $timeout 连接到远程服务器 - * @param int $sock_flag 连接到远程服务器 - * @return bool - */ - public function connect($host, $port, $timeout, $sock_flag) - { - } - - /** - * - *用于从服务器端接收数据 - * @example - * @param int $size 用于从服务器端接收数据 - * @param int $flag 用于从服务器端接收数据 - * @return string - */ - public function recv($size, $flag) - { - } - - /** - * - *发送数据到远程服务器,必须在建立连接后,才可向Server发送数据 - * @example - * @param string $data 发送数据到远程服务器,必须在建立连接后,才可向Server发送数据 - * @param mixed $flag - * @return int - */ - public function send($data, $flag) - { - } - - /** - * - *使用管道发送数据 - * @example - * @param int $dst_socket 使用管道发送数据 - * @return - */ - public function pipe($dst_socket) - { - } - - /** - * - *发送文件到服务器,本函数是基于sendfile操作系统调用的 - * @example - * @param string $filename 发送文件到服务器,本函数是基于sendfile操作系统调用的 - * @param int $offset 发送文件到服务器,本函数是基于sendfile操作系统调用的 - * @return bool - */ - public function sendfile($filename, $offset) - { - } - - /** - * - *向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象。 - * @example - * @param string $ip 向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象。 - * @param int $port 向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象。 - * @param string $data 向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象。 - * @return bool - */ - public function sendto($ip, $port, $data) - { - } - - /** - * - *调用此方法会从事件循环中移除当前socket的可读监听,停止接收数据 - * @example - * @return - */ - public function sleep() - { - } - - /** - * - *调用此方法会重新监听可读事件,将socket连接从睡眠中唤醒(如果socket并未进入sleep模式,wakeup操作没有任何作用) - * @example - * @return - */ - public function wakeup() - { - } - - /** - * - *暂停数据接收 - * @example - * @return - */ - public function pause() - { - } - - /** - * - *恢复数据接收 - * @example - * @return - */ - public function resume() - { - } - - /** - * - *返回swoole_client的连接状态 - * @example - * @return bool - */ - public function isConnected() - { - } - - /** - * - *用于获取客户端socket的本地host:port,必须在连接之后才可以使用 - * @example - * @return array - */ - public function getsockname() - { - } - - /** - * - *获取对端socket的IP地址和端口,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象(此函数必须在$client->recv() 之后调用) - * @example - * @return bool - */ - public function getpeername() - { - } - - /** - * - *关闭连接 - * @example - * @param bool $force 关闭连接 - * @return bool - */ - public function close($force) - { - } - - /** - * - *注册异步事件回调函数,调用on方法会使当前的socket变成非阻塞的 - * @example - * @param string $event_name 注册异步事件回调函数,调用on方法会使当前的socket变成非阻塞的 - * @param string $callback 注册异步事件回调函数,调用on方法会使当前的socket变成非阻塞的 - * @return int - */ - public function on($event_name, $callback) - { - } - -} - diff --git a/src/Swoole/Connection/Iterator.php b/src/Swoole/Connection/Iterator.php deleted file mode 100644 index a03aac7..0000000 --- a/src/Swoole/Connection/Iterator.php +++ /dev/null @@ -1,120 +0,0 @@ -recv方法的第二个参数,阻塞等待直到收到指定长度的数据后返回 - */ - const MSG_WAITALL = 256; - - /** - * @var int $errCode - * 错误码。errCode的值等于Linux errno。可使用socket_strerror将错误码转为错误信息 - * @access public - */ - public $errCode = 0; - - /** - * @var int $sock - * sock属性是此socket的文件描述符 - * @access public - */ - public $sock = 0; - - /** - * - *创建tcp/udp客户端 - * @example - * @return - */ - public function __construct() - { - } - - /** - * - *析构函数 - * @example - * @return - */ - public function __destruct() - { - } - - /** - * - *设置客户端参数 - * @example - * @return - */ - public function set() - { - } - - /** - * - *连接到远程服务器 - * @example - * @return bool - */ - public function connect() - { - } - - /** - * - *用于从服务器端接收数据 - * @example - * @return string - */ - public function recv() - { - } - - /** - * - *发送数据到远程服务器,必须在建立连接后,才可向Server发送数据 - * @example - * @return int - */ - public function send() - { - } - - /** - * - *发送文件到服务器,本函数是基于sendfile操作系统调用的 - * @example - * @return bool - */ - public function sendfile() - { - } - - /** - * - *向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象。 - * @example - * @return bool - */ - public function sendto() - { - } - - /** - * - *返回swoole_client的连接状态 - * @example - * @return bool - */ - public function isConnected() - { - } - - /** - * - *用于获取客户端socket的本地host:port,必须在连接之后才可以使用 - * @example - * @return array - */ - public function getsockname() - { - } - - /** - * - *获取对端socket的IP地址和端口,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象(此函数必须在$client->recv() 之后调用) - * @example - * @return bool - */ - public function getpeername() - { - } - - /** - * - *关闭连接 - * @example - * @return bool - */ - public function close() - { - } - -} - diff --git a/src/Swoole/Coroutine/Http/Client.php b/src/Swoole/Coroutine/Http/Client.php deleted file mode 100644 index 162663c..0000000 --- a/src/Swoole/Coroutine/Http/Client.php +++ /dev/null @@ -1,189 +0,0 @@ - - * $redis->connect('127.0.0.1', 6379); - * $redis->connect('127.0.0.1'); // port 6379 by default - * $redis->connect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout. - * $redis->connect('/tmp/redis.sock'); // unix domain socket. - * - * @return bool - */ - public function connect() - { - } - - /** - * - *设置defer - * @example - * @return - */ - public function setDefer() - { - } - - /** - * - *获取当前defer - * @example - * @return - */ - public function getDefer() - { - } - - /** - * - * - * @example - * @return - */ - public function recv() - { - } - - /** - * - *Disconnects from the Redis instance, except when pconnect is used. - * @example - * @return - */ - public function close() - { - } - - /** - * - *Set the string value in argument as value of the key. - * @example - * @return bool - */ - public function set() - { - } - - /** - * - *Changes a single bit of a string. - * @example - *
-     * $redis->set('key', "*");     // ord("*") = 42 = 0x2f = "0010 1010"
-     * $redis->setBit('key', 5, 1); // returns 0
-     * $redis->setBit('key', 7, 1); // returns 0
-     * $redis->get('key');          // chr(0x2f) = "/" = b("0010 1111")
-     * 
- * @return int: - */ - public function setBit() - { - } - - /** - * - * - * @example - * @return - */ - public function setEx() - { - } - - /** - * - * - * @example - * @return - */ - public function psetEx() - { - } - - /** - * - *Set the list at index with the new value. - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->lGet('key1', 0);     // 'A'
-     * $redis->lSet('key1', 0, 'X');
-     * $redis->lGet('key1', 0);     // 'X'
-     * 
- * @return is - */ - public function lSet() - { - } - - /** - * - *Get the value related to the specified key - * @example $redis->get('key'); - * @return string|bool: - */ - public function get() - { - } - - /** - * - * - * @example - * @return - */ - public function mGet() - { - } - - /** - * - *Remove specified keys. - * @example - *
-     * $redis->set('key1', 'val1');
-     * $redis->set('key2', 'val2');
-     * $redis->set('key3', 'val3');
-     * $redis->set('key4', 'val4');
-     * $redis->delete('key1', 'key2');          // return 2
-     * $redis->delete(array('key3', 'key4'));   // return 2
-     * 
- * @return int - */ - public function del() - { - } - - /** - * - *Removes a values from the hash stored at key. - *If the hash table doesn't exist, or the key doesn't exist, FALSE is returned. - * @example - *
-     * $redis->hMSet('h',
-     * array(
-     * 'f1' => 'v1',
-     * 'f2' => 'v2',
-     * 'f3' => 'v3',
-     * 'f4' => 'v4',
-     * ));
-     * var_dump( $redis->hDel('h', 'f1') );        // int(1)
-     * var_dump( $redis->hDel('h', 'f2', 'f3') );  // int(2)
-     * s
-     * var_dump( $redis->hGetAll('h') );
-     * //// Output:
-     * //  array(1) {
-     * //    ["f4"]=> string(2) "v4"
-     * //  }
-     * 
- * @return int - */ - public function hDel() - { - } - - /** - * - *Adds a value to the hash stored at key. If this value is already in the hash, FALSE is returned. - * @example - *
-     * $redis->delete('h')
-     * $redis->hSet('h', 'key1', 'hello');  // 1, 'key1' => 'hello' in the hash at "h"
-     * $redis->hGet('h', 'key1');           // returns "hello"
-     * $redis->hSet('h', 'key1', 'plop');   // 0, value was replaced.
-     * $redis->hGet('h', 'key1');           // returns "plop"
-     * 
- * @return 0 - */ - public function hSet() - { - } - - /** - * - * - * @example - * @return - */ - public function hMSet() - { - } - - /** - * - *Adds a value to the hash stored at key only if this field isn't already in the hash. - * @example - *
-     * $redis->delete('h')
-     * $redis->hSetNx('h', 'key1', 'hello'); // TRUE, 'key1' => 'hello' in the hash at "h"
-     * $redis->hSetNx('h', 'key1', 'world'); // FALSE, 'key1' => 'hello' in the hash at "h". No change since the field
-     * wasn't replaced.
-     * 
- * @return bool - */ - public function hSetNx() - { - } - - /** - * - * - * @example - * @return int - */ - public function delete() - { - } - - /** - * - * - * @example - * @return - */ - public function mSet() - { - } - - /** - * - * - * @example - * @return - */ - public function mSetNx() - { - } - - /** - * - * - * @example - * @return - */ - public function getKeys() - { - } - - /** - * - *Returns the keys that match a certain pattern. - * @example - *
-     * $allKeys = $redis->keys('*');   // all keys will match this.
-     * $keyWithUserPrefix = $redis->keys('user*');
-     * 
- * @return array - */ - public function keys() - { - } - - /** - * - *Verify if the specified key exists. - * @example - *
-     * $redis->set('key', 'value');
-     * $redis->exists('key');               //  TRUE
-     * $redis->exists('NonExistingKey');    // FALSE
-     * 
- * @return bool: - */ - public function exists() - { - } - - /** - * - *Returns the type of data pointed by a given key. - * @example $redis->type('key'); - * @return - - */ - public function type() - { - } - - /** - * - * - * @example - * @return - */ - public function strLen() - { - } - - /** - * - *Returns and removes the first element of the list. - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->lPop('key1');        // key1 => [ 'B', 'C' ]
-     * 
- * @return string - */ - public function lPop() - { - } - - /** - * - *Is a blocking lPop primitive. If at least one of the lists contains at least one element, - *the element will be popped from the head of the list and returned to the caller. - *Il all the list identified by the keys passed in arguments are empty, blPop will block - *during the specified timeout until an element is pushed to one of those lists. This element will be popped. - * @example - *
-     * // Non blocking feature
-     * $redis->lPush('key1', 'A');
-     * $redis->delete('key2');
-     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * // Blocking feature
-     * // process 1
-     * $redis->delete('key1');
-     * $redis->blPop('key1', 10);
-     * // blocking for 10 seconds
-     * // process 2
-     * $redis->lPush('key1', 'A');
-     * // process 1
-     * // array('key1', 'A') is returned
-     * 
- * @return array - */ - public function blPop() - { - } - - /** - * - *Returns and removes the last element of the list. - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->rPop('key1');        // key1 => [ 'A', 'B' ]
-     * 
- * @return string - */ - public function rPop() - { - } - - /** - * - *Is a blocking rPop primitive. If at least one of the lists contains at least one element, - *the element will be popped from the head of the list and returned to the caller. - *Il all the list identified by the keys passed in arguments are empty, brPop will - *block during the specified timeout until an element is pushed to one of those lists. T - *his element will be popped. - * @example - *
-     * // Non blocking feature
-     * $redis->lPush('key1', 'A');
-     * $redis->delete('key2');
-     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * // Blocking feature
-     * // process 1
-     * $redis->delete('key1');
-     * $redis->blPop('key1', 10);
-     * // blocking for 10 seconds
-     * // process 2
-     * $redis->lPush('key1', 'A');
-     * // process 1
-     * // array('key1', 'A') is returned
-     * 
- * @return array - */ - public function brPop() - { - } - - /** - * - * - * @example - * @return - */ - public function bRPopLPush() - { - } - - /** - * - * - * @example - * @return - */ - public function lSize() - { - } - - /** - * - *Returns the size of a list identified by Key. If the list didn't exist or is empty, - *the command returns 0. If the data type identified by Key is not a list, the command return FALSE. - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->lLen('key1');       // 3
-     * $redis->rPop('key1');
-     * $redis->lLen('key1');       // 2
-     * 
- * @return bool - */ - public function lLen() - { - } - - /** - * - * - * @example - * @return - */ - public function sSize() - { - } - - /** - * - * - * @example - * @return - */ - public function scard() - { - } - - /** - * - *Removes and returns a random element from the set value at Key. - * @example - *
-     * $redis->sAdd('key1' , 'set1');
-     * $redis->sAdd('key1' , 'set2');
-     * $redis->sAdd('key1' , 'set3');   // 'key1' => {'set3', 'set1', 'set2'}
-     * $redis->sPop('key1');            // 'set1', 'key1' => {'set3', 'set2'}
-     * $redis->sPop('key1');            // 'set3', 'key1' => {'set2'}
-     * 
- * @return bool - */ - public function sPop() - { - } - - /** - * - *Returns the contents of a set. - * @example - *
-     * $redis->delete('s');
-     * $redis->sAdd('s', 'a');
-     * $redis->sAdd('s', 'b');
-     * $redis->sAdd('s', 'a');
-     * $redis->sAdd('s', 'c');
-     * var_dump($redis->sMembers('s'));
-     * //array(3) {
-     * //  [0]=>
-     * //  string(1) "c"
-     * //  [1]=>
-     * //  string(1) "a"
-     * //  [2]=>
-     * //  string(1) "b"
-     * //}
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @return array - */ - public function sMembers() - { - } - - /** - * - * - * @example - * @return array - */ - public function sGetMembers() - { - } - - /** - * - *Returns a random element(s) from the set value at Key, without removing it. - * @example - *
-     * $redis->sAdd('key1' , 'one');
-     * $redis->sAdd('key1' , 'two');
-     * $redis->sAdd('key1' , 'three');              // 'key1' => {'one', 'two', 'three'}
-     * var_dump( $redis->sRandMember('key1') );     // 'key1' => {'one', 'two', 'three'}
-     * // string(5) "three"
-     * var_dump( $redis->sRandMember('key1', 2) );  // 'key1' => {'one', 'two', 'three'}
-     * // array(2) {
-     * //   [0]=> string(2) "one"
-     * //   [1]=> string(2) "three"
-     * // }
-     * 
- * @return bool - */ - public function sRandMember() - { - } - - /** - * - *Remove the expiration timer from a key. - * @example $redis->persist('key'); - * @return bool: - */ - public function persist() - { - } - - /** - * - *Returns the time to live left for a given key, in seconds. If the key doesn't exist, FALSE is returned. - * @example $redis->ttl('key'); - * @return int, - */ - public function ttl() - { - } - - /** - * - *Returns a time to live left for a given key, in milliseconds. - * @example $redis->pttl('key'); - * @return int - */ - public function pttl() - { - } - - /** - * - *Returns the cardinality of an ordered set. - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zCard('key');            // 3
-     * 
- * @return int - */ - public function zCard() - { - } - - /** - * - * - * @example - * @return - */ - public function zSize() - { - } - - /** - * - *Returns the length of a hash, in number of items - * @example - *
-     * $redis->delete('h')
-     * $redis->hSet('h', 'key1', 'hello');
-     * $redis->hSet('h', 'key2', 'plop');
-     * $redis->hLen('h'); // returns 2
-     * 
- * @return int - */ - public function hLen() - { - } - - /** - * - *Returns the keys in a hash, as an array of strings. - * @example - *
-     * $redis->delete('h');
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hSet('h', 'b', 'y');
-     * $redis->hSet('h', 'c', 'z');
-     * $redis->hSet('h', 'd', 't');
-     * var_dump($redis->hKeys('h'));
-     * // Output:
-     * // array(4) {
-     * // [0]=>
-     * // string(1) "a"
-     * // [1]=>
-     * // string(1) "b"
-     * // [2]=>
-     * // string(1) "c"
-     * // [3]=>
-     * // string(1) "d"
-     * // }
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @return array - */ - public function hKeys() - { - } - - /** - * - *Returns the values in a hash, as an array of strings. - * @example - *
-     * $redis->delete('h');
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hSet('h', 'b', 'y');
-     * $redis->hSet('h', 'c', 'z');
-     * $redis->hSet('h', 'd', 't');
-     * var_dump($redis->hVals('h'));
-     * // Output
-     * // array(4) {
-     * //   [0]=>
-     * //   string(1) "x"
-     * //   [1]=>
-     * //   string(1) "y"
-     * //   [2]=>
-     * //   string(1) "z"
-     * //   [3]=>
-     * //   string(1) "t"
-     * // }
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @return array - */ - public function hVals() - { - } - - /** - * - *Returns the whole hash, as an array of strings indexed by strings. - * @example - *
-     * $redis->delete('h');
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hSet('h', 'b', 'y');
-     * $redis->hSet('h', 'c', 'z');
-     * $redis->hSet('h', 'd', 't');
-     * var_dump($redis->hGetAll('h'));
-     * // Output:
-     * // array(4) {
-     * //   ["a"]=>
-     * //   string(1) "x"
-     * //   ["b"]=>
-     * //   string(1) "y"
-     * //   ["c"]=>
-     * //   string(1) "z"
-     * //   ["d"]=>
-     * //   string(1) "t"
-     * // }
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @return array - */ - public function hGetAll() - { - } - - /** - * - * - * @example - * @return - */ - public function debug() - { - } - - /** - * - *Restore a key from the result of a DUMP operation. - * @example - *
-     * $redis->set('foo', 'bar');
-     * $val = $redis->dump('foo');
-     * $redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo'
-     * 
- * @return - */ - public function restore() - { - } - - /** - * - *Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command. - *The data that comes out of DUMP is a binary representation of the key as Redis stores it. - * @example - *
-     * $redis->set('foo', 'bar');
-     * $val = $redis->dump('foo'); // $val will be the Redis encoded key value
-     * 
- * @return string - */ - public function dump() - { - } - - /** - * - * - * @example - * @return - */ - public function renameKey() - { - } - - /** - * - *Renames a key. - * @example - *
-     * $redis->set('x', '42');
-     * $redis->rename('x', 'y');
-     * $redis->get('y');   // → 42
-     * $redis->get('x');   // → `FALSE`
-     * 
- * @return bool: - */ - public function rename() - { - } - - /** - * - *Renames a key. - * @example - *
-     * $redis->set('x', '42');
-     * $redis->rename('x', 'y');
-     * $redis->get('y');   // → 42
-     * $redis->get('x');   // → `FALSE`
-     * 
- * @return bool: - */ - public function renameNx() - { - } - - /** - * - *Pops a value from the tail of a list, and pushes it to the front of another list. - *Also return this value. - * @example - *
-     * $redis->delete('x', 'y');
-     * $redis->lPush('x', 'abc');
-     * $redis->lPush('x', 'def');
-     * $redis->lPush('y', '123');
-     * $redis->lPush('y', '456');
-     * // move the last of x to the front of y.
-     * var_dump($redis->rpoplpush('x', 'y'));
-     * var_dump($redis->lRange('x', 0, -1));
-     * var_dump($redis->lRange('y', 0, -1));
-     * //Output:
-     * //
-     * //string(3) "abc"
-     * //array(1) {
-     * //  [0]=>
-     * //  string(3) "def"
-     * //}
-     * //array(3) {
-     * //  [0]=>
-     * //  string(3) "abc"
-     * //  [1]=>
-     * //  string(3) "456"
-     * //  [2]=>
-     * //  string(3) "123"
-     * //}
-     * 
- * @return string - */ - public function rpoplpush() - { - } - - /** - * - *Returns a random key. - * @example - *
-     * $key = $redis->randomKey();
-     * $surprise = $redis->get($key);  // who knows what's in there.
-     * 
- * @return string: - */ - public function randomKey() - { - } - - /** - * - *Check the current connection status - * @example - * @return string - */ - public function ping() - { - } - - /** - * - *Authenticate the connection using a password. - *Warning: The password is sent in plain-text over the network. - * @example $redis->auth('foobared'); - * @return bool: - */ - public function auth() - { - } - - /** - * - * - * @example - * @return - */ - public function unwatch() - { - } - - /** - * - *Watches a key for modifications by another client. If the key is modified between WATCH and EXEC, - *the MULTI/EXEC transaction will fail (return FALSE). unwatch cancels all the watching of all keys by this client. - * @example - *
-     * $redis->watch('x');
-     * // long code here during the execution of which other clients could well modify `x`
-     * $ret = $redis->multi()
-     * ->incr('x')
-     * ->exec();
-     * // $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.
-     * 
- * @return - */ - public function watch() - { - } - - /** - * - *Performs a synchronous save. - * @example $redis->save(); - * @return If - */ - public function save() - { - } - - /** - * - * - * @example - * @return - */ - public function bgSave() - { - } - - /** - * - *Returns the timestamp of the last disk save. - * @example $redis->lastSave(); - * @return int: - */ - public function lastSave() - { - } - - /** - * - *Removes all entries from the current database. - * @example $redis->flushDB(); - * @return bool: - */ - public function flushDB() - { - } - - /** - * - *Removes all entries from all databases. - * @example $redis->flushAll(); - * @return bool: - */ - public function flushAll() - { - } - - /** - * - *Returns the current database's size. - * @example - *
-     * $count = $redis->dbSize();
-     * echo "Redis has $count keys\n";
-     * 
- * @return int: - */ - public function dbSize() - { - } - - /** - * - *Starts the background rewrite of AOF (Append-Only File) - * @example $redis->bgrewriteaof(); - * @return bool: - */ - public function bgrewriteaof() - { - } - - /** - * - *Return the current Redis server time. - * @example - *
-     * var_dump( $redis->time() );
-     * // array(2) {
-     * //   [0] => string(10) "1342364352"
-     * //   [1] => string(6) "253002"
-     * // }
-     * 
- * @return unix - */ - public function time() - { - } - - /** - * - * - * @example - * @return - */ - public function role() - { - } - - /** - * - *Changes a substring of a larger string. - * @example - *
-     * $redis->set('key', 'Hello world');
-     * $redis->setRange('key', 6, "redis"); // returns 11
-     * $redis->get('key');                  // "Hello redis"
-     * 
- * @return string: - */ - public function setRange() - { - } - - /** - * - * - * @example - * @return - */ - public function setNx() - { - } - - /** - * - *Sets a value and returns the previous entry at that key. - * @example - *
-     * $redis->set('x', '42');
-     * $exValue = $redis->getSet('x', 'lol');   // return '42', replaces x by 'lol'
-     * $newValue = $redis->get('x')'            // return 'lol'
-     * 
- * @return string - */ - public function getSet() - { - } - - /** - * - *Append specified string to the string stored in specified key. - * @example - *
-     * $redis->set('key', 'value1');
-     * $redis->append('key', 'value2'); // 12
-     * $redis->get('key');              // 'value1value2'
-     * 
- * @return int: - */ - public function append() - { - } - - /** - * - *Adds the string value to the head (left) of the list if the list exists. - * @example - *
-     * $redis->delete('key1');
-     * $redis->lPushx('key1', 'A');     // returns 0
-     * $redis->lPush('key1', 'A');      // returns 1
-     * $redis->lPushx('key1', 'B');     // returns 2
-     * $redis->lPushx('key1', 'C');     // returns 3
-     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
-     * 
- * @return int - */ - public function lPushx() - { - } - - /** - * - *Adds the string values to the head (left) of the list. Creates the list if the key didn't exist. - *If the key exists and is not a list, FALSE is returned. - * @example - *
-     * $redis->lPush('l', 'v1', 'v2', 'v3', 'v4')   // int(4)
-     * var_dump( $redis->lRange('l', 0, -1) );
-     * //// Output:
-     * // array(4) {
-     * //   [0]=> string(2) "v4"
-     * //   [1]=> string(2) "v3"
-     * //   [2]=> string(2) "v2"
-     * //   [3]=> string(2) "v1"
-     * // }
-     * 
- * @return int - */ - public function lPush() - { - } - - /** - * - *Adds the string values to the tail (right) of the list. Creates the list if the key didn't exist. - *If the key exists and is not a list, FALSE is returned. - * @example - *
-     * $redis->rPush('l', 'v1', 'v2', 'v3', 'v4');    // int(4)
-     * var_dump( $redis->lRange('l', 0, -1) );
-     * //// Output:
-     * // array(4) {
-     * //   [0]=> string(2) "v1"
-     * //   [1]=> string(2) "v2"
-     * //   [2]=> string(2) "v3"
-     * //   [3]=> string(2) "v4"
-     * // }
-     * 
- * @return int - */ - public function rPush() - { - } - - /** - * - *Adds the string value to the tail (right) of the list if the ist exists. FALSE in case of Failure. - * @example - *
-     * $redis->delete('key1');
-     * $redis->rPushx('key1', 'A'); // returns 0
-     * $redis->rPush('key1', 'A'); // returns 1
-     * $redis->rPushx('key1', 'B'); // returns 2
-     * $redis->rPushx('key1', 'C'); // returns 3
-     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
-     * 
- * @return int - */ - public function rPushx() - { - } - - /** - * - * - * @example - * @return - */ - public function sContains() - { - } - - /** - * - * - * @example - * @return - */ - public function sismember() - { - } - - /** - * - *Returns the score of a given member in the specified sorted set. - * @example - *
-     * $redis->zAdd('key', 2.5, 'val2');
-     * $redis->zScore('key', 'val2'); // 2.5
-     * 
- * @return - */ - public function zScore() - { - } - - /** - * - *Returns the rank of a given member in the specified sorted set, starting at 0 for the item - *with the smallest score. zRevRank starts at 0 for the item with the largest score. - * @example - *
-     * $redis->delete('z');
-     * $redis->zAdd('key', 1, 'one');
-     * $redis->zAdd('key', 2, 'two');
-     * $redis->zRank('key', 'one');     // 0
-     * $redis->zRank('key', 'two');     // 1
-     * $redis->zRevRank('key', 'one');  // 1
-     * $redis->zRevRank('key', 'two');  // 0
-     * 
- * @return int - */ - public function zRank() - { - } - - /** - * - * - * @example - * @return int - */ - public function zRevRank() - { - } - - /** - * - *Gets a value from the hash stored at key. - *If the hash table doesn't exist, or the key doesn't exist, FALSE is returned. - * @example - * @return string - */ - public function hGet() - { - } - - /** - * - *Retirieve the values associated to the specified fields in the hash. - * @example - *
-     * $redis->delete('h');
-     * $redis->hSet('h', 'field1', 'value1');
-     * $redis->hSet('h', 'field2', 'value2');
-     * $redis->hmGet('h', array('field1', 'field2')); // returns array('field1' => 'value1', 'field2' => 'value2')
-     * 
- * @return with - */ - public function hMGet() - { - } - - /** - * - *Verify if the specified member exists in a key. - * @example - *
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hExists('h', 'a');               //  TRUE
-     * $redis->hExists('h', 'NonExistingKey');  // FALSE
-     * 
- * @return bool: - */ - public function hExists() - { - } - - /** - * - *Publish messages to channels. Warning: this function will probably change in the future. - * @example $redis->publish('chan-1', 'hello, world!'); // send message. - * @return int - */ - public function publish() - { - } - - /** - * - *Increments the score of a member from a sorted set by a given amount. - * @example - *
-     * $redis->delete('key');
-     * $redis->zIncrBy('key', 2.5, 'member1');  // key or member1 didn't exist, so member1's score is to 0
-     * // before the increment and now has the value 2.5
-     * $redis->zIncrBy('key', 1, 'member1');    // 3.5
-     * 
- * @return float - */ - public function zIncrBy() - { - } - - /** - * - *Adds the specified member with a given score to the sorted set stored at key. - * @example - *
-     * 
-     * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
-     * $redis->zRem('z', 'v2', 'v3');                           // int(2)
-     * var_dump( $redis->zRange('z', 0, -1) );
-     * //// Output:
-     * // array(2) {
-     * //   [0]=> string(2) "v1"
-     * //   [1]=> string(2) "v4"
-     * // }
-     * 
- *
- * @return int - */ - public function zAdd() - { - } - - /** - * - * - * @example - * @return - */ - public function zDeleteRangeByScore() - { - } - - /** - * - *Deletes the elements of the sorted set stored at the specified key which have scores in the range [start,end]. - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zRemRangeByScore('key', 0, 3); // 2
-     * 
- * @return int - */ - public function zRemRangeByScore() - { - } - - /** - * - *Returns the number of elements of the sorted set stored at the specified key which have - *scores in the range [start,end]. Adding a parenthesis before start or end excludes it - *from the range. +inf and -inf are also valid limits. - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zCount('key', 0, 3); // 2, corresponding to array('val0', 'val2')
-     * 
- * @return int - */ - public function zCount() - { - } - - /** - * - *Returns a range of elements from the ordered set stored at the specified key, - *with values in the range [start, end]. start and stop are interpreted as zero-based indices: - *0 the first element, - *1 the second ... - *-1 the last element, - *-2 the penultimate ... - * @example - *
-     * $redis->zAdd('key1', 0, 'val0');
-     * $redis->zAdd('key1', 2, 'val2');
-     * $redis->zAdd('key1', 10, 'val10');
-     * $redis->zRange('key1', 0, -1); // array('val0', 'val2', 'val10')
-     * // with scores
-     * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10)
-     * 
- * @return array - */ - public function zRange() - { - } - - /** - * - *Returns the elements of the sorted set stored at the specified key in the range [start, end] - *in reverse order. start and stop are interpretated as zero-based indices: - *0 the first element, - *1 the second ... - *-1 the last element, - *-2 the penultimate ... - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zRevRange('key', 0, -1); // array('val10', 'val2', 'val0')
-     * // with scores
-     * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0)
-     * 
- * @return array - */ - public function zRevRange() - { - } - - /** - * - *Returns the elements of the sorted set stored at the specified key which have scores in the - *range [start,end]. Adding a parenthesis before start or end excludes it from the range. - *+inf and -inf are also valid limits. - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
-     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
-     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
-     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
-     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
-     * 
- * @return array - */ - public function zRangeByScore() - { - } - - /** - * - * - * @example - * @return - */ - public function zRevRangeByScore() - { - } - - /** - * - *Returns a lexigraphical range of members in a sorted set, assuming the members have the same score. The - *min and max values are required to start with '(' (exclusive), '[' (inclusive), or be exactly the values - *'-' (negative inf) or '+' (positive inf). The command must be called with either three *or* five - *arguments or will return FALSE. - * @example - *
-     * foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g') as $char) {
-     * $redis->zAdd('key', $char);
-     * }
-     * $redis->zRangeByLex('key', '-', '[c'); // array('a', 'b', 'c')
-     * $redis->zRangeByLex('key', '-', '(c'); // array('a', 'b')
-     * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c')
-     * 
- * @return array - */ - public function zRangeByLex() - { - } - - /** - * - * - * @example - * @return - */ - public function zRevRangeByLex() - { - } - - /** - * - *Creates an intersection of sorted sets given in second argument. - *The result of the union will be stored in the sorted set defined by the first argument. - *The third optional argument defines weights to apply to the sorted sets in input. - *In this case, the weights will be multiplied by the score of each element in the sorted set - *before applying the aggregation. The forth argument defines the AGGREGATE option which - *specify how the results of the union are aggregated. - * @example - *
-     * $redis->delete('k1');
-     * $redis->delete('k2');
-     * $redis->delete('k3');
-     * $redis->delete('ko1');
-     * $redis->delete('ko2');
-     * $redis->delete('ko3');
-     * $redis->delete('ko4');
-     * $redis->zAdd('k1', 0, 'val0');
-     * $redis->zAdd('k1', 1, 'val1');
-     * $redis->zAdd('k1', 3, 'val3');
-     * $redis->zAdd('k2', 2, 'val1');
-     * $redis->zAdd('k2', 3, 'val3');
-     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
-     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
-     * // Weighted zInter
-     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
-     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
-     * 
- * @return int - */ - public function zInter() - { - } - - /** - * - * - * @example - * @return - */ - public function zinterstore() - { - } - - /** - * - *Creates an union of sorted sets given in second argument. - *The result of the union will be stored in the sorted set defined by the first argument. - *The third optionnel argument defines weights to apply to the sorted sets in input. - *In this case, the weights will be multiplied by the score of each element in the sorted set - *before applying the aggregation. The forth argument defines the AGGREGATE option which - *specify how the results of the union are aggregated. - * @example - *
-     * $redis->delete('k1');
-     * $redis->delete('k2');
-     * $redis->delete('k3');
-     * $redis->delete('ko1');
-     * $redis->delete('ko2');
-     * $redis->delete('ko3');
-     * $redis->zAdd('k1', 0, 'val0');
-     * $redis->zAdd('k1', 1, 'val1');
-     * $redis->zAdd('k2', 2, 'val2');
-     * $redis->zAdd('k2', 3, 'val3');
-     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
-     * // Weighted zUnion
-     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
-     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
-     * 
- * @return int - */ - public function zUnion() - { - } - - /** - * - * - * @example - * @return - */ - public function zunionstore() - { - } - - /** - * - *Increment the number stored at key by one. If the second argument is filled, it will be used as the integer - *value of the increment. - * @example - *
-     * $redis->incr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value 1
-     * $redis->incr('key1');        // 2
-     * $redis->incr('key1');        // 3
-     * $redis->incr('key1');        // 4
-     * $redis->incrBy('key1', 10);  // 14
-     * 
- * @return int - */ - public function incrBy() - { - } - - /** - * - *Increments the value of a member from a hash by a given amount. - * @example - *
-     * $redis->delete('h');
-     * $redis->hIncrBy('h', 'x', 2); // returns 2: h[x] = 2 now.
-     * $redis->hIncrBy('h', 'x', 1); // h[x] ← 2 + 1. Returns 3
-     * 
- * @return int - */ - public function hIncrBy() - { - } - - /** - * - *Increment the number stored at key by one. - * @example - *
-     * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
-     * $redis->incr('key1'); // 2
-     * $redis->incr('key1'); // 3
-     * $redis->incr('key1'); // 4
-     * 
- * @return int - */ - public function incr() - { - } - - /** - * - *Decrement the number stored at key by one. If the second argument is filled, it will be used as the integer - *value of the decrement. - * @example - *
-     * $redis->decr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value -1
-     * $redis->decr('key1');        // -2
-     * $redis->decr('key1');        // -3
-     * $redis->decrBy('key1', 10);  // -13
-     * 
- * @return int - */ - public function decrBy() - { - } - - /** - * - *Decrement the number stored at key by one. - * @example - *
-     * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
-     * $redis->decr('key1'); // -2
-     * $redis->decr('key1'); // -3
-     * 
- * @return int - */ - public function decr() - { - } - - /** - * - *Return a single bit out of a larger string - * @example - *
-     * $redis->set('key', "\x7f");  // this is 0111 1111
-     * $redis->getBit('key', 0);    // 0
-     * $redis->getBit('key', 1);    // 1
-     * 
- * @return int: - */ - public function getBit() - { - } - - /** - * - *Insert value in the list before or after the pivot value. the parameter options - *specify the position of the insert (before or after). If the list didn't exists, - *or the pivot didn't exists, the value is not inserted. - * @example - *
-     * $redis->delete('key1');
-     * $redis->lInsert('key1', Redis::AFTER, 'A', 'X');     // 0
-     * $redis->lPush('key1', 'A');
-     * $redis->lPush('key1', 'B');
-     * $redis->lPush('key1', 'C');
-     * $redis->lInsert('key1', Redis::BEFORE, 'C', 'X');    // 4
-     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C')
-     * $redis->lInsert('key1', Redis::AFTER, 'C', 'Y');     // 5
-     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C', 'Y')
-     * $redis->lInsert('key1', Redis::AFTER, 'W', 'value'); // -1
-     * 
- * @return int - */ - public function lInsert() - { - } - - /** - * - * - * @example - * @return - */ - public function lGet() - { - } - - /** - * - *Return the specified element of the list stored at the specified key. - *0 the first element, 1 the second ... -1 the last element, -2 the penultimate ... - *Return FALSE in case of a bad index or a key that doesn't point to a list. - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->lGet('key1', 0);     // 'A'
-     * $redis->lGet('key1', -1);    // 'C'
-     * $redis->lGet('key1', 10);    // `FALSE`
-     * 
- * @return Bool - */ - public function lIndex() - { - } - - /** - * - * - * @example - * @return - */ - public function setTimeout() - { - } - - /** - * - *Sets an expiration date (a timeout) on an item. - * @example - *
-     * $redis->set('x', '42');
-     * $redis->setTimeout('x', 3);  // x will disappear in 3 seconds.
-     * sleep(5);                    // wait 5 seconds
-     * $redis->get('x');            // will return `FALSE`, as 'x' has expired.
-     * 
- * @return bool: - */ - public function expire() - { - } - - /** - * - * - * @example - * @return - */ - public function pexpire() - { - } - - /** - * - *Sets an expiration date (a timestamp) on an item. - * @example - *
-     * $redis->set('x', '42');
-     * $now = time(NULL);               // current timestamp
-     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
-     * sleep(5);                        // wait 5 seconds
-     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
-     * 
- * @return bool: - */ - public function expireAt() - { - } - - /** - * - * - * @example - * @return - */ - public function pexpireAt() - { - } - - /** - * - *Moves a key to a different database. - * @example - *
-     * $redis->select(0);       // switch to DB 0
-     * $redis->set('x', '42');  // write 42 to x
-     * $redis->move('x', 1);    // move to DB 1
-     * $redis->select(1);       // switch to DB 1
-     * $redis->get('x');        // will return 42
-     * 
- * @return bool: - */ - public function move() - { - } - - /** - * - *Switches to a given database. - * @example - *
-     * $redis->select(0);       // switch to DB 0
-     * $redis->set('x', '42');  // write 42 to x
-     * $redis->move('x', 1);    // move to DB 1
-     * $redis->select(1);       // switch to DB 1
-     * $redis->get('x');        // will return 42
-     * 
- * @return bool - */ - public function select() - { - } - - /** - * - *Return a substring of a larger string - * @example - *
-     * $redis->set('key', 'string value');
-     * $redis->getRange('key', 0, 5);   // 'string'
-     * $redis->getRange('key', -5, -1); // 'value'
-     * 
- * @return string: - */ - public function getRange() - { - } - - /** - * - * - * @example - * @return - */ - public function listTrim() - { - } - - /** - * - * - * @example - * @return - */ - public function ltrim() - { - } - - /** - * - * - * @example - * @return - */ - public function lGetRange() - { - } - - /** - * - *Returns the specified elements of the list stored at the specified key in - *the range [start, end]. start and stop are interpretated as indices: 0 the first element, - *1 the second ... -1 the last element, -2 the penultimate ... - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');
-     * $redis->lRange('key1', 0, -1); // array('A', 'B', 'C')
-     * 
- * @return array - */ - public function lRange() - { - } - - /** - * - *Removes the first count occurences of the value element from the list. - *If count is zero, all the matching elements are removed. If count is negative, - *elements are removed from tail to head. - * @example - *
-     * $redis->lPush('key1', 'A');
-     * $redis->lPush('key1', 'B');
-     * $redis->lPush('key1', 'C');
-     * $redis->lPush('key1', 'A');
-     * $redis->lPush('key1', 'A');
-     * $redis->lRange('key1', 0, -1);   // array('A', 'A', 'C', 'B', 'A')
-     * $redis->lRem('key1', 'A', 2);    // 2
-     * $redis->lRange('key1', 0, -1);   // array('C', 'B', 'A')
-     * 
- * @return bool - */ - public function lRem() - { - } - - /** - * - * - * @example - * @return - */ - public function lRemove() - { - } - - /** - * - * - * @example - * @return - */ - public function zDeleteRangeByRank() - { - } - - /** - * - *Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end]. - * @example - *
-     * $redis->zAdd('key', 1, 'one');
-     * $redis->zAdd('key', 2, 'two');
-     * $redis->zAdd('key', 3, 'three');
-     * $redis->zRemRangeByRank('key', 0, 1); // 2
-     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
-     * 
- * @return int - */ - public function zRemRangeByRank() - { - } - - /** - * - *Increment the float value of a key by the given amount - * @example - *
-     * $redis = new Redis();
-     * $redis->connect('127.0.0.1');
-     * $redis->set('x', 3);
-     * var_dump( $redis->incrByFloat('x', 1.5) );   // float(4.5)
-     * // ! SIC
-     * var_dump( $redis->get('x') );                // string(3) "4.5"
-     * 
- * @return - */ - public function incrByFloat() - { - } - - /** - * - *Increment the float value of a hash field by the given amount - * @example - *
-     * $redis = new Redis();
-     * $redis->connect('127.0.0.1');
-     * $redis->hset('h', 'float', 3);
-     * $redis->hset('h', 'int',   3);
-     * var_dump( $redis->hIncrByFloat('h', 'float', 1.5) ); // float(4.5)
-     * var_dump( $redis->hGetAll('h') );
-     * // Output
-     * array(2) {
-     * ["float"]=>
-     * string(3) "4.5"
-     * ["int"]=>
-     * string(1) "3"
-     * }
-     * 
- * @return - */ - public function hIncrByFloat() - { - } - - /** - * - *Count bits in a string. - * @example - *
-     * $redis->set('bit', '345'); // // 11 0011  0011 0100  0011 0101
-     * var_dump( $redis->bitCount('bit', 0, 0) ); // int(4)
-     * var_dump( $redis->bitCount('bit', 1, 1) ); // int(3)
-     * var_dump( $redis->bitCount('bit', 2, 2) ); // int(4)
-     * var_dump( $redis->bitCount('bit', 0, 2) ); // int(11)
-     * 
- * @return int - */ - public function bitCount() - { - } - - /** - * - *Bitwise operation on multiple keys. - * @example - *
-     * $redis->set('bit1', '1'); // 11 0001
-     * $redis->set('bit2', '2'); // 11 0010
-     * $redis->bitOp('AND', 'bit', 'bit1', 'bit2'); // bit = 110000
-     * $redis->bitOp('OR',  'bit', 'bit1', 'bit2'); // bit = 110011
-     * $redis->bitOp('NOT', 'bit', 'bit1', 'bit2'); // bit = 110011
-     * $redis->bitOp('XOR', 'bit', 'bit1', 'bit2'); // bit = 11
-     * 
- * @return int - */ - public function bitOp() - { - } - - /** - * - *Adds a values to the set value stored at key. - *If this value is already in the set, FALSE is returned. - * @example - *
-     * $redis->sAdd('k', 'v1');                // int(1)
-     * $redis->sAdd('k', 'v1', 'v2', 'v3');    // int(2)
-     * 
- * @return int - */ - public function sAdd() - { - } - - /** - * - *Moves the specified member from the set at srcKey to the set at dstKey. - * @example - *
-     * $redis->sAdd('key1' , 'set11');
-     * $redis->sAdd('key1' , 'set12');
-     * $redis->sAdd('key1' , 'set13');          // 'key1' => {'set11', 'set12', 'set13'}
-     * $redis->sAdd('key2' , 'set21');
-     * $redis->sAdd('key2' , 'set22');          // 'key2' => {'set21', 'set22'}
-     * $redis->sMove('key1', 'key2', 'set13');  // 'key1' =>  {'set11', 'set12'}
-     * // 'key2' =>  {'set21', 'set22', 'set13'}
-     * 
- * @return If - */ - public function sMove() - { - } - - /** - * - *Performs the difference between N sets and returns it. - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s0', '3');
-     * $redis->sAdd('s0', '4');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * var_dump($redis->sDiff('s0', 's1', 's2'));
-     * //array(2) {
-     * //  [0]=>
-     * //  string(1) "4"
-     * //  [1]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @return array - */ - public function sDiff() - { - } - - /** - * - *Performs the same action as sDiff, but stores the result in the first key - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s0', '3');
-     * $redis->sAdd('s0', '4');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * var_dump($redis->sDiffStore('dst', 's0', 's1', 's2'));
-     * var_dump($redis->sMembers('dst'));
-     * //int(2)
-     * //array(2) {
-     * //  [0]=>
-     * //  string(1) "4"
-     * //  [1]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @return int: - */ - public function sDiffStore() - { - } - - /** - * - *Performs the union between N sets and returns it. - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s1', '3');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * $redis->sAdd('s2', '4');
-     * var_dump($redis->sUnion('s0', 's1', 's2'));
-     * array(4) {
-     * //  [0]=>
-     * //  string(1) "3"
-     * //  [1]=>
-     * //  string(1) "4"
-     * //  [2]=>
-     * //  string(1) "1"
-     * //  [3]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @return array - */ - public function sUnion() - { - } - - /** - * - *Performs the same action as sUnion, but stores the result in the first key - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s1', '3');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * $redis->sAdd('s2', '4');
-     * var_dump($redis->sUnionStore('dst', 's0', 's1', 's2'));
-     * var_dump($redis->sMembers('dst'));
-     * //int(4)
-     * //array(4) {
-     * //  [0]=>
-     * //  string(1) "3"
-     * //  [1]=>
-     * //  string(1) "4"
-     * //  [2]=>
-     * //  string(1) "1"
-     * //  [3]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @return int - */ - public function sUnionStore() - { - } - - /** - * - *Returns the members of a set resulting from the intersection of all the sets - *held at the specified keys. If just a single key is specified, then this command - *produces the members of this set. If one of the keys is missing, FALSE is returned. - * @example - *
-     * $redis->sAdd('key1', 'val1');
-     * $redis->sAdd('key1', 'val2');
-     * $redis->sAdd('key1', 'val3');
-     * $redis->sAdd('key1', 'val4');
-     * $redis->sAdd('key2', 'val3');
-     * $redis->sAdd('key2', 'val4');
-     * $redis->sAdd('key3', 'val3');
-     * $redis->sAdd('key3', 'val4');
-     * var_dump($redis->sInter('key1', 'key2', 'key3'));
-     * //array(2) {
-     * //  [0]=>
-     * //  string(4) "val4"
-     * //  [1]=>
-     * //  string(4) "val3"
-     * //}
-     * 
- * @return If - */ - public function sInter() - { - } - - /** - * - *Performs a sInter command and stores the result in a new set. - * @example - *
-     * $redis->sAdd('key1', 'val1');
-     * $redis->sAdd('key1', 'val2');
-     * $redis->sAdd('key1', 'val3');
-     * $redis->sAdd('key1', 'val4');
-     * $redis->sAdd('key2', 'val3');
-     * $redis->sAdd('key2', 'val4');
-     * $redis->sAdd('key3', 'val3');
-     * $redis->sAdd('key3', 'val4');
-     * var_dump($redis->sInterStore('output', 'key1', 'key2', 'key3'));
-     * var_dump($redis->sMembers('output'));
-     * //int(2)
-     * //
-     * //array(2) {
-     * //  [0]=>
-     * //  string(4) "val4"
-     * //  [1]=>
-     * //  string(4) "val3"
-     * //}
-     * 
- * @return int: - */ - public function sInterStore() - { - } - - /** - * - * - * @example - * @return - */ - public function sRemove() - { - } - - /** - * - * - * @example - * @return - */ - public function srem() - { - } - - /** - * - * - * @example - * @return int - */ - public function zDelete() - { - } - - /** - * - * - * @example - * @return - */ - public function zRemove() - { - } - - /** - * - *Deletes a specified member from the ordered set. - * @example - *
-     * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
-     * $redis->zRem('z', 'v2', 'v3');                           // int(2)
-     * var_dump( $redis->zRange('z', 0, -1) );
-     * //// Output:
-     * // array(2) {
-     * //   [0]=> string(2) "v1"
-     * //   [1]=> string(2) "v4"
-     * // }
-     * 
- * @return int - */ - public function zRem() - { - } - - /** - * - * - * @example - * @return - */ - public function pSubscribe() - { - } - - /** - * - *Subscribe to channels. Warning: this function will probably change in the future. - * @example - *
-     * function f($redis, $chan, $msg) {
-     * switch($chan) {
-     * case 'chan-1':
-     * ...
-     * break;
-     * case 'chan-2':
-     * ...
-     * break;
-     * case 'chan-2':
-     * ...
-     * break;
-     * }
-     * }
-     * $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
-     * 
- * @return mixed - */ - public function subscribe() - { - } - - /** - * - *Enter and exit transactional mode. - * @example - *
-     * $ret = $redis->multi()
-     * ->set('key1', 'val1')
-     * ->get('key1')
-     * ->set('key2', 'val2')
-     * ->get('key2')
-     * ->exec();
-     * //$ret == array (
-     * //    0 => TRUE,
-     * //    1 => 'val1',
-     * //    2 => TRUE,
-     * //    3 => 'val2');
-     * 
- * @return Once - */ - public function multi() - { - } - - /** - * - * - * @example - * @return - */ - public function exec() - { - } - -} - diff --git a/src/Swoole/Event.php b/src/Swoole/Event.php deleted file mode 100644 index d3a0cfa..0000000 --- a/src/Swoole/Event.php +++ /dev/null @@ -1,97 +0,0 @@ -lock()或$lock->trylock(),这两个方法是获取独占锁的 - * @example - * @return - */ - public function lock_read() - { - } - - /** - * - *加锁。此方法与lock_read相同,但是非阻塞的。调用会立即返回,必须检测返回值以确定是否拿到了锁 - * @example - * @return - */ - public function trylock_read() - { - } - - /** - * - *释放锁 - * @example - * @return - */ - public function unlock() - { - } - -} - diff --git a/src/Swoole/Mmap.php b/src/Swoole/Mmap.php deleted file mode 100644 index b577c0c..0000000 --- a/src/Swoole/Mmap.php +++ /dev/null @@ -1,28 +0,0 @@ - '192.168.56.102', - * 'user' => 'test', - * 'password' => 'test', - * 'database' => 'test', - * 'charset' => 'utf8', - * ); - * $db->connect($server, function($db, $result){ - * if (!$result) { - * echo 'connect failed'; - * } - * }) - * @param array $server_config 异步连接到MySQL服务器 - * @param callable $callback 异步连接到MySQL服务器 - * @return - */ - public function connect(Array $server_config, Callable $callback) - { - } - - /** - * - *执行SQL查询 - * @example $db->query('select * from user', function($link, $result){ - * var_dump($result); - * }) - * @param string $sql 执行SQL查询 - * @param callable $callback 执行SQL查询 - * @return - */ - public function query($sql, Callable $callback) - { - } - - /** - * - *关闭MySQL连接 - * @example - * @return - */ - public function close() - { - } - - /** - * - *设置事件回调函数。目前仅支持onClose事件回调 - * @example - * @param string $event_name 设置事件回调函数。目前仅支持onClose事件回调 - * @param callable $callback 设置事件回调函数。目前仅支持onClose事件回调 - * @return - */ - public function on($event_name, Callable $callback) - { - } - -} - diff --git a/src/Swoole/MySQL/Exception.php b/src/Swoole/MySQL/Exception.php deleted file mode 100644 index 6e1c603..0000000 --- a/src/Swoole/MySQL/Exception.php +++ /dev/null @@ -1,156 +0,0 @@ -connnection_list是一致的,但是更加友好。遍历的元素为单个连接的fd - * @access public - */ - public $connections; - - /** - * - *创建一个swoole tcp/udp server对象 - * @example - * @param string $host 创建一个swoole tcp/udp server对象 - * @param int $port 创建一个swoole tcp/udp server对象 - * @param int $mode 创建一个swoole tcp/udp server对象 - * @param int $sock_type 创建一个swoole tcp/udp server对象 - * @return - */ - public function __construct($host, $port, $mode, $sock_type) - { - } - - /** - * - *监听一个新的Server端口,此方法是addlistener的别名 - * @example - * @param string $host 监听一个新的Server端口,此方法是addlistener的别名 - * @param int $port 监听一个新的Server端口,此方法是addlistener的别名 - * @param int $sock_type 监听一个新的Server端口,此方法是addlistener的别名 - * @return - */ - public function listen($host, $port, $sock_type) - { - } - - /** - * - *监听一个新的Server端口,此方法是addlistener的别名 - * @example - * @param string $host 监听一个新的Server端口,此方法是addlistener的别名 - * @param int $port 监听一个新的Server端口,此方法是addlistener的别名 - * @param int $sock_type 监听一个新的Server端口,此方法是addlistener的别名 - * @return - */ - public function addlistener($host, $port, $sock_type) - { - } - - /** - * - *注册Server的事件回调函数 - * @example - * @param string $event_name 注册Server的事件回调函数 - * @param callable $callback 注册Server的事件回调函数 - * @return bool - */ - public function on($event_name, Callable $callback) - { - } - - /** - * - *设置选项 - * @example - * @param array $settings 设置选项 - * @return - */ - public function set(Array $settings) - { - } - - /** - * - *启动server,监听所有TCP/UDP端口 - * @example - * @return bool - */ - public function start() - { - } - - /** - * - *向客户端发送数据 - * @example - * @param int $fd 向客户端发送数据 - * @param string $send_data 向客户端发送数据 - * @param int $reactor_id 向客户端发送数据 - * @return bool - */ - public function send($fd, $send_data, $reactor_id) - { - } - - /** - * - *向任意的客户端IP:PORT发送UDP数据包 - * @example - * @param string $ip 向任意的客户端IP:PORT发送UDP数据包 - * @param int $port 向任意的客户端IP:PORT发送UDP数据包 - * @param string $send_data 向任意的客户端IP:PORT发送UDP数据包 - * @param int $server_socket 向任意的客户端IP:PORT发送UDP数据包 - * @return bool - */ - public function sendto($ip, $port, $send_data, $server_socket) - { - } - - /** - * - *阻塞地向客户端发送数据 - * @example - * @param int $conn_fd 阻塞地向客户端发送数据 - * @param string $send_data 阻塞地向客户端发送数据 - * @return bool - */ - public function sendwait($conn_fd, $send_data) - { - } - - /** - * - *检测fd对应的连接是否存在 - * @example - * @param int $fd 检测fd对应的连接是否存在 - * @return bool - */ - public function exist($fd) - { - } - - /** - * - *用于保护某些连接不被心跳线程切断 - * @example - * @param int $fd 用于保护某些连接不被心跳线程切断 - * @param bool $is_protected 用于保护某些连接不被心跳线程切断 - * @return - */ - public function protect($fd, $is_protected) - { - } - - /** - * - *发送文件到TCP客户端连接 - * @example - * @param int $conn_fd 发送文件到TCP客户端连接 - * @param string $filename 发送文件到TCP客户端连接 - * @param int $offset 发送文件到TCP客户端连接 - * @return bool - */ - public function sendfile($conn_fd, $filename, $offset) - { - } - - /** - * - *关闭客户端连接 - * @example - * @param int $fd 关闭客户端连接 - * @param bool $reset 关闭客户端连接 - * @return - */ - public function close($fd, $reset) - { - } - - /** - * - *连接确认 - * @example - * @param int $fd 连接确认 - * @return - */ - public function confirm($fd) - { - } - - /** - * - *停止接收数据 - * @example - * @param int $fd 停止接收数据 - * @return - */ - public function pause($fd) - { - } - - /** - * - *恢复数据接收 - * @example - * @param int $fd 恢复数据接收 - * @return - */ - public function resume($fd) - { - } - - /** - * - *投递一个异步任务到task_worker池中。此函数是非阻塞的,执行完毕会立即返回 - * @example - * @param mixed $data 投递一个异步任务到task_worker池中。此函数是非阻塞的,执行完毕会立即返回 - * @param int $worker_id 投递一个异步任务到task_worker池中。此函数是非阻塞的,执行完毕会立即返回 - * @param callable $finish_callback 投递一个异步任务到task_worker池中。此函数是非阻塞的,执行完毕会立即返回 - * @return - */ - public function task($data, $worker_id, Callable $finish_callback) - { - } - - /** - * - *用于投递一个异步的任务到task进程池去执行。与task不同的是taskwait是阻塞等待的,直到任务完成或者超时返回。 - * @example - * @param mixed $data 用于投递一个异步的任务到task进程池去执行。与task不同的是taskwait是阻塞等待的,直到任务完成或者超时返回。 - * @param float $timeout 用于投递一个异步的任务到task进程池去执行。与task不同的是taskwait是阻塞等待的,直到任务完成或者超时返回。 - * @param int $worker_id 用于投递一个异步的任务到task进程池去执行。与task不同的是taskwait是阻塞等待的,直到任务完成或者超时返回。 - * @return - */ - public function taskwait($data, $timeout, $worker_id) - { - } - - /** - * - *并发执行多个Task - * @example - * @param array $tasks 并发执行多个Task - * @param double $timeout 并发执行多个Task - * @return - */ - public function taskWaitMulti(Array $tasks, $timeout) - { - } - - /** - * - *此函数用于在task进程中通知worker进程,投递的任务已完成。此函数可以传递结果数据给worker进程 - * @example - * @param string $data 此函数用于在task进程中通知worker进程,投递的任务已完成。此函数可以传递结果数据给worker进程 - * @return - */ - public function finish($data) - { - } - - /** - * - *重启所有worker进程 - * @example - * @return - */ - public function reload() - { - } - - /** - * - *关闭服务器 - * @example - * @return - */ - public function shutdown() - { - } - - /** - * - *使当前worker进程停止运行,并立即触发onWorkerStop回调函数 - * @example - * @param int $worker_id 使当前worker进程停止运行,并立即触发onWorkerStop回调函数 - * @return - */ - public function stop($worker_id) - { - } - - /** - * - *获取最近一次操作错误的错误码。业务代码中可以根据错误码类型执行不同的逻辑。 - * @example - * @return int - */ - public function getLastError() - { - } - - /** - * - *检测服务器所有连接,并找出已经超过约定时间的连接。如果指定if_close_connection,则自动关闭超时的连接。未指定仅返回连接的fd数组。 - * @example - * @param mixed $reactor_id - * @return - */ - public function heartbeat($reactor_id) - { - } - - /** - * - *获取连接的信息 - * @example - * @param int $fd 获取连接的信息 - * @param int $reactor_id 获取连接的信息 - * @return - */ - public function connection_info($fd, $reactor_id) - { - } - - /** - * - *用来遍历当前Server所有的客户端连接 - * @example - * @param int $start_fd 用来遍历当前Server所有的客户端连接 - * @param int $find_count 用来遍历当前Server所有的客户端连接 - * @return - */ - public function connection_list($start_fd, $find_count) - { - } - - /** - * - *获取连接的信息 - * @example - * @param int $fd 获取连接的信息 - * @param int $reactor_id 获取连接的信息 - * @return - */ - public function getClientInfo($fd, $reactor_id) - { - } - - /** - * - *用来遍历当前Server所有的客户端连接 - * @example - * @param int $start_fd 用来遍历当前Server所有的客户端连接 - * @param int $find_count 用来遍历当前Server所有的客户端连接 - * @return - */ - public function getClientList($start_fd, $find_count) - { - } - - /** - * - *在指定的时间后执行函数 - * @example - * @param int $ms 在指定的时间后执行函数 - * @param callable $callback 在指定的时间后执行函数 - * @param array $param 在指定的时间后执行函数 - * @return - */ - public function after($ms, Callable $callback, Array $param) - { - } - - /** - * - *tick定时器,可以自定义回调函数 - * @example - * @param int $ms tick定时器,可以自定义回调函数 - * @param callable $callback tick定时器,可以自定义回调函数 - * @return - */ - public function tick($ms, Callable $callback) - { - } - - /** - * - *清除tick/after定时器,此函数是swoole_timer_clear的别名 - * @example - * @param int $timer_id 清除tick/after定时器,此函数是swoole_timer_clear的别名 - * @return - */ - public function clearTimer($timer_id) - { - } - - /** - * - *延后执行一个PHP函数。Swoole底层会在EventLoop循环完成后执行此函数。此函数的目的是为了让一些PHP代码延后执行,程序优先处理IO事件 - * @example - * @param callable $callback 延后执行一个PHP函数。Swoole底层会在EventLoop循环完成后执行此函数。此函数的目的是为了让一些PHP代码延后执行,程序优先处理IO事件 - * @return - */ - public function defer(Callable $callback) - { - } - - /** - * - *此函数可以向任意worker进程或者task进程发送消息。在非主进程和管理进程中可调用。收到消息的进程会触发onPipeMessage事件。 - * @example - * @param int $dst_worker_id 此函数可以向任意worker进程或者task进程发送消息。在非主进程和管理进程中可调用。收到消息的进程会触发onPipeMessage事件。 - * @param string $data 此函数可以向任意worker进程或者task进程发送消息。在非主进程和管理进程中可调用。收到消息的进程会触发onPipeMessage事件。 - * @return - */ - public function sendMessage($dst_worker_id, $data) - { - } - - /** - * - *添加一个用户自定义的工作进程 - * @example - * @param object $process 添加一个用户自定义的工作进程 - * @return - */ - public function addProcess($process) - { - } - - /** - * - *得到当前Server的活动TCP连接数,启动时间,accpet/close的总次数等信息 - * @example - * @return array - */ - public function stats() - { - } - - /** - * - *将连接绑定一个用户定义的ID,可以设置dispatch_mode=5设置已此ID值进行hash固定分配。可以保证某一个UID的连接全部会分配到同一个Worker进程 - * @example - * @param int $fd 将连接绑定一个用户定义的ID,可以设置dispatch_mode=5设置已此ID值进行hash固定分配。可以保证某一个UID的连接全部会分配到同一个Worker进程 - * @param int $uid 将连接绑定一个用户定义的ID,可以设置dispatch_mode=5设置已此ID值进行hash固定分配。可以保证某一个UID的连接全部会分配到同一个Worker进程 - * @return - */ - public function bind($fd, $uid) - { - } - -} - diff --git a/src/Swoole/Server/Port.php b/src/Swoole/Server/Port.php deleted file mode 100644 index 926defb..0000000 --- a/src/Swoole/Server/Port.php +++ /dev/null @@ -1,58 +0,0 @@ -column('id', swoole_table::TYPE_INT, 4); //1,2,4,8 - * $table->column('name', swoole_table::TYPE_STRING, 64); - * $table->column('num', swoole_table::TYPE_FLOAT); - * $table->create(); - * @return - */ - public function create() - { - } - - /** - * - *销毁内存表 - * @example - * @return - */ - public function destroy() - { - } - - /** - * - *设置行的数据,swoole_table使用key-value的方式来访问数据。 - * @example - * @param string $key 设置行的数据,swoole_table使用key-value的方式来访问数据。 - * @param array $value 设置行的数据,swoole_table使用key-value的方式来访问数据。 - * @return - */ - public function set($key, Array $value) - { - } - - /** - * - *获取一行数据 - * @example - * @param string $key 获取一行数据 - * @return array - */ - public function get($key) - { - } - - /** - * - *获取键的数量 - * @example - * @return int - */ - public function count() - { - } - - /** - * - *删除指定key的值 - * @example - * @param string $key 删除指定key的值 - * @return boolean - */ - public function del($key) - { - } - - /** - * - *检查table中是否存在某一个key - * @example - * @param string $key 检查table中是否存在某一个key - * @return boolean - */ - public function exist($key) - { - } - - /** - * - *原子自增操作 - * @example - * @param string $key 原子自增操作 - * @param number $column 原子自增操作 - * @param mixed $incrby 原子自增操作 - * @return - */ - public function incr($key, $column, $incrby) - { - } - - /** - * - *原子自减操作 - * @example - * @param string $key 原子自减操作 - * @param number $column 原子自减操作 - * @param mixed $decrby 原子自减操作 - * @return - */ - public function decr($key, $column, $decrby) - { - } - - /** - * - *返回到迭代器的第一个元素 - * @example - * @return void - */ - public function rewind() - { - } - - /** - * - *向前移动到下一个元素 - * @example - * @return void - */ - public function next() - { - } - - /** - * - *返回当前元素 - * @example - * @return mixed - */ - public function current() - { - } - - /** - * - *返回当前元素的键 - * @example - * @return scalar - */ - public function key() - { - } - - /** - * - *此方法在 rewind() 和 next() 方法之后被调用以此用来检查当前位置是否有效 - * @example - * @return boolean - */ - public function valid() - { - } - -} - diff --git a/src/Swoole/Timer.php b/src/Swoole/Timer.php deleted file mode 100644 index 12b4777..0000000 --- a/src/Swoole/Timer.php +++ /dev/null @@ -1,62 +0,0 @@ -'192.168.0.25')) -*/ -function swoole_get_local_ip() -{ -} - -/** -* -*从标准的Unix Errno错误码转换成错误信息 -* @example -* $errmsg = swoole_strerror($errno); -* @param int $errno -* @return string -*/ -function swoole_strerror($errno) -{ -} - -/** -* -*获取最近一次系统调用的错误码 -* @example -* echo swoole_strerror(swoole_errno()); -* @return int -*/ -function swoole_errno() -{ -} - -/** -* -*动态加载扩展模块 -* @example -* -* @param string $name -* @return -*/ -function swoole_load_module($name) -{ -} - diff --git a/src/Swoole/swoole.php b/src/Swoole/swoole.php deleted file mode 100644 index 66fc89e..0000000 --- a/src/Swoole/swoole.php +++ /dev/null @@ -1,569 +0,0 @@ -'192.168.0.25')) -*/ -function swoole_get_local_ip() -{ -} - -/** -* -*从标准的Unix Errno错误码转换成错误信息 -* @example -* $errmsg = swoole_strerror($errno); -* @param int $errno -* @return string -*/ -function swoole_strerror($errno) -{ -} - -/** -* -*获取最近一次系统调用的错误码 -* @example -* echo swoole_strerror(swoole_errno()); -* @return int -*/ -function swoole_errno() -{ -} - -/** -* -*动态加载扩展模块 -* @example -* -* @param string $name -* @return -*/ -function swoole_load_module($name) -{ -} - diff --git a/src/Swoole/swoole_async.php b/src/Swoole/swoole_async.php deleted file mode 100644 index 24de8a5..0000000 --- a/src/Swoole/swoole_async.php +++ /dev/null @@ -1,91 +0,0 @@ -start前创建;在swoole_process中使用原子计数器,必须在swoole_process->start前创建) - * @example - * @param int $value 创建一个原子计数对象(只能操作32位整数,最大支持42亿.在swoole_server中使用原子计数器,必须在swoole_server->start前创建;在swoole_process中使用原子计数器,必须在swoole_process->start前创建) - * @return - */ - public function __construct($value) - { - } - - /** - * - *增加计数 - * @example - * @param int $add_value 增加计数 - * @return - */ - public function add($add_value) - { - } - - /** - * - *减少计数 - * @example - * @param int $sub_value 减少计数 - * @return - */ - public function sub($sub_value) - { - } - - /** - * - *获取当前计数的值 - * @example - * @return - */ - public function get() - { - } - - /** - * - *将当前值设置为指定的数字 - * @example - * @param int $value 将当前值设置为指定的数字 - * @return - */ - public function set($value) - { - } - - /** - * - *如果当前数值等于参数1,则将当前数值设置为参数2($cmp_value,$set_value 必须为小于42亿的整数) - * @example - * @param int $cmp_value 如果当前数值等于参数1,则将当前数值设置为参数2($cmp_value,$set_value 必须为小于42亿的整数) - * @param int $new_value 如果当前数值等于参数1,则将当前数值设置为参数2($cmp_value,$set_value 必须为小于42亿的整数) - * @return - */ - public function cmpset($cmp_value, $new_value) - { - } - -} - diff --git a/src/Swoole/swoole_buffer.php b/src/Swoole/swoole_buffer.php deleted file mode 100644 index c0283a7..0000000 --- a/src/Swoole/swoole_buffer.php +++ /dev/null @@ -1,124 +0,0 @@ -recv方法的第二个参数,阻塞等待直到收到指定长度的数据后返回 - */ - const MSG_WAITALL = 256; - - /** - * @var int $errCode - * 错误码。errCode的值等于Linux errno。可使用socket_strerror将错误码转为错误信息 - * @access public - */ - public $errCode = 0; - - /** - * @var int $sock - * sock属性是此socket的文件描述符 - * @access public - */ - public $sock = 0; - - /** - * @var bool $reuse - * 表示此连接是新创建的还是复用已存在的。与SWOOLE_KEEP配合使用 - * @access public - */ - public $reuse = ''; - - /** - * @var int $reuseCount - * - * @access public - */ - public $reuseCount = 0; - - /** - * - *创建tcp/udp客户端 - * @example - * @param int $type 创建tcp/udp客户端 - * @param int $async 创建tcp/udp客户端 - * @return - */ - public function __construct($type, $async) - { - } - - /** - * - *析构函数 - * @example - * @return - */ - public function __destruct() - { - } - - /** - * - *设置客户端参数 - * @example - * @param array $settings 设置客户端参数 - * @return - */ - public function set(Array $settings) - { - } - - /** - * - *连接到远程服务器 - * @example - * @param string $host 连接到远程服务器 - * @param int $port 连接到远程服务器 - * @param float $timeout 连接到远程服务器 - * @param int $sock_flag 连接到远程服务器 - * @return bool - */ - public function connect($host, $port, $timeout, $sock_flag) - { - } - - /** - * - *用于从服务器端接收数据 - * @example - * @param int $size 用于从服务器端接收数据 - * @param int $flag 用于从服务器端接收数据 - * @return string - */ - public function recv($size, $flag) - { - } - - /** - * - *发送数据到远程服务器,必须在建立连接后,才可向Server发送数据 - * @example - * @param string $data 发送数据到远程服务器,必须在建立连接后,才可向Server发送数据 - * @param mixed $flag - * @return int - */ - public function send($data, $flag) - { - } - - /** - * - *使用管道发送数据 - * @example - * @param int $dst_socket 使用管道发送数据 - * @return - */ - public function pipe($dst_socket) - { - } - - /** - * - *发送文件到服务器,本函数是基于sendfile操作系统调用的 - * @example - * @param string $filename 发送文件到服务器,本函数是基于sendfile操作系统调用的 - * @param int $offset 发送文件到服务器,本函数是基于sendfile操作系统调用的 - * @return bool - */ - public function sendfile($filename, $offset) - { - } - - /** - * - *向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象。 - * @example - * @param string $ip 向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象。 - * @param int $port 向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象。 - * @param string $data 向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象。 - * @return bool - */ - public function sendto($ip, $port, $data) - { - } - - /** - * - *调用此方法会从事件循环中移除当前socket的可读监听,停止接收数据 - * @example - * @return - */ - public function sleep() - { - } - - /** - * - *调用此方法会重新监听可读事件,将socket连接从睡眠中唤醒(如果socket并未进入sleep模式,wakeup操作没有任何作用) - * @example - * @return - */ - public function wakeup() - { - } - - /** - * - *暂停数据接收 - * @example - * @return - */ - public function pause() - { - } - - /** - * - *恢复数据接收 - * @example - * @return - */ - public function resume() - { - } - - /** - * - *返回swoole_client的连接状态 - * @example - * @return bool - */ - public function isConnected() - { - } - - /** - * - *用于获取客户端socket的本地host:port,必须在连接之后才可以使用 - * @example - * @return array - */ - public function getsockname() - { - } - - /** - * - *获取对端socket的IP地址和端口,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象(此函数必须在$client->recv() 之后调用) - * @example - * @return bool - */ - public function getpeername() - { - } - - /** - * - *关闭连接 - * @example - * @param bool $force 关闭连接 - * @return bool - */ - public function close($force) - { - } - - /** - * - *注册异步事件回调函数,调用on方法会使当前的socket变成非阻塞的 - * @example - * @param string $event_name 注册异步事件回调函数,调用on方法会使当前的socket变成非阻塞的 - * @param string $callback 注册异步事件回调函数,调用on方法会使当前的socket变成非阻塞的 - * @return int - */ - public function on($event_name, $callback) - { - } - -} - diff --git a/src/Swoole/swoole_client_coro.php b/src/Swoole/swoole_client_coro.php deleted file mode 100644 index f9dfc27..0000000 --- a/src/Swoole/swoole_client_coro.php +++ /dev/null @@ -1,168 +0,0 @@ -recv方法的第二个参数,阻塞等待直到收到指定长度的数据后返回 - */ - const MSG_WAITALL = 256; - - /** - * @var int $errCode - * 错误码。errCode的值等于Linux errno。可使用socket_strerror将错误码转为错误信息 - * @access public - */ - public $errCode = 0; - - /** - * @var int $sock - * sock属性是此socket的文件描述符 - * @access public - */ - public $sock = 0; - - /** - * - *创建tcp/udp客户端 - * @example - * @return - */ - public function __construct() - { - } - - /** - * - *析构函数 - * @example - * @return - */ - public function __destruct() - { - } - - /** - * - *设置客户端参数 - * @example - * @return - */ - public function set() - { - } - - /** - * - *连接到远程服务器 - * @example - * @return bool - */ - public function connect() - { - } - - /** - * - *用于从服务器端接收数据 - * @example - * @return string - */ - public function recv() - { - } - - /** - * - *发送数据到远程服务器,必须在建立连接后,才可向Server发送数据 - * @example - * @return int - */ - public function send() - { - } - - /** - * - *发送文件到服务器,本函数是基于sendfile操作系统调用的 - * @example - * @return bool - */ - public function sendfile() - { - } - - /** - * - *向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象。 - * @example - * @return bool - */ - public function sendto() - { - } - - /** - * - *返回swoole_client的连接状态 - * @example - * @return bool - */ - public function isConnected() - { - } - - /** - * - *用于获取客户端socket的本地host:port,必须在连接之后才可以使用 - * @example - * @return array - */ - public function getsockname() - { - } - - /** - * - *获取对端socket的IP地址和端口,仅支持SWOOLE_SOCK_UDP/SWOOLE_SOCK_UDP6类型的swoole_client对象(此函数必须在$client->recv() 之后调用) - * @example - * @return bool - */ - public function getpeername() - { - } - - /** - * - *关闭连接 - * @example - * @return bool - */ - public function close() - { - } - -} - diff --git a/src/Swoole/swoole_connection_iterator.php b/src/Swoole/swoole_connection_iterator.php deleted file mode 100644 index e1e6563..0000000 --- a/src/Swoole/swoole_connection_iterator.php +++ /dev/null @@ -1,119 +0,0 @@ -lock()或$lock->trylock(),这两个方法是获取独占锁的 - * @example - * @return - */ - public function lock_read() - { - } - - /** - * - *加锁。此方法与lock_read相同,但是非阻塞的。调用会立即返回,必须检测返回值以确定是否拿到了锁 - * @example - * @return - */ - public function trylock_read() - { - } - - /** - * - *释放锁 - * @example - * @return - */ - public function unlock() - { - } - -} - diff --git a/src/Swoole/swoole_mmap.php b/src/Swoole/swoole_mmap.php deleted file mode 100644 index cbe8338..0000000 --- a/src/Swoole/swoole_mmap.php +++ /dev/null @@ -1,27 +0,0 @@ - '192.168.56.102', - * 'user' => 'test', - * 'password' => 'test', - * 'database' => 'test', - * 'charset' => 'utf8', - * ); - * $db->connect($server, function($db, $result){ - * if (!$result) { - * echo 'connect failed'; - * } - * }) - * @param array $server_config 异步连接到MySQL服务器 - * @param callable $callback 异步连接到MySQL服务器 - * @return - */ - public function connect(Array $server_config, Callable $callback) - { - } - - /** - * - *执行SQL查询 - * @example $db->query('select * from user', function($link, $result){ - * var_dump($result); - * }) - * @param string $sql 执行SQL查询 - * @param callable $callback 执行SQL查询 - * @return - */ - public function query($sql, Callable $callback) - { - } - - /** - * - *关闭MySQL连接 - * @example - * @return - */ - public function close() - { - } - - /** - * - *设置事件回调函数。目前仅支持onClose事件回调 - * @example - * @param string $event_name 设置事件回调函数。目前仅支持onClose事件回调 - * @param callable $callback 设置事件回调函数。目前仅支持onClose事件回调 - * @return - */ - public function on($event_name, Callable $callback) - { - } - -} - diff --git a/src/Swoole/swoole_mysql_coro.php b/src/Swoole/swoole_mysql_coro.php deleted file mode 100644 index 07ef417..0000000 --- a/src/Swoole/swoole_mysql_coro.php +++ /dev/null @@ -1,157 +0,0 @@ - - * $redis->connect('127.0.0.1', 6379); - * $redis->connect('127.0.0.1'); // port 6379 by default - * $redis->connect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout. - * $redis->connect('/tmp/redis.sock'); // unix domain socket. - * - * @return bool - */ - public function connect() - { - } - - /** - * - *设置defer - * @example - * @return - */ - public function setDefer() - { - } - - /** - * - *获取当前defer - * @example - * @return - */ - public function getDefer() - { - } - - /** - * - * - * @example - * @return - */ - public function recv() - { - } - - /** - * - *Disconnects from the Redis instance, except when pconnect is used. - * @example - * @return - */ - public function close() - { - } - - /** - * - *Set the string value in argument as value of the key. - * @example - * @return bool - */ - public function set() - { - } - - /** - * - *Changes a single bit of a string. - * @example - *
-     * $redis->set('key', "*");     // ord("*") = 42 = 0x2f = "0010 1010"
-     * $redis->setBit('key', 5, 1); // returns 0
-     * $redis->setBit('key', 7, 1); // returns 0
-     * $redis->get('key');          // chr(0x2f) = "/" = b("0010 1111")
-     * 
- * @return int: - */ - public function setBit() - { - } - - /** - * - * - * @example - * @return - */ - public function setEx() - { - } - - /** - * - * - * @example - * @return - */ - public function psetEx() - { - } - - /** - * - *Set the list at index with the new value. - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->lGet('key1', 0);     // 'A'
-     * $redis->lSet('key1', 0, 'X');
-     * $redis->lGet('key1', 0);     // 'X'
-     * 
- * @return is - */ - public function lSet() - { - } - - /** - * - *Get the value related to the specified key - * @example $redis->get('key'); - * @return string|bool: - */ - public function get() - { - } - - /** - * - * - * @example - * @return - */ - public function mGet() - { - } - - /** - * - *Remove specified keys. - * @example - *
-     * $redis->set('key1', 'val1');
-     * $redis->set('key2', 'val2');
-     * $redis->set('key3', 'val3');
-     * $redis->set('key4', 'val4');
-     * $redis->delete('key1', 'key2');          // return 2
-     * $redis->delete(array('key3', 'key4'));   // return 2
-     * 
- * @return int - */ - public function del() - { - } - - /** - * - *Removes a values from the hash stored at key. - *If the hash table doesn't exist, or the key doesn't exist, FALSE is returned. - * @example - *
-     * $redis->hMSet('h',
-     * array(
-     * 'f1' => 'v1',
-     * 'f2' => 'v2',
-     * 'f3' => 'v3',
-     * 'f4' => 'v4',
-     * ));
-     * var_dump( $redis->hDel('h', 'f1') );        // int(1)
-     * var_dump( $redis->hDel('h', 'f2', 'f3') );  // int(2)
-     * s
-     * var_dump( $redis->hGetAll('h') );
-     * //// Output:
-     * //  array(1) {
-     * //    ["f4"]=> string(2) "v4"
-     * //  }
-     * 
- * @return int - */ - public function hDel() - { - } - - /** - * - *Adds a value to the hash stored at key. If this value is already in the hash, FALSE is returned. - * @example - *
-     * $redis->delete('h')
-     * $redis->hSet('h', 'key1', 'hello');  // 1, 'key1' => 'hello' in the hash at "h"
-     * $redis->hGet('h', 'key1');           // returns "hello"
-     * $redis->hSet('h', 'key1', 'plop');   // 0, value was replaced.
-     * $redis->hGet('h', 'key1');           // returns "plop"
-     * 
- * @return 0 - */ - public function hSet() - { - } - - /** - * - * - * @example - * @return - */ - public function hMSet() - { - } - - /** - * - *Adds a value to the hash stored at key only if this field isn't already in the hash. - * @example - *
-     * $redis->delete('h')
-     * $redis->hSetNx('h', 'key1', 'hello'); // TRUE, 'key1' => 'hello' in the hash at "h"
-     * $redis->hSetNx('h', 'key1', 'world'); // FALSE, 'key1' => 'hello' in the hash at "h". No change since the field
-     * wasn't replaced.
-     * 
- * @return bool - */ - public function hSetNx() - { - } - - /** - * - * - * @example - * @return int - */ - public function delete() - { - } - - /** - * - * - * @example - * @return - */ - public function mSet() - { - } - - /** - * - * - * @example - * @return - */ - public function mSetNx() - { - } - - /** - * - * - * @example - * @return - */ - public function getKeys() - { - } - - /** - * - *Returns the keys that match a certain pattern. - * @example - *
-     * $allKeys = $redis->keys('*');   // all keys will match this.
-     * $keyWithUserPrefix = $redis->keys('user*');
-     * 
- * @return array - */ - public function keys() - { - } - - /** - * - *Verify if the specified key exists. - * @example - *
-     * $redis->set('key', 'value');
-     * $redis->exists('key');               //  TRUE
-     * $redis->exists('NonExistingKey');    // FALSE
-     * 
- * @return bool: - */ - public function exists() - { - } - - /** - * - *Returns the type of data pointed by a given key. - * @example $redis->type('key'); - * @return - - */ - public function type() - { - } - - /** - * - * - * @example - * @return - */ - public function strLen() - { - } - - /** - * - *Returns and removes the first element of the list. - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->lPop('key1');        // key1 => [ 'B', 'C' ]
-     * 
- * @return string - */ - public function lPop() - { - } - - /** - * - *Is a blocking lPop primitive. If at least one of the lists contains at least one element, - *the element will be popped from the head of the list and returned to the caller. - *Il all the list identified by the keys passed in arguments are empty, blPop will block - *during the specified timeout until an element is pushed to one of those lists. This element will be popped. - * @example - *
-     * // Non blocking feature
-     * $redis->lPush('key1', 'A');
-     * $redis->delete('key2');
-     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * // Blocking feature
-     * // process 1
-     * $redis->delete('key1');
-     * $redis->blPop('key1', 10);
-     * // blocking for 10 seconds
-     * // process 2
-     * $redis->lPush('key1', 'A');
-     * // process 1
-     * // array('key1', 'A') is returned
-     * 
- * @return array - */ - public function blPop() - { - } - - /** - * - *Returns and removes the last element of the list. - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->rPop('key1');        // key1 => [ 'A', 'B' ]
-     * 
- * @return string - */ - public function rPop() - { - } - - /** - * - *Is a blocking rPop primitive. If at least one of the lists contains at least one element, - *the element will be popped from the head of the list and returned to the caller. - *Il all the list identified by the keys passed in arguments are empty, brPop will - *block during the specified timeout until an element is pushed to one of those lists. T - *his element will be popped. - * @example - *
-     * // Non blocking feature
-     * $redis->lPush('key1', 'A');
-     * $redis->delete('key2');
-     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * // Blocking feature
-     * // process 1
-     * $redis->delete('key1');
-     * $redis->blPop('key1', 10);
-     * // blocking for 10 seconds
-     * // process 2
-     * $redis->lPush('key1', 'A');
-     * // process 1
-     * // array('key1', 'A') is returned
-     * 
- * @return array - */ - public function brPop() - { - } - - /** - * - * - * @example - * @return - */ - public function bRPopLPush() - { - } - - /** - * - * - * @example - * @return - */ - public function lSize() - { - } - - /** - * - *Returns the size of a list identified by Key. If the list didn't exist or is empty, - *the command returns 0. If the data type identified by Key is not a list, the command return FALSE. - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->lLen('key1');       // 3
-     * $redis->rPop('key1');
-     * $redis->lLen('key1');       // 2
-     * 
- * @return bool - */ - public function lLen() - { - } - - /** - * - * - * @example - * @return - */ - public function sSize() - { - } - - /** - * - * - * @example - * @return - */ - public function scard() - { - } - - /** - * - *Removes and returns a random element from the set value at Key. - * @example - *
-     * $redis->sAdd('key1' , 'set1');
-     * $redis->sAdd('key1' , 'set2');
-     * $redis->sAdd('key1' , 'set3');   // 'key1' => {'set3', 'set1', 'set2'}
-     * $redis->sPop('key1');            // 'set1', 'key1' => {'set3', 'set2'}
-     * $redis->sPop('key1');            // 'set3', 'key1' => {'set2'}
-     * 
- * @return bool - */ - public function sPop() - { - } - - /** - * - *Returns the contents of a set. - * @example - *
-     * $redis->delete('s');
-     * $redis->sAdd('s', 'a');
-     * $redis->sAdd('s', 'b');
-     * $redis->sAdd('s', 'a');
-     * $redis->sAdd('s', 'c');
-     * var_dump($redis->sMembers('s'));
-     * //array(3) {
-     * //  [0]=>
-     * //  string(1) "c"
-     * //  [1]=>
-     * //  string(1) "a"
-     * //  [2]=>
-     * //  string(1) "b"
-     * //}
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @return array - */ - public function sMembers() - { - } - - /** - * - * - * @example - * @return array - */ - public function sGetMembers() - { - } - - /** - * - *Returns a random element(s) from the set value at Key, without removing it. - * @example - *
-     * $redis->sAdd('key1' , 'one');
-     * $redis->sAdd('key1' , 'two');
-     * $redis->sAdd('key1' , 'three');              // 'key1' => {'one', 'two', 'three'}
-     * var_dump( $redis->sRandMember('key1') );     // 'key1' => {'one', 'two', 'three'}
-     * // string(5) "three"
-     * var_dump( $redis->sRandMember('key1', 2) );  // 'key1' => {'one', 'two', 'three'}
-     * // array(2) {
-     * //   [0]=> string(2) "one"
-     * //   [1]=> string(2) "three"
-     * // }
-     * 
- * @return bool - */ - public function sRandMember() - { - } - - /** - * - *Remove the expiration timer from a key. - * @example $redis->persist('key'); - * @return bool: - */ - public function persist() - { - } - - /** - * - *Returns the time to live left for a given key, in seconds. If the key doesn't exist, FALSE is returned. - * @example $redis->ttl('key'); - * @return int, - */ - public function ttl() - { - } - - /** - * - *Returns a time to live left for a given key, in milliseconds. - * @example $redis->pttl('key'); - * @return int - */ - public function pttl() - { - } - - /** - * - *Returns the cardinality of an ordered set. - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zCard('key');            // 3
-     * 
- * @return int - */ - public function zCard() - { - } - - /** - * - * - * @example - * @return - */ - public function zSize() - { - } - - /** - * - *Returns the length of a hash, in number of items - * @example - *
-     * $redis->delete('h')
-     * $redis->hSet('h', 'key1', 'hello');
-     * $redis->hSet('h', 'key2', 'plop');
-     * $redis->hLen('h'); // returns 2
-     * 
- * @return int - */ - public function hLen() - { - } - - /** - * - *Returns the keys in a hash, as an array of strings. - * @example - *
-     * $redis->delete('h');
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hSet('h', 'b', 'y');
-     * $redis->hSet('h', 'c', 'z');
-     * $redis->hSet('h', 'd', 't');
-     * var_dump($redis->hKeys('h'));
-     * // Output:
-     * // array(4) {
-     * // [0]=>
-     * // string(1) "a"
-     * // [1]=>
-     * // string(1) "b"
-     * // [2]=>
-     * // string(1) "c"
-     * // [3]=>
-     * // string(1) "d"
-     * // }
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @return array - */ - public function hKeys() - { - } - - /** - * - *Returns the values in a hash, as an array of strings. - * @example - *
-     * $redis->delete('h');
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hSet('h', 'b', 'y');
-     * $redis->hSet('h', 'c', 'z');
-     * $redis->hSet('h', 'd', 't');
-     * var_dump($redis->hVals('h'));
-     * // Output
-     * // array(4) {
-     * //   [0]=>
-     * //   string(1) "x"
-     * //   [1]=>
-     * //   string(1) "y"
-     * //   [2]=>
-     * //   string(1) "z"
-     * //   [3]=>
-     * //   string(1) "t"
-     * // }
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @return array - */ - public function hVals() - { - } - - /** - * - *Returns the whole hash, as an array of strings indexed by strings. - * @example - *
-     * $redis->delete('h');
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hSet('h', 'b', 'y');
-     * $redis->hSet('h', 'c', 'z');
-     * $redis->hSet('h', 'd', 't');
-     * var_dump($redis->hGetAll('h'));
-     * // Output:
-     * // array(4) {
-     * //   ["a"]=>
-     * //   string(1) "x"
-     * //   ["b"]=>
-     * //   string(1) "y"
-     * //   ["c"]=>
-     * //   string(1) "z"
-     * //   ["d"]=>
-     * //   string(1) "t"
-     * // }
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @return array - */ - public function hGetAll() - { - } - - /** - * - * - * @example - * @return - */ - public function debug() - { - } - - /** - * - *Restore a key from the result of a DUMP operation. - * @example - *
-     * $redis->set('foo', 'bar');
-     * $val = $redis->dump('foo');
-     * $redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo'
-     * 
- * @return - */ - public function restore() - { - } - - /** - * - *Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command. - *The data that comes out of DUMP is a binary representation of the key as Redis stores it. - * @example - *
-     * $redis->set('foo', 'bar');
-     * $val = $redis->dump('foo'); // $val will be the Redis encoded key value
-     * 
- * @return string - */ - public function dump() - { - } - - /** - * - * - * @example - * @return - */ - public function renameKey() - { - } - - /** - * - *Renames a key. - * @example - *
-     * $redis->set('x', '42');
-     * $redis->rename('x', 'y');
-     * $redis->get('y');   // → 42
-     * $redis->get('x');   // → `FALSE`
-     * 
- * @return bool: - */ - public function rename() - { - } - - /** - * - *Renames a key. - * @example - *
-     * $redis->set('x', '42');
-     * $redis->rename('x', 'y');
-     * $redis->get('y');   // → 42
-     * $redis->get('x');   // → `FALSE`
-     * 
- * @return bool: - */ - public function renameNx() - { - } - - /** - * - *Pops a value from the tail of a list, and pushes it to the front of another list. - *Also return this value. - * @example - *
-     * $redis->delete('x', 'y');
-     * $redis->lPush('x', 'abc');
-     * $redis->lPush('x', 'def');
-     * $redis->lPush('y', '123');
-     * $redis->lPush('y', '456');
-     * // move the last of x to the front of y.
-     * var_dump($redis->rpoplpush('x', 'y'));
-     * var_dump($redis->lRange('x', 0, -1));
-     * var_dump($redis->lRange('y', 0, -1));
-     * //Output:
-     * //
-     * //string(3) "abc"
-     * //array(1) {
-     * //  [0]=>
-     * //  string(3) "def"
-     * //}
-     * //array(3) {
-     * //  [0]=>
-     * //  string(3) "abc"
-     * //  [1]=>
-     * //  string(3) "456"
-     * //  [2]=>
-     * //  string(3) "123"
-     * //}
-     * 
- * @return string - */ - public function rpoplpush() - { - } - - /** - * - *Returns a random key. - * @example - *
-     * $key = $redis->randomKey();
-     * $surprise = $redis->get($key);  // who knows what's in there.
-     * 
- * @return string: - */ - public function randomKey() - { - } - - /** - * - *Check the current connection status - * @example - * @return string - */ - public function ping() - { - } - - /** - * - *Authenticate the connection using a password. - *Warning: The password is sent in plain-text over the network. - * @example $redis->auth('foobared'); - * @return bool: - */ - public function auth() - { - } - - /** - * - * - * @example - * @return - */ - public function unwatch() - { - } - - /** - * - *Watches a key for modifications by another client. If the key is modified between WATCH and EXEC, - *the MULTI/EXEC transaction will fail (return FALSE). unwatch cancels all the watching of all keys by this client. - * @example - *
-     * $redis->watch('x');
-     * // long code here during the execution of which other clients could well modify `x`
-     * $ret = $redis->multi()
-     * ->incr('x')
-     * ->exec();
-     * // $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.
-     * 
- * @return - */ - public function watch() - { - } - - /** - * - *Performs a synchronous save. - * @example $redis->save(); - * @return If - */ - public function save() - { - } - - /** - * - * - * @example - * @return - */ - public function bgSave() - { - } - - /** - * - *Returns the timestamp of the last disk save. - * @example $redis->lastSave(); - * @return int: - */ - public function lastSave() - { - } - - /** - * - *Removes all entries from the current database. - * @example $redis->flushDB(); - * @return bool: - */ - public function flushDB() - { - } - - /** - * - *Removes all entries from all databases. - * @example $redis->flushAll(); - * @return bool: - */ - public function flushAll() - { - } - - /** - * - *Returns the current database's size. - * @example - *
-     * $count = $redis->dbSize();
-     * echo "Redis has $count keys\n";
-     * 
- * @return int: - */ - public function dbSize() - { - } - - /** - * - *Starts the background rewrite of AOF (Append-Only File) - * @example $redis->bgrewriteaof(); - * @return bool: - */ - public function bgrewriteaof() - { - } - - /** - * - *Return the current Redis server time. - * @example - *
-     * var_dump( $redis->time() );
-     * // array(2) {
-     * //   [0] => string(10) "1342364352"
-     * //   [1] => string(6) "253002"
-     * // }
-     * 
- * @return unix - */ - public function time() - { - } - - /** - * - * - * @example - * @return - */ - public function role() - { - } - - /** - * - *Changes a substring of a larger string. - * @example - *
-     * $redis->set('key', 'Hello world');
-     * $redis->setRange('key', 6, "redis"); // returns 11
-     * $redis->get('key');                  // "Hello redis"
-     * 
- * @return string: - */ - public function setRange() - { - } - - /** - * - * - * @example - * @return - */ - public function setNx() - { - } - - /** - * - *Sets a value and returns the previous entry at that key. - * @example - *
-     * $redis->set('x', '42');
-     * $exValue = $redis->getSet('x', 'lol');   // return '42', replaces x by 'lol'
-     * $newValue = $redis->get('x')'            // return 'lol'
-     * 
- * @return string - */ - public function getSet() - { - } - - /** - * - *Append specified string to the string stored in specified key. - * @example - *
-     * $redis->set('key', 'value1');
-     * $redis->append('key', 'value2'); // 12
-     * $redis->get('key');              // 'value1value2'
-     * 
- * @return int: - */ - public function append() - { - } - - /** - * - *Adds the string value to the head (left) of the list if the list exists. - * @example - *
-     * $redis->delete('key1');
-     * $redis->lPushx('key1', 'A');     // returns 0
-     * $redis->lPush('key1', 'A');      // returns 1
-     * $redis->lPushx('key1', 'B');     // returns 2
-     * $redis->lPushx('key1', 'C');     // returns 3
-     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
-     * 
- * @return int - */ - public function lPushx() - { - } - - /** - * - *Adds the string values to the head (left) of the list. Creates the list if the key didn't exist. - *If the key exists and is not a list, FALSE is returned. - * @example - *
-     * $redis->lPush('l', 'v1', 'v2', 'v3', 'v4')   // int(4)
-     * var_dump( $redis->lRange('l', 0, -1) );
-     * //// Output:
-     * // array(4) {
-     * //   [0]=> string(2) "v4"
-     * //   [1]=> string(2) "v3"
-     * //   [2]=> string(2) "v2"
-     * //   [3]=> string(2) "v1"
-     * // }
-     * 
- * @return int - */ - public function lPush() - { - } - - /** - * - *Adds the string values to the tail (right) of the list. Creates the list if the key didn't exist. - *If the key exists and is not a list, FALSE is returned. - * @example - *
-     * $redis->rPush('l', 'v1', 'v2', 'v3', 'v4');    // int(4)
-     * var_dump( $redis->lRange('l', 0, -1) );
-     * //// Output:
-     * // array(4) {
-     * //   [0]=> string(2) "v1"
-     * //   [1]=> string(2) "v2"
-     * //   [2]=> string(2) "v3"
-     * //   [3]=> string(2) "v4"
-     * // }
-     * 
- * @return int - */ - public function rPush() - { - } - - /** - * - *Adds the string value to the tail (right) of the list if the ist exists. FALSE in case of Failure. - * @example - *
-     * $redis->delete('key1');
-     * $redis->rPushx('key1', 'A'); // returns 0
-     * $redis->rPush('key1', 'A'); // returns 1
-     * $redis->rPushx('key1', 'B'); // returns 2
-     * $redis->rPushx('key1', 'C'); // returns 3
-     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
-     * 
- * @return int - */ - public function rPushx() - { - } - - /** - * - * - * @example - * @return - */ - public function sContains() - { - } - - /** - * - * - * @example - * @return - */ - public function sismember() - { - } - - /** - * - *Returns the score of a given member in the specified sorted set. - * @example - *
-     * $redis->zAdd('key', 2.5, 'val2');
-     * $redis->zScore('key', 'val2'); // 2.5
-     * 
- * @return - */ - public function zScore() - { - } - - /** - * - *Returns the rank of a given member in the specified sorted set, starting at 0 for the item - *with the smallest score. zRevRank starts at 0 for the item with the largest score. - * @example - *
-     * $redis->delete('z');
-     * $redis->zAdd('key', 1, 'one');
-     * $redis->zAdd('key', 2, 'two');
-     * $redis->zRank('key', 'one');     // 0
-     * $redis->zRank('key', 'two');     // 1
-     * $redis->zRevRank('key', 'one');  // 1
-     * $redis->zRevRank('key', 'two');  // 0
-     * 
- * @return int - */ - public function zRank() - { - } - - /** - * - * - * @example - * @return int - */ - public function zRevRank() - { - } - - /** - * - *Gets a value from the hash stored at key. - *If the hash table doesn't exist, or the key doesn't exist, FALSE is returned. - * @example - * @return string - */ - public function hGet() - { - } - - /** - * - *Retirieve the values associated to the specified fields in the hash. - * @example - *
-     * $redis->delete('h');
-     * $redis->hSet('h', 'field1', 'value1');
-     * $redis->hSet('h', 'field2', 'value2');
-     * $redis->hmGet('h', array('field1', 'field2')); // returns array('field1' => 'value1', 'field2' => 'value2')
-     * 
- * @return with - */ - public function hMGet() - { - } - - /** - * - *Verify if the specified member exists in a key. - * @example - *
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hExists('h', 'a');               //  TRUE
-     * $redis->hExists('h', 'NonExistingKey');  // FALSE
-     * 
- * @return bool: - */ - public function hExists() - { - } - - /** - * - *Publish messages to channels. Warning: this function will probably change in the future. - * @example $redis->publish('chan-1', 'hello, world!'); // send message. - * @return int - */ - public function publish() - { - } - - /** - * - *Increments the score of a member from a sorted set by a given amount. - * @example - *
-     * $redis->delete('key');
-     * $redis->zIncrBy('key', 2.5, 'member1');  // key or member1 didn't exist, so member1's score is to 0
-     * // before the increment and now has the value 2.5
-     * $redis->zIncrBy('key', 1, 'member1');    // 3.5
-     * 
- * @return float - */ - public function zIncrBy() - { - } - - /** - * - *Adds the specified member with a given score to the sorted set stored at key. - * @example - *
-     * 
-     * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
-     * $redis->zRem('z', 'v2', 'v3');                           // int(2)
-     * var_dump( $redis->zRange('z', 0, -1) );
-     * //// Output:
-     * // array(2) {
-     * //   [0]=> string(2) "v1"
-     * //   [1]=> string(2) "v4"
-     * // }
-     * 
- *
- * @return int - */ - public function zAdd() - { - } - - /** - * - * - * @example - * @return - */ - public function zDeleteRangeByScore() - { - } - - /** - * - *Deletes the elements of the sorted set stored at the specified key which have scores in the range [start,end]. - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zRemRangeByScore('key', 0, 3); // 2
-     * 
- * @return int - */ - public function zRemRangeByScore() - { - } - - /** - * - *Returns the number of elements of the sorted set stored at the specified key which have - *scores in the range [start,end]. Adding a parenthesis before start or end excludes it - *from the range. +inf and -inf are also valid limits. - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zCount('key', 0, 3); // 2, corresponding to array('val0', 'val2')
-     * 
- * @return int - */ - public function zCount() - { - } - - /** - * - *Returns a range of elements from the ordered set stored at the specified key, - *with values in the range [start, end]. start and stop are interpreted as zero-based indices: - *0 the first element, - *1 the second ... - *-1 the last element, - *-2 the penultimate ... - * @example - *
-     * $redis->zAdd('key1', 0, 'val0');
-     * $redis->zAdd('key1', 2, 'val2');
-     * $redis->zAdd('key1', 10, 'val10');
-     * $redis->zRange('key1', 0, -1); // array('val0', 'val2', 'val10')
-     * // with scores
-     * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10)
-     * 
- * @return array - */ - public function zRange() - { - } - - /** - * - *Returns the elements of the sorted set stored at the specified key in the range [start, end] - *in reverse order. start and stop are interpretated as zero-based indices: - *0 the first element, - *1 the second ... - *-1 the last element, - *-2 the penultimate ... - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zRevRange('key', 0, -1); // array('val10', 'val2', 'val0')
-     * // with scores
-     * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0)
-     * 
- * @return array - */ - public function zRevRange() - { - } - - /** - * - *Returns the elements of the sorted set stored at the specified key which have scores in the - *range [start,end]. Adding a parenthesis before start or end excludes it from the range. - *+inf and -inf are also valid limits. - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
-     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
-     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
-     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
-     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
-     * 
- * @return array - */ - public function zRangeByScore() - { - } - - /** - * - * - * @example - * @return - */ - public function zRevRangeByScore() - { - } - - /** - * - *Returns a lexigraphical range of members in a sorted set, assuming the members have the same score. The - *min and max values are required to start with '(' (exclusive), '[' (inclusive), or be exactly the values - *'-' (negative inf) or '+' (positive inf). The command must be called with either three *or* five - *arguments or will return FALSE. - * @example - *
-     * foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g') as $char) {
-     * $redis->zAdd('key', $char);
-     * }
-     * $redis->zRangeByLex('key', '-', '[c'); // array('a', 'b', 'c')
-     * $redis->zRangeByLex('key', '-', '(c'); // array('a', 'b')
-     * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c')
-     * 
- * @return array - */ - public function zRangeByLex() - { - } - - /** - * - * - * @example - * @return - */ - public function zRevRangeByLex() - { - } - - /** - * - *Creates an intersection of sorted sets given in second argument. - *The result of the union will be stored in the sorted set defined by the first argument. - *The third optional argument defines weights to apply to the sorted sets in input. - *In this case, the weights will be multiplied by the score of each element in the sorted set - *before applying the aggregation. The forth argument defines the AGGREGATE option which - *specify how the results of the union are aggregated. - * @example - *
-     * $redis->delete('k1');
-     * $redis->delete('k2');
-     * $redis->delete('k3');
-     * $redis->delete('ko1');
-     * $redis->delete('ko2');
-     * $redis->delete('ko3');
-     * $redis->delete('ko4');
-     * $redis->zAdd('k1', 0, 'val0');
-     * $redis->zAdd('k1', 1, 'val1');
-     * $redis->zAdd('k1', 3, 'val3');
-     * $redis->zAdd('k2', 2, 'val1');
-     * $redis->zAdd('k2', 3, 'val3');
-     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
-     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
-     * // Weighted zInter
-     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
-     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
-     * 
- * @return int - */ - public function zInter() - { - } - - /** - * - * - * @example - * @return - */ - public function zinterstore() - { - } - - /** - * - *Creates an union of sorted sets given in second argument. - *The result of the union will be stored in the sorted set defined by the first argument. - *The third optionnel argument defines weights to apply to the sorted sets in input. - *In this case, the weights will be multiplied by the score of each element in the sorted set - *before applying the aggregation. The forth argument defines the AGGREGATE option which - *specify how the results of the union are aggregated. - * @example - *
-     * $redis->delete('k1');
-     * $redis->delete('k2');
-     * $redis->delete('k3');
-     * $redis->delete('ko1');
-     * $redis->delete('ko2');
-     * $redis->delete('ko3');
-     * $redis->zAdd('k1', 0, 'val0');
-     * $redis->zAdd('k1', 1, 'val1');
-     * $redis->zAdd('k2', 2, 'val2');
-     * $redis->zAdd('k2', 3, 'val3');
-     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
-     * // Weighted zUnion
-     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
-     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
-     * 
- * @return int - */ - public function zUnion() - { - } - - /** - * - * - * @example - * @return - */ - public function zunionstore() - { - } - - /** - * - *Increment the number stored at key by one. If the second argument is filled, it will be used as the integer - *value of the increment. - * @example - *
-     * $redis->incr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value 1
-     * $redis->incr('key1');        // 2
-     * $redis->incr('key1');        // 3
-     * $redis->incr('key1');        // 4
-     * $redis->incrBy('key1', 10);  // 14
-     * 
- * @return int - */ - public function incrBy() - { - } - - /** - * - *Increments the value of a member from a hash by a given amount. - * @example - *
-     * $redis->delete('h');
-     * $redis->hIncrBy('h', 'x', 2); // returns 2: h[x] = 2 now.
-     * $redis->hIncrBy('h', 'x', 1); // h[x] ← 2 + 1. Returns 3
-     * 
- * @return int - */ - public function hIncrBy() - { - } - - /** - * - *Increment the number stored at key by one. - * @example - *
-     * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
-     * $redis->incr('key1'); // 2
-     * $redis->incr('key1'); // 3
-     * $redis->incr('key1'); // 4
-     * 
- * @return int - */ - public function incr() - { - } - - /** - * - *Decrement the number stored at key by one. If the second argument is filled, it will be used as the integer - *value of the decrement. - * @example - *
-     * $redis->decr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value -1
-     * $redis->decr('key1');        // -2
-     * $redis->decr('key1');        // -3
-     * $redis->decrBy('key1', 10);  // -13
-     * 
- * @return int - */ - public function decrBy() - { - } - - /** - * - *Decrement the number stored at key by one. - * @example - *
-     * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
-     * $redis->decr('key1'); // -2
-     * $redis->decr('key1'); // -3
-     * 
- * @return int - */ - public function decr() - { - } - - /** - * - *Return a single bit out of a larger string - * @example - *
-     * $redis->set('key', "\x7f");  // this is 0111 1111
-     * $redis->getBit('key', 0);    // 0
-     * $redis->getBit('key', 1);    // 1
-     * 
- * @return int: - */ - public function getBit() - { - } - - /** - * - *Insert value in the list before or after the pivot value. the parameter options - *specify the position of the insert (before or after). If the list didn't exists, - *or the pivot didn't exists, the value is not inserted. - * @example - *
-     * $redis->delete('key1');
-     * $redis->lInsert('key1', Redis::AFTER, 'A', 'X');     // 0
-     * $redis->lPush('key1', 'A');
-     * $redis->lPush('key1', 'B');
-     * $redis->lPush('key1', 'C');
-     * $redis->lInsert('key1', Redis::BEFORE, 'C', 'X');    // 4
-     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C')
-     * $redis->lInsert('key1', Redis::AFTER, 'C', 'Y');     // 5
-     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C', 'Y')
-     * $redis->lInsert('key1', Redis::AFTER, 'W', 'value'); // -1
-     * 
- * @return int - */ - public function lInsert() - { - } - - /** - * - * - * @example - * @return - */ - public function lGet() - { - } - - /** - * - *Return the specified element of the list stored at the specified key. - *0 the first element, 1 the second ... -1 the last element, -2 the penultimate ... - *Return FALSE in case of a bad index or a key that doesn't point to a list. - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->lGet('key1', 0);     // 'A'
-     * $redis->lGet('key1', -1);    // 'C'
-     * $redis->lGet('key1', 10);    // `FALSE`
-     * 
- * @return Bool - */ - public function lIndex() - { - } - - /** - * - * - * @example - * @return - */ - public function setTimeout() - { - } - - /** - * - *Sets an expiration date (a timeout) on an item. - * @example - *
-     * $redis->set('x', '42');
-     * $redis->setTimeout('x', 3);  // x will disappear in 3 seconds.
-     * sleep(5);                    // wait 5 seconds
-     * $redis->get('x');            // will return `FALSE`, as 'x' has expired.
-     * 
- * @return bool: - */ - public function expire() - { - } - - /** - * - * - * @example - * @return - */ - public function pexpire() - { - } - - /** - * - *Sets an expiration date (a timestamp) on an item. - * @example - *
-     * $redis->set('x', '42');
-     * $now = time(NULL);               // current timestamp
-     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
-     * sleep(5);                        // wait 5 seconds
-     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
-     * 
- * @return bool: - */ - public function expireAt() - { - } - - /** - * - * - * @example - * @return - */ - public function pexpireAt() - { - } - - /** - * - *Moves a key to a different database. - * @example - *
-     * $redis->select(0);       // switch to DB 0
-     * $redis->set('x', '42');  // write 42 to x
-     * $redis->move('x', 1);    // move to DB 1
-     * $redis->select(1);       // switch to DB 1
-     * $redis->get('x');        // will return 42
-     * 
- * @return bool: - */ - public function move() - { - } - - /** - * - *Switches to a given database. - * @example - *
-     * $redis->select(0);       // switch to DB 0
-     * $redis->set('x', '42');  // write 42 to x
-     * $redis->move('x', 1);    // move to DB 1
-     * $redis->select(1);       // switch to DB 1
-     * $redis->get('x');        // will return 42
-     * 
- * @return bool - */ - public function select() - { - } - - /** - * - *Return a substring of a larger string - * @example - *
-     * $redis->set('key', 'string value');
-     * $redis->getRange('key', 0, 5);   // 'string'
-     * $redis->getRange('key', -5, -1); // 'value'
-     * 
- * @return string: - */ - public function getRange() - { - } - - /** - * - * - * @example - * @return - */ - public function listTrim() - { - } - - /** - * - * - * @example - * @return - */ - public function ltrim() - { - } - - /** - * - * - * @example - * @return - */ - public function lGetRange() - { - } - - /** - * - *Returns the specified elements of the list stored at the specified key in - *the range [start, end]. start and stop are interpretated as indices: 0 the first element, - *1 the second ... -1 the last element, -2 the penultimate ... - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');
-     * $redis->lRange('key1', 0, -1); // array('A', 'B', 'C')
-     * 
- * @return array - */ - public function lRange() - { - } - - /** - * - *Removes the first count occurences of the value element from the list. - *If count is zero, all the matching elements are removed. If count is negative, - *elements are removed from tail to head. - * @example - *
-     * $redis->lPush('key1', 'A');
-     * $redis->lPush('key1', 'B');
-     * $redis->lPush('key1', 'C');
-     * $redis->lPush('key1', 'A');
-     * $redis->lPush('key1', 'A');
-     * $redis->lRange('key1', 0, -1);   // array('A', 'A', 'C', 'B', 'A')
-     * $redis->lRem('key1', 'A', 2);    // 2
-     * $redis->lRange('key1', 0, -1);   // array('C', 'B', 'A')
-     * 
- * @return bool - */ - public function lRem() - { - } - - /** - * - * - * @example - * @return - */ - public function lRemove() - { - } - - /** - * - * - * @example - * @return - */ - public function zDeleteRangeByRank() - { - } - - /** - * - *Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end]. - * @example - *
-     * $redis->zAdd('key', 1, 'one');
-     * $redis->zAdd('key', 2, 'two');
-     * $redis->zAdd('key', 3, 'three');
-     * $redis->zRemRangeByRank('key', 0, 1); // 2
-     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
-     * 
- * @return int - */ - public function zRemRangeByRank() - { - } - - /** - * - *Increment the float value of a key by the given amount - * @example - *
-     * $redis = new Redis();
-     * $redis->connect('127.0.0.1');
-     * $redis->set('x', 3);
-     * var_dump( $redis->incrByFloat('x', 1.5) );   // float(4.5)
-     * // ! SIC
-     * var_dump( $redis->get('x') );                // string(3) "4.5"
-     * 
- * @return - */ - public function incrByFloat() - { - } - - /** - * - *Increment the float value of a hash field by the given amount - * @example - *
-     * $redis = new Redis();
-     * $redis->connect('127.0.0.1');
-     * $redis->hset('h', 'float', 3);
-     * $redis->hset('h', 'int',   3);
-     * var_dump( $redis->hIncrByFloat('h', 'float', 1.5) ); // float(4.5)
-     * var_dump( $redis->hGetAll('h') );
-     * // Output
-     * array(2) {
-     * ["float"]=>
-     * string(3) "4.5"
-     * ["int"]=>
-     * string(1) "3"
-     * }
-     * 
- * @return - */ - public function hIncrByFloat() - { - } - - /** - * - *Count bits in a string. - * @example - *
-     * $redis->set('bit', '345'); // // 11 0011  0011 0100  0011 0101
-     * var_dump( $redis->bitCount('bit', 0, 0) ); // int(4)
-     * var_dump( $redis->bitCount('bit', 1, 1) ); // int(3)
-     * var_dump( $redis->bitCount('bit', 2, 2) ); // int(4)
-     * var_dump( $redis->bitCount('bit', 0, 2) ); // int(11)
-     * 
- * @return int - */ - public function bitCount() - { - } - - /** - * - *Bitwise operation on multiple keys. - * @example - *
-     * $redis->set('bit1', '1'); // 11 0001
-     * $redis->set('bit2', '2'); // 11 0010
-     * $redis->bitOp('AND', 'bit', 'bit1', 'bit2'); // bit = 110000
-     * $redis->bitOp('OR',  'bit', 'bit1', 'bit2'); // bit = 110011
-     * $redis->bitOp('NOT', 'bit', 'bit1', 'bit2'); // bit = 110011
-     * $redis->bitOp('XOR', 'bit', 'bit1', 'bit2'); // bit = 11
-     * 
- * @return int - */ - public function bitOp() - { - } - - /** - * - *Adds a values to the set value stored at key. - *If this value is already in the set, FALSE is returned. - * @example - *
-     * $redis->sAdd('k', 'v1');                // int(1)
-     * $redis->sAdd('k', 'v1', 'v2', 'v3');    // int(2)
-     * 
- * @return int - */ - public function sAdd() - { - } - - /** - * - *Moves the specified member from the set at srcKey to the set at dstKey. - * @example - *
-     * $redis->sAdd('key1' , 'set11');
-     * $redis->sAdd('key1' , 'set12');
-     * $redis->sAdd('key1' , 'set13');          // 'key1' => {'set11', 'set12', 'set13'}
-     * $redis->sAdd('key2' , 'set21');
-     * $redis->sAdd('key2' , 'set22');          // 'key2' => {'set21', 'set22'}
-     * $redis->sMove('key1', 'key2', 'set13');  // 'key1' =>  {'set11', 'set12'}
-     * // 'key2' =>  {'set21', 'set22', 'set13'}
-     * 
- * @return If - */ - public function sMove() - { - } - - /** - * - *Performs the difference between N sets and returns it. - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s0', '3');
-     * $redis->sAdd('s0', '4');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * var_dump($redis->sDiff('s0', 's1', 's2'));
-     * //array(2) {
-     * //  [0]=>
-     * //  string(1) "4"
-     * //  [1]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @return array - */ - public function sDiff() - { - } - - /** - * - *Performs the same action as sDiff, but stores the result in the first key - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s0', '3');
-     * $redis->sAdd('s0', '4');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * var_dump($redis->sDiffStore('dst', 's0', 's1', 's2'));
-     * var_dump($redis->sMembers('dst'));
-     * //int(2)
-     * //array(2) {
-     * //  [0]=>
-     * //  string(1) "4"
-     * //  [1]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @return int: - */ - public function sDiffStore() - { - } - - /** - * - *Performs the union between N sets and returns it. - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s1', '3');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * $redis->sAdd('s2', '4');
-     * var_dump($redis->sUnion('s0', 's1', 's2'));
-     * array(4) {
-     * //  [0]=>
-     * //  string(1) "3"
-     * //  [1]=>
-     * //  string(1) "4"
-     * //  [2]=>
-     * //  string(1) "1"
-     * //  [3]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @return array - */ - public function sUnion() - { - } - - /** - * - *Performs the same action as sUnion, but stores the result in the first key - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s1', '3');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * $redis->sAdd('s2', '4');
-     * var_dump($redis->sUnionStore('dst', 's0', 's1', 's2'));
-     * var_dump($redis->sMembers('dst'));
-     * //int(4)
-     * //array(4) {
-     * //  [0]=>
-     * //  string(1) "3"
-     * //  [1]=>
-     * //  string(1) "4"
-     * //  [2]=>
-     * //  string(1) "1"
-     * //  [3]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @return int - */ - public function sUnionStore() - { - } - - /** - * - *Returns the members of a set resulting from the intersection of all the sets - *held at the specified keys. If just a single key is specified, then this command - *produces the members of this set. If one of the keys is missing, FALSE is returned. - * @example - *
-     * $redis->sAdd('key1', 'val1');
-     * $redis->sAdd('key1', 'val2');
-     * $redis->sAdd('key1', 'val3');
-     * $redis->sAdd('key1', 'val4');
-     * $redis->sAdd('key2', 'val3');
-     * $redis->sAdd('key2', 'val4');
-     * $redis->sAdd('key3', 'val3');
-     * $redis->sAdd('key3', 'val4');
-     * var_dump($redis->sInter('key1', 'key2', 'key3'));
-     * //array(2) {
-     * //  [0]=>
-     * //  string(4) "val4"
-     * //  [1]=>
-     * //  string(4) "val3"
-     * //}
-     * 
- * @return If - */ - public function sInter() - { - } - - /** - * - *Performs a sInter command and stores the result in a new set. - * @example - *
-     * $redis->sAdd('key1', 'val1');
-     * $redis->sAdd('key1', 'val2');
-     * $redis->sAdd('key1', 'val3');
-     * $redis->sAdd('key1', 'val4');
-     * $redis->sAdd('key2', 'val3');
-     * $redis->sAdd('key2', 'val4');
-     * $redis->sAdd('key3', 'val3');
-     * $redis->sAdd('key3', 'val4');
-     * var_dump($redis->sInterStore('output', 'key1', 'key2', 'key3'));
-     * var_dump($redis->sMembers('output'));
-     * //int(2)
-     * //
-     * //array(2) {
-     * //  [0]=>
-     * //  string(4) "val4"
-     * //  [1]=>
-     * //  string(4) "val3"
-     * //}
-     * 
- * @return int: - */ - public function sInterStore() - { - } - - /** - * - * - * @example - * @return - */ - public function sRemove() - { - } - - /** - * - * - * @example - * @return - */ - public function srem() - { - } - - /** - * - * - * @example - * @return int - */ - public function zDelete() - { - } - - /** - * - * - * @example - * @return - */ - public function zRemove() - { - } - - /** - * - *Deletes a specified member from the ordered set. - * @example - *
-     * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
-     * $redis->zRem('z', 'v2', 'v3');                           // int(2)
-     * var_dump( $redis->zRange('z', 0, -1) );
-     * //// Output:
-     * // array(2) {
-     * //   [0]=> string(2) "v1"
-     * //   [1]=> string(2) "v4"
-     * // }
-     * 
- * @return int - */ - public function zRem() - { - } - - /** - * - * - * @example - * @return - */ - public function pSubscribe() - { - } - - /** - * - *Subscribe to channels. Warning: this function will probably change in the future. - * @example - *
-     * function f($redis, $chan, $msg) {
-     * switch($chan) {
-     * case 'chan-1':
-     * ...
-     * break;
-     * case 'chan-2':
-     * ...
-     * break;
-     * case 'chan-2':
-     * ...
-     * break;
-     * }
-     * }
-     * $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
-     * 
- * @return mixed - */ - public function subscribe() - { - } - - /** - * - *Enter and exit transactional mode. - * @example - *
-     * $ret = $redis->multi()
-     * ->set('key1', 'val1')
-     * ->get('key1')
-     * ->set('key2', 'val2')
-     * ->get('key2')
-     * ->exec();
-     * //$ret == array (
-     * //    0 => TRUE,
-     * //    1 => 'val1',
-     * //    2 => TRUE,
-     * //    3 => 'val2');
-     * 
- * @return Once - */ - public function multi() - { - } - - /** - * - * - * @example - * @return - */ - public function exec() - { - } - -} - diff --git a/src/Swoole/swoole_redis_server.php b/src/Swoole/swoole_redis_server.php deleted file mode 100644 index 0b27688..0000000 --- a/src/Swoole/swoole_redis_server.php +++ /dev/null @@ -1,509 +0,0 @@ -connnection_list是一致的,但是更加友好。遍历的元素为单个连接的fd - * @access public - */ - public $connections; - - /** - * - *创建一个swoole tcp/udp server对象 - * @example - * @param string $host 创建一个swoole tcp/udp server对象 - * @param int $port 创建一个swoole tcp/udp server对象 - * @param int $mode 创建一个swoole tcp/udp server对象 - * @param int $sock_type 创建一个swoole tcp/udp server对象 - * @return - */ - public function __construct($host, $port, $mode, $sock_type) - { - } - - /** - * - *监听一个新的Server端口,此方法是addlistener的别名 - * @example - * @param string $host 监听一个新的Server端口,此方法是addlistener的别名 - * @param int $port 监听一个新的Server端口,此方法是addlistener的别名 - * @param int $sock_type 监听一个新的Server端口,此方法是addlistener的别名 - * @return - */ - public function listen($host, $port, $sock_type) - { - } - - /** - * - *监听一个新的Server端口,此方法是addlistener的别名 - * @example - * @param string $host 监听一个新的Server端口,此方法是addlistener的别名 - * @param int $port 监听一个新的Server端口,此方法是addlistener的别名 - * @param int $sock_type 监听一个新的Server端口,此方法是addlistener的别名 - * @return - */ - public function addlistener($host, $port, $sock_type) - { - } - - /** - * - *注册Server的事件回调函数 - * @example - * @param string $event_name 注册Server的事件回调函数 - * @param callable $callback 注册Server的事件回调函数 - * @return bool - */ - public function on($event_name, Callable $callback) - { - } - - /** - * - *设置选项 - * @example - * @param array $settings 设置选项 - * @return - */ - public function set(Array $settings) - { - } - - /** - * - *启动server,监听所有TCP/UDP端口 - * @example - * @return bool - */ - public function start() - { - } - - /** - * - *向客户端发送数据 - * @example - * @param int $fd 向客户端发送数据 - * @param string $send_data 向客户端发送数据 - * @param int $reactor_id 向客户端发送数据 - * @return bool - */ - public function send($fd, $send_data, $reactor_id) - { - } - - /** - * - *向任意的客户端IP:PORT发送UDP数据包 - * @example - * @param string $ip 向任意的客户端IP:PORT发送UDP数据包 - * @param int $port 向任意的客户端IP:PORT发送UDP数据包 - * @param string $send_data 向任意的客户端IP:PORT发送UDP数据包 - * @param int $server_socket 向任意的客户端IP:PORT发送UDP数据包 - * @return bool - */ - public function sendto($ip, $port, $send_data, $server_socket) - { - } - - /** - * - *阻塞地向客户端发送数据 - * @example - * @param int $conn_fd 阻塞地向客户端发送数据 - * @param string $send_data 阻塞地向客户端发送数据 - * @return bool - */ - public function sendwait($conn_fd, $send_data) - { - } - - /** - * - *检测fd对应的连接是否存在 - * @example - * @param int $fd 检测fd对应的连接是否存在 - * @return bool - */ - public function exist($fd) - { - } - - /** - * - *用于保护某些连接不被心跳线程切断 - * @example - * @param int $fd 用于保护某些连接不被心跳线程切断 - * @param bool $is_protected 用于保护某些连接不被心跳线程切断 - * @return - */ - public function protect($fd, $is_protected) - { - } - - /** - * - *发送文件到TCP客户端连接 - * @example - * @param int $conn_fd 发送文件到TCP客户端连接 - * @param string $filename 发送文件到TCP客户端连接 - * @param int $offset 发送文件到TCP客户端连接 - * @return bool - */ - public function sendfile($conn_fd, $filename, $offset) - { - } - - /** - * - *关闭客户端连接 - * @example - * @param int $fd 关闭客户端连接 - * @param bool $reset 关闭客户端连接 - * @return - */ - public function close($fd, $reset) - { - } - - /** - * - *连接确认 - * @example - * @param int $fd 连接确认 - * @return - */ - public function confirm($fd) - { - } - - /** - * - *停止接收数据 - * @example - * @param int $fd 停止接收数据 - * @return - */ - public function pause($fd) - { - } - - /** - * - *恢复数据接收 - * @example - * @param int $fd 恢复数据接收 - * @return - */ - public function resume($fd) - { - } - - /** - * - *投递一个异步任务到task_worker池中。此函数是非阻塞的,执行完毕会立即返回 - * @example - * @param mixed $data 投递一个异步任务到task_worker池中。此函数是非阻塞的,执行完毕会立即返回 - * @param int $worker_id 投递一个异步任务到task_worker池中。此函数是非阻塞的,执行完毕会立即返回 - * @param callable $finish_callback 投递一个异步任务到task_worker池中。此函数是非阻塞的,执行完毕会立即返回 - * @return - */ - public function task($data, $worker_id, Callable $finish_callback) - { - } - - /** - * - *用于投递一个异步的任务到task进程池去执行。与task不同的是taskwait是阻塞等待的,直到任务完成或者超时返回。 - * @example - * @param mixed $data 用于投递一个异步的任务到task进程池去执行。与task不同的是taskwait是阻塞等待的,直到任务完成或者超时返回。 - * @param float $timeout 用于投递一个异步的任务到task进程池去执行。与task不同的是taskwait是阻塞等待的,直到任务完成或者超时返回。 - * @param int $worker_id 用于投递一个异步的任务到task进程池去执行。与task不同的是taskwait是阻塞等待的,直到任务完成或者超时返回。 - * @return - */ - public function taskwait($data, $timeout, $worker_id) - { - } - - /** - * - *并发执行多个Task - * @example - * @param array $tasks 并发执行多个Task - * @param double $timeout 并发执行多个Task - * @return - */ - public function taskWaitMulti(Array $tasks, $timeout) - { - } - - /** - * - *此函数用于在task进程中通知worker进程,投递的任务已完成。此函数可以传递结果数据给worker进程 - * @example - * @param string $data 此函数用于在task进程中通知worker进程,投递的任务已完成。此函数可以传递结果数据给worker进程 - * @return - */ - public function finish($data) - { - } - - /** - * - *重启所有worker进程 - * @example - * @return - */ - public function reload() - { - } - - /** - * - *关闭服务器 - * @example - * @return - */ - public function shutdown() - { - } - - /** - * - *使当前worker进程停止运行,并立即触发onWorkerStop回调函数 - * @example - * @param int $worker_id 使当前worker进程停止运行,并立即触发onWorkerStop回调函数 - * @return - */ - public function stop($worker_id) - { - } - - /** - * - *获取最近一次操作错误的错误码。业务代码中可以根据错误码类型执行不同的逻辑。 - * @example - * @return int - */ - public function getLastError() - { - } - - /** - * - *检测服务器所有连接,并找出已经超过约定时间的连接。如果指定if_close_connection,则自动关闭超时的连接。未指定仅返回连接的fd数组。 - * @example - * @param mixed $reactor_id - * @return - */ - public function heartbeat($reactor_id) - { - } - - /** - * - *获取连接的信息 - * @example - * @param int $fd 获取连接的信息 - * @param int $reactor_id 获取连接的信息 - * @return - */ - public function connection_info($fd, $reactor_id) - { - } - - /** - * - *用来遍历当前Server所有的客户端连接 - * @example - * @param int $start_fd 用来遍历当前Server所有的客户端连接 - * @param int $find_count 用来遍历当前Server所有的客户端连接 - * @return - */ - public function connection_list($start_fd, $find_count) - { - } - - /** - * - *获取连接的信息 - * @example - * @param int $fd 获取连接的信息 - * @param int $reactor_id 获取连接的信息 - * @return - */ - public function getClientInfo($fd, $reactor_id) - { - } - - /** - * - *用来遍历当前Server所有的客户端连接 - * @example - * @param int $start_fd 用来遍历当前Server所有的客户端连接 - * @param int $find_count 用来遍历当前Server所有的客户端连接 - * @return - */ - public function getClientList($start_fd, $find_count) - { - } - - /** - * - *在指定的时间后执行函数 - * @example - * @param int $ms 在指定的时间后执行函数 - * @param callable $callback 在指定的时间后执行函数 - * @param array $param 在指定的时间后执行函数 - * @return - */ - public function after($ms, Callable $callback, Array $param) - { - } - - /** - * - *tick定时器,可以自定义回调函数 - * @example - * @param int $ms tick定时器,可以自定义回调函数 - * @param callable $callback tick定时器,可以自定义回调函数 - * @return - */ - public function tick($ms, Callable $callback) - { - } - - /** - * - *清除tick/after定时器,此函数是swoole_timer_clear的别名 - * @example - * @param int $timer_id 清除tick/after定时器,此函数是swoole_timer_clear的别名 - * @return - */ - public function clearTimer($timer_id) - { - } - - /** - * - *延后执行一个PHP函数。Swoole底层会在EventLoop循环完成后执行此函数。此函数的目的是为了让一些PHP代码延后执行,程序优先处理IO事件 - * @example - * @param callable $callback 延后执行一个PHP函数。Swoole底层会在EventLoop循环完成后执行此函数。此函数的目的是为了让一些PHP代码延后执行,程序优先处理IO事件 - * @return - */ - public function defer(Callable $callback) - { - } - - /** - * - *此函数可以向任意worker进程或者task进程发送消息。在非主进程和管理进程中可调用。收到消息的进程会触发onPipeMessage事件。 - * @example - * @param int $dst_worker_id 此函数可以向任意worker进程或者task进程发送消息。在非主进程和管理进程中可调用。收到消息的进程会触发onPipeMessage事件。 - * @param string $data 此函数可以向任意worker进程或者task进程发送消息。在非主进程和管理进程中可调用。收到消息的进程会触发onPipeMessage事件。 - * @return - */ - public function sendMessage($dst_worker_id, $data) - { - } - - /** - * - *添加一个用户自定义的工作进程 - * @example - * @param object $process 添加一个用户自定义的工作进程 - * @return - */ - public function addProcess($process) - { - } - - /** - * - *得到当前Server的活动TCP连接数,启动时间,accpet/close的总次数等信息 - * @example - * @return array - */ - public function stats() - { - } - - /** - * - *将连接绑定一个用户定义的ID,可以设置dispatch_mode=5设置已此ID值进行hash固定分配。可以保证某一个UID的连接全部会分配到同一个Worker进程 - * @example - * @param int $fd 将连接绑定一个用户定义的ID,可以设置dispatch_mode=5设置已此ID值进行hash固定分配。可以保证某一个UID的连接全部会分配到同一个Worker进程 - * @param int $uid 将连接绑定一个用户定义的ID,可以设置dispatch_mode=5设置已此ID值进行hash固定分配。可以保证某一个UID的连接全部会分配到同一个Worker进程 - * @return - */ - public function bind($fd, $uid) - { - } - -} - diff --git a/src/Swoole/swoole_server_port.php b/src/Swoole/swoole_server_port.php deleted file mode 100644 index 750b9dc..0000000 --- a/src/Swoole/swoole_server_port.php +++ /dev/null @@ -1,57 +0,0 @@ -column('id', swoole_table::TYPE_INT, 4); //1,2,4,8 - * $table->column('name', swoole_table::TYPE_STRING, 64); - * $table->column('num', swoole_table::TYPE_FLOAT); - * $table->create(); - * @return - */ - public function create() - { - } - - /** - * - *销毁内存表 - * @example - * @return - */ - public function destroy() - { - } - - /** - * - *设置行的数据,swoole_table使用key-value的方式来访问数据。 - * @example - * @param string $key 设置行的数据,swoole_table使用key-value的方式来访问数据。 - * @param array $value 设置行的数据,swoole_table使用key-value的方式来访问数据。 - * @return - */ - public function set($key, Array $value) - { - } - - /** - * - *获取一行数据 - * @example - * @param string $key 获取一行数据 - * @return array - */ - public function get($key) - { - } - - /** - * - *获取键的数量 - * @example - * @return int - */ - public function count() - { - } - - /** - * - *删除指定key的值 - * @example - * @param string $key 删除指定key的值 - * @return boolean - */ - public function del($key) - { - } - - /** - * - *检查table中是否存在某一个key - * @example - * @param string $key 检查table中是否存在某一个key - * @return boolean - */ - public function exist($key) - { - } - - /** - * - *原子自增操作 - * @example - * @param string $key 原子自增操作 - * @param number $column 原子自增操作 - * @param mixed $incrby 原子自增操作 - * @return - */ - public function incr($key, $column, $incrby) - { - } - - /** - * - *原子自减操作 - * @example - * @param string $key 原子自减操作 - * @param number $column 原子自减操作 - * @param mixed $decrby 原子自减操作 - * @return - */ - public function decr($key, $column, $decrby) - { - } - - /** - * - *返回到迭代器的第一个元素 - * @example - * @return void - */ - public function rewind() - { - } - - /** - * - *向前移动到下一个元素 - * @example - * @return void - */ - public function next() - { - } - - /** - * - *返回当前元素 - * @example - * @return mixed - */ - public function current() - { - } - - /** - * - *返回当前元素的键 - * @example - * @return scalar - */ - public function key() - { - } - - /** - * - *此方法在 rewind() 和 next() 方法之后被调用以此用来检查当前位置是否有效 - * @example - * @return boolean - */ - public function valid() - { - } - -} - diff --git a/src/Swoole/swoole_timer.php b/src/Swoole/swoole_timer.php deleted file mode 100644 index 65581ca..0000000 --- a/src/Swoole/swoole_timer.php +++ /dev/null @@ -1,61 +0,0 @@ -2))"},"swoole_async_read":{"comment":"异步读文件,使用此函数读取文件是非阻塞的,当读操作完成时会自动回调指定的函数","parameters":{"filename":{"comment":"文件名","options":[],"type":"string"},"callback":{"comment":"读操作完成后的回调函数, 其回调函数原型:\n bool callback(string $filename, string $content);\n * $filename,文件名称 \n * $content,读取到的分段内容,如果内容为空,表明文件已读完","options":[],"type":"callable"},"chunk_size":{"comment":"读的块大小","options":[],"type":"int"},"offset":{"comment":"读文件的指针偏移量","options":[],"type":"int"}},"return":"bool","example":""},"swoole_async_write":{"comment":"异步写文件,与swoole_async_writefile不同,write是分段读写的。不需要一次性将要写的内容放到内存里,所以只占用少量内存。swoole_async_write通过传入的offset参数来确定写入的位置","parameters":{"filename":{"comment":"写入的文件名","options":[],"type":"string"},"content":{"comment":"写入的文件内容","options":[],"type":"string"},"offset":{"comment":"写入的文件位置(指针偏移)","options":[],"type":"int"},"callback":{"comment":"写完成后执行的回调函数","options":[],"type":"callable"}},"return":"","example":""},"swoole_async_readfile":{"comment":"异步读取文件内容(与readfile功能类似),完成后并执行某个函数","parameters":{"filename":{"comment":"文件名","options":[],"type":"string"},"callback":{"comment":"读文件完成后的回调函数","options":[],"type":"callable"}},"return":"","example":"swoole_async_readfile(__DIR__.\"\/server.php\", function($filename, $content) {\n echo \"$filename: $content\";\n});"},"swoole_async_writefile":{"comment":"异步写文件,调用此函数后会立即返回。当写入完成时会自动回调指定的callback函数","parameters":{"filename":{"comment":"写入的文件名","options":[],"type":"string"},"content":{"comment":"写入的内容","options":[],"type":"string"},"callback":{"comment":"写文件完成后的回调函数","options":[],"type":"callable"},"flags":{"comment":"","options":[],"type":""}},"return":"","example":""},"swoole_async_dns_lookup":{"comment":"将域名解析为IP地址。调用此函数是非阻塞的,调用会立即返回","parameters":{"hostname":{"comment":"域名","options":[],"type":"string"},"callback":{"comment":"解析后的回调函数","options":[],"type":"callable"}},"return":"","example":"swoole_async_dns_lookup(\"www.baidu.com\", function($host, $ip){ \necho \"{$host} : {$ip}\n \";\n});"},"swoole_async_dns_lookup_coro":{"comment":"协程DNS查询","parameters":{"domain_name":{"comment":"要查询的域名","options":[],"type":"string"}},"return":"string|bool","example":""},"swoole_client_select":{"comment":"swoole_client的并行处理中用了select来做IO事件循环","parameters":{"read_array":{"comment":"可读文件描述符","options":[],"type":"array"},"write_array":{"comment":"可写文件描述符","options":[],"type":"array"},"error_array":{"comment":"错误文件描述符","options":[],"type":"array"},"timeout":{"comment":"超时时间","options":[],"type":"float"}},"return":"int","example":""},"swoole_select":{"comment":"swoole的并行处理中用了select来做IO事件循环","parameters":{"read_array":{"comment":"","options":[],"type":""},"write_array":{"comment":"","options":[],"type":""},"error_array":{"comment":"","options":[],"type":""},"timeout":{"comment":"","options":[],"type":""}},"return":"","example":""},"swoole_set_process_name":{"comment":"设置进程的名称(存在兼容性问题,优先使用PHP内置的cli_set_process_title函数)","parameters":{"process_name":{"comment":"进程名称","options":[],"type":"string"}},"return":"","example":"swoole_set_process_name('swoole_server');"},"swoole_get_local_ip":{"comment":"用于获取本地所有网络接口的IP地址(返回以interface名称为key的关联数组)","parameters":[],"return":"array (只返回IPv4地址,返回结果会过滤掉本地的loop地址127.0.0.1,类似于array('eth0'=>'192.168.0.25'))","example":"$ips = swoole_get_local_ip();"},"swoole_get_local_mac":{"comment":"获取本地所有网络接口的mac地址(返回以interface名称为key的关联数组)","parameters":[],"return":"array","example":"$macs = swoole_get_local_mac();"},"swoole_strerror":{"comment":"从标准的Unix Errno错误码转换成错误信息","parameters":{"errno":{"comment":"标准错误码","options":[],"type":"int"}},"return":"string","example":""},"swoole_errno":{"comment":"获取最近一次系统调用的错误码","parameters":[],"return":"int","example":"echo swoole_strerror(swoole_errno());"}}} \ No newline at end of file diff --git a/src/swoole/swoole_async.json b/src/swoole/swoole_async.json new file mode 100644 index 0000000..11f7481 --- /dev/null +++ b/src/swoole/swoole_async.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_async"},"comment":"异步IO操作","namespace":"","consts":[],"properties":[],"methods":{"read":{"access":"public","comment":"异步读文件,使用此函数读取文件是非阻塞的,当读操作完成时会自动回调指定的函数","isStatic":true,"return":"boolean","example":"","parameters":{"filename":{"comment":"读入的文件名","type":"string","options":[]},"callback":{"comment":"读文件完成后的回调函数(回调函数可使用的参数$fileName, $content)","type":"callable","options":[]},"chunk_size":{"comment":"每次读入的块大小","type":"int","options":[]},"offset":{"comment":"读入每次的偏移量","type":"int","options":[]}}},"write":{"access":"public","comment":"异步写文件,与swoole_async_writefile不同,write是分段读写的。不需要一次性将要写的内容放到内存里,所以只占用少量内存。swoole_async_write通过传入的offset参数来确定写入的位置","isStatic":true,"return":"","example":"","parameters":{"filename":{"comment":"写入的文件名","type":"string","options":[]},"content":{"comment":"写入的内容","type":"string","options":[]},"offset":{"comment":"写入的位置","type":"int","options":[]},"callback":{"comment":"写操作完成后的回调函数","type":"callable","options":[]}}},"readFile":{"access":"public","comment":"异步读取文件内容","isStatic":true,"return":"","example":"","parameters":{"filename":{"comment":"读入的文件名","type":"string","options":[]},"callback":{"comment":"读文件完成后的回调函数","type":"callable","options":[]}}},"writeFile":{"access":"public","comment":"异步写文件","isStatic":true,"return":"","example":"","parameters":{"filename":{"comment":"写入的文件名","type":"string","options":[]},"content":{"comment":"写入的内容","type":"string","options":[]},"callback":{"comment":"写操作完成后的回调函数","type":"callable","options":[]},"flags":{"comment":"参数4为写入的选项,可以使用FILE_APPEND表示追加到文件末尾","type":"int","options":[]}}},"dnsLookup":{"access":"public","comment":"将域名解析为IP地址。调用此函数是非阻塞的,调用会立即返回。将向下执行后面的代码(当DNS查询完成时,自动回调指定的callback函数)","isStatic":true,"return":"","example":"","parameters":{"hostname":{"comment":"域名","type":"string","options":[]},"callback":{"comment":"解析完成后的回调函数","type":"callable","options":[]}}},"dnsLookupCoro":{"access":"public","comment":"协程DNS查询","isStatic":true,"return":"","example":"","parameters":{"domain_name":{"comment":"解析的域名","type":"string","options":[]}}},"set":{"access":"public","comment":"置异步IO相关的选项\n设置的选项可以为以下值:\n thread_num : 设置异步文件IO线程的数量\n aio_mode : 设置异步文件IO的操作模式,目前支持SWOOLE_AIO_BASE(使用类似于Node.js的线程池同步阻塞模拟异步)、SWOOLE_AIO_LINUX(Linux Native AIO) 2种模式\n enable_signalfd : 开启和关闭signalfd特性的使用\n socket_buffer_size : 设置SOCKET内存缓存区尺寸\n socket_dontwait :在内存缓存区已满的情况下禁止底层阻塞等待\n log_file :设置日志文件路径\n log_level : 设置错误日志等级","isStatic":true,"return":"","example":"","parameters":{"settings":{"comment":"要设置的选项","type":"array","options":[]}}},"exec":{"access":"public","comment":"异步执行Shell命令。相当于shell_exec函数,执行后底层会fork一个子进程,并执行对应的command命令","isStatic":true,"return":"","example":"","parameters":{"command":{"comment":"为执行的终端指令,如ls","type":"string","options":[]},"callback":{"comment":"命令执行完毕子进程退出后会回调指定的$callback函数,回调函数接收2个参数,第一个参数为命令执行后的屏幕输出内容$result,第二个参数为进程退出的状态信息$status","type":"callable","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_atomic.json b/src/swoole/swoole_atomic.json new file mode 100644 index 0000000..43e3bc2 --- /dev/null +++ b/src/swoole/swoole_atomic.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_atomic"},"comment":"原子计数操作类,可以方便整数的无锁原子增减","namespace":"","consts":[],"properties":[],"methods":{"__construct":{"access":"public","comment":"初始化一个计数器对象","isStatic":false,"return":"","example":"","parameters":{"value":{"comment":"初始值","type":"int","options":[]}}},"add":{"access":"public","comment":"增加计数","isStatic":false,"return":"","example":"","parameters":{"add_value":{"comment":"要增加的数值,默认为1,必须为正整数","type":"int","options":[]}}},"sub":{"access":"public","comment":"减少计数","isStatic":false,"return":"","example":"","parameters":{"sub_value":{"comment":"要减少的数值,默认为1","type":"int","options":[]}}},"get":{"access":"public","comment":"获取当前计数的值","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"将当前值设置为指定的数字","isStatic":false,"return":"","example":"","parameters":{"value":{"comment":"指定要设置的目标数值","type":"int","options":[]}}},"wait":{"access":"public","comment":"当原子计数的值为0时程序进入等待状态。另外一个进程调用wakeup可以再次唤醒程序。底层基于Linux Futex实现,使用此特性,可以仅用4字节内存实现一个等待、通知、锁的功能","isStatic":false,"return":"","example":"","parameters":{"timeout":{"comment":"指定超时时间,默认为-1,表示永不超时,会持续等待直到有其他进程唤醒;超时返回false,错误码为EAGAIN,可使用swoole_errno函数获取;成功返回true,表示有其他进程通过wakeup成功唤醒了当前的锁;使用wait\/wakeup特性时,原子计数的值只能为0或1,否则会导致无法正常使用;当然原子计数的值为1时,表示不需要进入等待状态,资源当前就是可用。wait函数会立即返回true","type":"float","options":[]}}},"wakeup":{"access":"public","comment":"唤醒处于wait状态的其他进程","isStatic":false,"return":"","example":"","parameters":{"count":{"comment":"计数(当前原子计数如果为0时,表示没有进程正在wait,wakeup会立即返回true;当前原子计数如果为1时,表示当前有进程正在wait,wakeup会唤醒等待的进程,并返回true;如果同时有多个进程处于wait状态,$n参数可以控制唤醒的进程数量;被唤醒的进程返回后,会将原子计数设置为0,这时可以再次调用wakeup唤醒其他正在wait的进程)","type":"int","options":[]}}},"cmpset":{"access":"public","comment":"如果当前计数器的值与比较的值的相等,则设置它为新的值","isStatic":false,"return":"","example":"","parameters":{"cmp_value":{"comment":"用于比较的值","type":"int","options":[]},"new_value":{"comment":"用于设置的新值","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_atomic_long.json b/src/swoole/swoole_atomic_long.json new file mode 100644 index 0000000..97e66cb --- /dev/null +++ b/src/swoole/swoole_atomic_long.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_atomic_long"},"comment":"swoole对64位有符号长整型原子计数的支持","namespace":"","consts":[],"properties":[],"methods":{"__construct":{"access":"public","comment":"创建一个64位的长整型原子计数对象","isStatic":false,"return":"","example":"","parameters":{"value":{"comment":"初始化数值","type":"int","options":[]}}},"add":{"access":"public","comment":"增加计数","isStatic":false,"return":"mixed","example":"","parameters":{"add_value":{"comment":"要增加的数值,默认为1,必须为正整数","type":"int","options":[]}}},"sub":{"access":"public","comment":"减少计数","isStatic":false,"return":"","example":"","parameters":{"sub_value":{"comment":"要减少的数值,默认为1","type":"int","options":[]}}},"get":{"access":"public","comment":"获取当前计数的值","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"将当前值设置为指定的数字","isStatic":false,"return":"","example":"","parameters":{"value":{"comment":"指定要设置的目标数值","type":"int","options":[]}}},"cmpset":{"access":"public","comment":"如果当前数值等于参数1,则将当前数值设置为参数2","isStatic":false,"return":"","example":"","parameters":{"cmp_value":{"comment":"用于比较的值","type":"int","options":[]},"new_value":{"comment":"用于设置的新值","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_buffer.json b/src/swoole/swoole_buffer.json new file mode 100644 index 0000000..baeed5f --- /dev/null +++ b/src/swoole/swoole_buffer.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_buffer"},"comment":"让PHP开发者可以像C一样直接读写内存,提升程序的性能,又不用担心内存越界。swoole_buffer会检测offset(swoole_buffer申请的内存并非共享内存,所以无法在多个进程间被共享)","namespace":"","consts":[],"properties":{"length":{"access":"public","comment":"当前数据的长度","isStatic":false,"type":"int","value":0},"capacity":{"access":"public","comment":"当前缓存区的容量","isStatic":false,"type":"int","value":0}},"methods":{"__construct":{"access":"public","comment":"buffer初始化(创建一个内存对象)","isStatic":false,"return":"","example":"","parameters":{"size":{"comment":"指定了缓冲区内存的初始尺寸。当申请的内存容量不够时swoole底层会自动扩容","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构方法","isStatic":false,"return":"","example":"","parameters":[]},"__toString":{"access":"public","comment":"将对象转化为string","isStatic":false,"return":"","example":"","parameters":[]},"substr":{"access":"public","comment":"从缓冲区取出内容(会复制一次内存)","isStatic":false,"return":"string","example":"","parameters":{"offset":{"comment":"表示偏移量,如果为负数,表示倒数计算偏移量","type":"int","options":[]},"length":{"comment":"表示读取数据的长度,默认为从 $offset 到整个缓存区末尾","type":"int","options":[]},"seek":{"comment":"表示从缓冲区的头部将此数据移除","type":"boolean","options":[]}}},"write":{"access":"public","comment":"往缓冲区中写入内容(向缓存区的任意内存位置写数据。read\/write函数可以直接读写内存。所以使用务必要谨慎,否则可能会破坏现有数据。)","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]},"data":{"comment":"写入的数据","type":"string","options":[]}}},"read":{"access":"public","comment":"从缓冲区读内容(此接口是一个底层接口,可直接操作内存)","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]},"length":{"comment":"要读取的数据长度","type":"int","options":[]}}},"append":{"access":"public","comment":"将数据添加到缓冲区末尾","isStatic":false,"return":"int","example":"","parameters":{"data":{"comment":"要写入的数据,支持二进制内容","type":"string","options":[]}}},"expand":{"access":"public","comment":"给缓冲区扩容","isStatic":false,"return":"","example":"","parameters":{"size":{"comment":"指定新的缓冲区尺寸,必须大于当前的尺寸","type":"int","options":[]}}},"recycle":{"access":"public","comment":"回收缓冲中已经废弃的内存","isStatic":false,"return":"","example":"","parameters":[]},"clear":{"access":"public","comment":"清理缓冲区数据(执行此操作后,缓存区将重置。swoole_buffer对象就可以用来处理新的请求了)","isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_channel.json b/src/swoole/swoole_channel.json new file mode 100644 index 0000000..e968e8e --- /dev/null +++ b/src/swoole/swoole_channel.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_channel"},"comment":"一个新的内存数据结构Channel,类似于Go的chan通道,底层基于共享内存+Mutex互斥锁实现,可实现用户态的高性能内存队列(Channel可用于多进程环境下,底层在读取写入时会自动加锁,应用层不需要担心数据同步问题;必须在父进程内创建才可以在子进程内使用)","namespace":"","consts":[],"properties":[],"methods":{"__construct":{"access":"public","comment":"创建通道","isStatic":false,"return":"","example":"","parameters":{"size":{"comment":"通道占用的内存的尺寸,单位为字节。最小值为64K,最大值没有限制","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构方法","isStatic":false,"return":"","example":"","parameters":[]},"push":{"access":"public","comment":"向通道写入数据","isStatic":false,"return":"boolean","example":"","parameters":{"data":{"comment":"可以为任意PHP变量,当$data是非字符串类型时底层会自动进行串化($data的尺寸超过8K时会启用临时文件存储数据;$data必须为非空变量,如空字符串、空数组、0、null、false)","type":"mixed","options":[]}}},"pop":{"access":"public","comment":"弹出数据","isStatic":false,"return":"","example":"","parameters":[]},"stats":{"access":"public","comment":"获取通道的状态(返回一个数组,包括2项信息:queue_num 通道中的元素数量;queue_bytes 通道当前占用的内存字节数)","isStatic":false,"return":"array","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_client.json b/src/swoole/swoole_client.json new file mode 100644 index 0000000..9a843b7 --- /dev/null +++ b/src/swoole/swoole_client.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_client"},"comment":"提供了tcp\/udp socket的客户端的封装代码","namespace":"","consts":{"MSG_OOB":{"comment":"读取带外数据","type":"int","value":1},"MSG_PEEK":{"comment":"窥视socket缓存区中的数据。设置MSG_PEEK参数后,recv读取数据不会修改指针,因此下一次调用recv仍然会从上一次的位置起返回数据","type":"int","value":2},"MSG_DONTWAIT":{"comment":"非阻塞接收数据,无论是否有数据都会立即返回","type":"int","value":64},"MSG_WAITALL":{"comment":"阻塞等待直到收到指定长度的数据后返回","type":"int","value":256}},"properties":{"errCode":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0},"sock":{"access":"public","type":"int","comment":"此socket的文件描述符","isStatic":false,"value":0},"reuse":{"access":"public","type":"boolean","comment":"表示此连接是新创建的还是复用已存在的","isStatic":false,"value":false},"reuseCount":{"access":"public","type":"int","comment":"表示此连接复用次数","isStatic":false,"value":0},"type":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"id":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"setting":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onConnect":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onError":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onReceive":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onClose":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onBufferFull":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onBufferEmpty":{"access":"public","type":"unknown","comment":false,"isStatic":false}},"methods":{"__construct":{"access":"public","comment":"创建tcp客户端对象","isStatic":false,"return":"","example":"","parameters":{"type":{"comment":"表示socket的类型,如TCP\/UDP(使用常量)","type":"int","options":[]},"async":{"comment":"表示同步阻塞还是异步非阻塞,默认为同步阻塞","type":"boolean","options":[]}}},"__destruct":{"access":"public","comment":"析构方法","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置客户端参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"设置的参数","type":"array","options":[]}}},"connect":{"access":"public","comment":"连接远程服务器","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"是远程服务器的地址,1.9.24或更高版本已支持自动异步解析域名,$host可直接传入域名","type":"string","options":[]},"port":{"comment":"是远程服务器端口","type":"int","options":[]},"timeout":{"comment":"是网络IO的超时,包括connect\/send\/recv,单位是s,支持浮点数。默认为0.5s,即500ms","type":"float","options":[]},"sock_flag":{"comment":"在UDP类型时表示是否启用udp_connect 设定此选项后将绑定$host与$port,此UDP将会丢弃非指定host\/port的数据包;","type":"int","options":[]}}},"recv":{"access":"public","comment":"从服务器端接收数据","isStatic":false,"return":"string","example":"","parameters":{"size":{"comment":"接收数据的缓存区最大长度,此参数不要设置过大,否则会占用较大内存","type":"int","options":[]},"flag":{"comment":"是否等待所有数据到达后返回","type":"boolean","options":[]}}},"send":{"access":"public","comment":"发送数据到远程服务器","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要发送的数据","type":"string","options":[]},"flag":{"comment":"是否等待所有数据到达后返回","type":"boolean","options":[]}}},"pipe":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"dst_socket":{"comment":"","type":"unknown","options":[]}}},"sendfile":{"access":"public","comment":"向服务器发送文件","isStatic":false,"return":"boolean","example":"","parameters":{"filename":{"comment":"指定要发送文件的路径","type":"string","options":[]},"offset":{"comment":"上传文件的偏移量,可以指定从文件的中间部分开始传输数据。此特性可用于支持断点续传","type":"int","options":[]},"length":{"comment":"发送数据的尺寸,默认为整个文件的尺寸","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意主机发送UDP数据包","isStatic":false,"return":"boolean","example":"","parameters":{"ip":{"comment":"目标主机的IP地址,支持IPv4\/IPv6","type":"string","options":[]},"port":{"comment":"目标主机端口","type":"int","options":[]},"data":{"comment":"要发送的数据内容,不得超过64K","type":"string","options":[]}}},"sleep":{"access":"public","comment":"调用此方法会从事件循环中移除当前socket的可读监听,停止接收数据","isStatic":false,"return":"","example":"","parameters":[]},"wakeup":{"access":"public","comment":"调用此方法会重新监听可读事件,将socket连接从睡眠中唤醒","isStatic":false,"return":"","example":"","parameters":[]},"pause":{"access":"public","comment":"停止接收数据","isStatic":false,"return":"","example":"","parameters":[]},"resume":{"access":"public","comment":"恢复数据接收。与pause方法成对使用","isStatic":false,"return":"","example":"","parameters":[]},"isConnected":{"access":"public","comment":"返回swoole_client的连接状态","isStatic":false,"return":"","example":"","parameters":[]},"getsockname":{"access":"public","comment":"用于获取客户端socket的本地host:port,必须在连接之后才可以使用","isStatic":false,"return":"","example":"","parameters":[]},"getpeername":{"access":"public","comment":"获取对端socket的IP地址和端口","isStatic":false,"return":"","example":"","parameters":[]},"close":{"access":"public","comment":"关闭连接","isStatic":false,"return":"","example":"","parameters":{"force":{"comment":"表示强制关闭连接,可用于关闭SWOOLE_KEEP长连接","type":"boolean","options":[]}}},"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件类型,支持connect\/error\/receive\/close 4种","type":"string","options":[]},"callback":{"comment":"回调函数,可以是函数名字符串、匿名函数、类静态方法、对象方法","type":"callable","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_client_coro.json b/src/swoole/swoole_client_coro.json new file mode 100644 index 0000000..00f76ad --- /dev/null +++ b/src/swoole/swoole_client_coro.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_client_coro"},"comment":false,"namespace":"","consts":{"MSG_OOB":{"comment":"","type":"unknown","value":1},"MSG_PEEK":{"comment":"","type":"unknown","value":2},"MSG_DONTWAIT":{"comment":"","type":"unknown","value":64},"MSG_WAITALL":{"comment":"","type":"unknown","value":256}},"properties":{"errCode":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"sock":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"type":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"setting":{"access":"public","type":"unknown","comment":false,"isStatic":false}},"methods":{"__construct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"type":{"comment":"","type":"unknown","options":[]}}},"__destruct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"","type":{},"options":[]}}},"connect":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"","type":"unknown","options":[]},"port":{"comment":"","type":"unknown","options":[]},"timeout":{"comment":"","type":"unknown","options":[]}}},"recv":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"send":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"","type":"unknown","options":[]},"flag":{"comment":"","type":"unknown","options":[]}}},"sendfile":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"filename":{"comment":"","type":"unknown","options":[]},"offset":{"comment":"","type":"unknown","options":[]},"length":{"comment":"","type":"unknown","options":[]}}},"sendto":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"ip":{"comment":"","type":"unknown","options":[]},"port":{"comment":"","type":"unknown","options":[]},"data":{"comment":"","type":"unknown","options":[]}}},"isConnected":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getsockname":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getpeername":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"close":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_connection_iterator.json b/src/swoole/swoole_connection_iterator.json new file mode 100644 index 0000000..bc4b2a7 --- /dev/null +++ b/src/swoole/swoole_connection_iterator.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_connection_iterator"},"comment":false,"namespace":"","consts":[],"properties":[],"methods":{"rewind":{"access":"public","comment":"返回到连接迭代器的第一个元素","isStatic":false,"return":"","example":"","parameters":[]},"next":{"access":"public","comment":"向前移动到下一个元素","isStatic":false,"return":"","example":"","parameters":[]},"current":{"access":"public","comment":"返回当前元素","isStatic":false,"return":"","example":"","parameters":[]},"key":{"access":"public","comment":"返回当前元素的键","isStatic":false,"return":"","example":"","parameters":[]},"valid":{"access":"public","comment":"检查当前位置是否有效","isStatic":false,"return":"","example":"","parameters":[]},"count":{"access":"public","comment":"计算迭代器中元素的个数","isStatic":false,"return":"int","example":"","parameters":[]},"offsetExists":{"access":"public","comment":"检查一个偏移位置是否存在","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"offsetGet":{"access":"public","comment":"取一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"offsetSet":{"access":"public","comment":"设置一个偏移位置的值(来自ArrayAccess接口)","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"value":{"comment":"需要设置的值","type":"mixed","options":[]}}},"offsetUnset":{"access":"public","comment":"复位一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_coroutine.json b/src/swoole/swoole_coroutine.json new file mode 100644 index 0000000..5dcac47 --- /dev/null +++ b/src/swoole/swoole_coroutine.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_coroutine"},"comment":"swoole内置协程(协程可以理解为纯用户态的线程,其通过协作而不是抢占来进行切换。相对于进程或者线程,协程所有的操作都可以在用户态完成,创建和切换的消耗更低。Swoole可以为每一个请求创建对应的协程,根据IO的状态来合理的调度协程)","namespace":"","consts":[],"properties":[],"methods":{"create":{"access":"public","comment":"创建协程","isStatic":true,"return":"","example":"","parameters":[]},"cli_wait":{"access":"public","comment":false,"isStatic":true,"return":"","example":"","parameters":[]},"suspend":{"access":"public","comment":"挂起当前协程","isStatic":true,"return":"","example":"","parameters":[]},"resume":{"access":"public","comment":"恢复某个协程,使其继续运行","isStatic":true,"return":"","example":"","parameters":[]},"getuid":{"access":"public","comment":"获取当前协程的ID","isStatic":true,"return":"int","example":"","parameters":[]},"sleep":{"access":"public","comment":"进入等待状态。相当于PHP的sleep函数,不同的是Coroutine::sleep是协程调度器实现的,底层会yield当前协程,让出时间片,并添加一个异步定时器,当超时时间到达时重新resume当前协程,恢复运行。使用sleep接口可以方便地实现超时等待功能。","isStatic":true,"return":"","example":"","parameters":{"seconds":{"comment":"为睡眠的时间,单位为秒,支持浮点型,最小精度为毫秒","type":"float","options":[]}}},"call_user_func":{"access":"public","comment":"协程版反射调用函数","isStatic":true,"return":"","example":"","parameters":[]},"call_user_func_array":{"access":"public","comment":"协程版反射调用函数","isStatic":true,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_coroutine_client.json b/src/swoole/swoole_coroutine_client.json new file mode 100644 index 0000000..58e9392 --- /dev/null +++ b/src/swoole/swoole_coroutine_client.json @@ -0,0 +1 @@ +{"object":{"name":"Swoole\\Coroutine\\Client"},"comment":"提供了TCP和UDP传输协议Socket客户端的封装代码","namespace":"Swoole\\Coroutine","consts":{"MSG_OOB":{"comment":"读取带外数据","type":"int","value":1},"MSG_PEEK":{"comment":"窥视socket缓存区中的数据。设置MSG_PEEK参数后,recv读取数据不会修改指针,因此下一次调用recv仍然会从上一次的位置起返回数据","type":"int","value":2},"MSG_DONTWAIT":{"comment":"非阻塞接收数据,无论是否有数据都会立即返回","type":"int","value":64},"MSG_WAITALL":{"comment":"阻塞等待直到收到指定长度的数据后返回","type":"int","value":256}},"properties":{"errCode":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0},"sock":{"access":"public","type":"int","comment":"此socket的文件描述符","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket 类型","isStatic":false,"value":0},"setting":{"access":"public","type":"array","comment":"设置参数","isStatic":false}},"methods":{"__construct":{"access":"public","comment":"客户端初始化","isStatic":false,"return":"","example":"","parameters":{"type":{"comment":"表示socket的类型,如TCP\/UDP","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置客户端参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置参数","type":"array","options":[]}}},"connect":{"access":"public","comment":"连接到远程服务器","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"远程服务器的地址","type":"string","options":[]},"port":{"comment":"远程服务器端口","type":"int","options":[]},"timeout":{"comment":"网络IO的超时,包括connect\/send\/recv,单位是s,支持浮点数。默认为0.1s,即100ms,超时发生时,连接会被自动close掉","type":"float","options":[]}}},"recv":{"access":"public","comment":"用于从服务器端接收数据。底层会自动yield,等待数据接收完成后自动切换到当前协程","isStatic":false,"return":"string","example":"","parameters":[]},"send":{"access":"public","comment":"发送数据","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要发送的数据","type":"string","options":[]},"flag":{"comment":"是否立即返回","type":"boolean","options":[]}}},"sendfile":{"access":"public","comment":"发送文件到服务器,本函数是基于sendfile操作系统调用的","isStatic":false,"return":"boolean","example":"","parameters":{"filename":{"comment":"指定要发送文件的路径","type":"string","options":[]},"offset":{"comment":"上传文件的偏移量,可以指定从文件的中间部分开始传输数据。此特性可用于支持断点续传","type":"int","options":[]},"length":{"comment":"发送数据的尺寸,默认为整个文件的尺寸","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP\/SWOOLE_SOCK_UDP6类型的swoole_client对象。","isStatic":false,"return":"boolean","example":"","parameters":{"ip":{"comment":"目标主机的IP地址,支持IPv4\/IPv6","type":"string","options":[]},"port":{"comment":"目标主机端口","type":"int","options":[]},"data":{"comment":"要发送的数据内容,不得超过64K","type":"string","options":[]}}},"isConnected":{"access":"public","comment":"返回swoole_client的连接状态","isStatic":false,"return":"boolean","example":"","parameters":[]},"getsockname":{"access":"public","comment":"用于获取客户端socket的本地host:port,必须在连接之后才可以使用","isStatic":false,"return":"array","example":"","parameters":[]},"getpeername":{"access":"public","comment":"获取对端socket的IP地址和端口,仅支持SWOOLE_SOCK_UDP\/SWOOLE_SOCK_UDP6类型的swoole_client对象","isStatic":false,"return":"boolean","example":"","parameters":[]},"close":{"access":"public","comment":"关闭连接","isStatic":false,"return":"boolean","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_coroutine_http_client.json b/src/swoole/swoole_coroutine_http_client.json new file mode 100644 index 0000000..3e64ae0 --- /dev/null +++ b/src/swoole/swoole_coroutine_http_client.json @@ -0,0 +1 @@ +{"object":{"name":"Swoole\\Coroutine\\Http\\Client"},"comment":"http协程客户端","namespace":"Swoole\\Coroutine\\Http","consts":[],"properties":{"type":{"access":"public","type":"int","comment":"socket类型","isStatic":false,"value":0},"errCode":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0},"statusCode":{"access":"public","type":"int","comment":"状态码","isStatic":false,"value":0},"host":{"access":"public","type":"string","comment":"请求的服务器地址","isStatic":false},"port":{"access":"public","type":"int","comment":"请求的服务器端口","isStatic":false,"value":0},"requestMethod":{"access":"public","type":"string","comment":"请求方式","isStatic":false},"requestHeaders":{"access":"public","type":"array","comment":"请求头","isStatic":false},"requestBody":{"access":"public","type":"string","comment":"请求体","isStatic":false},"uploadFiles":{"access":"public","type":"array","comment":"上传的文件","isStatic":false},"headers":{"access":"public","type":"array","comment":"请求响应头","isStatic":false},"cookies":{"access":"public","type":"array","comment":"请求响应cookie","isStatic":false},"body":{"access":"public","type":"string","comment":"请求响应后服务器端返回的内容","isStatic":false}},"methods":{"__construct":{"access":"public","comment":"客户端初始化函数","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置选项","isStatic":false,"return":"","example":"","parameters":[]},"setMethod":{"access":"public","comment":"设置请求方式","isStatic":false,"return":"","example":"","parameters":[]},"setHeaders":{"access":"public","comment":"设置请求头","isStatic":false,"return":"","example":"","parameters":[]},"setCookies":{"access":"public","comment":"设置cookie","isStatic":false,"return":"","example":"","parameters":[]},"setData":{"access":"public","comment":"设置Http请求的包体","isStatic":false,"return":"","example":"","parameters":[]},"execute":{"access":"public","comment":"更底层的Http请求方法,需要代码中调用setMethod和setData等接口设置请求的方法和数据","isStatic":false,"return":"","example":"","parameters":[]},"get":{"access":"public","comment":"发起GET请求","isStatic":false,"return":"","example":"","parameters":[]},"post":{"access":"public","comment":"发送POST请求","isStatic":false,"return":"","example":"","parameters":[]},"addFile":{"access":"public","comment":"添加POST文件","isStatic":false,"return":"","example":"","parameters":[]},"isConnected":{"access":"public","comment":"连接是否成功","isStatic":false,"return":"boolean","example":"","parameters":[]},"close":{"access":"public","comment":"关闭连接","isStatic":false,"return":"","example":"","parameters":[]},"setDefer":{"access":"public","comment":"设置是否延迟","isStatic":false,"return":"boolean","example":"","parameters":[]},"getDefer":{"access":"public","comment":"返回当前设置的defer","isStatic":false,"return":"boolean","example":"","parameters":[]},"recv":{"access":"public","comment":"用于从服务器端接收数据。底层会自动yield,等待数据接收完成后自动切换到当前协程","isStatic":false,"return":"string","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_coroutine_mysql.json b/src/swoole/swoole_coroutine_mysql.json new file mode 100644 index 0000000..2a33e8d --- /dev/null +++ b/src/swoole/swoole_coroutine_mysql.json @@ -0,0 +1 @@ +{"object":{"name":"Swoole\\Coroutine\\MySQL"},"comment":"mysql操作协程客户端","namespace":"Swoole\\Coroutine","consts":[],"properties":{"serverInfo":{"access":"private","type":"array","comment":"连接信息,保存的是传递给构造函数的数组","isStatic":false,"value":""},"sock":{"access":"public","type":"int","comment":"连接使用的文件描述符","isStatic":false,"value":0},"connected":{"access":"public","type":"boolean","comment":"是否连接上了MySQL服务器","isStatic":false,"value":false},"connect_error":{"access":"public","type":"string","comment":"连接错误信息","isStatic":false,"value":""},"connect_errno":{"access":"public","type":"int","comment":"连接错误码","isStatic":false,"value":0},"affected_rows":{"access":"public","type":"int","comment":"影响的行数","isStatic":false,"value":0},"insert_id":{"access":"public","type":"int","comment":"最后一个插入的记录id","isStatic":false,"value":0},"error":{"access":"public","type":"string","comment":"错误信息","isStatic":false,"value":""},"errno":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0}},"methods":{"__construct":{"access":"public","comment":"mysql异步客户端初始化","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"connect":{"access":"public","comment":"连接mysql服务器","isStatic":false,"return":"","example":"$server = array(\n 'host' => '192.168.56.102',\n 'user' => 'test',\n 'password' => 'test',\n 'database' => 'test',\n 'charset' => 'utf8',\n);","parameters":{"server_config":{"comment":"连接配置信息","type":"array","options":[]}}},"query":{"access":"public","comment":"执行sql语句","isStatic":false,"return":"array|boolean","example":"","parameters":{"sql":{"comment":"要执行的sql语句","type":"string","options":[]},"timeout":{"comment":"超时时间,超时的话会断开MySQL连接,0表示不设置超时时间","type":"double","options":[]}}},"recv":{"access":"public","comment":"接收包(获取延迟收包的结果,当没有进行延迟收包或者收包超时,返回false)","isStatic":false,"return":"mixed","example":"","parameters":[]},"begin":{"access":"public","comment":"启动事务","isStatic":false,"return":"","example":"","parameters":[]},"commit":{"access":"public","comment":"提交事务","isStatic":false,"return":"","example":"","parameters":[]},"rollback":{"access":"public","comment":"回滚事务(必须先调用begin启动事务才能调用rollback否则底层会抛出异常)","isStatic":false,"return":"","example":"","parameters":[]},"setDefer":{"access":"public","comment":"设置是否延迟","isStatic":false,"return":"boolean","example":"","parameters":{"defer":{"comment":"为true时,表明该Client要延迟收包,为false时,表明该Client非延迟收包,默认值为true","type":"boolean","options":[]}}},"getDefer":{"access":"public","comment":"返回当前设置的defer","isStatic":false,"return":"boolean","example":"","parameters":[]},"close":{"access":"public","comment":"关闭连接","isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_coroutine_mysql_exception.json b/src/swoole/swoole_coroutine_mysql_exception.json new file mode 100644 index 0000000..58adef2 --- /dev/null +++ b/src/swoole/swoole_coroutine_mysql_exception.json @@ -0,0 +1 @@ +{"object":{"name":"Swoole\\Coroutine\\MySQL\\Exception"},"comment":"swoole mysql 协程 异常类","namespace":"Swoole\\Coroutine\\MySQL","extends":"Exception","consts":[],"properties":{"message":{"access":"protected","type":"string","comment":"异常错误信息","isStatic":false,"value":""},"code":{"access":"protected","type":"int","comment":"异常错误码","isStatic":false,"value":0},"file":{"access":"protected","type":"string","comment":"错误文件位置","isStatic":false},"line":{"access":"protected","type":"int","comment":"错误文件行数","isStatic":false}},"methods":{"__clone":{"access":"private","isFinal":1,"comment":"克隆魔术方法(这里禁止克隆)","isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":"异常初始化","isStatic":false,"return":"","example":"","parameters":{"message":{"comment":"异常提示信息","type":"string","options":[]},"code":{"comment":"异常错误码","type":"int","options":[]},"previous":{"comment":"异常链中的前一个异常","type":"Throwable","options":[]}}},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"getMessage":{"access":"public","isFinal":1,"comment":"获取异常提示信息","isStatic":false,"return":"string","example":"","parameters":[]},"getCode":{"access":"public","isFinal":1,"comment":"获取异常代码","isStatic":false,"return":"int","example":"","parameters":[]},"getFile":{"access":"public","isFinal":1,"comment":"创建异常时的程序文件名称","isStatic":false,"return":"string","example":"","parameters":[]},"getLine":{"access":"public","isFinal":1,"comment":"获取创建的异常所在文件中的行号","isStatic":false,"return":"int","example":"","parameters":[]},"getTrace":{"access":"public","isFinal":1,"comment":"获取异常追踪信息","isStatic":false,"return":"array","example":"","parameters":[]},"getPrevious":{"access":"public","isFinal":1,"comment":"返回异常链中的前一个异常","isStatic":false,"return":"Throwable","example":"","parameters":[]},"getTraceAsString":{"access":"public","isFinal":1,"comment":"获取字符串类型的异常追踪信息","isStatic":false,"return":"string","example":"","parameters":[]},"__toString":{"access":"public","comment":"将异常信息转化为字符串","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_event.json b/src/swoole/swoole_event.json new file mode 100644 index 0000000..4d54cf0 --- /dev/null +++ b/src/swoole/swoole_event.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_event"},"comment":"swoole 事件处理","namespace":"","consts":[],"properties":[],"methods":{"add":{"access":"public","comment":"将一个socket加入到底层的reactor事件监听中","isStatic":true,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"read_callback":{"comment":"读事件回调","type":"callable","options":[]},"write_callback":{"comment":"写事件回调","type":"callable","options":[]},"events":{"comment":"事件类型的掩码,可选择关闭\/开启可读可写事件,如SWOOLE_EVENT_READ,SWOOLE_EVENT_WRITE,或者SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE","type":"int","options":[]}}},"del":{"access":"public","comment":"从reactor中移除监听的socket","isStatic":true,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"set":{"access":"public","comment":"修改事件监听的回调函数和掩码","isStatic":true,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"read_callback":{"comment":"将修改可读事件回调函数为指定的函数","type":"callable","options":[]},"write_callback":{"comment":"修改可写事件回调函数为指定的函数","type":"callable","options":[]},"events":{"comment":"可关闭\/开启,可写(SW_EVENT_READ)和可读(SW_EVENT_WRITE)事件的监听","type":"int","options":[]}}},"exit":{"access":"public","comment":"退出事件循环","isStatic":true,"return":"","example":"","parameters":[]},"write":{"access":"public","comment":"将stream\/sockets资源的数据发送变成异步的,当缓冲区满了或者返回EAGAIN,swoole底层会将数据加入到发送队列,并监听可写。socket可写时swoole底层会自动写入","isStatic":true,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"data":{"comment":"写入的数据","type":"string","options":[]}}},"wait":{"access":"public","comment":"使脚本开始进行事件轮询","isStatic":true,"return":"","example":"","parameters":[]},"defer":{"access":"public","comment":"在下一个事件循环开始时执行函数","isStatic":true,"return":"","example":"","parameters":{"callback":{"comment":"执行的函数","type":"callable","options":[]}}},"cycle":{"access":"public","comment":"定义事件循环周期执行函数。此函数会在每一轮事件循环结束时调用","isStatic":true,"return":"","example":"","parameters":{"callback":{"comment":"循环调用的函数","type":"callable","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_exception.json b/src/swoole/swoole_exception.json new file mode 100644 index 0000000..ea1d237 --- /dev/null +++ b/src/swoole/swoole_exception.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_exception"},"comment":"swoole 异常类","namespace":"","extends":"Exception","consts":[],"properties":{"message":{"access":"protected","type":"string","comment":"异常错误信息","isStatic":false,"value":""},"code":{"access":"protected","type":"int","comment":"异常错误码","isStatic":false,"value":0},"file":{"access":"protected","type":"string","comment":"错误文件位置","isStatic":false},"line":{"access":"protected","type":"int","comment":"错误文件行数","isStatic":false}},"methods":{"__clone":{"access":"private","isFinal":1,"comment":"克隆魔术方法(这里禁止克隆)","isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":"异常初始化","isStatic":false,"return":"","example":"","parameters":{"message":{"comment":"异常提示信息","type":"string","options":[]},"code":{"comment":"异常错误码","type":"int","options":[]},"previous":{"comment":"异常链中的前一个异常","type":"Throwable","options":[]}}},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"getMessage":{"access":"public","isFinal":1,"comment":"获取异常提示信息","isStatic":false,"return":"string","example":"","parameters":[]},"getCode":{"access":"public","isFinal":1,"comment":"获取异常代码","isStatic":false,"return":"int","example":"","parameters":[]},"getFile":{"access":"public","isFinal":1,"comment":"创建异常时的程序文件名称","isStatic":false,"return":"string","example":"","parameters":[]},"getLine":{"access":"public","isFinal":1,"comment":"获取创建的异常所在文件中的行号","isStatic":false,"return":"int","example":"","parameters":[]},"getTrace":{"access":"public","isFinal":1,"comment":"获取异常追踪信息","isStatic":false,"return":"array","example":"","parameters":[]},"getPrevious":{"access":"public","isFinal":1,"comment":"返回异常链中的前一个异常","isStatic":false,"return":"Throwable","example":"","parameters":[]},"getTraceAsString":{"access":"public","isFinal":1,"comment":"获取字符串类型的异常追踪信息","isStatic":false,"return":"string","example":"","parameters":[]},"__toString":{"access":"public","comment":"将异常信息转化为字符串","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_http_client.json b/src/swoole/swoole_http_client.json new file mode 100644 index 0000000..377fc25 --- /dev/null +++ b/src/swoole/swoole_http_client.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_http_client"},"comment":"HTTP异步客户端","namespace":"","consts":[],"properties":{"type":{"access":"public","type":"int","comment":"socket类型","isStatic":false,"value":0},"errCode":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0},"sock":{"access":"public","type":"int","comment":"socket的文件描述符","isStatic":false,"value":0},"statusCode":{"access":"public","type":"int","comment":"状态码","isStatic":false,"value":0},"host":{"access":"public","type":"string","comment":"请求的服务器地址","isStatic":false},"port":{"access":"public","type":"int","comment":"请求的服务器端口","isStatic":false,"value":0},"requestMethod":{"access":"public","type":"string","comment":"请求方式","isStatic":false},"requestHeaders":{"access":"public","type":"array","comment":"请求头","isStatic":false},"requestBody":{"access":"public","type":"string","comment":"请求体","isStatic":false},"uploadFiles":{"access":"public","type":"array","comment":"上传的文件","isStatic":false},"set_cookie_headers":{"access":"public","type":"array","comment":"设置请求头中的cookie","isStatic":false},"downloadFile":{"access":"public","type":"string","comment":"下载文件","isStatic":false},"headers":{"access":"public","type":"array","comment":"请求响应头","isStatic":false},"cookies":{"access":"public","type":"array","comment":"请求响应cookie","isStatic":false},"body":{"access":"public","type":"string","comment":"请求响应后服务器端返回的内容","isStatic":false},"onConnect":{"access":"public","type":"callable","comment":"连接成功的回调函数","isStatic":false},"onError":{"access":"public","type":"callable","comment":"连接错误时的回调函数","isStatic":false},"onMessage":{"access":"public","type":"callable","comment":"当接收到消息时的回调函数(websocket)","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"连接关闭时的回调函数","isStatic":false}},"methods":{"__construct":{"access":"public","comment":"客户端连接初始化","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"连接的主机IP","type":"string","options":[]},"port":{"comment":"连接的主机端口","type":"int","options":[]},"ssl":{"comment":"是否开启TLS\/SSL隧道加密,https网站必须设置为true","type":"boolean","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置选项","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"setMethod":{"access":"public","comment":"设置请求方式","isStatic":false,"return":"","example":"","parameters":{"method":{"comment":"请求方式","type":"string","options":[]}}},"setHeaders":{"access":"public","comment":"设置请求头","isStatic":false,"return":"","example":"","parameters":{"headers":{"comment":"请求头","type":"array","options":[]}}},"setCookies":{"access":"public","comment":"设置cookie","isStatic":false,"return":"","example":"","parameters":{"cookies":{"comment":"cookie数组","type":"array","options":[]}}},"setData":{"access":"public","comment":"设置Http请求的包体","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"请求体内容","type":"string","options":[]}}},"addFile":{"access":"public","comment":"添加POST文件","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"文件的路径,必选参数,不能为空文件或者不存在的文件","type":"string","options":[]},"name":{"comment":"表单的名称,必选参数,FILES参数中的key","type":"string","options":[]},"type":{"comment":"文件的MIME格式,可选参数,底层会根据文件的扩展名自动推断","type":"string","options":[]},"filename":{"comment":"文件名称","type":"string","options":[]},"offset":{"comment":"上传文件的偏移量,可以指定从文件的中间部分开始传输数据。此特性可用于支持断点续传。","type":"int","options":[]},"length":{"comment":"发送数据的尺寸,默认为整个文件的尺寸","type":"int","options":[]}}},"execute":{"access":"public","comment":"更底层的Http请求方法,需要代码中调用setMethod和setData等接口设置请求的方法和数据","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"请求地址","type":"string","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"push":{"access":"public","comment":"向WebSocket服务器发送数据","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要发送的数据内容,默认为UTF-8文本格式,如果为其他格式编码或二进制数据,请使用WEBSOCKET_OPCODE_BINARY","type":"string","options":[]},"opcode":{"comment":"操作类型,默认为WEBSOCKET_OPCODE_TEXT_FRAME表示发送文本","type":"int","options":[]},"finish":{"comment":"发送成功后是否结束","type":"boolean","options":[]}}},"get":{"access":"public","comment":"发起GET请求","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"请求路径","type":"string","options":[]},"callback":{"comment":"请求成功后的回调函数","type":"callable","options":[]}}},"post":{"access":"public","comment":"发送POST请求","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"请求地址","type":"string","options":[]},"data":{"comment":"求的包体数据,如果$data为数组底层自动会打包为x-www-form-urlencoded格式的POST内容,并设置Content-Type为application\/x-www-form-urlencoded","type":"mixed","options":[]},"callback":{"comment":"请求成功后的回调","type":"callable","options":[]}}},"upgrade":{"access":"public","comment":"发起WebSocket握手请求,并将连接升级为WebSocket","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"请求地址","type":"string","options":[]},"callback":{"comment":"成功或失败后回调函数","type":"callable","options":[]}}},"download":{"access":"public","comment":"通过Http下载文件","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"请求地址","type":"string","options":[]},"file":{"comment":"指定下载内容写入的文件路径,会自动写入到downloadFile属性","type":"string","options":[]},"callback":{"comment":"下载成功后的回调函数","type":"callable","options":[]},"offset":{"comment":"为0时若文件已存在,底层会自动清空此文件","type":"int","options":[]}}},"isConnected":{"access":"public","comment":"连接是否成功","isStatic":false,"return":"boolean","example":"","parameters":[]},"close":{"access":"public","comment":"关闭连接","isStatic":false,"return":"","example":"","parameters":[]},"on":{"access":"public","comment":"绑定事件","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_http_client_coro.json b/src/swoole/swoole_http_client_coro.json new file mode 100644 index 0000000..590e6cb --- /dev/null +++ b/src/swoole/swoole_http_client_coro.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_http_client_coro"},"comment":false,"namespace":"","consts":[],"properties":{"type":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"errCode":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"statusCode":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"host":{"access":"public","type":"unknown","comment":false,"isStatic":false},"port":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"requestMethod":{"access":"public","type":"unknown","comment":false,"isStatic":false},"requestHeaders":{"access":"public","type":"unknown","comment":false,"isStatic":false},"requestBody":{"access":"public","type":"unknown","comment":false,"isStatic":false},"uploadFiles":{"access":"public","type":"unknown","comment":false,"isStatic":false},"headers":{"access":"public","type":"unknown","comment":false,"isStatic":false},"cookies":{"access":"public","type":"unknown","comment":false,"isStatic":false},"body":{"access":"public","type":"unknown","comment":false,"isStatic":false}},"methods":{"__construct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setMethod":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setHeaders":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setCookies":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setData":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"execute":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"get":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"post":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"addFile":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"isConnected":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"close":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setDefer":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getDefer":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"recv":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_http_request.json b/src/swoole/swoole_http_request.json new file mode 100644 index 0000000..597046f --- /dev/null +++ b/src/swoole/swoole_http_request.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_http_request"},"comment":"http请求对象,保存了Http客户端请求的相关信息,包括GET、POST、COOKIE、Header等","namespace":"","consts":[],"properties":{"fd":{"access":"public","type":"int","comment":"http连接句柄","isStatic":false,"value":0},"header":{"access":"public","type":"array","comment":"请求头(每个key都是小写)","isStatic":false},"server":{"access":"public","type":"array","comment":"请求相当的服务器信息,相当于$_SERVER","isStatic":false},"request":{"access":"public","type":"unknown","comment":false,"isStatic":false},"cookie":{"access":"public","type":"array","comment":"请求中的cookie数据","isStatic":false},"get":{"access":"public","type":"array","comment":"get请求参数","isStatic":false},"files":{"access":"public","type":"array","comment":"请求中的文件上传信息\nname 浏览器上传时传入的文件名称","isStatic":false},"post":{"access":"public","type":"array","comment":"post请求数据","isStatic":false},"tmpfiles":{"access":"public","type":"array","comment":"临时文件信息","isStatic":false}},"methods":{"rawcontent":{"access":"public","comment":"获取请求的原始数据","isStatic":false,"return":"string","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_http_response.json b/src/swoole/swoole_http_response.json new file mode 100644 index 0000000..ae3e01f --- /dev/null +++ b/src/swoole/swoole_http_response.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_http_response"},"comment":"http响应对象","namespace":"","consts":[],"properties":{"fd":{"access":"public","type":"int","comment":"连接句柄","isStatic":false,"value":0},"header":{"access":"public","type":"array","comment":"请求头(每个key都是小写)","isStatic":false},"cookie":{"access":"public","type":"array","comment":"请求中的cookie数据","isStatic":false},"trailer":{"access":"public","type":"unknown","comment":false,"isStatic":false}},"methods":{"initHeader":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"cookie":{"access":"public","comment":"设置cookie","isStatic":false,"return":"","example":"","parameters":{"name":{"comment":"cookie键名","type":"string","options":[]},"value":{"comment":"cookie键值","type":"string","options":[]},"expires":{"comment":"有效期","type":"int","options":[]},"path":{"comment":"存放位置","type":"string","options":[]},"domain":{"comment":"域名","type":"string","options":[]},"secure":{"comment":"是否为HTTPS","type":"boolean","options":[]},"httponly":{"comment":"是否只是http","type":"boolean","options":[]}}},"rawcookie":{"access":"public","comment":"设置最原始的cookie信息","isStatic":false,"return":"","example":"","parameters":{"name":{"comment":"cookie键名","type":"string","options":[]},"value":{"comment":"cookie键值","type":"string","options":[]},"expires":{"comment":"有效期","type":"int","options":[]},"path":{"comment":"存放位置","type":"string","options":[]},"domain":{"comment":"域名","type":"string","options":[]},"secure":{"comment":"是否为HTTPS","type":"boolean","options":[]},"httponly":{"comment":"是否只是http","type":"boolean","options":[]}}},"status":{"access":"public","comment":"设置http状态码","isStatic":false,"return":"","example":"","parameters":{"http_code":{"comment":"状态码","type":"int","options":[]}}},"gzip":{"access":"public","comment":"启用gzip压缩","isStatic":false,"return":"","example":"","parameters":{"compress_level":{"comment":"压缩等级","type":"int","options":[]}}},"header":{"access":"public","comment":"设置响应头信息","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"响应头key","type":"string","options":[]},"value":{"comment":"响应头值","type":"string","options":[]},"ucwords":{"comment":"首字母是否大写","type":"boolean","options":[]}}},"write":{"access":"public","comment":"启用Http Chunk分段向浏览器发送相应内容","isStatic":false,"return":"","example":"","parameters":{"content":{"comment":"输出的内容","type":"string","options":[]}}},"end":{"access":"public","comment":"发送响应体,并结束当前请求","isStatic":false,"return":"","example":"","parameters":{"content":{"comment":"输出的内容","type":"string","options":[]}}},"sendfile":{"access":"public","comment":"发送文件给浏览器","isStatic":false,"return":"","example":"","parameters":{"filename":{"comment":"文件名","type":"string","options":[]},"offset":{"comment":"偏移量","type":"int","options":[]},"length":{"comment":"长度","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_http_server.json b/src/swoole/swoole_http_server.json new file mode 100644 index 0000000..023b42e --- /dev/null +++ b/src/swoole/swoole_http_server.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_http_server"},"comment":"http异步客户端","namespace":"","extends":"swoole_server","consts":[],"properties":{"onConnect":{"access":"public","type":"callable","comment":"连接成功回调函数","isStatic":false},"onReceive":{"access":"public","type":"callable","comment":"接收到数据时回调此函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"TCP客户端连接关闭后,在worker进程中回调此函数","isStatic":false},"onPacket":{"access":"public","type":"callable","comment":"接收到UDP数据包时回调此函数,发生在worker进程中","isStatic":false},"onBufferFull":{"access":"public","type":"callable","comment":"当缓存区达到最高水位时触发此事件","isStatic":false},"onBufferEmpty":{"access":"public","type":"callable","comment":"当缓存区低于最低水位线时触发此事件","isStatic":false},"onStart":{"access":"public","type":"callable","comment":"Server启动在主进程的主线程回调此函数","isStatic":false},"onShutdown":{"access":"public","type":"callable","comment":"此事件在Server正常结束时发生","isStatic":false},"onWorkerStart":{"access":"public","type":"callable","comment":"此事件在Worker进程\/Task进程启动时发生","isStatic":false},"onWorkerStop":{"access":"public","type":"callable","comment":"此事件在worker进程终止时发生。在此函数中可以回收worker进程申请的各类资源","isStatic":false},"onWorkerExit":{"access":"public","type":"callable","comment":"仅在开启reload_async特性后有效。异步重启特性,会先创建新的Worker进程处理新请求,旧的Worker进程自行退出","isStatic":false},"onWorkerError":{"access":"public","type":"callable","comment":"当worker\/task_worker进程发生异常后会在Manager进程内回调此函数","isStatic":false},"onTask":{"access":"public","type":"callable","comment":"在task_worker进程内被调用","isStatic":false},"onFinish":{"access":"public","type":"callable","comment":"当worker进程投递的任务在task_worker中完成时,task进程会通过swoole_server->finish()方法将任务处理的结果发送给worker进程。","isStatic":false},"onManagerStart":{"access":"public","type":"callable","comment":"当管理进程启动时调用它","isStatic":false},"onManagerStop":{"access":"public","type":"callable","comment":"当管理进程结束时调用它","isStatic":false},"onPipeMessage":{"access":"public","type":"callable","comment":"当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件","isStatic":false},"connections":{"access":"public","type":"iterator","comment":"TCP连接迭代器","isStatic":false},"host":{"access":"public","type":"string","comment":"连接的主机","isStatic":false},"port":{"access":"public","type":"int","comment":"连接的主机的端口","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket的类型","isStatic":false,"value":0},"mode":{"access":"public","type":"int","comment":"运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式)","isStatic":false,"value":0},"ports":{"access":"public","type":"array","comment":"当监听多端口时的端口列表","isStatic":false},"master_pid":{"access":"public","type":"int","comment":"主进程ID","isStatic":false,"value":0},"manager_pid":{"access":"public","type":"int","comment":"管理进程ID","isStatic":false,"value":0},"worker_id":{"access":"public","type":"int","comment":"当前工作进程(包括worker进程和task进程)编号","isStatic":false,"value":0},"taskworker":{"access":"public","type":"boolean","comment":"当前进程是否是task工作进程","isStatic":false,"value":false},"worker_pid":{"access":"public","type":"int","comment":"当前工作进程ID(操作系统进程)","isStatic":false,"value":0},"onRequest":{"access":"public","type":"callable","comment":"请求回调函数","isStatic":false},"onHandshake":{"access":"public","type":"callable","comment":"TCP握手时的回调函数","isStatic":false},"setting":{"access":"public","type":"array","comment":"通过swoole_server:set()设置的参数会保存到setting属性上","isStatic":false}},"methods":{"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}},"start":{"access":"public","comment":"启动HTTP server","isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":"swoole_server初始化方法","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"主机IP","type":"string","options":[]},"port":{"comment":"端口","type":"int","options":[]},"mode":{"comment":"运行模式","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"listen":{"access":"public","comment":"添加监听端口(是addlistener的别名)","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"addlistener":{"access":"public","comment":"添加监听端口","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"set":{"access":"public","comment":"设置swoole_server运行时的参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"send":{"access":"public","comment":"向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]},"reactor_id":{"comment":"UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意客户端发送UDP数据包","isStatic":false,"return":"","example":"","parameters":{"ip":{"comment":"IPv4字符串,如192.168.1.102。如果IP不合法会返回错误","type":"string","options":[]},"port":{"comment":"为 1-65535的网络端口号,如果端口错误发送会失败","type":"int","options":[]},"send_data":{"comment":"发送的数据内容,可以是文本或者二进制内容","type":"string","options":[]},"server_socket":{"comment":"服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包","type":"int","options":[]}}},"sendwait":{"access":"public","comment":"阻塞的向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"与客户端连接的句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]}}},"exist":{"access":"public","comment":"检测fd对应的连接是否存在","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"protect":{"access":"public","comment":"设置客户端连接为保护状态,不被心跳线程切断","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"要设置保护状态的客户端连接fd","type":"int","options":[]},"is_protected":{"comment":"设置的状态,true表示保护状态,false表示不保护","type":"boolean","options":[]}}},"sendfile":{"access":"public","comment":"向客户端发送文件","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"连接句柄","type":"int","options":[]},"filename":{"comment":"文件名","type":"string","options":[]},"offset":{"comment":"指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送","type":"int","options":[]},"length":{"comment":"指定发送的长度,默认为文件尺寸","type":"int","options":[]}}},"close":{"access":"public","comment":"关闭客户端连接","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"reset":{"comment":"设置为true会强制关闭连接,丢弃发送队列中的数据","type":"boolean","options":[]}}},"confirm":{"access":"public","comment":"确认连接,与enable_delay_receive或wait_for_bind配合使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"pause":{"access":"public","comment":"停止接收数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"resume":{"access":"public","comment":"恢复数据接收。与pause方法成对使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"task":{"access":"public","comment":"投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]},"finish_callback":{"comment":"完成后的回调函数","type":"callable","options":[]}}},"taskwait":{"access":"public","comment":"以阻塞的形式投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"timeout":{"comment":"超时时间","type":"float","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]}}},"taskWaitMulti":{"access":"public","comment":"并发执行多个Task","isStatic":false,"return":"","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"taskCo":{"access":"public","comment":"并发执行Task并进行协程调度","isStatic":false,"return":"array","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"finish":{"access":"public","comment":"用于在task进程中通知worker进程任务已完成","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"","type":[],"options":[]}}},"reload":{"access":"public","comment":"重启所有工作进程","isStatic":false,"return":"","example":"","parameters":[]},"shutdown":{"access":"public","comment":"关闭服务器","isStatic":false,"return":"","example":"","parameters":[]},"stop":{"access":"public","comment":"停止当前worker进程","isStatic":false,"return":"","example":"","parameters":{"worker_id":{"comment":"工作进程ID","type":"int","options":[]}}},"getLastError":{"access":"public","comment":"获取最近一次操作错误的错误码\n返回的错误码:\n1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据","isStatic":false,"return":"","example":"","parameters":[]},"heartbeat":{"access":"public","comment":"检测所有服务器连接,并找出已经超时的连接","isStatic":false,"return":"","example":"","parameters":{"reactor_id":{"comment":"是否关闭超时的连接,默认为true","type":"boolean","options":[]}}},"connection_info":{"access":"public","comment":"获取客户端连接信息","isStatic":false,"return":"from_id","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"connection_list":{"access":"public","comment":"用来遍历所有客户端连接","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"getClientInfo":{"access":"public","comment":"获取连接的信息,别名是swoole_server->connection_info","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"getClientList":{"access":"public","comment":"用来遍历所有客户端连接(server->connection_list的别名)","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"after":{"access":"public","comment":"在指定时间后执行某个回调函数","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]},"param":{"comment":"给回调函数传入的参数","type":"array","options":[]}}},"tick":{"access":"public","comment":"添加定时器","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"clearTimer":{"access":"public","comment":"清除定时器","isStatic":false,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}},"defer":{"access":"public","comment":"延迟执行一个PHP函数","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"执行的函数","type":"callable","options":[]}}},"sendMessage":{"access":"public","comment":"向任意worker进程或task进程发送消息","isStatic":false,"return":"","example":"","parameters":{"dst_worker_id":{"comment":"目标worker的ID","type":"int","options":[]},"data":{"comment":"发送的消息","type":"string","options":[]}}},"addProcess":{"access":"public","comment":"添加一个自定义的工作进程","isStatic":false,"return":"","example":"","parameters":{"process":{"comment":"进程对象","type":"Swoole\\Process","options":[]}}},"stats":{"access":"public","comment":"得到当前server的活动TCP连接数\narray (","isStatic":false,"return":"","example":"","parameters":[]},"bind":{"access":"public","comment":"将连接绑定到某个用户定义的ID","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"uid":{"comment":"用户定义的ID","type":"int","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_lock.json b/src/swoole/swoole_lock.json new file mode 100644 index 0000000..c168518 --- /dev/null +++ b/src/swoole/swoole_lock.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_lock"},"comment":"锁的实现。PHP代码中可以很方便地创建一个锁,用来实现数据同步。swoole_lock类支持5种锁的类型:","namespace":"","consts":{"FILELOCK":{"comment":"文件锁","type":"int","value":2},"MUTEX":{"comment":"互斥锁","type":"int","value":3},"SEM":{"comment":"信号量","type":"int","value":4},"RWLOCK":{"comment":"读写锁","type":"int","value":1},"SPINLOCK":{"comment":"自旋锁","type":"int","value":5}},"properties":[],"methods":{"__construct":{"access":"public","comment":"创建锁","isStatic":false,"return":"","example":"","parameters":{"type":{"comment":"锁的类型(使用常量)","type":"int","options":[]},"filename":{"comment":"当类型为SWOOLE_FILELOCK时必须传入,指定文件锁的路径","type":"string","options":[]}}},"__destruct":{"access":"public","comment":"析构方法","isStatic":false,"return":"","example":"","parameters":[]},"lock":{"access":"public","comment":"加锁操作","isStatic":false,"return":"","example":"","parameters":[]},"lockwait":{"access":"public","comment":"加锁操作,作用于swoole_lock->lock一致,但lockwait可以设置超时时间","isStatic":false,"return":"","example":"","parameters":{"timeout":{"comment":"超时时间","type":"float","options":[]}}},"trylock":{"access":"public","comment":"非阻塞的加锁操作","isStatic":false,"return":"","example":"","parameters":[]},"lock_read":{"access":"public","comment":"锁定读","isStatic":false,"return":"","example":"","parameters":[]},"trylock_read":{"access":"public","comment":"非阻塞式锁定读","isStatic":false,"return":"","example":"","parameters":[]},"unlock":{"access":"public","comment":"释放锁操作","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_mmap.json b/src/swoole/swoole_mmap.json new file mode 100644 index 0000000..f9a5ec0 --- /dev/null +++ b/src/swoole/swoole_mmap.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_mmap"},"comment":"提供了对操作系统mmap的封装。使用mmap可以很方便地将一个磁盘文件映射为内存,读写性能更高。","namespace":"","consts":[],"properties":[],"methods":{"open":{"access":"public","comment":"创建文件内存映射(执行成功将返回一个PHP的stream资源,可使用PHP提供的流式操作函数读写数据)","isStatic":true,"return":"","example":"","parameters":{"filename":{"comment":"磁盘文件名称,必须是存在的文件,如果文件不存在将会创建失败。可以使用file_put_contents来初始化文件","type":"string","options":[]},"size":{"comment":"映射操作,默认为整个文件的长度,操作系统会分配同等大小的内存。注意不要尝试将超过系统内存尺寸的文件进行映射","type":"int","options":[]},"offset":{"comment":"文件的映射起始位置,默认为0","type":"int","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_mysql.json b/src/swoole/swoole_mysql.json new file mode 100644 index 0000000..8d2812e --- /dev/null +++ b/src/swoole/swoole_mysql.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_mysql"},"comment":"异步MySQL客户端","namespace":"","consts":{"STATE_QUERY":{"comment":"查询状态","type":"int","value":0},"STATE_READ_START":{"comment":"读开始状态","type":"int","value":1},"STATE_READ_FIELD ":{"comment":"读失败状态","type":"int","value":2},"STATE_READ_ROW":{"comment":"读数据行状态","type":"int","value":3},"STATE_READ_END":{"comment":"读完成状态","type":"int","value":4},"STATE_CLOSED":{"comment":"关闭状态","type":"int","value":5}},"properties":{"serverInfo":{"access":"public","type":"array","comment":"连接信息,保存的是传递给构造函数的数组","isStatic":false},"sock":{"access":"public","type":"int","comment":"连接使用的文件描述符","isStatic":false},"connected":{"access":"public","type":"boolean","comment":"是否连接上了MySQL服务器","isStatic":false,"value":false},"errno":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0},"connect_errno":{"access":"public","type":"int","comment":"连接错误码","isStatic":false,"value":0},"error":{"access":"public","type":"string","comment":"错误信息","isStatic":false},"connect_error":{"access":"public","type":"string","comment":"连接错误信息","isStatic":false},"insert_id":{"access":"public","type":"int","comment":"最后一个插入的记录id","isStatic":false},"affected_rows":{"access":"public","type":"int","comment":"影响的行数","isStatic":false},"onConnect":{"access":"public","type":"callable","comment":"连接时的回调函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"关闭连接时的回调函数","isStatic":false}},"methods":{"__construct":{"access":"public","comment":"mysql异步客户端初始化","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"connect":{"access":"public","comment":"连接mysql服务器","isStatic":false,"return":"","example":"$server = array(\n 'host' => '192.168.56.102',\n 'user' => 'test',\n 'password' => 'test',\n 'database' => 'test',\n 'charset' => 'utf8',\n);\n回调函数:function onConnect(swoole_mysql $db, bool $result);","parameters":{"server_config":{"comment":"连接配置信息","type":"array","options":[]},"callback":{"comment":"连接成功的回调","type":"callable","options":[]}}},"begin":{"access":"public","comment":"启动事务","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"启动一个MySQL事务,事务启动成功会回调指定的函数","type":"callable","options":[]}}},"commit":{"access":"public","comment":"提交事务","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"提交事务,当服务器返回响应时回调此函数","type":"callable","options":[]}}},"rollback":{"access":"public","comment":"回滚事务(必须先调用begin启动事务才能调用rollback否则底层会抛出异常)","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"回滚完成后执行的回调","type":"callable","options":[]}}},"query":{"access":"public","comment":"执行sql语句","isStatic":false,"return":"","example":"\n回调函数:function onSQLReady(swoole_mysqli $link, mixed $result);\n注:执行失败,$result为false,读取$link对象的error属性获得错误信息,errno属性获得错误码\n执行成功,SQL为非查询语句,$result为true,读取$link对象的affected_rows属性获得影响的行数,insert_id属性获得Insert操作的自增ID\n执行成功,SQL为查询语句,$result为结果数组","parameters":{"sql":{"comment":"要执行的SQL语句","type":"string","options":[]},"callback":{"comment":"执行成功后会回调此函数","type":"callable","options":[]}}},"close":{"access":"public","comment":"关闭mysql连接","isStatic":false,"return":"","example":"","parameters":[]},"getState":{"access":"public","comment":"获取当前服务器状态","isStatic":false,"return":"int","example":"","parameters":[]},"on":{"access":"public","comment":"设置事件回调函数(目前仅支持onClose事件回调)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称(目前仅支持Close)","type":"String","options":[]},"callback":{"comment":"连接关闭时回调此函数","type":"callable","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_mysql_coro.json b/src/swoole/swoole_mysql_coro.json new file mode 100644 index 0000000..6cb343e --- /dev/null +++ b/src/swoole/swoole_mysql_coro.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_mysql_coro"},"comment":false,"namespace":"","consts":[],"properties":{"serverInfo":{"access":"private","type":"unknown","comment":false,"isStatic":false,"value":""},"sock":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"connected":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":false},"connect_error":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":""},"connect_errno":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"affected_rows":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"insert_id":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"error":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":""},"errno":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0}},"methods":{"__construct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"connect":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"server_config":{"comment":"","type":{},"options":[]}}},"query":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"sql":{"comment":"","type":"unknown","options":[]},"timeout":{"comment":"","type":"unknown","options":[]}}},"recv":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"begin":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"commit":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"rollback":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setDefer":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"defer":{"comment":"","type":"unknown","options":[]}}},"getDefer":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"close":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_mysql_coro_exception.json b/src/swoole/swoole_mysql_coro_exception.json new file mode 100644 index 0000000..5ac0901 --- /dev/null +++ b/src/swoole/swoole_mysql_coro_exception.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_mysql_coro_exception"},"comment":false,"namespace":"","extends":"Exception","consts":[],"properties":{"message":{"access":"protected","type":"unknown","comment":false,"isStatic":false,"value":""},"code":{"access":"protected","type":"unknown","comment":false,"isStatic":false,"value":0},"file":{"access":"protected","type":"unknown","comment":false,"isStatic":false},"line":{"access":"protected","type":"unknown","comment":false,"isStatic":false}},"methods":{"__clone":{"access":"private","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"message":{"comment":"","type":"unknown","options":[]},"code":{"comment":"","type":"unknown","options":[]},"previous":{"comment":"","type":"unknown","options":[]}}},"__wakeup":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getMessage":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getCode":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getFile":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getLine":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getTrace":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getPrevious":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getTraceAsString":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__toString":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_mysql_exception.json b/src/swoole/swoole_mysql_exception.json new file mode 100644 index 0000000..0b642fe --- /dev/null +++ b/src/swoole/swoole_mysql_exception.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_mysql_exception"},"comment":"swoole mysql 异常类","namespace":"","extends":"Exception","consts":[],"properties":{"message":{"access":"protected","type":"string","comment":"异常错误信息","isStatic":false,"value":""},"code":{"access":"protected","type":"int","comment":"异常错误码","isStatic":false,"value":0},"file":{"access":"protected","type":"string","comment":"错误文件位置","isStatic":false},"line":{"access":"protected","type":"int","comment":"错误文件行数","isStatic":false}},"methods":{"__clone":{"access":"private","isFinal":1,"comment":"克隆魔术方法(这里禁止克隆)","isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":"异常初始化","isStatic":false,"return":"","example":"","parameters":{"message":{"comment":"异常提示信息","type":"string","options":[]},"code":{"comment":"异常错误码","type":"int","options":[]},"previous":{"comment":"异常链中的前一个异常","type":"Throwable","options":[]}}},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"getMessage":{"access":"public","isFinal":1,"comment":"获取异常提示信息","isStatic":false,"return":"string","example":"","parameters":[]},"getCode":{"access":"public","isFinal":1,"comment":"获取异常代码","isStatic":false,"return":"int","example":"","parameters":[]},"getFile":{"access":"public","isFinal":1,"comment":"创建异常时的程序文件名称","isStatic":false,"return":"string","example":"","parameters":[]},"getLine":{"access":"public","isFinal":1,"comment":"获取创建的异常所在文件中的行号","isStatic":false,"return":"int","example":"","parameters":[]},"getTrace":{"access":"public","isFinal":1,"comment":"获取异常追踪信息","isStatic":false,"return":"array","example":"","parameters":[]},"getPrevious":{"access":"public","isFinal":1,"comment":"返回异常链中的前一个异常","isStatic":false,"return":"Throwable","example":"","parameters":[]},"getTraceAsString":{"access":"public","isFinal":1,"comment":"获取字符串类型的异常追踪信息","isStatic":false,"return":"string","example":"","parameters":[]},"__toString":{"access":"public","comment":"将异常信息转化为字符串","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_process.json b/src/swoole/swoole_process.json new file mode 100644 index 0000000..504582f --- /dev/null +++ b/src/swoole/swoole_process.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_process"},"comment":"进程管理模块,用来替代PHP的pcntl扩展","namespace":"","consts":{"IPC_NOWAIT":{"comment":"队列设置为非阻塞","type":"int","value":256}},"properties":{"pipe":{"access":"public","type":"unknown","comment":false,"isStatic":false},"callback":{"access":"public","type":"unknown","comment":false,"isStatic":false},"msgQueueId":{"access":"public","type":"unknown","comment":false,"isStatic":false},"msgQueueKey":{"access":"public","type":"unknown","comment":false,"isStatic":false},"pid":{"access":"public","type":"unknown","comment":false,"isStatic":false},"id":{"access":"public","type":"unknown","comment":false,"isStatic":false}},"methods":{"__construct":{"access":"public","comment":"创建子进程","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"子进程创建成功后要执行的函数","type":"callable","options":[]},"redirect_stdin_and_stdout":{"comment":"重定向子进程的标准输入和输出。启用此选项后,在子进程内输出内容将不是打印屏幕,而是写入到主进程管道。读取键盘输入将变为从管道中读取数据。默认为阻塞读取","type":"boolean","options":[]},"pipe_type":{"comment":"是否创建管道,启用$redirect_stdin_stdout后,此选项将忽略用户参数,强制为true。如果子进程内没有进程间通信,可以设置为 false","type":"boolean","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"wait":{"access":"public","comment":"回收结束运行的子进程。","isStatic":true,"return":"","example":"","parameters":{"blocking":{"comment":"指定是否阻塞等待,默认为阻塞","type":"boolean","options":[]}}},"signal":{"access":"public","comment":"设置异步信号监听","isStatic":true,"return":"","example":"","parameters":{"signal_no":{"comment":"信号量","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"alarm":{"access":"public","comment":"高精度定时器,是操作系统setitimer系统调用的封装,可以设置微秒级别的定时器","isStatic":true,"return":"","example":"","parameters":{"usec":{"comment":"定时器间隔时间,单位为微秒。如果为负数表示清除定时器","type":"int","options":[]}}},"kill":{"access":"public","comment":"向子进程发送信号","isStatic":true,"return":"","example":"","parameters":{"pid":{"comment":"进程ID","type":"int","options":[]},"signal_no":{"comment":"信号量(默认的信号为SIGTERM,表示终止进程)","type":"int","options":[]}}},"daemon":{"access":"public","comment":"使当前进程脱变为一个守护进程","isStatic":true,"return":"","example":"","parameters":{"nochdir":{"comment":"为true表示不要切换当前目录到根目录","type":"boolean","options":[]},"noclose":{"comment":"为true表示不要关闭标准输入输出文件描述符","type":"boolean","options":[]}}},"setaffinity":{"access":"public","comment":"设置CPU亲和性,可以将进程绑定到特定的CPU核上","isStatic":true,"return":"","example":"","parameters":{"cpu_settings":{"comment":"表示绑定哪些CPU核,如array(0,2,3)表示绑定CPU0\/CPU2\/CPU3","type":"array","options":[]}}},"setTimeout":{"access":"public","comment":"设置管道读写操作的超时时间","isStatic":false,"return":"","example":"","parameters":{"seconds":{"comment":"单位为秒,支持浮点型,如1.5表示1s+500ms","type":"double","options":[]}}},"useQueue":{"access":"public","comment":"启用消息队列作为进程间通信","isStatic":false,"return":"boolean","example":"","parameters":{"key":{"comment":"消息队列的key,默认会使用ftok(__FILE__, 1)作为KEY","type":"string","options":[]},"mode":{"comment":"通信模式,默认为2,表示争抢模式,所有创建的子进程都会从队列中取数据","type":"int","options":[]}}},"statQueue":{"access":"public","comment":"查看消息队列状态\n返回字段:\nqueue_num 队列中的任务数量;queue_bytes 队列数据的总字节数","isStatic":false,"return":"array","example":"","parameters":[]},"freeQueue":{"access":"public","comment":"删除队列","isStatic":false,"return":"","example":"","parameters":[]},"start":{"access":"public","comment":"执行fork系统调用,启动进程","isStatic":false,"return":"int","example":"","parameters":[]},"write":{"access":"public","comment":"向管道内写入数据","isStatic":false,"return":"int","example":"","parameters":{"data":{"comment":"写入的数据","type":"string","options":[]}}},"close":{"access":"public","comment":"用于关闭创建的好的管道","isStatic":false,"return":"boolean","example":"","parameters":[]},"read":{"access":"public","comment":"从管道中读取数据","isStatic":false,"return":"string | bool","example":"","parameters":{"size":{"comment":"是缓冲区的大小,默认为8192,最大不超过64K","type":"int","options":[]}}},"push":{"access":"public","comment":"向消息队列推送数据","isStatic":false,"return":"boolean","example":"","parameters":{"data":{"comment":"要投递的数据,长度受限与操作系统内核参数的限制。默认为8192,最大不超过65536","type":"string","options":[]}}},"pop":{"access":"public","comment":"从消息队列中获取数据","isStatic":false,"return":"string","example":"","parameters":{"size":{"comment":"表示获取数据的最大尺寸,默认为8192","type":"int","options":[]}}},"exit":{"access":"public","comment":"退出子进程","isStatic":false,"return":"int","example":"","parameters":{"exit_code":{"comment":"退出进程的状态码,如果为0表示正常结束,会继续执行PHP的shutdown_function,其他扩展的清理工作;如果$status不为0,表示异常退出,会立即终止进程。不再执行PHP的shutdown_function,其他扩展的清理工作","type":"int","options":[]}}},"exec":{"access":"public","comment":"执行一个外部程序,此函数是exec系统调用的封装","isStatic":false,"return":"boolean","example":"","parameters":{"exec_file":{"comment":"指定可执行文件的绝对路径,如 \/usr\/bin\/python","type":"string","options":[]},"args":{"comment":"参数列表,如 array('test.py', 123),相当与python test.py 123","type":"array","options":[]}}},"name":{"access":"public","comment":"修改进程名称","isStatic":false,"return":"boolean","example":"","parameters":{"process_name":{"comment":"进程名称","type":"string","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_redis.json b/src/swoole/swoole_redis.json new file mode 100644 index 0000000..4d92237 --- /dev/null +++ b/src/swoole/swoole_redis.json @@ -0,0 +1,97 @@ +{ + "object": { + "name": "Swoole\\Redis" + }, + "comment": "异步redis客户端", + "namespace": "Swoole", + "consts": [], + "properties": [], + "methods": { + "__construct": { + "access": "public", + "comment": "初始化函数", + "isStatic": false, + "return": "", + "example": "", + "parameters": [] + }, + "__destruct": { + "access": "public", + "comment": "析构函数", + "isStatic": false, + "return": "", + "example": "", + "parameters": [] + }, + "on": { + "access": "public", + "comment": "注册事件回调函数", + "isStatic": false, + "return": "", + "example": "", + "parameters": { + "event_name": { + "comment": "事件类型,目前只支持close和message", + "type": "string", + "options": [] + }, + "callback": { + "comment": "事件回调函数", + "type": "callable", + "options": [] + } + } + }, + "connect": { + "access": "public", + "comment": "连接redis服务器", + "isStatic": false, + "return": "", + "example": "", + "parameters": { + "host": { + "comment": "主机", + "type": "string", + "options": [] + }, + "port": { + "comment": "端口", + "type": "int", + "options": [] + }, + "callback": { + "comment": "连接回调函数", + "type": "callable", + "options": [] + } + } + }, + "close": { + "access": "public", + "comment": "关闭redis连接", + "isStatic": false, + "return": "", + "example": "", + "parameters": [] + }, + "__call": { + "access": "public", + "comment": "执行redis命令", + "isStatic": false, + "return": "", + "example": "", + "parameters": { + "command": { + "comment": "redis指令", + "type": "string", + "options": [] + }, + "params": { + "comment": "参数", + "type": "array", + "options": [] + } + } + } + } +} \ No newline at end of file diff --git a/src/swoole/swoole_redis_server.json b/src/swoole/swoole_redis_server.json new file mode 100644 index 0000000..339c0a3 --- /dev/null +++ b/src/swoole/swoole_redis_server.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_redis_server"},"comment":"Swoole实现的Redis Server","namespace":"","extends":"swoole_server","consts":{"NIL":{"comment":"nil类型","type":"int","value":1},"ERROR":{"comment":"错误","type":"int","value":0},"STATUS":{"comment":"状态","type":"int","value":2},"INT":{"comment":"整型","type":"int","value":3},"STRING":{"comment":"字符串型","type":"int","value":4},"SET":{"comment":"集合类型","type":"int","value":5},"MAP":{"comment":"映射类型","type":"int","value":6}},"properties":{"onConnect":{"access":"public","type":"callable","comment":"连接成功回调函数","isStatic":false},"onReceive":{"access":"public","type":"callable","comment":"接收到数据时回调此函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"TCP客户端连接关闭后,在worker进程中回调此函数","isStatic":false},"onPacket":{"access":"public","type":"callable","comment":"接收到UDP数据包时回调此函数,发生在worker进程中","isStatic":false},"onBufferFull":{"access":"public","type":"callable","comment":"当缓存区达到最高水位时触发此事件","isStatic":false},"onBufferEmpty":{"access":"public","type":"callable","comment":"当缓存区低于最低水位线时触发此事件","isStatic":false},"onStart":{"access":"public","type":"callable","comment":"Server启动在主进程的主线程回调此函数","isStatic":false},"onShutdown":{"access":"public","type":"callable","comment":"此事件在Server正常结束时发生","isStatic":false},"onWorkerStart":{"access":"public","type":"callable","comment":"此事件在Worker进程\/Task进程启动时发生","isStatic":false},"onWorkerStop":{"access":"public","type":"callable","comment":"此事件在worker进程终止时发生。在此函数中可以回收worker进程申请的各类资源","isStatic":false},"onWorkerExit":{"access":"public","type":"callable","comment":"仅在开启reload_async特性后有效。异步重启特性,会先创建新的Worker进程处理新请求,旧的Worker进程自行退出","isStatic":false},"onWorkerError":{"access":"public","type":"callable","comment":"当worker\/task_worker进程发生异常后会在Manager进程内回调此函数","isStatic":false},"onTask":{"access":"public","type":"callable","comment":"在task_worker进程内被调用","isStatic":false},"onFinish":{"access":"public","type":"callable","comment":"当worker进程投递的任务在task_worker中完成时,task进程会通过swoole_server->finish()方法将任务处理的结果发送给worker进程。","isStatic":false},"onManagerStart":{"access":"public","type":"callable","comment":"当管理进程启动时调用它","isStatic":false},"onManagerStop":{"access":"public","type":"callable","comment":"当管理进程结束时调用它","isStatic":false},"onPipeMessage":{"access":"public","type":"callable","comment":"当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件","isStatic":false},"setting":{"access":"public","type":"array","comment":"通过swoole_server:set()设置的参数会保存到setting属性上","isStatic":false},"connections":{"access":"public","type":"iterator","comment":"TCP连接迭代器","isStatic":false},"host":{"access":"public","type":"string","comment":"连接的主机","isStatic":false},"port":{"access":"public","type":"int","comment":"连接的主机的端口","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket的类型","isStatic":false,"value":0},"mode":{"access":"public","type":"int","comment":"运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式)","isStatic":false,"value":0},"ports":{"access":"public","type":"array","comment":"当监听多端口时的端口列表","isStatic":false},"master_pid":{"access":"public","type":"int","comment":"主进程ID","isStatic":false,"value":0},"manager_pid":{"access":"public","type":"int","comment":"管理进程ID","isStatic":false,"value":0},"worker_id":{"access":"public","type":"int","comment":"当前工作进程(包括worker进程和task进程)编号","isStatic":false,"value":0},"taskworker":{"access":"public","type":"boolean","comment":"当前进程是否是task工作进程","isStatic":false,"value":false},"worker_pid":{"access":"public","type":"int","comment":"当前工作进程ID(操作系统进程)","isStatic":false,"value":0}},"methods":{"start":{"access":"public","comment":"启动server","isStatic":false,"return":"","example":"","parameters":[]},"setHandler":{"access":"public","comment":"设置Redis命令字的处理器","isStatic":false,"return":"","example":"","parameters":{"command":{"comment":"命令的名称","type":"string","options":[]},"callback":{"comment":"命令的处理函数,回调函数返回字符串类型时会自动发送给客户端","type":"callable","options":[]},"number_of_string_param":{"comment":"字符串参数的长度","type":"int","options":[]},"type_of_array_param":{"comment":"数组参数元素的类型","type":"int","options":[]}}},"format":{"access":"public","comment":"格式化命令响应数据","isStatic":true,"return":"","example":"","parameters":{"type":{"comment":"表示数据类型,NIL类型不需要传入$value,ERROR和STATUS类型$value可选,INT、STRING、SET、MAP必选","type":"int","options":[]},"value":{"comment":"要处理的数据","type":"mixed","options":[]}}},"__construct":{"access":"public","comment":"swoole_server初始化方法","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"主机IP","type":"string","options":[]},"port":{"comment":"端口","type":"int","options":[]},"mode":{"comment":"运行模式","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"listen":{"access":"public","comment":"添加监听端口(是addlistener的别名)","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"addlistener":{"access":"public","comment":"添加监听端口","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}},"set":{"access":"public","comment":"设置swoole_server运行时的参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"send":{"access":"public","comment":"向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]},"reactor_id":{"comment":"UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意客户端发送UDP数据包","isStatic":false,"return":"","example":"","parameters":{"ip":{"comment":"IPv4字符串,如192.168.1.102。如果IP不合法会返回错误","type":"string","options":[]},"port":{"comment":"为 1-65535的网络端口号,如果端口错误发送会失败","type":"int","options":[]},"send_data":{"comment":"发送的数据内容,可以是文本或者二进制内容","type":"string","options":[]},"server_socket":{"comment":"服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包","type":"int","options":[]}}},"sendwait":{"access":"public","comment":"阻塞的向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"与客户端连接的句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]}}},"exist":{"access":"public","comment":"检测fd对应的连接是否存在","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"protect":{"access":"public","comment":"设置客户端连接为保护状态,不被心跳线程切断","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"要设置保护状态的客户端连接fd","type":"int","options":[]},"is_protected":{"comment":"设置的状态,true表示保护状态,false表示不保护","type":"boolean","options":[]}}},"sendfile":{"access":"public","comment":"向客户端发送文件","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"连接句柄","type":"int","options":[]},"filename":{"comment":"文件名","type":"string","options":[]},"offset":{"comment":"指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送","type":"int","options":[]},"length":{"comment":"指定发送的长度,默认为文件尺寸","type":"int","options":[]}}},"close":{"access":"public","comment":"关闭客户端连接","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"reset":{"comment":"设置为true会强制关闭连接,丢弃发送队列中的数据","type":"boolean","options":[]}}},"confirm":{"access":"public","comment":"确认连接,与enable_delay_receive或wait_for_bind配合使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"pause":{"access":"public","comment":"停止接收数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"resume":{"access":"public","comment":"恢复数据接收。与pause方法成对使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"task":{"access":"public","comment":"投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]},"finish_callback":{"comment":"完成后的回调函数","type":"callable","options":[]}}},"taskwait":{"access":"public","comment":"以阻塞的形式投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"timeout":{"comment":"超时时间","type":"float","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]}}},"taskWaitMulti":{"access":"public","comment":"并发执行多个Task","isStatic":false,"return":"","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"taskCo":{"access":"public","comment":"并发执行Task并进行协程调度","isStatic":false,"return":"array","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"finish":{"access":"public","comment":"用于在task进程中通知worker进程任务已完成","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要传递的数据","type":"string","options":[]}}},"reload":{"access":"public","comment":"重启所有工作进程","isStatic":false,"return":"boolean","example":"","parameters":[]},"shutdown":{"access":"public","comment":"关闭服务器","isStatic":false,"return":"","example":"","parameters":[]},"stop":{"access":"public","comment":"停止当前worker进程","isStatic":false,"return":"","example":"","parameters":{"worker_id":{"comment":"进程ID","type":"int","options":[]}}},"getLastError":{"access":"public","comment":"获取最近一次操作错误的错误码\n返回的错误码:\n1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据","isStatic":false,"return":"","example":"","parameters":[]},"heartbeat":{"access":"public","comment":"检测所有服务器连接,并找出已经超时的连接","isStatic":false,"return":"","example":"","parameters":{"reactor_id":{"comment":"是否关闭超时的连接,默认为true","type":"boolean","options":[]}}},"connection_info":{"access":"public","comment":"获取客户端连接信息","isStatic":false,"return":"from_id","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"connection_list":{"access":"public","comment":"用来遍历所有客户端连接","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"getClientInfo":{"access":"public","comment":"获取连接的信息,别名是swoole_server->connection_info","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"getClientList":{"access":"public","comment":"用来遍历所有客户端连接(server->connection_list的别名)","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"after":{"access":"public","comment":"在指定时间后执行某个回调函数","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]},"param":{"comment":"给回调函数传入的参数","type":"array","options":[]}}},"tick":{"access":"public","comment":"添加定时器","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"clearTimer":{"access":"public","comment":"清除定时器","isStatic":false,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}},"defer":{"access":"public","comment":"延迟执行一个PHP函数","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"执行的函数","type":"callable","options":[]}}},"sendMessage":{"access":"public","comment":"向任意worker进程或task进程发送消息","isStatic":false,"return":"","example":"","parameters":{"dst_worker_id":{"comment":"目标worker的ID","type":"int","options":[]},"data":{"comment":"发送的消息","type":"string","options":[]}}},"addProcess":{"access":"public","comment":"添加一个自定义的工作进程","isStatic":false,"return":"","example":"","parameters":{"process":{"comment":"进程对象","type":"Swoole\\Process","options":[]}}},"stats":{"access":"public","comment":"得到当前server的活动TCP连接数\narray (","isStatic":false,"return":"","example":"","parameters":[]},"bind":{"access":"public","comment":"将连接绑定到某个用户定义的ID","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"uid":{"comment":"用户定义的ID","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_serialize.json b/src/swoole/swoole_serialize.json new file mode 100644 index 0000000..07ced9a --- /dev/null +++ b/src/swoole/swoole_serialize.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_serialize"},"comment":"一个高性能的序列化库,其特性如下:1、序列化后的结果为二进制格式,只适合机器读取,不适合人读;2、序列化性能更高,可节省大量CPU资源;3、序列化后的结果数据尺寸更小,可节省内存资源","namespace":"","consts":[],"properties":[],"methods":{"pack":{"access":"public","comment":"将PHP变量序列化","isStatic":true,"return":"string | boolean","example":"","parameters":{"data":{"comment":"为要进行序列化的变量,请注意function和resource类型的变量是不支持序列化的","type":"mixed","options":[]},"flag":{"comment":"是否启用快速模式,swoole_serialize默认会使用静态表保存关联数组的Key,设置此参数为SWOOLE_FAST_PACK后将不再保存数组key","type":"int","options":[]}}},"unpack":{"access":"public","comment":"反序列化","isStatic":true,"return":"mixed","example":"","parameters":{"string":{"comment":"序列化数据,必须是由pack函数生成","type":"string","options":[]},"args":{"comment":"反序列化附加参数,使用UNSERIALIZE_OBJECT_TO_ARRAY或UNSERIALIZE_OBJECT_TO_STDCLASS等常量","type":"int","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_server.json b/src/swoole/swoole_server.json new file mode 100644 index 0000000..8e0dd09 --- /dev/null +++ b/src/swoole/swoole_server.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_server"},"comment":"swoole TCP\/UDP服务器","namespace":"","consts":[],"properties":{"onConnect":{"access":"public","type":"callable","comment":"连接成功回调函数","isStatic":false},"onReceive":{"access":"public","type":"callable","comment":"接收到数据时回调此函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"TCP客户端连接关闭后,在worker进程中回调此函数","isStatic":false},"onPacket":{"access":"public","type":"callable","comment":"接收到UDP数据包时回调此函数,发生在worker进程中","isStatic":false},"onBufferFull":{"access":"public","type":"callable","comment":"当缓存区达到最高水位时触发此事件","isStatic":false},"onBufferEmpty":{"access":"public","type":"callable","comment":"当缓存区低于最低水位线时触发此事件","isStatic":false},"onStart":{"access":"public","type":"callable","comment":"Server启动在主进程的主线程回调此函数","isStatic":false},"onShutdown":{"access":"public","type":"callable","comment":"此事件在Server正常结束时发生","isStatic":false},"onWorkerStart":{"access":"public","type":"callable","comment":"此事件在Worker进程\/Task进程启动时发生","isStatic":false},"onWorkerStop":{"access":"public","type":"callable","comment":"此事件在worker进程终止时发生。在此函数中可以回收worker进程申请的各类资源","isStatic":false},"onWorkerExit":{"access":"public","type":"callable","comment":"仅在开启reload_async特性后有效。异步重启特性,会先创建新的Worker进程处理新请求,旧的Worker进程自行退出","isStatic":false},"onWorkerError":{"access":"public","type":"callable","comment":"当worker\/task_worker进程发生异常后会在Manager进程内回调此函数","isStatic":false},"onTask":{"access":"public","type":"callable","comment":"在task_worker进程内被调用","isStatic":false},"onFinish":{"access":"public","type":"callable","comment":"当worker进程投递的任务在task_worker中完成时,task进程会通过swoole_server->finish()方法将任务处理的结果发送给worker进程。","isStatic":false},"onManagerStart":{"access":"public","type":"callable","comment":"当管理进程启动时调用它","isStatic":false},"onManagerStop":{"access":"public","type":"callable","comment":"当管理进程结束时调用它","isStatic":false},"onPipeMessage":{"access":"public","type":"callable","comment":"当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件","isStatic":false},"setting":{"access":"public","type":"array","comment":"通过swoole_server:set()设置的参数会保存到setting属性上","isStatic":false},"connections":{"access":"public","type":"iterator","comment":"TCP连接迭代器","isStatic":false},"host":{"access":"public","type":"string","comment":"连接的主机","isStatic":false},"port":{"access":"public","type":"int","comment":"连接的主机的端口","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket的类型","isStatic":false,"value":0},"mode":{"access":"public","type":"int","comment":"运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式)","isStatic":false,"value":0},"ports":{"access":"public","type":"array","comment":"当监听多端口时的端口列表","isStatic":false},"master_pid":{"access":"public","type":"int","comment":"主进程ID","isStatic":false,"value":0},"manager_pid":{"access":"public","type":"int","comment":"管理进程ID","isStatic":false,"value":0},"worker_id":{"access":"public","type":"int","comment":"当前工作进程(包括worker进程和task进程)编号","isStatic":false,"value":0},"taskworker":{"access":"public","type":"boolean","comment":"当前进程是否是task工作进程","isStatic":false,"value":false},"worker_pid":{"access":"public","type":"int","comment":"当前工作进程ID(操作系统进程)","isStatic":false,"value":0}},"methods":{"__construct":{"access":"public","comment":"swoole_server初始化方法","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"主机IP","type":"string","options":[]},"port":{"comment":"端口","type":"int","options":[]},"mode":{"comment":"运行模式","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"listen":{"access":"public","comment":"添加监听端口(是addlistener的别名)","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"addlistener":{"access":"public","comment":"添加监听端口","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}},"set":{"access":"public","comment":"设置swoole_server运行时的参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"start":{"access":"public","comment":"启动server","isStatic":false,"return":"","example":"","parameters":[]},"send":{"access":"public","comment":"向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]},"reactor_id":{"comment":"UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意客户端发送UDP数据包","isStatic":false,"return":"","example":"","parameters":{"ip":{"comment":"IPv4字符串,如192.168.1.102。如果IP不合法会返回错误","type":"string","options":[]},"port":{"comment":"为 1-65535的网络端口号,如果端口错误发送会失败","type":"int","options":[]},"send_data":{"comment":"发送的数据内容,可以是文本或者二进制内容","type":"string","options":[]},"server_socket":{"comment":"服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包","type":"int","options":[]}}},"sendwait":{"access":"public","comment":"阻塞的向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"与客户端连接的句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]}}},"exist":{"access":"public","comment":"检测fd对应的连接是否存在","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"protect":{"access":"public","comment":"设置客户端连接为保护状态,不被心跳线程切断","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"要设置保护状态的客户端连接fd","type":"int","options":[]},"is_protected":{"comment":"设置的状态,true表示保护状态,false表示不保护","type":"boolean","options":[]}}},"sendfile":{"access":"public","comment":"向客户端发送文件","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"连接句柄","type":"int","options":[]},"filename":{"comment":"文件名","type":"string","options":[]},"offset":{"comment":"指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送","type":"int","options":[]},"length":{"comment":"指定发送的长度,默认为文件尺寸","type":"int","options":[]}}},"close":{"access":"public","comment":"关闭客户端连接","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"reset":{"comment":"设置为true会强制关闭连接,丢弃发送队列中的数据","type":"boolean","options":[]}}},"confirm":{"access":"public","comment":"确认连接,与enable_delay_receive或wait_for_bind配合使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"pause":{"access":"public","comment":"停止接收数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"resume":{"access":"public","comment":"恢复数据接收。与pause方法成对使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"task":{"access":"public","comment":"投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]},"finish_callback":{"comment":"完成后的回调函数","type":"callable","options":[]}}},"taskwait":{"access":"public","comment":"以阻塞的形式投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"timeout":{"comment":"超时时间","type":"float","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]}}},"taskWaitMulti":{"access":"public","comment":"并发执行多个Task","isStatic":false,"return":"","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"taskCo":{"access":"public","comment":"并发执行Task并进行协程调度","isStatic":false,"return":"array","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"finish":{"access":"public","comment":"用于在task进程中通知worker进程任务已完成","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要传递的数据","type":"string","options":[]}}},"reload":{"access":"public","comment":"重启所有工作进程","isStatic":false,"return":"boolean","example":"","parameters":[]},"shutdown":{"access":"public","comment":"关闭服务器","isStatic":false,"return":"","example":"","parameters":[]},"stop":{"access":"public","comment":"停止当前worker进程","isStatic":false,"return":"","example":"","parameters":{"worker_id":{"comment":"进程ID","type":"int","options":[]}}},"getLastError":{"access":"public","comment":"获取最近一次操作错误的错误码\n返回的错误码:\n1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据","isStatic":false,"return":"","example":"","parameters":[]},"heartbeat":{"access":"public","comment":"检测所有服务器连接,并找出已经超时的连接","isStatic":false,"return":"","example":"","parameters":{"reactor_id":{"comment":"是否关闭超时的连接,默认为true","type":"boolean","options":[]}}},"connection_info":{"access":"public","comment":"获取客户端连接信息","isStatic":false,"return":"from_id","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"connection_list":{"access":"public","comment":"用来遍历所有客户端连接","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"getClientInfo":{"access":"public","comment":"获取连接的信息,别名是swoole_server->connection_info","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"getClientList":{"access":"public","comment":"用来遍历所有客户端连接(server->connection_list的别名)","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"after":{"access":"public","comment":"在指定时间后执行某个回调函数","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]},"param":{"comment":"给回调函数传入的参数","type":"array","options":[]}}},"tick":{"access":"public","comment":"添加定时器","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"clearTimer":{"access":"public","comment":"清除定时器","isStatic":false,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}},"defer":{"access":"public","comment":"延迟执行一个PHP函数","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"执行的函数","type":"callable","options":[]}}},"sendMessage":{"access":"public","comment":"向任意worker进程或task进程发送消息","isStatic":false,"return":"","example":"","parameters":{"dst_worker_id":{"comment":"目标worker的ID","type":"int","options":[]},"data":{"comment":"发送的消息","type":"string","options":[]}}},"addProcess":{"access":"public","comment":"添加一个自定义的工作进程","isStatic":false,"return":"","example":"","parameters":{"process":{"comment":"进程对象","type":"Swoole\\Process","options":[]}}},"stats":{"access":"public","comment":"得到当前server的活动TCP连接数\narray (","isStatic":false,"return":"","example":"","parameters":[]},"bind":{"access":"public","comment":"将连接绑定到某个用户定义的ID","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"uid":{"comment":"用户定义的ID","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_server_port.json b/src/swoole/swoole_server_port.json new file mode 100644 index 0000000..aaad5ba --- /dev/null +++ b/src/swoole/swoole_server_port.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_server_port"},"comment":"TCP端口服务","namespace":"","consts":[],"properties":{"onConnect":{"access":"public","type":"callable","comment":"连接成功回调函数","isStatic":false},"onReceive":{"access":"public","type":"callable","comment":"接收到数据时回调此函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"TCP客户端连接关闭后,在worker进程中回调此函数","isStatic":false},"onPacket":{"access":"public","type":"callable","comment":"接收到UDP数据包时回调此函数,发生在worker进程中","isStatic":false},"onBufferFull":{"access":"public","type":"callable","comment":"当缓存区达到最高水位时触发此事件","isStatic":false},"onBufferEmpty":{"access":"public","type":"callable","comment":"当缓存区低于最低水位线时触发此事件","isStatic":false},"onRequest":{"access":"public","type":"callable","comment":"请求回调函数","isStatic":false},"onHandShake":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onMessage":{"access":"public","type":"callable","comment":"当接收到消息时的回调函数","isStatic":false},"onOpen":{"access":"public","type":"callable","comment":"当连接打开时的回调函数","isStatic":false},"host":{"access":"public","type":"string","comment":"连接的主机","isStatic":false},"port":{"access":"public","type":"int","comment":"连接的主机的端口","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket的类型","isStatic":false,"value":0},"sock":{"access":"public","type":"int","comment":"连接句柄","isStatic":false,"value":0},"setting":{"access":"public","type":"array","comment":"通过swoole_server:set()设置的参数会保存到setting属性上","isStatic":false}},"methods":{"__construct":{"access":"private","comment":"初始化方法","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置swoole_server运行时的参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_table.json b/src/swoole/swoole_table.json new file mode 100644 index 0000000..50414cc --- /dev/null +++ b/src/swoole/swoole_table.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_table"},"comment":"个基于共享内存和锁实现的超高性能,并发数据结构。用于解决多进程\/多线程数据共享和同步加锁问题","namespace":"","consts":{"TYPE_INT":{"comment":"整型","type":"int","value":1},"TYPE_STRING":{"comment":"字符串","type":"int","value":7},"TYPE_FLOAT":{"comment":"浮点型","type":"int","value":6}},"properties":[],"methods":{"__construct":{"access":"public","comment":"创建内存表","isStatic":false,"return":"","example":"","parameters":{"table_size":{"comment":"定表格的最大行数,如果$size不是为2的N次方,如1024、8192,65536等,底层会自动调整为接近的一个数字","type":"int","options":[]},"conflict_proportion":{"comment":"预留作为hash冲突的比例","type":"float","options":[]}}},"column":{"access":"public","comment":"内存表增加一列","isStatic":false,"return":"bool","example":"","parameters":{"name":{"comment":"指定字段的名称","type":"string","options":[]},"type":{"comment":"指定字段类型,支持3种类型,Swoole\\Table::TYPE_INT, Swoole\\Table::TYPE_FLOAT, Swoole\\Table::TYPE_STRING","type":"int","options":[]},"size":{"comment":"指定字符串字段的最大长度,单位为字节","type":"int","options":[]}}},"create":{"access":"public","comment":"创建内存表(在使用column创建内存表结构时执行)","isStatic":false,"return":"","example":"","parameters":[]},"destroy":{"access":"public","comment":"销毁内存表","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置行的数据","isStatic":false,"return":"","example":"$table->set('hello@qq.com', array('id' => 189, 'name' => 'rango3', 'num' => 3.1415));","parameters":{"key":{"comment":"数据的key,相同的$key对应同一行数据,如果set同一个key,会覆盖上一次的数据","type":"string","options":[]},"value":{"comment":"必须是一个数组,必须与字段定义的$name完全相同","type":"array","options":[]}}},"get":{"access":"public","comment":"获取一行数据","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"设置的key值","type":"string","options":[]},"field":{"comment":"字段值","type":"string","options":[]}}},"count":{"access":"public","comment":"获取数据行数","isStatic":false,"return":"int","example":"","parameters":[]},"del":{"access":"public","comment":"删除数据","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"要删除的键","type":"string","options":[]}}},"exist":{"access":"public","comment":"检查table中是否存在某一个key","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"","type":[],"options":[]}}},"incr":{"access":"public","comment":"原子自增操作","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"指定数据的key,如果$key对应的行不存在,默认列的值为0","type":"string","options":[]},"column":{"comment":"指定列名,仅支持浮点型和整型字段","type":"string","options":[]},"incrby":{"comment":"增量,默认为1。如果列为整形,$incrby必须为int型,如果列为浮点型,$incrby必须为float类型失败返回false,成功返回最终的结果数值","type":"mixed","options":[]}}},"decr":{"access":"public","comment":"原子自减操作","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"指定数据的key,如果$key对应的行不存在,默认列的值为0","type":"string","options":[]},"column":{"comment":"指定列名,仅支持浮点型和整型字段","type":"string","options":[]},"decrby":{"comment":"减量,默认为1。如果列为整形,$decrby必须为int型,如果列为浮点型,$decrby必须为float类型失败返回false,成功返回最终的结果数值","type":"mixed","options":[]}}},"getMemorySize":{"access":"public","comment":"获取table占用的内存大小","isStatic":false,"return":"int","example":"","parameters":[]},"offsetExists":{"access":"public","comment":"检查一个偏移位置是否存在","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"offsetGet":{"access":"public","comment":"取一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"offsetSet":{"access":"public","comment":"设置一个偏移位置的值(来自ArrayAccess接口)","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]},"value":{"comment":"需要设置的值","type":"mixed","options":[]}}},"offsetUnset":{"access":"public","comment":"复位一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"rewind":{"access":"public","comment":"返回到迭代器的第一个元素","isStatic":false,"return":"","example":"","parameters":[]},"next":{"access":"public","comment":"向前移动到下一个元素(此方法在 foreach 循环之后被调用)","isStatic":false,"return":"","example":"","parameters":[]},"current":{"access":"public","comment":"返回迭代器当前元素","isStatic":false,"return":"","example":"","parameters":[]},"key":{"access":"public","comment":"返回当前元素的键","isStatic":false,"return":"mixed","example":"","parameters":[]},"valid":{"access":"public","comment":"检查当前位置是否有效(迭代器方法,此方法在 Iterator::rewind() 和 Iterator::next() 方法之后被调用以此用来检查当前位置是否有效)","isStatic":false,"return":"boolean","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_table_row.json b/src/swoole/swoole_table_row.json new file mode 100644 index 0000000..4906d3a --- /dev/null +++ b/src/swoole/swoole_table_row.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_table_row"},"comment":"内存表行","namespace":"","consts":[],"properties":{"key":{"access":"public","type":"string","comment":"行对应的键","isStatic":false},"value":{"access":"public","type":"mixed","comment":"行值","isStatic":false}},"methods":{"offsetExists":{"access":"public","comment":"检查一个偏移位置是否存在","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"offsetGet":{"access":"public","comment":"取一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"offsetSet":{"access":"public","comment":"设置一个偏移位置的值(来自ArrayAccess接口)","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]},"value":{"comment":"需要设置的值","type":"mixed","options":[]}}},"offsetUnset":{"access":"public","comment":"复位一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"__destruct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_timer.json b/src/swoole/swoole_timer.json new file mode 100644 index 0000000..f0433bc --- /dev/null +++ b/src/swoole/swoole_timer.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_timer"},"comment":"swoole定时器","namespace":"","consts":[],"properties":[],"methods":{"tick":{"access":"public","comment":"设置一个间隔时钟定时器,与after定时器不同的是tick定时器会持续触发,直到调用swoole_timer_clear清除","isStatic":true,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]},"param":{"comment":"用户参数, 该参数会被传递到$callback_function中. 如果有多个参数可以使用数组形式. 也可以使用匿名函数的use语法传递参数到回调函数中","type":"mixed","options":[]}}},"after":{"access":"public","comment":"在指定的时间后执行函数","isStatic":true,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"exists":{"access":"public","comment":"检查某个定时器是否存在","isStatic":true,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}},"clear":{"access":"public","comment":"删除指定的定时器","isStatic":true,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_websocket_frame.json b/src/swoole/swoole_websocket_frame.json new file mode 100644 index 0000000..3ac1cb2 --- /dev/null +++ b/src/swoole/swoole_websocket_frame.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_websocket_frame"},"comment":"swoole websocket 帧","namespace":"","consts":[],"properties":[],"methods":[]} \ No newline at end of file diff --git a/src/swoole/swoole_websocket_server.json b/src/swoole/swoole_websocket_server.json new file mode 100644 index 0000000..9839dad --- /dev/null +++ b/src/swoole/swoole_websocket_server.json @@ -0,0 +1 @@ +{"object":{"name":"swoole_websocket_server"},"comment":"swoole websocket服务端","namespace":"","extends":"swoole_http_server","consts":[],"properties":{"onConnect":{"access":"public","type":"callable","comment":"连接成功回调函数","isStatic":false},"onReceive":{"access":"public","type":"callable","comment":"接收到数据时回调此函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"TCP客户端连接关闭后,在worker进程中回调此函数","isStatic":false},"onPacket":{"access":"public","type":"callable","comment":"接收到UDP数据包时回调此函数,发生在worker进程中","isStatic":false},"onBufferFull":{"access":"public","type":"callable","comment":"当缓存区达到最高水位时触发此事件","isStatic":false},"onBufferEmpty":{"access":"public","type":"callable","comment":"当缓存区低于最低水位线时触发此事件","isStatic":false},"onStart":{"access":"public","type":"callable","comment":"Server启动在主进程的主线程回调此函数","isStatic":false},"onShutdown":{"access":"public","type":"callable","comment":"此事件在Server正常结束时发生","isStatic":false},"onWorkerStart":{"access":"public","type":"callable","comment":"此事件在Worker进程\/Task进程启动时发生","isStatic":false},"onWorkerStop":{"access":"public","type":"callable","comment":"此事件在worker进程终止时发生。在此函数中可以回收worker进程申请的各类资源","isStatic":false},"onWorkerExit":{"access":"public","type":"callable","comment":"仅在开启reload_async特性后有效。异步重启特性,会先创建新的Worker进程处理新请求,旧的Worker进程自行退出","isStatic":false},"onWorkerError":{"access":"public","type":"callable","comment":"当worker\/task_worker进程发生异常后会在Manager进程内回调此函数","isStatic":false},"onTask":{"access":"public","type":"callable","comment":"在task_worker进程内被调用","isStatic":false},"onFinish":{"access":"public","type":"callable","comment":"当worker进程投递的任务在task_worker中完成时,task进程会通过swoole_server->finish()方法将任务处理的结果发送给worker进程。","isStatic":false},"onManagerStart":{"access":"public","type":"callable","comment":"当管理进程启动时调用它","isStatic":false},"onManagerStop":{"access":"public","type":"callable","comment":"当管理进程结束时调用它","isStatic":false},"onPipeMessage":{"access":"public","type":"callable","comment":"当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件","isStatic":false},"connections":{"access":"public","type":"iterator","comment":"TCP连接迭代器","isStatic":false},"host":{"access":"public","type":"string","comment":"连接的主机","isStatic":false},"port":{"access":"public","type":"int","comment":"连接的主机的端口","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket的类型","isStatic":false,"value":0},"mode":{"access":"public","type":"int","comment":"运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式)","isStatic":false,"value":0},"ports":{"access":"public","type":"array","comment":"当监听多端口时的端口列表","isStatic":false},"master_pid":{"access":"public","type":"int","comment":"主进程ID","isStatic":false,"value":0},"manager_pid":{"access":"public","type":"int","comment":"管理进程ID","isStatic":false,"value":0},"worker_id":{"access":"public","type":"int","comment":"当前工作进程(包括worker进程和task进程)编号","isStatic":false,"value":0},"taskworker":{"access":"public","type":"boolean","comment":"当前进程是否是task工作进程","isStatic":false,"value":false},"worker_pid":{"access":"public","type":"int","comment":"当前工作进程ID(操作系统进程)","isStatic":false,"value":0},"onRequest":{"access":"public","type":"callable","comment":"请求回调函数","isStatic":false},"onHandshake":{"access":"public","type":"callable","comment":"TCP握手时的回调函数","isStatic":false},"setting":{"access":"public","type":"array","comment":"通过swoole_server:set()设置的参数会保存到setting属性上","isStatic":false}},"methods":{"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}},"push":{"access":"public","comment":"向websocket客户端连接推送数据,长度最大不得超过2M","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"客户端连接的ID,如果指定的$fd对应的TCP连接并非websocket客户端,将会发送失败","type":"int","options":[]},"data":{"comment":"要发送的数据内容","type":"string","options":[]},"opcode":{"comment":"指定发送数据内容的格式,默认为文本。发送二进制内容$opcode参数需要设置","type":"int","options":[]},"finish":{"comment":"帧是否完成","type":"boolean","options":[]}}},"exist":{"access":"public","comment":"检测fd对应的连接是否存在","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"pack":{"access":"public","comment":"打包数据","isStatic":true,"return":"","example":"","parameters":{"data":{"comment":"消息内容","type":"string","options":[]},"opcode":{"comment":"WebSocket的opcode指令类型,1表示文本,2表示二进制数据,9表示心跳ping","type":"int","options":[]},"finish":{"comment":"帧是否完成","type":"boolean","options":[]},"mask":{"comment":"是否设置掩码","type":"boolean","options":[]}}},"unpack":{"access":"public","comment":"参数据进行解包","isStatic":true,"return":"","example":"","parameters":{"data":{"comment":"解包的数据","type":"string","options":[]}}},"start":{"access":"public","comment":"启动server","isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":"swoole_server初始化方法","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"主机IP","type":"string","options":[]},"port":{"comment":"端口","type":"int","options":[]},"mode":{"comment":"运行模式","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"listen":{"access":"public","comment":"添加监听端口(是addlistener的别名)","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"addlistener":{"access":"public","comment":"添加监听端口","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"set":{"access":"public","comment":"设置swoole_server运行时的参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"send":{"access":"public","comment":"向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]},"reactor_id":{"comment":"UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意客户端发送UDP数据包","isStatic":false,"return":"","example":"","parameters":{"ip":{"comment":"IPv4字符串,如192.168.1.102。如果IP不合法会返回错误","type":"string","options":[]},"port":{"comment":"为 1-65535的网络端口号,如果端口错误发送会失败","type":"int","options":[]},"send_data":{"comment":"发送的数据内容,可以是文本或者二进制内容","type":"string","options":[]},"server_socket":{"comment":"服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包","type":"int","options":[]}}},"sendwait":{"access":"public","comment":"阻塞的向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"与客户端连接的句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]}}},"protect":{"access":"public","comment":"设置客户端连接为保护状态,不被心跳线程切断","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"要设置保护状态的客户端连接fd","type":"int","options":[]},"is_protected":{"comment":"设置的状态,true表示保护状态,false表示不保护","type":"boolean","options":[]}}},"sendfile":{"access":"public","comment":"向客户端发送文件","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"连接句柄","type":"int","options":[]},"filename":{"comment":"文件名","type":"string","options":[]},"offset":{"comment":"指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送","type":"int","options":[]},"length":{"comment":"指定发送的长度,默认为文件尺寸","type":"int","options":[]}}},"close":{"access":"public","comment":"关闭客户端连接","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"reset":{"comment":"设置为true会强制关闭连接,丢弃发送队列中的数据","type":"boolean","options":[]}}},"confirm":{"access":"public","comment":"确认连接,与enable_delay_receive或wait_for_bind配合使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"pause":{"access":"public","comment":"停止接收数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"resume":{"access":"public","comment":"恢复数据接收。与pause方法成对使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"task":{"access":"public","comment":"投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]},"finish_callback":{"comment":"完成后的回调函数","type":"callable","options":[]}}},"taskwait":{"access":"public","comment":"以阻塞的形式投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"timeout":{"comment":"超时时间","type":"float","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]}}},"taskWaitMulti":{"access":"public","comment":"并发执行多个Task","isStatic":false,"return":"","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"taskCo":{"access":"public","comment":"并发执行Task并进行协程调度","isStatic":false,"return":"array","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"finish":{"access":"public","comment":"用于在task进程中通知worker进程任务已完成","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要传递的数据","type":"string","options":[]}}},"reload":{"access":"public","comment":"重启所有工作进程","isStatic":false,"return":"boolean","example":"","parameters":[]},"shutdown":{"access":"public","comment":"关闭服务器","isStatic":false,"return":"","example":"","parameters":[]},"stop":{"access":"public","comment":"停止当前worker进程","isStatic":false,"return":"","example":"","parameters":{"worker_id":{"comment":"进程ID","type":"int","options":[]}}},"getLastError":{"access":"public","comment":"获取最近一次操作错误的错误码\n返回的错误码:\n1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据","isStatic":false,"return":"","example":"","parameters":[]},"heartbeat":{"access":"public","comment":"检测所有服务器连接,并找出已经超时的连接","isStatic":false,"return":"","example":"","parameters":{"reactor_id":{"comment":"是否关闭超时的连接,默认为true","type":"boolean","options":[]}}},"connection_info":{"access":"public","comment":"获取客户端连接信息","isStatic":false,"return":"from_id","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"connection_list":{"access":"public","comment":"用来遍历所有客户端连接","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"getClientInfo":{"access":"public","comment":"获取连接的信息,别名是swoole_server->connection_info","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"getClientList":{"access":"public","comment":"用来遍历所有客户端连接(server->connection_list的别名)","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"after":{"access":"public","comment":"在指定时间后执行某个回调函数","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]},"param":{"comment":"给回调函数传入的参数","type":"array","options":[]}}},"tick":{"access":"public","comment":"添加定时器","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"clearTimer":{"access":"public","comment":"清除定时器","isStatic":false,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}},"defer":{"access":"public","comment":"延迟执行一个PHP函数","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"执行的函数","type":"callable","options":[]}}},"sendMessage":{"access":"public","comment":"向任意worker进程或task进程发送消息","isStatic":false,"return":"","example":"","parameters":{"dst_worker_id":{"comment":"目标worker的ID","type":"int","options":[]},"data":{"comment":"发送的消息","type":"string","options":[]}}},"addProcess":{"access":"public","comment":"添加一个自定义的工作进程","isStatic":false,"return":"","example":"","parameters":{"process":{"comment":"进程对象","type":"Swoole\\Process","options":[]}}},"stats":{"access":"public","comment":"得到当前server的活动TCP连接数\narray (","isStatic":false,"return":"","example":"","parameters":[]},"bind":{"access":"public","comment":"将连接绑定到某个用户定义的ID","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"uid":{"comment":"用户定义的ID","type":"int","options":[]}}}}} \ No newline at end of file From 34eb6703521c0e9146545b9cf951e4583d15ebaa Mon Sep 17 00:00:00 2001 From: shixinke Date: Tue, 26 Dec 2017 18:44:38 +0800 Subject: [PATCH 02/34] =?UTF-8?q?=E6=9B=B4=E6=96=B0swoole=E5=88=B02.0.10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Swoole/Async.php | 123 +++ src/Swoole/Atomic.php | 123 +++ src/Swoole/Atomic/Long.php | 101 +++ src/Swoole/Buffer.php | 159 ++++ src/Swoole/Channel.php | 67 ++ src/Swoole/Client.php | 327 ++++++++ src/Swoole/Connection/Iterator.php | 120 +++ src/Swoole/Coroutine.php | 96 +++ src/Swoole/Coroutine/Client.php | 216 +++++ src/Swoole/Coroutine/Http/Client.php | 279 +++++++ src/Swoole/Coroutine/MySQL.php | 218 +++++ src/Swoole/Coroutine/MySQL/Exception.php | 156 ++++ src/Swoole/Event.php | 108 +++ src/Swoole/Exception.php | 156 ++++ src/Swoole/Http/Client.php | 350 ++++++++ src/Swoole/Http/Request.php | 119 +++ src/Swoole/Http/Response.php | 187 +++++ src/Swoole/Http/Server.php | 712 ++++++++++++++++ src/Swoole/Lock.php | 123 +++ src/Swoole/Mmap.php | 28 + src/Swoole/MySQL.php | 242 ++++++ src/Swoole/MySQL/Exception.php | 156 ++++ src/Swoole/Process.php | 297 +++++++ src/Swoole/Redis/Server.php | 759 ++++++++++++++++++ src/Swoole/Serialize.php | 39 + src/Swoole/Server.php | 698 ++++++++++++++++ src/Swoole/Server/Port.php | 183 +++++ src/Swoole/Table.php | 282 +++++++ src/Swoole/Table/Row.php | 84 ++ src/Swoole/Timer.php | 62 ++ src/Swoole/WebSocket/Frame.php | 15 + src/Swoole/WebSocket/Server.php | 751 +++++++++++++++++ src/Swoole/swoole.namespace.php | 584 ++++++++++++++ src/Swoole/swoole.php | 584 ++++++++++++++ src/Swoole/swoole_async.php | 122 +++ src/Swoole/swoole_atomic.php | 122 +++ src/Swoole/swoole_atomic_long.php | 100 +++ src/Swoole/swoole_buffer.php | 158 ++++ src/Swoole/swoole_channel.php | 66 ++ src/Swoole/swoole_client.php | 326 ++++++++ src/Swoole/swoole_client_coro.php | 215 +++++ src/Swoole/swoole_connection_iterator.php | 119 +++ src/Swoole/swoole_coroutine.php | 95 +++ src/Swoole/swoole_event.php | 107 +++ src/Swoole/swoole_exception.php | 155 ++++ src/Swoole/swoole_http_client.php | 349 ++++++++ src/Swoole/swoole_http_client_coro.php | 278 +++++++ src/Swoole/swoole_http_request.php | 118 +++ src/Swoole/swoole_http_response.php | 186 +++++ src/Swoole/swoole_http_server.php | 711 ++++++++++++++++ src/Swoole/swoole_lock.php | 122 +++ src/Swoole/swoole_mmap.php | 27 + src/Swoole/swoole_mysql.php | 241 ++++++ src/Swoole/swoole_mysql_coro.php | 211 +++++ src/Swoole/swoole_mysql_coro_exception.php | 155 ++++ src/Swoole/swoole_mysql_exception.php | 155 ++++ src/Swoole/swoole_process.php | 296 +++++++ src/Swoole/swoole_redis_server.php | 758 +++++++++++++++++ src/Swoole/swoole_serialize.php | 38 + src/Swoole/swoole_server.php | 697 ++++++++++++++++ src/Swoole/swoole_server_port.php | 182 +++++ src/Swoole/swoole_table.php | 281 +++++++ src/Swoole/swoole_table_row.php | 83 ++ src/Swoole/swoole_timer.php | 61 ++ src/Swoole/swoole_websocket_frame.php | 14 + src/Swoole/swoole_websocket_server.php | 750 +++++++++++++++++ src/swoole/swoole.json | 1 - src/swoole/swoole_async.json | 1 - src/swoole/swoole_atomic.json | 1 - src/swoole/swoole_atomic_long.json | 1 - src/swoole/swoole_buffer.json | 1 - src/swoole/swoole_channel.json | 1 - src/swoole/swoole_client.json | 1 - src/swoole/swoole_client_coro.json | 1 - src/swoole/swoole_connection_iterator.json | 1 - src/swoole/swoole_coroutine.json | 1 - src/swoole/swoole_coroutine_client.json | 1 - src/swoole/swoole_coroutine_http_client.json | 1 - src/swoole/swoole_coroutine_mysql.json | 1 - .../swoole_coroutine_mysql_exception.json | 1 - src/swoole/swoole_event.json | 1 - src/swoole/swoole_exception.json | 1 - src/swoole/swoole_http_client.json | 1 - src/swoole/swoole_http_client_coro.json | 1 - src/swoole/swoole_http_request.json | 1 - src/swoole/swoole_http_response.json | 1 - src/swoole/swoole_http_server.json | 1 - src/swoole/swoole_lock.json | 1 - src/swoole/swoole_mmap.json | 1 - src/swoole/swoole_mysql.json | 1 - src/swoole/swoole_mysql_coro.json | 1 - src/swoole/swoole_mysql_coro_exception.json | 1 - src/swoole/swoole_mysql_exception.json | 1 - src/swoole/swoole_process.json | 1 - src/swoole/swoole_redis.json | 97 --- src/swoole/swoole_redis_server.json | 1 - src/swoole/swoole_serialize.json | 1 - src/swoole/swoole_server.json | 1 - src/swoole/swoole_server_port.json | 1 - src/swoole/swoole_table.json | 1 - src/swoole/swoole_table_row.json | 1 - src/swoole/swoole_timer.json | 1 - src/swoole/swoole_websocket_frame.json | 1 - src/swoole/swoole_websocket_server.json | 1 - 104 files changed, 15802 insertions(+), 134 deletions(-) create mode 100644 src/Swoole/Async.php create mode 100644 src/Swoole/Atomic.php create mode 100644 src/Swoole/Atomic/Long.php create mode 100644 src/Swoole/Buffer.php create mode 100644 src/Swoole/Channel.php create mode 100644 src/Swoole/Client.php create mode 100644 src/Swoole/Connection/Iterator.php create mode 100644 src/Swoole/Coroutine.php create mode 100644 src/Swoole/Coroutine/Client.php create mode 100644 src/Swoole/Coroutine/Http/Client.php create mode 100644 src/Swoole/Coroutine/MySQL.php create mode 100644 src/Swoole/Coroutine/MySQL/Exception.php create mode 100644 src/Swoole/Event.php create mode 100644 src/Swoole/Exception.php create mode 100644 src/Swoole/Http/Client.php create mode 100644 src/Swoole/Http/Request.php create mode 100644 src/Swoole/Http/Response.php create mode 100644 src/Swoole/Http/Server.php create mode 100644 src/Swoole/Lock.php create mode 100644 src/Swoole/Mmap.php create mode 100644 src/Swoole/MySQL.php create mode 100644 src/Swoole/MySQL/Exception.php create mode 100644 src/Swoole/Process.php create mode 100644 src/Swoole/Redis/Server.php create mode 100644 src/Swoole/Serialize.php create mode 100644 src/Swoole/Server.php create mode 100644 src/Swoole/Server/Port.php create mode 100644 src/Swoole/Table.php create mode 100644 src/Swoole/Table/Row.php create mode 100644 src/Swoole/Timer.php create mode 100644 src/Swoole/WebSocket/Frame.php create mode 100644 src/Swoole/WebSocket/Server.php create mode 100644 src/Swoole/swoole.namespace.php create mode 100644 src/Swoole/swoole.php create mode 100644 src/Swoole/swoole_async.php create mode 100644 src/Swoole/swoole_atomic.php create mode 100644 src/Swoole/swoole_atomic_long.php create mode 100644 src/Swoole/swoole_buffer.php create mode 100644 src/Swoole/swoole_channel.php create mode 100644 src/Swoole/swoole_client.php create mode 100644 src/Swoole/swoole_client_coro.php create mode 100644 src/Swoole/swoole_connection_iterator.php create mode 100644 src/Swoole/swoole_coroutine.php create mode 100644 src/Swoole/swoole_event.php create mode 100644 src/Swoole/swoole_exception.php create mode 100644 src/Swoole/swoole_http_client.php create mode 100644 src/Swoole/swoole_http_client_coro.php create mode 100644 src/Swoole/swoole_http_request.php create mode 100644 src/Swoole/swoole_http_response.php create mode 100644 src/Swoole/swoole_http_server.php create mode 100644 src/Swoole/swoole_lock.php create mode 100644 src/Swoole/swoole_mmap.php create mode 100644 src/Swoole/swoole_mysql.php create mode 100644 src/Swoole/swoole_mysql_coro.php create mode 100644 src/Swoole/swoole_mysql_coro_exception.php create mode 100644 src/Swoole/swoole_mysql_exception.php create mode 100644 src/Swoole/swoole_process.php create mode 100644 src/Swoole/swoole_redis_server.php create mode 100644 src/Swoole/swoole_serialize.php create mode 100644 src/Swoole/swoole_server.php create mode 100644 src/Swoole/swoole_server_port.php create mode 100644 src/Swoole/swoole_table.php create mode 100644 src/Swoole/swoole_table_row.php create mode 100644 src/Swoole/swoole_timer.php create mode 100644 src/Swoole/swoole_websocket_frame.php create mode 100644 src/Swoole/swoole_websocket_server.php delete mode 100644 src/swoole/swoole.json delete mode 100644 src/swoole/swoole_async.json delete mode 100644 src/swoole/swoole_atomic.json delete mode 100644 src/swoole/swoole_atomic_long.json delete mode 100644 src/swoole/swoole_buffer.json delete mode 100644 src/swoole/swoole_channel.json delete mode 100644 src/swoole/swoole_client.json delete mode 100644 src/swoole/swoole_client_coro.json delete mode 100644 src/swoole/swoole_connection_iterator.json delete mode 100644 src/swoole/swoole_coroutine.json delete mode 100644 src/swoole/swoole_coroutine_client.json delete mode 100644 src/swoole/swoole_coroutine_http_client.json delete mode 100644 src/swoole/swoole_coroutine_mysql.json delete mode 100644 src/swoole/swoole_coroutine_mysql_exception.json delete mode 100644 src/swoole/swoole_event.json delete mode 100644 src/swoole/swoole_exception.json delete mode 100644 src/swoole/swoole_http_client.json delete mode 100644 src/swoole/swoole_http_client_coro.json delete mode 100644 src/swoole/swoole_http_request.json delete mode 100644 src/swoole/swoole_http_response.json delete mode 100644 src/swoole/swoole_http_server.json delete mode 100644 src/swoole/swoole_lock.json delete mode 100644 src/swoole/swoole_mmap.json delete mode 100644 src/swoole/swoole_mysql.json delete mode 100644 src/swoole/swoole_mysql_coro.json delete mode 100644 src/swoole/swoole_mysql_coro_exception.json delete mode 100644 src/swoole/swoole_mysql_exception.json delete mode 100644 src/swoole/swoole_process.json delete mode 100644 src/swoole/swoole_redis.json delete mode 100644 src/swoole/swoole_redis_server.json delete mode 100644 src/swoole/swoole_serialize.json delete mode 100644 src/swoole/swoole_server.json delete mode 100644 src/swoole/swoole_server_port.json delete mode 100644 src/swoole/swoole_table.json delete mode 100644 src/swoole/swoole_table_row.json delete mode 100644 src/swoole/swoole_timer.json delete mode 100644 src/swoole/swoole_websocket_frame.json delete mode 100644 src/swoole/swoole_websocket_server.json diff --git a/src/Swoole/Async.php b/src/Swoole/Async.php new file mode 100644 index 0000000..b17078e --- /dev/null +++ b/src/Swoole/Async.php @@ -0,0 +1,123 @@ + '192.168.56.102', + * 'user' => 'test', + * 'password' => 'test', + * 'database' => 'test', + * 'charset' => 'utf8', + * ); + * @param array $server_config 连接配置信息 + * @return + */ + public function connect(Array $server_config) + { + } + + /** + * + *执行sql语句 + * @example + * @param string $sql 要执行的sql语句 + * @param double $timeout 超时时间,超时的话会断开MySQL连接,0表示不设置超时时间 + * @return array|boolean + */ + public function query($sql, $timeout) + { + } + + /** + * + *接收包(获取延迟收包的结果,当没有进行延迟收包或者收包超时,返回false) + * @example + * @return mixed + */ + public function recv() + { + } + + /** + * + *启动事务 + * @example + * @return + */ + public function begin() + { + } + + /** + * + *提交事务 + * @example + * @return + */ + public function commit() + { + } + + /** + * + *回滚事务(必须先调用begin启动事务才能调用rollback否则底层会抛出异常) + * @example + * @return + */ + public function rollback() + { + } + + /** + * + *设置是否延迟 + * @example + * @param boolean $defer 为true时,表明该Client要延迟收包,为false时,表明该Client非延迟收包,默认值为true + * @return boolean + */ + public function setDefer($defer) + { + } + + /** + * + *返回当前设置的defer + * @example + * @return boolean + */ + public function getDefer() + { + } + + /** + * + *关闭连接 + * @example + * @return + */ + public function close() + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + +} + diff --git a/src/Swoole/Coroutine/MySQL/Exception.php b/src/Swoole/Coroutine/MySQL/Exception.php new file mode 100644 index 0000000..6c651d2 --- /dev/null +++ b/src/Swoole/Coroutine/MySQL/Exception.php @@ -0,0 +1,156 @@ +finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * @var callable $onRequest + * 请求回调函数 + * @access public + */ + public $onRequest; + + /** + * @var callable $onHandshake + * TCP握手时的回调函数 + * @access public + */ + public $onHandshake; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *启动HTTP server + * @example + * @return + */ + public function start() + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param mixed $data + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 工作进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + +} + diff --git a/src/Swoole/Lock.php b/src/Swoole/Lock.php new file mode 100644 index 0000000..afa0db4 --- /dev/null +++ b/src/Swoole/Lock.php @@ -0,0 +1,123 @@ +lock一致,但lockwait可以设置超时时间 + * @example + * @param float $timeout 超时时间 + * @return + */ + public function lockwait($timeout) + { + } + + /** + * + *非阻塞的加锁操作 + * @example + * @return + */ + public function trylock() + { + } + + /** + * + *锁定读 + * @example + * @return + */ + public function lock_read() + { + } + + /** + * + *非阻塞式锁定读 + * @example + * @return + */ + public function trylock_read() + { + } + + /** + * + *释放锁操作 + * @example + * @return + */ + public function unlock() + { + } + +} + diff --git a/src/Swoole/Mmap.php b/src/Swoole/Mmap.php new file mode 100644 index 0000000..d907e7c --- /dev/null +++ b/src/Swoole/Mmap.php @@ -0,0 +1,28 @@ + '192.168.56.102', + * 'user' => 'test', + * 'password' => 'test', + * 'database' => 'test', + * 'charset' => 'utf8', + * ); + * 回调函数:function onConnect(swoole_mysql $db, bool $result); + * @param array $server_config 连接配置信息 + * @param callable $callback 连接成功的回调 + * @return + */ + public function connect(Array $server_config, Callable $callback) + { + } + + /** + * + *启动事务 + * @example + * @param callable $callback 启动一个MySQL事务,事务启动成功会回调指定的函数 + * @return + */ + public function begin(Callable $callback) + { + } + + /** + * + *提交事务 + * @example + * @param callable $callback 提交事务,当服务器返回响应时回调此函数 + * @return + */ + public function commit(Callable $callback) + { + } + + /** + * + *回滚事务(必须先调用begin启动事务才能调用rollback否则底层会抛出异常) + * @example + * @param callable $callback 回滚完成后执行的回调 + * @return + */ + public function rollback(Callable $callback) + { + } + + /** + * + *执行sql语句 + * @example + * 回调函数:function onSQLReady(swoole_mysqli $link, mixed $result); + * 注:执行失败,$result为false,读取$link对象的error属性获得错误信息,errno属性获得错误码 + * 执行成功,SQL为非查询语句,$result为true,读取$link对象的affected_rows属性获得影响的行数,insert_id属性获得Insert操作的自增ID + * 执行成功,SQL为查询语句,$result为结果数组 + * @param string $sql 要执行的SQL语句 + * @param callable $callback 执行成功后会回调此函数 + * @return + */ + public function query($sql, Callable $callback) + { + } + + /** + * + *关闭mysql连接 + * @example + * @return + */ + public function close() + { + } + + /** + * + *获取当前服务器状态 + * @example + * @return int + */ + public function getState() + { + } + + /** + * + *设置事件回调函数(目前仅支持onClose事件回调) + * @example + * @param String $event_name 事件名称(目前仅支持Close) + * @param callable $callback 连接关闭时回调此函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + +} + diff --git a/src/Swoole/MySQL/Exception.php b/src/Swoole/MySQL/Exception.php new file mode 100644 index 0000000..44231f6 --- /dev/null +++ b/src/Swoole/MySQL/Exception.php @@ -0,0 +1,156 @@ +finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * + *启动server + * @example + * @return + */ + public function start() + { + } + + /** + * + *设置Redis命令字的处理器 + * @example + * @param string $command 命令的名称 + * @param callable $callback 命令的处理函数,回调函数返回字符串类型时会自动发送给客户端 + * @param int $number_of_string_param 字符串参数的长度 + * @param int $type_of_array_param 数组参数元素的类型 + * @return + */ + public function setHandler($command, Callable $callback, $number_of_string_param, $type_of_array_param) + { + } + + /** + * + *格式化命令响应数据 + * @example + * @param int $type 表示数据类型,NIL类型不需要传入$value,ERROR和STATUS类型$value可选,INT、STRING、SET、MAP必选 + * @param mixed $value 要处理的数据 + * @return + */ + public static function format($type, $value) + { + } + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param string $data 要传递的数据 + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return boolean + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + +} + diff --git a/src/Swoole/Serialize.php b/src/Swoole/Serialize.php new file mode 100644 index 0000000..6b27173 --- /dev/null +++ b/src/Swoole/Serialize.php @@ -0,0 +1,39 @@ +finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *启动server + * @example + * @return + */ + public function start() + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param string $data 要传递的数据 + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return boolean + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + +} + diff --git a/src/Swoole/Server/Port.php b/src/Swoole/Server/Port.php new file mode 100644 index 0000000..3cee75e --- /dev/null +++ b/src/Swoole/Server/Port.php @@ -0,0 +1,183 @@ +set('hello@qq.com', array('id' => 189, 'name' => 'rango3', 'num' => 3.1415)); + * @param string $key 数据的key,相同的$key对应同一行数据,如果set同一个key,会覆盖上一次的数据 + * @param array $value 必须是一个数组,必须与字段定义的$name完全相同 + * @return + */ + public function set($key, Array $value) + { + } + + /** + * + *获取一行数据 + * @example + * @param string $key 设置的key值 + * @param string $field 字段值 + * @return + */ + public function get($key, $field) + { + } + + /** + * + *获取数据行数 + * @example + * @return int + */ + public function count() + { + } + + /** + * + *删除数据 + * @example + * @param string $key 要删除的键 + * @return + */ + public function del($key) + { + } + + /** + * + *检查table中是否存在某一个key + * @example + * @param mixed $key + * @return + */ + public function exist($key) + { + } + + /** + * + *原子自增操作 + * @example + * @param string $key 指定数据的key,如果$key对应的行不存在,默认列的值为0 + * @param string $column 指定列名,仅支持浮点型和整型字段 + * @param mixed $incrby 增量,默认为1。如果列为整形,$incrby必须为int型,如果列为浮点型,$incrby必须为float类型失败返回false,成功返回最终的结果数值 + * @return + */ + public function incr($key, $column, $incrby) + { + } + + /** + * + *原子自减操作 + * @example + * @param string $key 指定数据的key,如果$key对应的行不存在,默认列的值为0 + * @param string $column 指定列名,仅支持浮点型和整型字段 + * @param mixed $decrby 减量,默认为1。如果列为整形,$decrby必须为int型,如果列为浮点型,$decrby必须为float类型失败返回false,成功返回最终的结果数值 + * @return + */ + public function decr($key, $column, $decrby) + { + } + + /** + * + *获取table占用的内存大小 + * @example + * @return int + */ + public function getMemorySize() + { + } + + /** + * + *检查一个偏移位置是否存在 + * @example + * @param int $offset 偏移量 + * @return + */ + public function offsetExists($offset) + { + } + + /** + * + *取一个偏移位置的值 + * @example + * @param int $offset 偏移量 + * @return + */ + public function offsetGet($offset) + { + } + + /** + * + *设置一个偏移位置的值(来自ArrayAccess接口) + * @example + * @param int $offset 偏移量 + * @param mixed $value 需要设置的值 + * @return + */ + public function offsetSet($offset, $value) + { + } + + /** + * + *复位一个偏移位置的值 + * @example + * @param int $offset 偏移量 + * @return + */ + public function offsetUnset($offset) + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + + /** + * + *返回到迭代器的第一个元素 + * @example + * @return + */ + public function rewind() + { + } + + /** + * + *向前移动到下一个元素(此方法在 foreach 循环之后被调用) + * @example + * @return + */ + public function next() + { + } + + /** + * + *返回迭代器当前元素 + * @example + * @return + */ + public function current() + { + } + + /** + * + *返回当前元素的键 + * @example + * @return mixed + */ + public function key() + { + } + + /** + * + *检查当前位置是否有效(迭代器方法,此方法在 Iterator::rewind() 和 Iterator::next() 方法之后被调用以此用来检查当前位置是否有效) + * @example + * @return boolean + */ + public function valid() + { + } + +} + diff --git a/src/Swoole/Table/Row.php b/src/Swoole/Table/Row.php new file mode 100644 index 0000000..37367e1 --- /dev/null +++ b/src/Swoole/Table/Row.php @@ -0,0 +1,84 @@ +finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * @var callable $onRequest + * 请求回调函数 + * @access public + */ + public $onRequest; + + /** + * @var callable $onHandshake + * TCP握手时的回调函数 + * @access public + */ + public $onHandshake; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *向websocket客户端连接推送数据,长度最大不得超过2M + * @example + * @param int $fd 客户端连接的ID,如果指定的$fd对应的TCP连接并非websocket客户端,将会发送失败 + * @param string $data 要发送的数据内容 + * @param int $opcode 指定发送数据内容的格式,默认为文本。发送二进制内容$opcode参数需要设置 + * @param boolean $finish 帧是否完成 + * @return + */ + public function push($fd, $data, $opcode, $finish) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *打包数据 + * @example + * @param string $data 消息内容 + * @param int $opcode WebSocket的opcode指令类型,1表示文本,2表示二进制数据,9表示心跳ping + * @param boolean $finish 帧是否完成 + * @param boolean $mask 是否设置掩码 + * @return + */ + public static function pack($data, $opcode, $finish, $mask) + { + } + + /** + * + *参数据进行解包 + * @example + * @param string $data 解包的数据 + * @return + */ + public static function unpack($data) + { + } + + /** + * + *启动server + * @example + * @return + */ + public function start() + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param string $data 要传递的数据 + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return boolean + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + +} + diff --git a/src/Swoole/swoole.namespace.php b/src/Swoole/swoole.namespace.php new file mode 100644 index 0000000..17fedb6 --- /dev/null +++ b/src/Swoole/swoole.namespace.php @@ -0,0 +1,584 @@ +2)) +* @param array $settings:设置的选项 +* @return +*/ +function swoole_async_set(Array $settings) +{ +} + +/** +* +*异步读文件,使用此函数读取文件是非阻塞的,当读操作完成时会自动回调指定的函数 +* @example +* +* @param string $filename:文件名 +* @param callable $callback:读操作完成后的回调函数, 其回调函数原型: + bool callback(string $filename, string $content); + * $filename,文件名称 + * $content,读取到的分段内容,如果内容为空,表明文件已读完 +* @param int $chunk_size:读的块大小 +* @param int $offset:读文件的指针偏移量 +* @return bool +*/ +function swoole_async_read($filename, Callable $callback, $chunk_size, $offset) +{ +} + +/** +* +*异步写文件,与swoole_async_writefile不同,write是分段读写的。不需要一次性将要写的内容放到内存里,所以只占用少量内存。swoole_async_write通过传入的offset参数来确定写入的位置 +* @example +* +* @param string $filename:写入的文件名 +* @param string $content:写入的文件内容 +* @param int $offset:写入的文件位置(指针偏移) +* @param callable $callback:写完成后执行的回调函数 +* @return +*/ +function swoole_async_write($filename, $content, $offset, Callable $callback) +{ +} + +/** +* +*异步读取文件内容(与readfile功能类似),完成后并执行某个函数 +* @example +* swoole_async_readfile(__DIR__."/server.php", function($filename, $content) { +* echo "$filename: $content"; +* }); +* @param string $filename:文件名 +* @param callable $callback:读文件完成后的回调函数 +* @return +*/ +function swoole_async_readfile($filename, Callable $callback) +{ +} + +/** +* +*异步写文件,调用此函数后会立即返回。当写入完成时会自动回调指定的callback函数 +* @example +* +* @param string $filename:写入的文件名 +* @param string $content:写入的内容 +* @param callable $callback:写文件完成后的回调函数 +* @param $flags: +* @return +*/ +function swoole_async_writefile($filename, $content, Callable $callback, $flags) +{ +} + +/** +* +*将域名解析为IP地址。调用此函数是非阻塞的,调用会立即返回 +* @example +* swoole_async_dns_lookup("www.baidu.com", function($host, $ip){ +* echo "{$host} : {$ip} +* "; +* }); +* @param string $hostname:域名 +* @param callable $callback:解析后的回调函数 +* @return +*/ +function swoole_async_dns_lookup($hostname, Callable $callback) +{ +} + +/** +* +*协程DNS查询 +* @example +* +* @param string $domain_name:要查询的域名 +* @return string|bool +*/ +function swoole_async_dns_lookup_coro($domain_name) +{ +} + +/** +* +*swoole_client的并行处理中用了select来做IO事件循环 +* @example +* +* @param array $read_array:可读文件描述符 +* @param array $write_array:可写文件描述符 +* @param array $error_array:错误文件描述符 +* @param float $timeout:超时时间 +* @return int +*/ +function swoole_client_select(Array $read_array, Array $write_array, Array $error_array, $timeout) +{ +} + +/** +* +*swoole的并行处理中用了select来做IO事件循环 +* @example +* +* @param $read_array: +* @param $write_array: +* @param $error_array: +* @param $timeout: +* @return +*/ +function swoole_select($read_array, $write_array, $error_array, $timeout) +{ +} + +/** +* +*设置进程的名称(存在兼容性问题,优先使用PHP内置的cli_set_process_title函数) +* @example +* swoole_set_process_name('swoole_server'); +* @param string $process_name:进程名称 +* @return +*/ +function swoole_set_process_name($process_name) +{ +} + +/** +* +*用于获取本地所有网络接口的IP地址(返回以interface名称为key的关联数组) +* @example +* $ips = swoole_get_local_ip(); +* @return array (只返回IPv4地址,返回结果会过滤掉本地的loop地址127.0.0.1,类似于array('eth0'=>'192.168.0.25')) +*/ +function swoole_get_local_ip() +{ +} + +/** +* +*获取本地所有网络接口的mac地址(返回以interface名称为key的关联数组) +* @example +* $macs = swoole_get_local_mac(); +* @return array +*/ +function swoole_get_local_mac() +{ +} + +/** +* +*从标准的Unix Errno错误码转换成错误信息 +* @example +* +* @param int $errno:标准错误码 +* @return string +*/ +function swoole_strerror($errno) +{ +} + +/** +* +*获取最近一次系统调用的错误码 +* @example +* echo swoole_strerror(swoole_errno()); +* @return int +*/ +function swoole_errno() +{ +} + diff --git a/src/Swoole/swoole.php b/src/Swoole/swoole.php new file mode 100644 index 0000000..fc4e3ee --- /dev/null +++ b/src/Swoole/swoole.php @@ -0,0 +1,584 @@ +2)) +* @param array $settings:设置的选项 +* @return +*/ +function swoole_async_set(Array $settings) +{ +} + +/** +* +*异步读文件,使用此函数读取文件是非阻塞的,当读操作完成时会自动回调指定的函数 +* @example +* +* @param string $filename:文件名 +* @param callable $callback:读操作完成后的回调函数, 其回调函数原型: + bool callback(string $filename, string $content); + * $filename,文件名称 + * $content,读取到的分段内容,如果内容为空,表明文件已读完 +* @param int $chunk_size:读的块大小 +* @param int $offset:读文件的指针偏移量 +* @return bool +*/ +function swoole_async_read($filename, Callable $callback, $chunk_size, $offset) +{ +} + +/** +* +*异步写文件,与swoole_async_writefile不同,write是分段读写的。不需要一次性将要写的内容放到内存里,所以只占用少量内存。swoole_async_write通过传入的offset参数来确定写入的位置 +* @example +* +* @param string $filename:写入的文件名 +* @param string $content:写入的文件内容 +* @param int $offset:写入的文件位置(指针偏移) +* @param callable $callback:写完成后执行的回调函数 +* @return +*/ +function swoole_async_write($filename, $content, $offset, Callable $callback) +{ +} + +/** +* +*异步读取文件内容(与readfile功能类似),完成后并执行某个函数 +* @example +* swoole_async_readfile(__DIR__."/server.php", function($filename, $content) { +* echo "$filename: $content"; +* }); +* @param string $filename:文件名 +* @param callable $callback:读文件完成后的回调函数 +* @return +*/ +function swoole_async_readfile($filename, Callable $callback) +{ +} + +/** +* +*异步写文件,调用此函数后会立即返回。当写入完成时会自动回调指定的callback函数 +* @example +* +* @param string $filename:写入的文件名 +* @param string $content:写入的内容 +* @param callable $callback:写文件完成后的回调函数 +* @param $flags: +* @return +*/ +function swoole_async_writefile($filename, $content, Callable $callback, $flags) +{ +} + +/** +* +*将域名解析为IP地址。调用此函数是非阻塞的,调用会立即返回 +* @example +* swoole_async_dns_lookup("www.baidu.com", function($host, $ip){ +* echo "{$host} : {$ip} +* "; +* }); +* @param string $hostname:域名 +* @param callable $callback:解析后的回调函数 +* @return +*/ +function swoole_async_dns_lookup($hostname, Callable $callback) +{ +} + +/** +* +*协程DNS查询 +* @example +* +* @param string $domain_name:要查询的域名 +* @return string|bool +*/ +function swoole_async_dns_lookup_coro($domain_name) +{ +} + +/** +* +*swoole_client的并行处理中用了select来做IO事件循环 +* @example +* +* @param array $read_array:可读文件描述符 +* @param array $write_array:可写文件描述符 +* @param array $error_array:错误文件描述符 +* @param float $timeout:超时时间 +* @return int +*/ +function swoole_client_select(Array $read_array, Array $write_array, Array $error_array, $timeout) +{ +} + +/** +* +*swoole的并行处理中用了select来做IO事件循环 +* @example +* +* @param $read_array: +* @param $write_array: +* @param $error_array: +* @param $timeout: +* @return +*/ +function swoole_select($read_array, $write_array, $error_array, $timeout) +{ +} + +/** +* +*设置进程的名称(存在兼容性问题,优先使用PHP内置的cli_set_process_title函数) +* @example +* swoole_set_process_name('swoole_server'); +* @param string $process_name:进程名称 +* @return +*/ +function swoole_set_process_name($process_name) +{ +} + +/** +* +*用于获取本地所有网络接口的IP地址(返回以interface名称为key的关联数组) +* @example +* $ips = swoole_get_local_ip(); +* @return array (只返回IPv4地址,返回结果会过滤掉本地的loop地址127.0.0.1,类似于array('eth0'=>'192.168.0.25')) +*/ +function swoole_get_local_ip() +{ +} + +/** +* +*获取本地所有网络接口的mac地址(返回以interface名称为key的关联数组) +* @example +* $macs = swoole_get_local_mac(); +* @return array +*/ +function swoole_get_local_mac() +{ +} + +/** +* +*从标准的Unix Errno错误码转换成错误信息 +* @example +* +* @param int $errno:标准错误码 +* @return string +*/ +function swoole_strerror($errno) +{ +} + +/** +* +*获取最近一次系统调用的错误码 +* @example +* echo swoole_strerror(swoole_errno()); +* @return int +*/ +function swoole_errno() +{ +} + diff --git a/src/Swoole/swoole_async.php b/src/Swoole/swoole_async.php new file mode 100644 index 0000000..6c7cb56 --- /dev/null +++ b/src/Swoole/swoole_async.php @@ -0,0 +1,122 @@ +finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * @var callable $onRequest + * 请求回调函数 + * @access public + */ + public $onRequest; + + /** + * @var callable $onHandshake + * TCP握手时的回调函数 + * @access public + */ + public $onHandshake; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *启动HTTP server + * @example + * @return + */ + public function start() + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param mixed $data + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 工作进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + +} + diff --git a/src/Swoole/swoole_lock.php b/src/Swoole/swoole_lock.php new file mode 100644 index 0000000..9ec5512 --- /dev/null +++ b/src/Swoole/swoole_lock.php @@ -0,0 +1,122 @@ +lock一致,但lockwait可以设置超时时间 + * @example + * @param float $timeout 超时时间 + * @return + */ + public function lockwait($timeout) + { + } + + /** + * + *非阻塞的加锁操作 + * @example + * @return + */ + public function trylock() + { + } + + /** + * + *锁定读 + * @example + * @return + */ + public function lock_read() + { + } + + /** + * + *非阻塞式锁定读 + * @example + * @return + */ + public function trylock_read() + { + } + + /** + * + *释放锁操作 + * @example + * @return + */ + public function unlock() + { + } + +} + diff --git a/src/Swoole/swoole_mmap.php b/src/Swoole/swoole_mmap.php new file mode 100644 index 0000000..2fca9ea --- /dev/null +++ b/src/Swoole/swoole_mmap.php @@ -0,0 +1,27 @@ + '192.168.56.102', + * 'user' => 'test', + * 'password' => 'test', + * 'database' => 'test', + * 'charset' => 'utf8', + * ); + * 回调函数:function onConnect(swoole_mysql $db, bool $result); + * @param array $server_config 连接配置信息 + * @param callable $callback 连接成功的回调 + * @return + */ + public function connect(Array $server_config, Callable $callback) + { + } + + /** + * + *启动事务 + * @example + * @param callable $callback 启动一个MySQL事务,事务启动成功会回调指定的函数 + * @return + */ + public function begin(Callable $callback) + { + } + + /** + * + *提交事务 + * @example + * @param callable $callback 提交事务,当服务器返回响应时回调此函数 + * @return + */ + public function commit(Callable $callback) + { + } + + /** + * + *回滚事务(必须先调用begin启动事务才能调用rollback否则底层会抛出异常) + * @example + * @param callable $callback 回滚完成后执行的回调 + * @return + */ + public function rollback(Callable $callback) + { + } + + /** + * + *执行sql语句 + * @example + * 回调函数:function onSQLReady(swoole_mysqli $link, mixed $result); + * 注:执行失败,$result为false,读取$link对象的error属性获得错误信息,errno属性获得错误码 + * 执行成功,SQL为非查询语句,$result为true,读取$link对象的affected_rows属性获得影响的行数,insert_id属性获得Insert操作的自增ID + * 执行成功,SQL为查询语句,$result为结果数组 + * @param string $sql 要执行的SQL语句 + * @param callable $callback 执行成功后会回调此函数 + * @return + */ + public function query($sql, Callable $callback) + { + } + + /** + * + *关闭mysql连接 + * @example + * @return + */ + public function close() + { + } + + /** + * + *获取当前服务器状态 + * @example + * @return int + */ + public function getState() + { + } + + /** + * + *设置事件回调函数(目前仅支持onClose事件回调) + * @example + * @param String $event_name 事件名称(目前仅支持Close) + * @param callable $callback 连接关闭时回调此函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + +} + diff --git a/src/Swoole/swoole_mysql_coro.php b/src/Swoole/swoole_mysql_coro.php new file mode 100644 index 0000000..b8172a1 --- /dev/null +++ b/src/Swoole/swoole_mysql_coro.php @@ -0,0 +1,211 @@ +finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * + *启动server + * @example + * @return + */ + public function start() + { + } + + /** + * + *设置Redis命令字的处理器 + * @example + * @param string $command 命令的名称 + * @param callable $callback 命令的处理函数,回调函数返回字符串类型时会自动发送给客户端 + * @param int $number_of_string_param 字符串参数的长度 + * @param int $type_of_array_param 数组参数元素的类型 + * @return + */ + public function setHandler($command, Callable $callback, $number_of_string_param, $type_of_array_param) + { + } + + /** + * + *格式化命令响应数据 + * @example + * @param int $type 表示数据类型,NIL类型不需要传入$value,ERROR和STATUS类型$value可选,INT、STRING、SET、MAP必选 + * @param mixed $value 要处理的数据 + * @return + */ + public static function format($type, $value) + { + } + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param string $data 要传递的数据 + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return boolean + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + +} + diff --git a/src/Swoole/swoole_serialize.php b/src/Swoole/swoole_serialize.php new file mode 100644 index 0000000..42e68ce --- /dev/null +++ b/src/Swoole/swoole_serialize.php @@ -0,0 +1,38 @@ +finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *启动server + * @example + * @return + */ + public function start() + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param string $data 要传递的数据 + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return boolean + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + +} + diff --git a/src/Swoole/swoole_server_port.php b/src/Swoole/swoole_server_port.php new file mode 100644 index 0000000..532650a --- /dev/null +++ b/src/Swoole/swoole_server_port.php @@ -0,0 +1,182 @@ +set('hello@qq.com', array('id' => 189, 'name' => 'rango3', 'num' => 3.1415)); + * @param string $key 数据的key,相同的$key对应同一行数据,如果set同一个key,会覆盖上一次的数据 + * @param array $value 必须是一个数组,必须与字段定义的$name完全相同 + * @return + */ + public function set($key, Array $value) + { + } + + /** + * + *获取一行数据 + * @example + * @param string $key 设置的key值 + * @param string $field 字段值 + * @return + */ + public function get($key, $field) + { + } + + /** + * + *获取数据行数 + * @example + * @return int + */ + public function count() + { + } + + /** + * + *删除数据 + * @example + * @param string $key 要删除的键 + * @return + */ + public function del($key) + { + } + + /** + * + *检查table中是否存在某一个key + * @example + * @param mixed $key + * @return + */ + public function exist($key) + { + } + + /** + * + *原子自增操作 + * @example + * @param string $key 指定数据的key,如果$key对应的行不存在,默认列的值为0 + * @param string $column 指定列名,仅支持浮点型和整型字段 + * @param mixed $incrby 增量,默认为1。如果列为整形,$incrby必须为int型,如果列为浮点型,$incrby必须为float类型失败返回false,成功返回最终的结果数值 + * @return + */ + public function incr($key, $column, $incrby) + { + } + + /** + * + *原子自减操作 + * @example + * @param string $key 指定数据的key,如果$key对应的行不存在,默认列的值为0 + * @param string $column 指定列名,仅支持浮点型和整型字段 + * @param mixed $decrby 减量,默认为1。如果列为整形,$decrby必须为int型,如果列为浮点型,$decrby必须为float类型失败返回false,成功返回最终的结果数值 + * @return + */ + public function decr($key, $column, $decrby) + { + } + + /** + * + *获取table占用的内存大小 + * @example + * @return int + */ + public function getMemorySize() + { + } + + /** + * + *检查一个偏移位置是否存在 + * @example + * @param int $offset 偏移量 + * @return + */ + public function offsetExists($offset) + { + } + + /** + * + *取一个偏移位置的值 + * @example + * @param int $offset 偏移量 + * @return + */ + public function offsetGet($offset) + { + } + + /** + * + *设置一个偏移位置的值(来自ArrayAccess接口) + * @example + * @param int $offset 偏移量 + * @param mixed $value 需要设置的值 + * @return + */ + public function offsetSet($offset, $value) + { + } + + /** + * + *复位一个偏移位置的值 + * @example + * @param int $offset 偏移量 + * @return + */ + public function offsetUnset($offset) + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + + /** + * + *返回到迭代器的第一个元素 + * @example + * @return + */ + public function rewind() + { + } + + /** + * + *向前移动到下一个元素(此方法在 foreach 循环之后被调用) + * @example + * @return + */ + public function next() + { + } + + /** + * + *返回迭代器当前元素 + * @example + * @return + */ + public function current() + { + } + + /** + * + *返回当前元素的键 + * @example + * @return mixed + */ + public function key() + { + } + + /** + * + *检查当前位置是否有效(迭代器方法,此方法在 Iterator::rewind() 和 Iterator::next() 方法之后被调用以此用来检查当前位置是否有效) + * @example + * @return boolean + */ + public function valid() + { + } + +} + diff --git a/src/Swoole/swoole_table_row.php b/src/Swoole/swoole_table_row.php new file mode 100644 index 0000000..3cbc2c1 --- /dev/null +++ b/src/Swoole/swoole_table_row.php @@ -0,0 +1,83 @@ +finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * @var callable $onRequest + * 请求回调函数 + * @access public + */ + public $onRequest; + + /** + * @var callable $onHandshake + * TCP握手时的回调函数 + * @access public + */ + public $onHandshake; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *向websocket客户端连接推送数据,长度最大不得超过2M + * @example + * @param int $fd 客户端连接的ID,如果指定的$fd对应的TCP连接并非websocket客户端,将会发送失败 + * @param string $data 要发送的数据内容 + * @param int $opcode 指定发送数据内容的格式,默认为文本。发送二进制内容$opcode参数需要设置 + * @param boolean $finish 帧是否完成 + * @return + */ + public function push($fd, $data, $opcode, $finish) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *打包数据 + * @example + * @param string $data 消息内容 + * @param int $opcode WebSocket的opcode指令类型,1表示文本,2表示二进制数据,9表示心跳ping + * @param boolean $finish 帧是否完成 + * @param boolean $mask 是否设置掩码 + * @return + */ + public static function pack($data, $opcode, $finish, $mask) + { + } + + /** + * + *参数据进行解包 + * @example + * @param string $data 解包的数据 + * @return + */ + public static function unpack($data) + { + } + + /** + * + *启动server + * @example + * @return + */ + public function start() + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param string $data 要传递的数据 + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return boolean + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + +} + diff --git a/src/swoole/swoole.json b/src/swoole/swoole.json deleted file mode 100644 index 3374a30..0000000 --- a/src/swoole/swoole.json +++ /dev/null @@ -1 +0,0 @@ -{"version":"2.0.10","comment":"面向生产环境的 PHP 异步网络通信引擎。使 PHP 开发人员可以编写高性能的异步并发 TCP、UDP、Unix Socket、HTTP,WebSocket 服务。Swoole 可以广泛应用于互联网、移动通信、企业软件、云计算、网络游戏、物联网(IOT)、车联网、智能家居等领域","constants":{"SWOOLE_BASE":{"value":4,"comment":"Base模式,传统的异步非阻塞模式,如果回调函数中有阻塞操作会导致server退化为同步模式"},"SWOOLE_THREAD":{"value":2,"comment":"线程模式(已废弃),多线程Worker模式。Reactor线程来处理网络事件轮询,读取数据。得到的请求交给worker线程去处理"},"SWOOLE_PROCESS":{"value":3,"comment":"进程模式(默认)。提供完善的进程管理、内存保护机制"},"SWOOLE_IPC_UNSOCK":{"value":1,"comment":"使用Unix的socket进行进程间通信"},"SWOOLE_IPC_MSGQUEUE":{"value":2,"comment":"使用消息队列进行进程间通信"},"SWOOLE_IPC_PREEMPTIVE":{"value":3,"comment":"抢占式进程间通信"},"SWOOLE_SOCK_TCP":{"value":1,"comment":"创建tcp socket"},"SWOOLE_SOCK_TCP6":{"value":3,"comment":"创建tcp ipv6 socket"},"SWOOLE_SOCK_UDP":{"value":2,"comment":"创建udp socket"},"SWOOLE_SOCK_UDP6":{"value":4,"comment":"创建udp ipv6 socket"},"SWOOLE_SOCK_UNIX_DGRAM":{"value":5,"comment":"UNIX UDP socket(数据报文)"},"SWOOLE_SOCK_UNIX_STREAM":{"value":6,"comment":"UNIX TCP socket(数据流)"},"SWOOLE_TCP":{"value":1,"comment":"TCP IPv4"},"SWOOLE_TCP6":{"value":3,"comment":"TCP IPv6"},"SWOOLE_UDP":{"value":2,"comment":"UDP IPv4"},"SWOOLE_UDP6":{"value":4,"comment":"UDP IPv6"},"SWOOLE_UNIX_DGRAM":{"value":5,"comment":"UNIX数据报文(一般是UDP协议)"},"SWOOLE_UNIX_STREAM":{"value":6,"comment":"UNIX数据流(一般是TCP协议)"},"SWOOLE_SOCK_SYNC":{"value":0,"comment":"同步socket"},"SWOOLE_SOCK_ASYNC":{"value":1,"comment":"异步socket"},"SWOOLE_SYNC":{"value":2048,"comment":"swoole同步"},"SWOOLE_ASYNC":{"value":1024,"comment":"swoole异步"},"SWOOLE_KEEP":{"value":4096,"comment":"长连接"},"SWOOLE_EVENT_READ":{"value":512,"comment":"swoole读事件"},"SWOOLE_EVENT_WRITE":{"value":1024,"comment":"swoole写事件"},"SWOOLE_VERSION":{"value":"2.0.10","comment":"swoole 版本号"},"SWOOLE_AIO_BASE":{"value":0,"comment":"使用类似于Node.js的线程池同步阻塞模拟异步"},"SWOOLE_AIO_LINUX":{"value":1,"comment":"Linux异步IO"},"SWOOLE_FILELOCK":{"value":2,"comment":"swoole文件锁"},"SWOOLE_MUTEX":{"value":3,"comment":"swoole互斥锁"},"SWOOLE_SEM":{"value":4,"comment":"swoole信号量"},"SWOOLE_RWLOCK":{"value":1,"comment":"swoole读写锁"},"SWOOLE_SPINLOCK":{"value":5,"comment":"swoole自旋锁"},"WEBSOCKET_OPCODE_TEXT":{"value":1,"comment":"UTF-8文本字符数据(websocket数据帧类型)"},"WEBSOCKET_OPCODE_BINARY":{"value":2,"comment":"二进制数据(websocket数据帧类型)"},"WEBSOCKET_OPCODE_PING":{"value":9,"comment":"ping数据(websocket数据帧类型)"},"WEBSOCKET_STATUS_CONNECTION":{"value":1,"comment":"连接进入等待握手"},"WEBSOCKET_STATUS_HANDSHAKE":{"value":2,"comment":"websocket正在握手状态"},"WEBSOCKET_STATUS_FRAME":{"value":3,"comment":"已握手成功等待浏览器发送数据帧"},"WEBSOCKET_STATUS_ACTIVE":{"value":3,"comment":"websocket活动连接状态"},"SWOOLE_FAST_PACK":{"value":1,"comment":"是否开启对异步任务数据进行序列化功能"},"UNSERIALIZE_OBJECT_TO_ARRAY":{"value":1,"comment":"将对象反序列化为数组"},"UNSERIALIZE_OBJECT_TO_STDCLASS":{"value":2,"comment":"将对象反序列化为标准类"}},"ini":{"swoole.aio_thread_num":{"value":"2","options":[],"comment":"swoole异步IO线程数"},"swoole.display_errors":{"value":"On","options":[],"comment":"是否显示错误"},"swoole.use_namespace":{"value":"0","options":[],"comment":"是否启用命名空间"},"swoole.fast_serialize":{"value":"1","options":[],"comment":"是否开启对异步任务数据进行序列化功能(开启使用On)"},"swoole.unixsock_buffer_size":{"value":"8388608","options":[],"comment":"unix域连接的缓冲区大小"}},"functions":{"swoole_version":{"comment":"获取swoole扩展的版本号","parameters":[],"return":"string","example":"$version = swoole_version();"},"swoole_cpu_num":{"comment":"获取本机CPU的数量","parameters":[],"return":"int","example":"$num = swoole_cpu_num();"},"swoole_last_error":{"comment":"获取最近一次的错误码","parameters":[],"return":"int","example":"$errno = swoole_last_error();"},"swoole_event_add":{"comment":"为指定的socket添加事件监听器","parameters":{"fd":{"comment":"连接句柄(文件描述符)","options":[],"type":"int"},"read_callback":{"comment":"读事件回调","options":[],"type":"callable"},"write_callback":{"comment":"写事件回调","options":[],"type":"callable"},"events":{"comment":"事件名称,可选择关闭\/开启可读可写事件,如SWOOLE_EVENT_READ,SWOOLE_EVENT_WRITE,或者SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE","options":[],"type":"int"}},"return":"boolean","example":""},"swoole_event_set":{"comment":"修改socket事件的设置","parameters":{"fd":{"comment":"连接句柄","options":[],"type":"int"},"read_callback":{"comment":"读事件回调","options":[],"type":"callable"},"write_callback":{"comment":"写事件回调","options":[],"type":"callable"},"events":{"comment":"事件名称,,可选择关闭\/开启可读可写事件,如SWOOLE_EVENT_READ,SWOOLE_EVENT_WRITE,或者SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE","options":[],"type":"int"}},"return":"boolean","example":""},"swoole_event_del":{"comment":"删除一个事件(必须在swoole_event_add后面使用)","parameters":{"fd":{"comment":"连接句柄","options":[],"type":"int"}},"return":"boolean","example":""},"swoole_event_exit":{"comment":"退出事件循环","parameters":[],"return":"void","example":""},"swoole_event_wait":{"comment":"事件轮询","parameters":[],"return":"void","example":""},"swoole_event_write":{"comment":"异步写事件","parameters":{"fd":{"comment":"连接句柄","options":[],"type":"int"},"data":{"comment":"写入的内容","options":[],"type":"string"}},"return":"","example":""},"swoole_event_defer":{"comment":"延后执行一个PHP函数","parameters":{"callback":{"comment":"要执行的函数","options":[],"type":"callable"}},"return":"","example":""},"swoole_event_cycle":{"comment":"定义事件循环周期执行函数。此函数会在每一轮事件循环结束时调用","parameters":{"callback":{"comment":"要设置的回调函数,必须为可执行。$callback为null时表示清除cycle函数","options":[],"type":"callable"}},"return":"boolean","example":""},"swoole_timer_after":{"comment":"添加一个在指定的时间后执行某个函数的定时器(执行成功返回定时器ID)","parameters":{"ms":{"comment":"延迟的毫秒数","options":[],"type":"int"},"callback":{"comment":"执行的函数","options":[],"type":"callable"},"param":{"comment":"函数参数","options":[],"type":"mixed"}},"return":"int","example":""},"swoole_timer_tick":{"comment":"添加一个在指定时间循环执行某个函数的定时器","parameters":{"ms":{"comment":"循环周期时间","options":[],"type":"int"},"callback":{"comment":"执行的函数","options":[],"type":"callable"}},"return":"int","example":""},"swoole_timer_exists":{"comment":"检查一个定时器是否存在","parameters":{"timer_id":{"comment":"定时器ID","options":[],"type":"int"}},"return":"bool","example":""},"swoole_timer_clear":{"comment":"清除某个定时器","parameters":{"timer_id":{"comment":"定时器ID","options":[],"type":"int"}},"return":"bool","example":""},"swoole_async_set":{"comment":"置异步IO相关的选项\n设置的选项可以为以下值:\n thread_num : 设置异步文件IO线程的数量\n aio_mode : 设置异步文件IO的操作模式,目前支持SWOOLE_AIO_BASE(使用类似于Node.js的线程池同步阻塞模拟异步)、SWOOLE_AIO_LINUX(Linux Native AIO) 2种模式\n enable_signalfd : 开启和关闭signalfd特性的使用\n socket_buffer_size : 设置SOCKET内存缓存区尺寸\n socket_dontwait :在内存缓存区已满的情况下禁止底层阻塞等待\n log_file :设置日志文件路径\n log_level : 设置错误日志等级","parameters":{"settings":{"comment":"设置的选项","options":[],"type":"array"}},"return":"","example":"swoole_async_set(array('thread_num'=>2))"},"swoole_async_read":{"comment":"异步读文件,使用此函数读取文件是非阻塞的,当读操作完成时会自动回调指定的函数","parameters":{"filename":{"comment":"文件名","options":[],"type":"string"},"callback":{"comment":"读操作完成后的回调函数, 其回调函数原型:\n bool callback(string $filename, string $content);\n * $filename,文件名称 \n * $content,读取到的分段内容,如果内容为空,表明文件已读完","options":[],"type":"callable"},"chunk_size":{"comment":"读的块大小","options":[],"type":"int"},"offset":{"comment":"读文件的指针偏移量","options":[],"type":"int"}},"return":"bool","example":""},"swoole_async_write":{"comment":"异步写文件,与swoole_async_writefile不同,write是分段读写的。不需要一次性将要写的内容放到内存里,所以只占用少量内存。swoole_async_write通过传入的offset参数来确定写入的位置","parameters":{"filename":{"comment":"写入的文件名","options":[],"type":"string"},"content":{"comment":"写入的文件内容","options":[],"type":"string"},"offset":{"comment":"写入的文件位置(指针偏移)","options":[],"type":"int"},"callback":{"comment":"写完成后执行的回调函数","options":[],"type":"callable"}},"return":"","example":""},"swoole_async_readfile":{"comment":"异步读取文件内容(与readfile功能类似),完成后并执行某个函数","parameters":{"filename":{"comment":"文件名","options":[],"type":"string"},"callback":{"comment":"读文件完成后的回调函数","options":[],"type":"callable"}},"return":"","example":"swoole_async_readfile(__DIR__.\"\/server.php\", function($filename, $content) {\n echo \"$filename: $content\";\n});"},"swoole_async_writefile":{"comment":"异步写文件,调用此函数后会立即返回。当写入完成时会自动回调指定的callback函数","parameters":{"filename":{"comment":"写入的文件名","options":[],"type":"string"},"content":{"comment":"写入的内容","options":[],"type":"string"},"callback":{"comment":"写文件完成后的回调函数","options":[],"type":"callable"},"flags":{"comment":"","options":[],"type":""}},"return":"","example":""},"swoole_async_dns_lookup":{"comment":"将域名解析为IP地址。调用此函数是非阻塞的,调用会立即返回","parameters":{"hostname":{"comment":"域名","options":[],"type":"string"},"callback":{"comment":"解析后的回调函数","options":[],"type":"callable"}},"return":"","example":"swoole_async_dns_lookup(\"www.baidu.com\", function($host, $ip){ \necho \"{$host} : {$ip}\n \";\n});"},"swoole_async_dns_lookup_coro":{"comment":"协程DNS查询","parameters":{"domain_name":{"comment":"要查询的域名","options":[],"type":"string"}},"return":"string|bool","example":""},"swoole_client_select":{"comment":"swoole_client的并行处理中用了select来做IO事件循环","parameters":{"read_array":{"comment":"可读文件描述符","options":[],"type":"array"},"write_array":{"comment":"可写文件描述符","options":[],"type":"array"},"error_array":{"comment":"错误文件描述符","options":[],"type":"array"},"timeout":{"comment":"超时时间","options":[],"type":"float"}},"return":"int","example":""},"swoole_select":{"comment":"swoole的并行处理中用了select来做IO事件循环","parameters":{"read_array":{"comment":"","options":[],"type":""},"write_array":{"comment":"","options":[],"type":""},"error_array":{"comment":"","options":[],"type":""},"timeout":{"comment":"","options":[],"type":""}},"return":"","example":""},"swoole_set_process_name":{"comment":"设置进程的名称(存在兼容性问题,优先使用PHP内置的cli_set_process_title函数)","parameters":{"process_name":{"comment":"进程名称","options":[],"type":"string"}},"return":"","example":"swoole_set_process_name('swoole_server');"},"swoole_get_local_ip":{"comment":"用于获取本地所有网络接口的IP地址(返回以interface名称为key的关联数组)","parameters":[],"return":"array (只返回IPv4地址,返回结果会过滤掉本地的loop地址127.0.0.1,类似于array('eth0'=>'192.168.0.25'))","example":"$ips = swoole_get_local_ip();"},"swoole_get_local_mac":{"comment":"获取本地所有网络接口的mac地址(返回以interface名称为key的关联数组)","parameters":[],"return":"array","example":"$macs = swoole_get_local_mac();"},"swoole_strerror":{"comment":"从标准的Unix Errno错误码转换成错误信息","parameters":{"errno":{"comment":"标准错误码","options":[],"type":"int"}},"return":"string","example":""},"swoole_errno":{"comment":"获取最近一次系统调用的错误码","parameters":[],"return":"int","example":"echo swoole_strerror(swoole_errno());"}}} \ No newline at end of file diff --git a/src/swoole/swoole_async.json b/src/swoole/swoole_async.json deleted file mode 100644 index 11f7481..0000000 --- a/src/swoole/swoole_async.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_async"},"comment":"异步IO操作","namespace":"","consts":[],"properties":[],"methods":{"read":{"access":"public","comment":"异步读文件,使用此函数读取文件是非阻塞的,当读操作完成时会自动回调指定的函数","isStatic":true,"return":"boolean","example":"","parameters":{"filename":{"comment":"读入的文件名","type":"string","options":[]},"callback":{"comment":"读文件完成后的回调函数(回调函数可使用的参数$fileName, $content)","type":"callable","options":[]},"chunk_size":{"comment":"每次读入的块大小","type":"int","options":[]},"offset":{"comment":"读入每次的偏移量","type":"int","options":[]}}},"write":{"access":"public","comment":"异步写文件,与swoole_async_writefile不同,write是分段读写的。不需要一次性将要写的内容放到内存里,所以只占用少量内存。swoole_async_write通过传入的offset参数来确定写入的位置","isStatic":true,"return":"","example":"","parameters":{"filename":{"comment":"写入的文件名","type":"string","options":[]},"content":{"comment":"写入的内容","type":"string","options":[]},"offset":{"comment":"写入的位置","type":"int","options":[]},"callback":{"comment":"写操作完成后的回调函数","type":"callable","options":[]}}},"readFile":{"access":"public","comment":"异步读取文件内容","isStatic":true,"return":"","example":"","parameters":{"filename":{"comment":"读入的文件名","type":"string","options":[]},"callback":{"comment":"读文件完成后的回调函数","type":"callable","options":[]}}},"writeFile":{"access":"public","comment":"异步写文件","isStatic":true,"return":"","example":"","parameters":{"filename":{"comment":"写入的文件名","type":"string","options":[]},"content":{"comment":"写入的内容","type":"string","options":[]},"callback":{"comment":"写操作完成后的回调函数","type":"callable","options":[]},"flags":{"comment":"参数4为写入的选项,可以使用FILE_APPEND表示追加到文件末尾","type":"int","options":[]}}},"dnsLookup":{"access":"public","comment":"将域名解析为IP地址。调用此函数是非阻塞的,调用会立即返回。将向下执行后面的代码(当DNS查询完成时,自动回调指定的callback函数)","isStatic":true,"return":"","example":"","parameters":{"hostname":{"comment":"域名","type":"string","options":[]},"callback":{"comment":"解析完成后的回调函数","type":"callable","options":[]}}},"dnsLookupCoro":{"access":"public","comment":"协程DNS查询","isStatic":true,"return":"","example":"","parameters":{"domain_name":{"comment":"解析的域名","type":"string","options":[]}}},"set":{"access":"public","comment":"置异步IO相关的选项\n设置的选项可以为以下值:\n thread_num : 设置异步文件IO线程的数量\n aio_mode : 设置异步文件IO的操作模式,目前支持SWOOLE_AIO_BASE(使用类似于Node.js的线程池同步阻塞模拟异步)、SWOOLE_AIO_LINUX(Linux Native AIO) 2种模式\n enable_signalfd : 开启和关闭signalfd特性的使用\n socket_buffer_size : 设置SOCKET内存缓存区尺寸\n socket_dontwait :在内存缓存区已满的情况下禁止底层阻塞等待\n log_file :设置日志文件路径\n log_level : 设置错误日志等级","isStatic":true,"return":"","example":"","parameters":{"settings":{"comment":"要设置的选项","type":"array","options":[]}}},"exec":{"access":"public","comment":"异步执行Shell命令。相当于shell_exec函数,执行后底层会fork一个子进程,并执行对应的command命令","isStatic":true,"return":"","example":"","parameters":{"command":{"comment":"为执行的终端指令,如ls","type":"string","options":[]},"callback":{"comment":"命令执行完毕子进程退出后会回调指定的$callback函数,回调函数接收2个参数,第一个参数为命令执行后的屏幕输出内容$result,第二个参数为进程退出的状态信息$status","type":"callable","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_atomic.json b/src/swoole/swoole_atomic.json deleted file mode 100644 index 43e3bc2..0000000 --- a/src/swoole/swoole_atomic.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_atomic"},"comment":"原子计数操作类,可以方便整数的无锁原子增减","namespace":"","consts":[],"properties":[],"methods":{"__construct":{"access":"public","comment":"初始化一个计数器对象","isStatic":false,"return":"","example":"","parameters":{"value":{"comment":"初始值","type":"int","options":[]}}},"add":{"access":"public","comment":"增加计数","isStatic":false,"return":"","example":"","parameters":{"add_value":{"comment":"要增加的数值,默认为1,必须为正整数","type":"int","options":[]}}},"sub":{"access":"public","comment":"减少计数","isStatic":false,"return":"","example":"","parameters":{"sub_value":{"comment":"要减少的数值,默认为1","type":"int","options":[]}}},"get":{"access":"public","comment":"获取当前计数的值","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"将当前值设置为指定的数字","isStatic":false,"return":"","example":"","parameters":{"value":{"comment":"指定要设置的目标数值","type":"int","options":[]}}},"wait":{"access":"public","comment":"当原子计数的值为0时程序进入等待状态。另外一个进程调用wakeup可以再次唤醒程序。底层基于Linux Futex实现,使用此特性,可以仅用4字节内存实现一个等待、通知、锁的功能","isStatic":false,"return":"","example":"","parameters":{"timeout":{"comment":"指定超时时间,默认为-1,表示永不超时,会持续等待直到有其他进程唤醒;超时返回false,错误码为EAGAIN,可使用swoole_errno函数获取;成功返回true,表示有其他进程通过wakeup成功唤醒了当前的锁;使用wait\/wakeup特性时,原子计数的值只能为0或1,否则会导致无法正常使用;当然原子计数的值为1时,表示不需要进入等待状态,资源当前就是可用。wait函数会立即返回true","type":"float","options":[]}}},"wakeup":{"access":"public","comment":"唤醒处于wait状态的其他进程","isStatic":false,"return":"","example":"","parameters":{"count":{"comment":"计数(当前原子计数如果为0时,表示没有进程正在wait,wakeup会立即返回true;当前原子计数如果为1时,表示当前有进程正在wait,wakeup会唤醒等待的进程,并返回true;如果同时有多个进程处于wait状态,$n参数可以控制唤醒的进程数量;被唤醒的进程返回后,会将原子计数设置为0,这时可以再次调用wakeup唤醒其他正在wait的进程)","type":"int","options":[]}}},"cmpset":{"access":"public","comment":"如果当前计数器的值与比较的值的相等,则设置它为新的值","isStatic":false,"return":"","example":"","parameters":{"cmp_value":{"comment":"用于比较的值","type":"int","options":[]},"new_value":{"comment":"用于设置的新值","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_atomic_long.json b/src/swoole/swoole_atomic_long.json deleted file mode 100644 index 97e66cb..0000000 --- a/src/swoole/swoole_atomic_long.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_atomic_long"},"comment":"swoole对64位有符号长整型原子计数的支持","namespace":"","consts":[],"properties":[],"methods":{"__construct":{"access":"public","comment":"创建一个64位的长整型原子计数对象","isStatic":false,"return":"","example":"","parameters":{"value":{"comment":"初始化数值","type":"int","options":[]}}},"add":{"access":"public","comment":"增加计数","isStatic":false,"return":"mixed","example":"","parameters":{"add_value":{"comment":"要增加的数值,默认为1,必须为正整数","type":"int","options":[]}}},"sub":{"access":"public","comment":"减少计数","isStatic":false,"return":"","example":"","parameters":{"sub_value":{"comment":"要减少的数值,默认为1","type":"int","options":[]}}},"get":{"access":"public","comment":"获取当前计数的值","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"将当前值设置为指定的数字","isStatic":false,"return":"","example":"","parameters":{"value":{"comment":"指定要设置的目标数值","type":"int","options":[]}}},"cmpset":{"access":"public","comment":"如果当前数值等于参数1,则将当前数值设置为参数2","isStatic":false,"return":"","example":"","parameters":{"cmp_value":{"comment":"用于比较的值","type":"int","options":[]},"new_value":{"comment":"用于设置的新值","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_buffer.json b/src/swoole/swoole_buffer.json deleted file mode 100644 index baeed5f..0000000 --- a/src/swoole/swoole_buffer.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_buffer"},"comment":"让PHP开发者可以像C一样直接读写内存,提升程序的性能,又不用担心内存越界。swoole_buffer会检测offset(swoole_buffer申请的内存并非共享内存,所以无法在多个进程间被共享)","namespace":"","consts":[],"properties":{"length":{"access":"public","comment":"当前数据的长度","isStatic":false,"type":"int","value":0},"capacity":{"access":"public","comment":"当前缓存区的容量","isStatic":false,"type":"int","value":0}},"methods":{"__construct":{"access":"public","comment":"buffer初始化(创建一个内存对象)","isStatic":false,"return":"","example":"","parameters":{"size":{"comment":"指定了缓冲区内存的初始尺寸。当申请的内存容量不够时swoole底层会自动扩容","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构方法","isStatic":false,"return":"","example":"","parameters":[]},"__toString":{"access":"public","comment":"将对象转化为string","isStatic":false,"return":"","example":"","parameters":[]},"substr":{"access":"public","comment":"从缓冲区取出内容(会复制一次内存)","isStatic":false,"return":"string","example":"","parameters":{"offset":{"comment":"表示偏移量,如果为负数,表示倒数计算偏移量","type":"int","options":[]},"length":{"comment":"表示读取数据的长度,默认为从 $offset 到整个缓存区末尾","type":"int","options":[]},"seek":{"comment":"表示从缓冲区的头部将此数据移除","type":"boolean","options":[]}}},"write":{"access":"public","comment":"往缓冲区中写入内容(向缓存区的任意内存位置写数据。read\/write函数可以直接读写内存。所以使用务必要谨慎,否则可能会破坏现有数据。)","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]},"data":{"comment":"写入的数据","type":"string","options":[]}}},"read":{"access":"public","comment":"从缓冲区读内容(此接口是一个底层接口,可直接操作内存)","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]},"length":{"comment":"要读取的数据长度","type":"int","options":[]}}},"append":{"access":"public","comment":"将数据添加到缓冲区末尾","isStatic":false,"return":"int","example":"","parameters":{"data":{"comment":"要写入的数据,支持二进制内容","type":"string","options":[]}}},"expand":{"access":"public","comment":"给缓冲区扩容","isStatic":false,"return":"","example":"","parameters":{"size":{"comment":"指定新的缓冲区尺寸,必须大于当前的尺寸","type":"int","options":[]}}},"recycle":{"access":"public","comment":"回收缓冲中已经废弃的内存","isStatic":false,"return":"","example":"","parameters":[]},"clear":{"access":"public","comment":"清理缓冲区数据(执行此操作后,缓存区将重置。swoole_buffer对象就可以用来处理新的请求了)","isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_channel.json b/src/swoole/swoole_channel.json deleted file mode 100644 index e968e8e..0000000 --- a/src/swoole/swoole_channel.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_channel"},"comment":"一个新的内存数据结构Channel,类似于Go的chan通道,底层基于共享内存+Mutex互斥锁实现,可实现用户态的高性能内存队列(Channel可用于多进程环境下,底层在读取写入时会自动加锁,应用层不需要担心数据同步问题;必须在父进程内创建才可以在子进程内使用)","namespace":"","consts":[],"properties":[],"methods":{"__construct":{"access":"public","comment":"创建通道","isStatic":false,"return":"","example":"","parameters":{"size":{"comment":"通道占用的内存的尺寸,单位为字节。最小值为64K,最大值没有限制","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构方法","isStatic":false,"return":"","example":"","parameters":[]},"push":{"access":"public","comment":"向通道写入数据","isStatic":false,"return":"boolean","example":"","parameters":{"data":{"comment":"可以为任意PHP变量,当$data是非字符串类型时底层会自动进行串化($data的尺寸超过8K时会启用临时文件存储数据;$data必须为非空变量,如空字符串、空数组、0、null、false)","type":"mixed","options":[]}}},"pop":{"access":"public","comment":"弹出数据","isStatic":false,"return":"","example":"","parameters":[]},"stats":{"access":"public","comment":"获取通道的状态(返回一个数组,包括2项信息:queue_num 通道中的元素数量;queue_bytes 通道当前占用的内存字节数)","isStatic":false,"return":"array","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_client.json b/src/swoole/swoole_client.json deleted file mode 100644 index 9a843b7..0000000 --- a/src/swoole/swoole_client.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_client"},"comment":"提供了tcp\/udp socket的客户端的封装代码","namespace":"","consts":{"MSG_OOB":{"comment":"读取带外数据","type":"int","value":1},"MSG_PEEK":{"comment":"窥视socket缓存区中的数据。设置MSG_PEEK参数后,recv读取数据不会修改指针,因此下一次调用recv仍然会从上一次的位置起返回数据","type":"int","value":2},"MSG_DONTWAIT":{"comment":"非阻塞接收数据,无论是否有数据都会立即返回","type":"int","value":64},"MSG_WAITALL":{"comment":"阻塞等待直到收到指定长度的数据后返回","type":"int","value":256}},"properties":{"errCode":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0},"sock":{"access":"public","type":"int","comment":"此socket的文件描述符","isStatic":false,"value":0},"reuse":{"access":"public","type":"boolean","comment":"表示此连接是新创建的还是复用已存在的","isStatic":false,"value":false},"reuseCount":{"access":"public","type":"int","comment":"表示此连接复用次数","isStatic":false,"value":0},"type":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"id":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"setting":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onConnect":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onError":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onReceive":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onClose":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onBufferFull":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onBufferEmpty":{"access":"public","type":"unknown","comment":false,"isStatic":false}},"methods":{"__construct":{"access":"public","comment":"创建tcp客户端对象","isStatic":false,"return":"","example":"","parameters":{"type":{"comment":"表示socket的类型,如TCP\/UDP(使用常量)","type":"int","options":[]},"async":{"comment":"表示同步阻塞还是异步非阻塞,默认为同步阻塞","type":"boolean","options":[]}}},"__destruct":{"access":"public","comment":"析构方法","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置客户端参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"设置的参数","type":"array","options":[]}}},"connect":{"access":"public","comment":"连接远程服务器","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"是远程服务器的地址,1.9.24或更高版本已支持自动异步解析域名,$host可直接传入域名","type":"string","options":[]},"port":{"comment":"是远程服务器端口","type":"int","options":[]},"timeout":{"comment":"是网络IO的超时,包括connect\/send\/recv,单位是s,支持浮点数。默认为0.5s,即500ms","type":"float","options":[]},"sock_flag":{"comment":"在UDP类型时表示是否启用udp_connect 设定此选项后将绑定$host与$port,此UDP将会丢弃非指定host\/port的数据包;","type":"int","options":[]}}},"recv":{"access":"public","comment":"从服务器端接收数据","isStatic":false,"return":"string","example":"","parameters":{"size":{"comment":"接收数据的缓存区最大长度,此参数不要设置过大,否则会占用较大内存","type":"int","options":[]},"flag":{"comment":"是否等待所有数据到达后返回","type":"boolean","options":[]}}},"send":{"access":"public","comment":"发送数据到远程服务器","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要发送的数据","type":"string","options":[]},"flag":{"comment":"是否等待所有数据到达后返回","type":"boolean","options":[]}}},"pipe":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"dst_socket":{"comment":"","type":"unknown","options":[]}}},"sendfile":{"access":"public","comment":"向服务器发送文件","isStatic":false,"return":"boolean","example":"","parameters":{"filename":{"comment":"指定要发送文件的路径","type":"string","options":[]},"offset":{"comment":"上传文件的偏移量,可以指定从文件的中间部分开始传输数据。此特性可用于支持断点续传","type":"int","options":[]},"length":{"comment":"发送数据的尺寸,默认为整个文件的尺寸","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意主机发送UDP数据包","isStatic":false,"return":"boolean","example":"","parameters":{"ip":{"comment":"目标主机的IP地址,支持IPv4\/IPv6","type":"string","options":[]},"port":{"comment":"目标主机端口","type":"int","options":[]},"data":{"comment":"要发送的数据内容,不得超过64K","type":"string","options":[]}}},"sleep":{"access":"public","comment":"调用此方法会从事件循环中移除当前socket的可读监听,停止接收数据","isStatic":false,"return":"","example":"","parameters":[]},"wakeup":{"access":"public","comment":"调用此方法会重新监听可读事件,将socket连接从睡眠中唤醒","isStatic":false,"return":"","example":"","parameters":[]},"pause":{"access":"public","comment":"停止接收数据","isStatic":false,"return":"","example":"","parameters":[]},"resume":{"access":"public","comment":"恢复数据接收。与pause方法成对使用","isStatic":false,"return":"","example":"","parameters":[]},"isConnected":{"access":"public","comment":"返回swoole_client的连接状态","isStatic":false,"return":"","example":"","parameters":[]},"getsockname":{"access":"public","comment":"用于获取客户端socket的本地host:port,必须在连接之后才可以使用","isStatic":false,"return":"","example":"","parameters":[]},"getpeername":{"access":"public","comment":"获取对端socket的IP地址和端口","isStatic":false,"return":"","example":"","parameters":[]},"close":{"access":"public","comment":"关闭连接","isStatic":false,"return":"","example":"","parameters":{"force":{"comment":"表示强制关闭连接,可用于关闭SWOOLE_KEEP长连接","type":"boolean","options":[]}}},"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件类型,支持connect\/error\/receive\/close 4种","type":"string","options":[]},"callback":{"comment":"回调函数,可以是函数名字符串、匿名函数、类静态方法、对象方法","type":"callable","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_client_coro.json b/src/swoole/swoole_client_coro.json deleted file mode 100644 index 00f76ad..0000000 --- a/src/swoole/swoole_client_coro.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_client_coro"},"comment":false,"namespace":"","consts":{"MSG_OOB":{"comment":"","type":"unknown","value":1},"MSG_PEEK":{"comment":"","type":"unknown","value":2},"MSG_DONTWAIT":{"comment":"","type":"unknown","value":64},"MSG_WAITALL":{"comment":"","type":"unknown","value":256}},"properties":{"errCode":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"sock":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"type":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"setting":{"access":"public","type":"unknown","comment":false,"isStatic":false}},"methods":{"__construct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"type":{"comment":"","type":"unknown","options":[]}}},"__destruct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"","type":{},"options":[]}}},"connect":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"","type":"unknown","options":[]},"port":{"comment":"","type":"unknown","options":[]},"timeout":{"comment":"","type":"unknown","options":[]}}},"recv":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"send":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"","type":"unknown","options":[]},"flag":{"comment":"","type":"unknown","options":[]}}},"sendfile":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"filename":{"comment":"","type":"unknown","options":[]},"offset":{"comment":"","type":"unknown","options":[]},"length":{"comment":"","type":"unknown","options":[]}}},"sendto":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"ip":{"comment":"","type":"unknown","options":[]},"port":{"comment":"","type":"unknown","options":[]},"data":{"comment":"","type":"unknown","options":[]}}},"isConnected":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getsockname":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getpeername":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"close":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_connection_iterator.json b/src/swoole/swoole_connection_iterator.json deleted file mode 100644 index bc4b2a7..0000000 --- a/src/swoole/swoole_connection_iterator.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_connection_iterator"},"comment":false,"namespace":"","consts":[],"properties":[],"methods":{"rewind":{"access":"public","comment":"返回到连接迭代器的第一个元素","isStatic":false,"return":"","example":"","parameters":[]},"next":{"access":"public","comment":"向前移动到下一个元素","isStatic":false,"return":"","example":"","parameters":[]},"current":{"access":"public","comment":"返回当前元素","isStatic":false,"return":"","example":"","parameters":[]},"key":{"access":"public","comment":"返回当前元素的键","isStatic":false,"return":"","example":"","parameters":[]},"valid":{"access":"public","comment":"检查当前位置是否有效","isStatic":false,"return":"","example":"","parameters":[]},"count":{"access":"public","comment":"计算迭代器中元素的个数","isStatic":false,"return":"int","example":"","parameters":[]},"offsetExists":{"access":"public","comment":"检查一个偏移位置是否存在","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"offsetGet":{"access":"public","comment":"取一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"offsetSet":{"access":"public","comment":"设置一个偏移位置的值(来自ArrayAccess接口)","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"value":{"comment":"需要设置的值","type":"mixed","options":[]}}},"offsetUnset":{"access":"public","comment":"复位一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_coroutine.json b/src/swoole/swoole_coroutine.json deleted file mode 100644 index 5dcac47..0000000 --- a/src/swoole/swoole_coroutine.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_coroutine"},"comment":"swoole内置协程(协程可以理解为纯用户态的线程,其通过协作而不是抢占来进行切换。相对于进程或者线程,协程所有的操作都可以在用户态完成,创建和切换的消耗更低。Swoole可以为每一个请求创建对应的协程,根据IO的状态来合理的调度协程)","namespace":"","consts":[],"properties":[],"methods":{"create":{"access":"public","comment":"创建协程","isStatic":true,"return":"","example":"","parameters":[]},"cli_wait":{"access":"public","comment":false,"isStatic":true,"return":"","example":"","parameters":[]},"suspend":{"access":"public","comment":"挂起当前协程","isStatic":true,"return":"","example":"","parameters":[]},"resume":{"access":"public","comment":"恢复某个协程,使其继续运行","isStatic":true,"return":"","example":"","parameters":[]},"getuid":{"access":"public","comment":"获取当前协程的ID","isStatic":true,"return":"int","example":"","parameters":[]},"sleep":{"access":"public","comment":"进入等待状态。相当于PHP的sleep函数,不同的是Coroutine::sleep是协程调度器实现的,底层会yield当前协程,让出时间片,并添加一个异步定时器,当超时时间到达时重新resume当前协程,恢复运行。使用sleep接口可以方便地实现超时等待功能。","isStatic":true,"return":"","example":"","parameters":{"seconds":{"comment":"为睡眠的时间,单位为秒,支持浮点型,最小精度为毫秒","type":"float","options":[]}}},"call_user_func":{"access":"public","comment":"协程版反射调用函数","isStatic":true,"return":"","example":"","parameters":[]},"call_user_func_array":{"access":"public","comment":"协程版反射调用函数","isStatic":true,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_coroutine_client.json b/src/swoole/swoole_coroutine_client.json deleted file mode 100644 index 58e9392..0000000 --- a/src/swoole/swoole_coroutine_client.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"Swoole\\Coroutine\\Client"},"comment":"提供了TCP和UDP传输协议Socket客户端的封装代码","namespace":"Swoole\\Coroutine","consts":{"MSG_OOB":{"comment":"读取带外数据","type":"int","value":1},"MSG_PEEK":{"comment":"窥视socket缓存区中的数据。设置MSG_PEEK参数后,recv读取数据不会修改指针,因此下一次调用recv仍然会从上一次的位置起返回数据","type":"int","value":2},"MSG_DONTWAIT":{"comment":"非阻塞接收数据,无论是否有数据都会立即返回","type":"int","value":64},"MSG_WAITALL":{"comment":"阻塞等待直到收到指定长度的数据后返回","type":"int","value":256}},"properties":{"errCode":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0},"sock":{"access":"public","type":"int","comment":"此socket的文件描述符","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket 类型","isStatic":false,"value":0},"setting":{"access":"public","type":"array","comment":"设置参数","isStatic":false}},"methods":{"__construct":{"access":"public","comment":"客户端初始化","isStatic":false,"return":"","example":"","parameters":{"type":{"comment":"表示socket的类型,如TCP\/UDP","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置客户端参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置参数","type":"array","options":[]}}},"connect":{"access":"public","comment":"连接到远程服务器","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"远程服务器的地址","type":"string","options":[]},"port":{"comment":"远程服务器端口","type":"int","options":[]},"timeout":{"comment":"网络IO的超时,包括connect\/send\/recv,单位是s,支持浮点数。默认为0.1s,即100ms,超时发生时,连接会被自动close掉","type":"float","options":[]}}},"recv":{"access":"public","comment":"用于从服务器端接收数据。底层会自动yield,等待数据接收完成后自动切换到当前协程","isStatic":false,"return":"string","example":"","parameters":[]},"send":{"access":"public","comment":"发送数据","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要发送的数据","type":"string","options":[]},"flag":{"comment":"是否立即返回","type":"boolean","options":[]}}},"sendfile":{"access":"public","comment":"发送文件到服务器,本函数是基于sendfile操作系统调用的","isStatic":false,"return":"boolean","example":"","parameters":{"filename":{"comment":"指定要发送文件的路径","type":"string","options":[]},"offset":{"comment":"上传文件的偏移量,可以指定从文件的中间部分开始传输数据。此特性可用于支持断点续传","type":"int","options":[]},"length":{"comment":"发送数据的尺寸,默认为整个文件的尺寸","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意IP:PORT的主机发送UDP数据包,仅支持SWOOLE_SOCK_UDP\/SWOOLE_SOCK_UDP6类型的swoole_client对象。","isStatic":false,"return":"boolean","example":"","parameters":{"ip":{"comment":"目标主机的IP地址,支持IPv4\/IPv6","type":"string","options":[]},"port":{"comment":"目标主机端口","type":"int","options":[]},"data":{"comment":"要发送的数据内容,不得超过64K","type":"string","options":[]}}},"isConnected":{"access":"public","comment":"返回swoole_client的连接状态","isStatic":false,"return":"boolean","example":"","parameters":[]},"getsockname":{"access":"public","comment":"用于获取客户端socket的本地host:port,必须在连接之后才可以使用","isStatic":false,"return":"array","example":"","parameters":[]},"getpeername":{"access":"public","comment":"获取对端socket的IP地址和端口,仅支持SWOOLE_SOCK_UDP\/SWOOLE_SOCK_UDP6类型的swoole_client对象","isStatic":false,"return":"boolean","example":"","parameters":[]},"close":{"access":"public","comment":"关闭连接","isStatic":false,"return":"boolean","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_coroutine_http_client.json b/src/swoole/swoole_coroutine_http_client.json deleted file mode 100644 index 3e64ae0..0000000 --- a/src/swoole/swoole_coroutine_http_client.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"Swoole\\Coroutine\\Http\\Client"},"comment":"http协程客户端","namespace":"Swoole\\Coroutine\\Http","consts":[],"properties":{"type":{"access":"public","type":"int","comment":"socket类型","isStatic":false,"value":0},"errCode":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0},"statusCode":{"access":"public","type":"int","comment":"状态码","isStatic":false,"value":0},"host":{"access":"public","type":"string","comment":"请求的服务器地址","isStatic":false},"port":{"access":"public","type":"int","comment":"请求的服务器端口","isStatic":false,"value":0},"requestMethod":{"access":"public","type":"string","comment":"请求方式","isStatic":false},"requestHeaders":{"access":"public","type":"array","comment":"请求头","isStatic":false},"requestBody":{"access":"public","type":"string","comment":"请求体","isStatic":false},"uploadFiles":{"access":"public","type":"array","comment":"上传的文件","isStatic":false},"headers":{"access":"public","type":"array","comment":"请求响应头","isStatic":false},"cookies":{"access":"public","type":"array","comment":"请求响应cookie","isStatic":false},"body":{"access":"public","type":"string","comment":"请求响应后服务器端返回的内容","isStatic":false}},"methods":{"__construct":{"access":"public","comment":"客户端初始化函数","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置选项","isStatic":false,"return":"","example":"","parameters":[]},"setMethod":{"access":"public","comment":"设置请求方式","isStatic":false,"return":"","example":"","parameters":[]},"setHeaders":{"access":"public","comment":"设置请求头","isStatic":false,"return":"","example":"","parameters":[]},"setCookies":{"access":"public","comment":"设置cookie","isStatic":false,"return":"","example":"","parameters":[]},"setData":{"access":"public","comment":"设置Http请求的包体","isStatic":false,"return":"","example":"","parameters":[]},"execute":{"access":"public","comment":"更底层的Http请求方法,需要代码中调用setMethod和setData等接口设置请求的方法和数据","isStatic":false,"return":"","example":"","parameters":[]},"get":{"access":"public","comment":"发起GET请求","isStatic":false,"return":"","example":"","parameters":[]},"post":{"access":"public","comment":"发送POST请求","isStatic":false,"return":"","example":"","parameters":[]},"addFile":{"access":"public","comment":"添加POST文件","isStatic":false,"return":"","example":"","parameters":[]},"isConnected":{"access":"public","comment":"连接是否成功","isStatic":false,"return":"boolean","example":"","parameters":[]},"close":{"access":"public","comment":"关闭连接","isStatic":false,"return":"","example":"","parameters":[]},"setDefer":{"access":"public","comment":"设置是否延迟","isStatic":false,"return":"boolean","example":"","parameters":[]},"getDefer":{"access":"public","comment":"返回当前设置的defer","isStatic":false,"return":"boolean","example":"","parameters":[]},"recv":{"access":"public","comment":"用于从服务器端接收数据。底层会自动yield,等待数据接收完成后自动切换到当前协程","isStatic":false,"return":"string","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_coroutine_mysql.json b/src/swoole/swoole_coroutine_mysql.json deleted file mode 100644 index 2a33e8d..0000000 --- a/src/swoole/swoole_coroutine_mysql.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"Swoole\\Coroutine\\MySQL"},"comment":"mysql操作协程客户端","namespace":"Swoole\\Coroutine","consts":[],"properties":{"serverInfo":{"access":"private","type":"array","comment":"连接信息,保存的是传递给构造函数的数组","isStatic":false,"value":""},"sock":{"access":"public","type":"int","comment":"连接使用的文件描述符","isStatic":false,"value":0},"connected":{"access":"public","type":"boolean","comment":"是否连接上了MySQL服务器","isStatic":false,"value":false},"connect_error":{"access":"public","type":"string","comment":"连接错误信息","isStatic":false,"value":""},"connect_errno":{"access":"public","type":"int","comment":"连接错误码","isStatic":false,"value":0},"affected_rows":{"access":"public","type":"int","comment":"影响的行数","isStatic":false,"value":0},"insert_id":{"access":"public","type":"int","comment":"最后一个插入的记录id","isStatic":false,"value":0},"error":{"access":"public","type":"string","comment":"错误信息","isStatic":false,"value":""},"errno":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0}},"methods":{"__construct":{"access":"public","comment":"mysql异步客户端初始化","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"connect":{"access":"public","comment":"连接mysql服务器","isStatic":false,"return":"","example":"$server = array(\n 'host' => '192.168.56.102',\n 'user' => 'test',\n 'password' => 'test',\n 'database' => 'test',\n 'charset' => 'utf8',\n);","parameters":{"server_config":{"comment":"连接配置信息","type":"array","options":[]}}},"query":{"access":"public","comment":"执行sql语句","isStatic":false,"return":"array|boolean","example":"","parameters":{"sql":{"comment":"要执行的sql语句","type":"string","options":[]},"timeout":{"comment":"超时时间,超时的话会断开MySQL连接,0表示不设置超时时间","type":"double","options":[]}}},"recv":{"access":"public","comment":"接收包(获取延迟收包的结果,当没有进行延迟收包或者收包超时,返回false)","isStatic":false,"return":"mixed","example":"","parameters":[]},"begin":{"access":"public","comment":"启动事务","isStatic":false,"return":"","example":"","parameters":[]},"commit":{"access":"public","comment":"提交事务","isStatic":false,"return":"","example":"","parameters":[]},"rollback":{"access":"public","comment":"回滚事务(必须先调用begin启动事务才能调用rollback否则底层会抛出异常)","isStatic":false,"return":"","example":"","parameters":[]},"setDefer":{"access":"public","comment":"设置是否延迟","isStatic":false,"return":"boolean","example":"","parameters":{"defer":{"comment":"为true时,表明该Client要延迟收包,为false时,表明该Client非延迟收包,默认值为true","type":"boolean","options":[]}}},"getDefer":{"access":"public","comment":"返回当前设置的defer","isStatic":false,"return":"boolean","example":"","parameters":[]},"close":{"access":"public","comment":"关闭连接","isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_coroutine_mysql_exception.json b/src/swoole/swoole_coroutine_mysql_exception.json deleted file mode 100644 index 58adef2..0000000 --- a/src/swoole/swoole_coroutine_mysql_exception.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"Swoole\\Coroutine\\MySQL\\Exception"},"comment":"swoole mysql 协程 异常类","namespace":"Swoole\\Coroutine\\MySQL","extends":"Exception","consts":[],"properties":{"message":{"access":"protected","type":"string","comment":"异常错误信息","isStatic":false,"value":""},"code":{"access":"protected","type":"int","comment":"异常错误码","isStatic":false,"value":0},"file":{"access":"protected","type":"string","comment":"错误文件位置","isStatic":false},"line":{"access":"protected","type":"int","comment":"错误文件行数","isStatic":false}},"methods":{"__clone":{"access":"private","isFinal":1,"comment":"克隆魔术方法(这里禁止克隆)","isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":"异常初始化","isStatic":false,"return":"","example":"","parameters":{"message":{"comment":"异常提示信息","type":"string","options":[]},"code":{"comment":"异常错误码","type":"int","options":[]},"previous":{"comment":"异常链中的前一个异常","type":"Throwable","options":[]}}},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"getMessage":{"access":"public","isFinal":1,"comment":"获取异常提示信息","isStatic":false,"return":"string","example":"","parameters":[]},"getCode":{"access":"public","isFinal":1,"comment":"获取异常代码","isStatic":false,"return":"int","example":"","parameters":[]},"getFile":{"access":"public","isFinal":1,"comment":"创建异常时的程序文件名称","isStatic":false,"return":"string","example":"","parameters":[]},"getLine":{"access":"public","isFinal":1,"comment":"获取创建的异常所在文件中的行号","isStatic":false,"return":"int","example":"","parameters":[]},"getTrace":{"access":"public","isFinal":1,"comment":"获取异常追踪信息","isStatic":false,"return":"array","example":"","parameters":[]},"getPrevious":{"access":"public","isFinal":1,"comment":"返回异常链中的前一个异常","isStatic":false,"return":"Throwable","example":"","parameters":[]},"getTraceAsString":{"access":"public","isFinal":1,"comment":"获取字符串类型的异常追踪信息","isStatic":false,"return":"string","example":"","parameters":[]},"__toString":{"access":"public","comment":"将异常信息转化为字符串","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_event.json b/src/swoole/swoole_event.json deleted file mode 100644 index 4d54cf0..0000000 --- a/src/swoole/swoole_event.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_event"},"comment":"swoole 事件处理","namespace":"","consts":[],"properties":[],"methods":{"add":{"access":"public","comment":"将一个socket加入到底层的reactor事件监听中","isStatic":true,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"read_callback":{"comment":"读事件回调","type":"callable","options":[]},"write_callback":{"comment":"写事件回调","type":"callable","options":[]},"events":{"comment":"事件类型的掩码,可选择关闭\/开启可读可写事件,如SWOOLE_EVENT_READ,SWOOLE_EVENT_WRITE,或者SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE","type":"int","options":[]}}},"del":{"access":"public","comment":"从reactor中移除监听的socket","isStatic":true,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"set":{"access":"public","comment":"修改事件监听的回调函数和掩码","isStatic":true,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"read_callback":{"comment":"将修改可读事件回调函数为指定的函数","type":"callable","options":[]},"write_callback":{"comment":"修改可写事件回调函数为指定的函数","type":"callable","options":[]},"events":{"comment":"可关闭\/开启,可写(SW_EVENT_READ)和可读(SW_EVENT_WRITE)事件的监听","type":"int","options":[]}}},"exit":{"access":"public","comment":"退出事件循环","isStatic":true,"return":"","example":"","parameters":[]},"write":{"access":"public","comment":"将stream\/sockets资源的数据发送变成异步的,当缓冲区满了或者返回EAGAIN,swoole底层会将数据加入到发送队列,并监听可写。socket可写时swoole底层会自动写入","isStatic":true,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"data":{"comment":"写入的数据","type":"string","options":[]}}},"wait":{"access":"public","comment":"使脚本开始进行事件轮询","isStatic":true,"return":"","example":"","parameters":[]},"defer":{"access":"public","comment":"在下一个事件循环开始时执行函数","isStatic":true,"return":"","example":"","parameters":{"callback":{"comment":"执行的函数","type":"callable","options":[]}}},"cycle":{"access":"public","comment":"定义事件循环周期执行函数。此函数会在每一轮事件循环结束时调用","isStatic":true,"return":"","example":"","parameters":{"callback":{"comment":"循环调用的函数","type":"callable","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_exception.json b/src/swoole/swoole_exception.json deleted file mode 100644 index ea1d237..0000000 --- a/src/swoole/swoole_exception.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_exception"},"comment":"swoole 异常类","namespace":"","extends":"Exception","consts":[],"properties":{"message":{"access":"protected","type":"string","comment":"异常错误信息","isStatic":false,"value":""},"code":{"access":"protected","type":"int","comment":"异常错误码","isStatic":false,"value":0},"file":{"access":"protected","type":"string","comment":"错误文件位置","isStatic":false},"line":{"access":"protected","type":"int","comment":"错误文件行数","isStatic":false}},"methods":{"__clone":{"access":"private","isFinal":1,"comment":"克隆魔术方法(这里禁止克隆)","isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":"异常初始化","isStatic":false,"return":"","example":"","parameters":{"message":{"comment":"异常提示信息","type":"string","options":[]},"code":{"comment":"异常错误码","type":"int","options":[]},"previous":{"comment":"异常链中的前一个异常","type":"Throwable","options":[]}}},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"getMessage":{"access":"public","isFinal":1,"comment":"获取异常提示信息","isStatic":false,"return":"string","example":"","parameters":[]},"getCode":{"access":"public","isFinal":1,"comment":"获取异常代码","isStatic":false,"return":"int","example":"","parameters":[]},"getFile":{"access":"public","isFinal":1,"comment":"创建异常时的程序文件名称","isStatic":false,"return":"string","example":"","parameters":[]},"getLine":{"access":"public","isFinal":1,"comment":"获取创建的异常所在文件中的行号","isStatic":false,"return":"int","example":"","parameters":[]},"getTrace":{"access":"public","isFinal":1,"comment":"获取异常追踪信息","isStatic":false,"return":"array","example":"","parameters":[]},"getPrevious":{"access":"public","isFinal":1,"comment":"返回异常链中的前一个异常","isStatic":false,"return":"Throwable","example":"","parameters":[]},"getTraceAsString":{"access":"public","isFinal":1,"comment":"获取字符串类型的异常追踪信息","isStatic":false,"return":"string","example":"","parameters":[]},"__toString":{"access":"public","comment":"将异常信息转化为字符串","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_http_client.json b/src/swoole/swoole_http_client.json deleted file mode 100644 index 377fc25..0000000 --- a/src/swoole/swoole_http_client.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_http_client"},"comment":"HTTP异步客户端","namespace":"","consts":[],"properties":{"type":{"access":"public","type":"int","comment":"socket类型","isStatic":false,"value":0},"errCode":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0},"sock":{"access":"public","type":"int","comment":"socket的文件描述符","isStatic":false,"value":0},"statusCode":{"access":"public","type":"int","comment":"状态码","isStatic":false,"value":0},"host":{"access":"public","type":"string","comment":"请求的服务器地址","isStatic":false},"port":{"access":"public","type":"int","comment":"请求的服务器端口","isStatic":false,"value":0},"requestMethod":{"access":"public","type":"string","comment":"请求方式","isStatic":false},"requestHeaders":{"access":"public","type":"array","comment":"请求头","isStatic":false},"requestBody":{"access":"public","type":"string","comment":"请求体","isStatic":false},"uploadFiles":{"access":"public","type":"array","comment":"上传的文件","isStatic":false},"set_cookie_headers":{"access":"public","type":"array","comment":"设置请求头中的cookie","isStatic":false},"downloadFile":{"access":"public","type":"string","comment":"下载文件","isStatic":false},"headers":{"access":"public","type":"array","comment":"请求响应头","isStatic":false},"cookies":{"access":"public","type":"array","comment":"请求响应cookie","isStatic":false},"body":{"access":"public","type":"string","comment":"请求响应后服务器端返回的内容","isStatic":false},"onConnect":{"access":"public","type":"callable","comment":"连接成功的回调函数","isStatic":false},"onError":{"access":"public","type":"callable","comment":"连接错误时的回调函数","isStatic":false},"onMessage":{"access":"public","type":"callable","comment":"当接收到消息时的回调函数(websocket)","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"连接关闭时的回调函数","isStatic":false}},"methods":{"__construct":{"access":"public","comment":"客户端连接初始化","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"连接的主机IP","type":"string","options":[]},"port":{"comment":"连接的主机端口","type":"int","options":[]},"ssl":{"comment":"是否开启TLS\/SSL隧道加密,https网站必须设置为true","type":"boolean","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置选项","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"setMethod":{"access":"public","comment":"设置请求方式","isStatic":false,"return":"","example":"","parameters":{"method":{"comment":"请求方式","type":"string","options":[]}}},"setHeaders":{"access":"public","comment":"设置请求头","isStatic":false,"return":"","example":"","parameters":{"headers":{"comment":"请求头","type":"array","options":[]}}},"setCookies":{"access":"public","comment":"设置cookie","isStatic":false,"return":"","example":"","parameters":{"cookies":{"comment":"cookie数组","type":"array","options":[]}}},"setData":{"access":"public","comment":"设置Http请求的包体","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"请求体内容","type":"string","options":[]}}},"addFile":{"access":"public","comment":"添加POST文件","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"文件的路径,必选参数,不能为空文件或者不存在的文件","type":"string","options":[]},"name":{"comment":"表单的名称,必选参数,FILES参数中的key","type":"string","options":[]},"type":{"comment":"文件的MIME格式,可选参数,底层会根据文件的扩展名自动推断","type":"string","options":[]},"filename":{"comment":"文件名称","type":"string","options":[]},"offset":{"comment":"上传文件的偏移量,可以指定从文件的中间部分开始传输数据。此特性可用于支持断点续传。","type":"int","options":[]},"length":{"comment":"发送数据的尺寸,默认为整个文件的尺寸","type":"int","options":[]}}},"execute":{"access":"public","comment":"更底层的Http请求方法,需要代码中调用setMethod和setData等接口设置请求的方法和数据","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"请求地址","type":"string","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"push":{"access":"public","comment":"向WebSocket服务器发送数据","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要发送的数据内容,默认为UTF-8文本格式,如果为其他格式编码或二进制数据,请使用WEBSOCKET_OPCODE_BINARY","type":"string","options":[]},"opcode":{"comment":"操作类型,默认为WEBSOCKET_OPCODE_TEXT_FRAME表示发送文本","type":"int","options":[]},"finish":{"comment":"发送成功后是否结束","type":"boolean","options":[]}}},"get":{"access":"public","comment":"发起GET请求","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"请求路径","type":"string","options":[]},"callback":{"comment":"请求成功后的回调函数","type":"callable","options":[]}}},"post":{"access":"public","comment":"发送POST请求","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"请求地址","type":"string","options":[]},"data":{"comment":"求的包体数据,如果$data为数组底层自动会打包为x-www-form-urlencoded格式的POST内容,并设置Content-Type为application\/x-www-form-urlencoded","type":"mixed","options":[]},"callback":{"comment":"请求成功后的回调","type":"callable","options":[]}}},"upgrade":{"access":"public","comment":"发起WebSocket握手请求,并将连接升级为WebSocket","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"请求地址","type":"string","options":[]},"callback":{"comment":"成功或失败后回调函数","type":"callable","options":[]}}},"download":{"access":"public","comment":"通过Http下载文件","isStatic":false,"return":"","example":"","parameters":{"path":{"comment":"请求地址","type":"string","options":[]},"file":{"comment":"指定下载内容写入的文件路径,会自动写入到downloadFile属性","type":"string","options":[]},"callback":{"comment":"下载成功后的回调函数","type":"callable","options":[]},"offset":{"comment":"为0时若文件已存在,底层会自动清空此文件","type":"int","options":[]}}},"isConnected":{"access":"public","comment":"连接是否成功","isStatic":false,"return":"boolean","example":"","parameters":[]},"close":{"access":"public","comment":"关闭连接","isStatic":false,"return":"","example":"","parameters":[]},"on":{"access":"public","comment":"绑定事件","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_http_client_coro.json b/src/swoole/swoole_http_client_coro.json deleted file mode 100644 index 590e6cb..0000000 --- a/src/swoole/swoole_http_client_coro.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_http_client_coro"},"comment":false,"namespace":"","consts":[],"properties":{"type":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"errCode":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"statusCode":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"host":{"access":"public","type":"unknown","comment":false,"isStatic":false},"port":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"requestMethod":{"access":"public","type":"unknown","comment":false,"isStatic":false},"requestHeaders":{"access":"public","type":"unknown","comment":false,"isStatic":false},"requestBody":{"access":"public","type":"unknown","comment":false,"isStatic":false},"uploadFiles":{"access":"public","type":"unknown","comment":false,"isStatic":false},"headers":{"access":"public","type":"unknown","comment":false,"isStatic":false},"cookies":{"access":"public","type":"unknown","comment":false,"isStatic":false},"body":{"access":"public","type":"unknown","comment":false,"isStatic":false}},"methods":{"__construct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setMethod":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setHeaders":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setCookies":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setData":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"execute":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"get":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"post":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"addFile":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"isConnected":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"close":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setDefer":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getDefer":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"recv":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_http_request.json b/src/swoole/swoole_http_request.json deleted file mode 100644 index 597046f..0000000 --- a/src/swoole/swoole_http_request.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_http_request"},"comment":"http请求对象,保存了Http客户端请求的相关信息,包括GET、POST、COOKIE、Header等","namespace":"","consts":[],"properties":{"fd":{"access":"public","type":"int","comment":"http连接句柄","isStatic":false,"value":0},"header":{"access":"public","type":"array","comment":"请求头(每个key都是小写)","isStatic":false},"server":{"access":"public","type":"array","comment":"请求相当的服务器信息,相当于$_SERVER","isStatic":false},"request":{"access":"public","type":"unknown","comment":false,"isStatic":false},"cookie":{"access":"public","type":"array","comment":"请求中的cookie数据","isStatic":false},"get":{"access":"public","type":"array","comment":"get请求参数","isStatic":false},"files":{"access":"public","type":"array","comment":"请求中的文件上传信息\nname 浏览器上传时传入的文件名称","isStatic":false},"post":{"access":"public","type":"array","comment":"post请求数据","isStatic":false},"tmpfiles":{"access":"public","type":"array","comment":"临时文件信息","isStatic":false}},"methods":{"rawcontent":{"access":"public","comment":"获取请求的原始数据","isStatic":false,"return":"string","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_http_response.json b/src/swoole/swoole_http_response.json deleted file mode 100644 index ae3e01f..0000000 --- a/src/swoole/swoole_http_response.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_http_response"},"comment":"http响应对象","namespace":"","consts":[],"properties":{"fd":{"access":"public","type":"int","comment":"连接句柄","isStatic":false,"value":0},"header":{"access":"public","type":"array","comment":"请求头(每个key都是小写)","isStatic":false},"cookie":{"access":"public","type":"array","comment":"请求中的cookie数据","isStatic":false},"trailer":{"access":"public","type":"unknown","comment":false,"isStatic":false}},"methods":{"initHeader":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"cookie":{"access":"public","comment":"设置cookie","isStatic":false,"return":"","example":"","parameters":{"name":{"comment":"cookie键名","type":"string","options":[]},"value":{"comment":"cookie键值","type":"string","options":[]},"expires":{"comment":"有效期","type":"int","options":[]},"path":{"comment":"存放位置","type":"string","options":[]},"domain":{"comment":"域名","type":"string","options":[]},"secure":{"comment":"是否为HTTPS","type":"boolean","options":[]},"httponly":{"comment":"是否只是http","type":"boolean","options":[]}}},"rawcookie":{"access":"public","comment":"设置最原始的cookie信息","isStatic":false,"return":"","example":"","parameters":{"name":{"comment":"cookie键名","type":"string","options":[]},"value":{"comment":"cookie键值","type":"string","options":[]},"expires":{"comment":"有效期","type":"int","options":[]},"path":{"comment":"存放位置","type":"string","options":[]},"domain":{"comment":"域名","type":"string","options":[]},"secure":{"comment":"是否为HTTPS","type":"boolean","options":[]},"httponly":{"comment":"是否只是http","type":"boolean","options":[]}}},"status":{"access":"public","comment":"设置http状态码","isStatic":false,"return":"","example":"","parameters":{"http_code":{"comment":"状态码","type":"int","options":[]}}},"gzip":{"access":"public","comment":"启用gzip压缩","isStatic":false,"return":"","example":"","parameters":{"compress_level":{"comment":"压缩等级","type":"int","options":[]}}},"header":{"access":"public","comment":"设置响应头信息","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"响应头key","type":"string","options":[]},"value":{"comment":"响应头值","type":"string","options":[]},"ucwords":{"comment":"首字母是否大写","type":"boolean","options":[]}}},"write":{"access":"public","comment":"启用Http Chunk分段向浏览器发送相应内容","isStatic":false,"return":"","example":"","parameters":{"content":{"comment":"输出的内容","type":"string","options":[]}}},"end":{"access":"public","comment":"发送响应体,并结束当前请求","isStatic":false,"return":"","example":"","parameters":{"content":{"comment":"输出的内容","type":"string","options":[]}}},"sendfile":{"access":"public","comment":"发送文件给浏览器","isStatic":false,"return":"","example":"","parameters":{"filename":{"comment":"文件名","type":"string","options":[]},"offset":{"comment":"偏移量","type":"int","options":[]},"length":{"comment":"长度","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_http_server.json b/src/swoole/swoole_http_server.json deleted file mode 100644 index 023b42e..0000000 --- a/src/swoole/swoole_http_server.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_http_server"},"comment":"http异步客户端","namespace":"","extends":"swoole_server","consts":[],"properties":{"onConnect":{"access":"public","type":"callable","comment":"连接成功回调函数","isStatic":false},"onReceive":{"access":"public","type":"callable","comment":"接收到数据时回调此函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"TCP客户端连接关闭后,在worker进程中回调此函数","isStatic":false},"onPacket":{"access":"public","type":"callable","comment":"接收到UDP数据包时回调此函数,发生在worker进程中","isStatic":false},"onBufferFull":{"access":"public","type":"callable","comment":"当缓存区达到最高水位时触发此事件","isStatic":false},"onBufferEmpty":{"access":"public","type":"callable","comment":"当缓存区低于最低水位线时触发此事件","isStatic":false},"onStart":{"access":"public","type":"callable","comment":"Server启动在主进程的主线程回调此函数","isStatic":false},"onShutdown":{"access":"public","type":"callable","comment":"此事件在Server正常结束时发生","isStatic":false},"onWorkerStart":{"access":"public","type":"callable","comment":"此事件在Worker进程\/Task进程启动时发生","isStatic":false},"onWorkerStop":{"access":"public","type":"callable","comment":"此事件在worker进程终止时发生。在此函数中可以回收worker进程申请的各类资源","isStatic":false},"onWorkerExit":{"access":"public","type":"callable","comment":"仅在开启reload_async特性后有效。异步重启特性,会先创建新的Worker进程处理新请求,旧的Worker进程自行退出","isStatic":false},"onWorkerError":{"access":"public","type":"callable","comment":"当worker\/task_worker进程发生异常后会在Manager进程内回调此函数","isStatic":false},"onTask":{"access":"public","type":"callable","comment":"在task_worker进程内被调用","isStatic":false},"onFinish":{"access":"public","type":"callable","comment":"当worker进程投递的任务在task_worker中完成时,task进程会通过swoole_server->finish()方法将任务处理的结果发送给worker进程。","isStatic":false},"onManagerStart":{"access":"public","type":"callable","comment":"当管理进程启动时调用它","isStatic":false},"onManagerStop":{"access":"public","type":"callable","comment":"当管理进程结束时调用它","isStatic":false},"onPipeMessage":{"access":"public","type":"callable","comment":"当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件","isStatic":false},"connections":{"access":"public","type":"iterator","comment":"TCP连接迭代器","isStatic":false},"host":{"access":"public","type":"string","comment":"连接的主机","isStatic":false},"port":{"access":"public","type":"int","comment":"连接的主机的端口","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket的类型","isStatic":false,"value":0},"mode":{"access":"public","type":"int","comment":"运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式)","isStatic":false,"value":0},"ports":{"access":"public","type":"array","comment":"当监听多端口时的端口列表","isStatic":false},"master_pid":{"access":"public","type":"int","comment":"主进程ID","isStatic":false,"value":0},"manager_pid":{"access":"public","type":"int","comment":"管理进程ID","isStatic":false,"value":0},"worker_id":{"access":"public","type":"int","comment":"当前工作进程(包括worker进程和task进程)编号","isStatic":false,"value":0},"taskworker":{"access":"public","type":"boolean","comment":"当前进程是否是task工作进程","isStatic":false,"value":false},"worker_pid":{"access":"public","type":"int","comment":"当前工作进程ID(操作系统进程)","isStatic":false,"value":0},"onRequest":{"access":"public","type":"callable","comment":"请求回调函数","isStatic":false},"onHandshake":{"access":"public","type":"callable","comment":"TCP握手时的回调函数","isStatic":false},"setting":{"access":"public","type":"array","comment":"通过swoole_server:set()设置的参数会保存到setting属性上","isStatic":false}},"methods":{"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}},"start":{"access":"public","comment":"启动HTTP server","isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":"swoole_server初始化方法","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"主机IP","type":"string","options":[]},"port":{"comment":"端口","type":"int","options":[]},"mode":{"comment":"运行模式","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"listen":{"access":"public","comment":"添加监听端口(是addlistener的别名)","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"addlistener":{"access":"public","comment":"添加监听端口","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"set":{"access":"public","comment":"设置swoole_server运行时的参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"send":{"access":"public","comment":"向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]},"reactor_id":{"comment":"UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意客户端发送UDP数据包","isStatic":false,"return":"","example":"","parameters":{"ip":{"comment":"IPv4字符串,如192.168.1.102。如果IP不合法会返回错误","type":"string","options":[]},"port":{"comment":"为 1-65535的网络端口号,如果端口错误发送会失败","type":"int","options":[]},"send_data":{"comment":"发送的数据内容,可以是文本或者二进制内容","type":"string","options":[]},"server_socket":{"comment":"服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包","type":"int","options":[]}}},"sendwait":{"access":"public","comment":"阻塞的向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"与客户端连接的句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]}}},"exist":{"access":"public","comment":"检测fd对应的连接是否存在","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"protect":{"access":"public","comment":"设置客户端连接为保护状态,不被心跳线程切断","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"要设置保护状态的客户端连接fd","type":"int","options":[]},"is_protected":{"comment":"设置的状态,true表示保护状态,false表示不保护","type":"boolean","options":[]}}},"sendfile":{"access":"public","comment":"向客户端发送文件","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"连接句柄","type":"int","options":[]},"filename":{"comment":"文件名","type":"string","options":[]},"offset":{"comment":"指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送","type":"int","options":[]},"length":{"comment":"指定发送的长度,默认为文件尺寸","type":"int","options":[]}}},"close":{"access":"public","comment":"关闭客户端连接","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"reset":{"comment":"设置为true会强制关闭连接,丢弃发送队列中的数据","type":"boolean","options":[]}}},"confirm":{"access":"public","comment":"确认连接,与enable_delay_receive或wait_for_bind配合使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"pause":{"access":"public","comment":"停止接收数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"resume":{"access":"public","comment":"恢复数据接收。与pause方法成对使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"task":{"access":"public","comment":"投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]},"finish_callback":{"comment":"完成后的回调函数","type":"callable","options":[]}}},"taskwait":{"access":"public","comment":"以阻塞的形式投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"timeout":{"comment":"超时时间","type":"float","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]}}},"taskWaitMulti":{"access":"public","comment":"并发执行多个Task","isStatic":false,"return":"","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"taskCo":{"access":"public","comment":"并发执行Task并进行协程调度","isStatic":false,"return":"array","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"finish":{"access":"public","comment":"用于在task进程中通知worker进程任务已完成","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"","type":[],"options":[]}}},"reload":{"access":"public","comment":"重启所有工作进程","isStatic":false,"return":"","example":"","parameters":[]},"shutdown":{"access":"public","comment":"关闭服务器","isStatic":false,"return":"","example":"","parameters":[]},"stop":{"access":"public","comment":"停止当前worker进程","isStatic":false,"return":"","example":"","parameters":{"worker_id":{"comment":"工作进程ID","type":"int","options":[]}}},"getLastError":{"access":"public","comment":"获取最近一次操作错误的错误码\n返回的错误码:\n1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据","isStatic":false,"return":"","example":"","parameters":[]},"heartbeat":{"access":"public","comment":"检测所有服务器连接,并找出已经超时的连接","isStatic":false,"return":"","example":"","parameters":{"reactor_id":{"comment":"是否关闭超时的连接,默认为true","type":"boolean","options":[]}}},"connection_info":{"access":"public","comment":"获取客户端连接信息","isStatic":false,"return":"from_id","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"connection_list":{"access":"public","comment":"用来遍历所有客户端连接","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"getClientInfo":{"access":"public","comment":"获取连接的信息,别名是swoole_server->connection_info","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"getClientList":{"access":"public","comment":"用来遍历所有客户端连接(server->connection_list的别名)","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"after":{"access":"public","comment":"在指定时间后执行某个回调函数","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]},"param":{"comment":"给回调函数传入的参数","type":"array","options":[]}}},"tick":{"access":"public","comment":"添加定时器","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"clearTimer":{"access":"public","comment":"清除定时器","isStatic":false,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}},"defer":{"access":"public","comment":"延迟执行一个PHP函数","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"执行的函数","type":"callable","options":[]}}},"sendMessage":{"access":"public","comment":"向任意worker进程或task进程发送消息","isStatic":false,"return":"","example":"","parameters":{"dst_worker_id":{"comment":"目标worker的ID","type":"int","options":[]},"data":{"comment":"发送的消息","type":"string","options":[]}}},"addProcess":{"access":"public","comment":"添加一个自定义的工作进程","isStatic":false,"return":"","example":"","parameters":{"process":{"comment":"进程对象","type":"Swoole\\Process","options":[]}}},"stats":{"access":"public","comment":"得到当前server的活动TCP连接数\narray (","isStatic":false,"return":"","example":"","parameters":[]},"bind":{"access":"public","comment":"将连接绑定到某个用户定义的ID","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"uid":{"comment":"用户定义的ID","type":"int","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_lock.json b/src/swoole/swoole_lock.json deleted file mode 100644 index c168518..0000000 --- a/src/swoole/swoole_lock.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_lock"},"comment":"锁的实现。PHP代码中可以很方便地创建一个锁,用来实现数据同步。swoole_lock类支持5种锁的类型:","namespace":"","consts":{"FILELOCK":{"comment":"文件锁","type":"int","value":2},"MUTEX":{"comment":"互斥锁","type":"int","value":3},"SEM":{"comment":"信号量","type":"int","value":4},"RWLOCK":{"comment":"读写锁","type":"int","value":1},"SPINLOCK":{"comment":"自旋锁","type":"int","value":5}},"properties":[],"methods":{"__construct":{"access":"public","comment":"创建锁","isStatic":false,"return":"","example":"","parameters":{"type":{"comment":"锁的类型(使用常量)","type":"int","options":[]},"filename":{"comment":"当类型为SWOOLE_FILELOCK时必须传入,指定文件锁的路径","type":"string","options":[]}}},"__destruct":{"access":"public","comment":"析构方法","isStatic":false,"return":"","example":"","parameters":[]},"lock":{"access":"public","comment":"加锁操作","isStatic":false,"return":"","example":"","parameters":[]},"lockwait":{"access":"public","comment":"加锁操作,作用于swoole_lock->lock一致,但lockwait可以设置超时时间","isStatic":false,"return":"","example":"","parameters":{"timeout":{"comment":"超时时间","type":"float","options":[]}}},"trylock":{"access":"public","comment":"非阻塞的加锁操作","isStatic":false,"return":"","example":"","parameters":[]},"lock_read":{"access":"public","comment":"锁定读","isStatic":false,"return":"","example":"","parameters":[]},"trylock_read":{"access":"public","comment":"非阻塞式锁定读","isStatic":false,"return":"","example":"","parameters":[]},"unlock":{"access":"public","comment":"释放锁操作","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_mmap.json b/src/swoole/swoole_mmap.json deleted file mode 100644 index f9a5ec0..0000000 --- a/src/swoole/swoole_mmap.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_mmap"},"comment":"提供了对操作系统mmap的封装。使用mmap可以很方便地将一个磁盘文件映射为内存,读写性能更高。","namespace":"","consts":[],"properties":[],"methods":{"open":{"access":"public","comment":"创建文件内存映射(执行成功将返回一个PHP的stream资源,可使用PHP提供的流式操作函数读写数据)","isStatic":true,"return":"","example":"","parameters":{"filename":{"comment":"磁盘文件名称,必须是存在的文件,如果文件不存在将会创建失败。可以使用file_put_contents来初始化文件","type":"string","options":[]},"size":{"comment":"映射操作,默认为整个文件的长度,操作系统会分配同等大小的内存。注意不要尝试将超过系统内存尺寸的文件进行映射","type":"int","options":[]},"offset":{"comment":"文件的映射起始位置,默认为0","type":"int","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_mysql.json b/src/swoole/swoole_mysql.json deleted file mode 100644 index 8d2812e..0000000 --- a/src/swoole/swoole_mysql.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_mysql"},"comment":"异步MySQL客户端","namespace":"","consts":{"STATE_QUERY":{"comment":"查询状态","type":"int","value":0},"STATE_READ_START":{"comment":"读开始状态","type":"int","value":1},"STATE_READ_FIELD ":{"comment":"读失败状态","type":"int","value":2},"STATE_READ_ROW":{"comment":"读数据行状态","type":"int","value":3},"STATE_READ_END":{"comment":"读完成状态","type":"int","value":4},"STATE_CLOSED":{"comment":"关闭状态","type":"int","value":5}},"properties":{"serverInfo":{"access":"public","type":"array","comment":"连接信息,保存的是传递给构造函数的数组","isStatic":false},"sock":{"access":"public","type":"int","comment":"连接使用的文件描述符","isStatic":false},"connected":{"access":"public","type":"boolean","comment":"是否连接上了MySQL服务器","isStatic":false,"value":false},"errno":{"access":"public","type":"int","comment":"错误码","isStatic":false,"value":0},"connect_errno":{"access":"public","type":"int","comment":"连接错误码","isStatic":false,"value":0},"error":{"access":"public","type":"string","comment":"错误信息","isStatic":false},"connect_error":{"access":"public","type":"string","comment":"连接错误信息","isStatic":false},"insert_id":{"access":"public","type":"int","comment":"最后一个插入的记录id","isStatic":false},"affected_rows":{"access":"public","type":"int","comment":"影响的行数","isStatic":false},"onConnect":{"access":"public","type":"callable","comment":"连接时的回调函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"关闭连接时的回调函数","isStatic":false}},"methods":{"__construct":{"access":"public","comment":"mysql异步客户端初始化","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"connect":{"access":"public","comment":"连接mysql服务器","isStatic":false,"return":"","example":"$server = array(\n 'host' => '192.168.56.102',\n 'user' => 'test',\n 'password' => 'test',\n 'database' => 'test',\n 'charset' => 'utf8',\n);\n回调函数:function onConnect(swoole_mysql $db, bool $result);","parameters":{"server_config":{"comment":"连接配置信息","type":"array","options":[]},"callback":{"comment":"连接成功的回调","type":"callable","options":[]}}},"begin":{"access":"public","comment":"启动事务","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"启动一个MySQL事务,事务启动成功会回调指定的函数","type":"callable","options":[]}}},"commit":{"access":"public","comment":"提交事务","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"提交事务,当服务器返回响应时回调此函数","type":"callable","options":[]}}},"rollback":{"access":"public","comment":"回滚事务(必须先调用begin启动事务才能调用rollback否则底层会抛出异常)","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"回滚完成后执行的回调","type":"callable","options":[]}}},"query":{"access":"public","comment":"执行sql语句","isStatic":false,"return":"","example":"\n回调函数:function onSQLReady(swoole_mysqli $link, mixed $result);\n注:执行失败,$result为false,读取$link对象的error属性获得错误信息,errno属性获得错误码\n执行成功,SQL为非查询语句,$result为true,读取$link对象的affected_rows属性获得影响的行数,insert_id属性获得Insert操作的自增ID\n执行成功,SQL为查询语句,$result为结果数组","parameters":{"sql":{"comment":"要执行的SQL语句","type":"string","options":[]},"callback":{"comment":"执行成功后会回调此函数","type":"callable","options":[]}}},"close":{"access":"public","comment":"关闭mysql连接","isStatic":false,"return":"","example":"","parameters":[]},"getState":{"access":"public","comment":"获取当前服务器状态","isStatic":false,"return":"int","example":"","parameters":[]},"on":{"access":"public","comment":"设置事件回调函数(目前仅支持onClose事件回调)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称(目前仅支持Close)","type":"String","options":[]},"callback":{"comment":"连接关闭时回调此函数","type":"callable","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_mysql_coro.json b/src/swoole/swoole_mysql_coro.json deleted file mode 100644 index 6cb343e..0000000 --- a/src/swoole/swoole_mysql_coro.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_mysql_coro"},"comment":false,"namespace":"","consts":[],"properties":{"serverInfo":{"access":"private","type":"unknown","comment":false,"isStatic":false,"value":""},"sock":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"connected":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":false},"connect_error":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":""},"connect_errno":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"affected_rows":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"insert_id":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0},"error":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":""},"errno":{"access":"public","type":"unknown","comment":false,"isStatic":false,"value":0}},"methods":{"__construct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"connect":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"server_config":{"comment":"","type":{},"options":[]}}},"query":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"sql":{"comment":"","type":"unknown","options":[]},"timeout":{"comment":"","type":"unknown","options":[]}}},"recv":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"begin":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"commit":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"rollback":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"setDefer":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"defer":{"comment":"","type":"unknown","options":[]}}},"getDefer":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"close":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_mysql_coro_exception.json b/src/swoole/swoole_mysql_coro_exception.json deleted file mode 100644 index 5ac0901..0000000 --- a/src/swoole/swoole_mysql_coro_exception.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_mysql_coro_exception"},"comment":false,"namespace":"","extends":"Exception","consts":[],"properties":{"message":{"access":"protected","type":"unknown","comment":false,"isStatic":false,"value":""},"code":{"access":"protected","type":"unknown","comment":false,"isStatic":false,"value":0},"file":{"access":"protected","type":"unknown","comment":false,"isStatic":false},"line":{"access":"protected","type":"unknown","comment":false,"isStatic":false}},"methods":{"__clone":{"access":"private","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":{"message":{"comment":"","type":"unknown","options":[]},"code":{"comment":"","type":"unknown","options":[]},"previous":{"comment":"","type":"unknown","options":[]}}},"__wakeup":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getMessage":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getCode":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getFile":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getLine":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getTrace":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getPrevious":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"getTraceAsString":{"access":"public","isFinal":1,"comment":false,"isStatic":false,"return":"","example":"","parameters":[]},"__toString":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_mysql_exception.json b/src/swoole/swoole_mysql_exception.json deleted file mode 100644 index 0b642fe..0000000 --- a/src/swoole/swoole_mysql_exception.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_mysql_exception"},"comment":"swoole mysql 异常类","namespace":"","extends":"Exception","consts":[],"properties":{"message":{"access":"protected","type":"string","comment":"异常错误信息","isStatic":false,"value":""},"code":{"access":"protected","type":"int","comment":"异常错误码","isStatic":false,"value":0},"file":{"access":"protected","type":"string","comment":"错误文件位置","isStatic":false},"line":{"access":"protected","type":"int","comment":"错误文件行数","isStatic":false}},"methods":{"__clone":{"access":"private","isFinal":1,"comment":"克隆魔术方法(这里禁止克隆)","isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":"异常初始化","isStatic":false,"return":"","example":"","parameters":{"message":{"comment":"异常提示信息","type":"string","options":[]},"code":{"comment":"异常错误码","type":"int","options":[]},"previous":{"comment":"异常链中的前一个异常","type":"Throwable","options":[]}}},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"getMessage":{"access":"public","isFinal":1,"comment":"获取异常提示信息","isStatic":false,"return":"string","example":"","parameters":[]},"getCode":{"access":"public","isFinal":1,"comment":"获取异常代码","isStatic":false,"return":"int","example":"","parameters":[]},"getFile":{"access":"public","isFinal":1,"comment":"创建异常时的程序文件名称","isStatic":false,"return":"string","example":"","parameters":[]},"getLine":{"access":"public","isFinal":1,"comment":"获取创建的异常所在文件中的行号","isStatic":false,"return":"int","example":"","parameters":[]},"getTrace":{"access":"public","isFinal":1,"comment":"获取异常追踪信息","isStatic":false,"return":"array","example":"","parameters":[]},"getPrevious":{"access":"public","isFinal":1,"comment":"返回异常链中的前一个异常","isStatic":false,"return":"Throwable","example":"","parameters":[]},"getTraceAsString":{"access":"public","isFinal":1,"comment":"获取字符串类型的异常追踪信息","isStatic":false,"return":"string","example":"","parameters":[]},"__toString":{"access":"public","comment":"将异常信息转化为字符串","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_process.json b/src/swoole/swoole_process.json deleted file mode 100644 index 504582f..0000000 --- a/src/swoole/swoole_process.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_process"},"comment":"进程管理模块,用来替代PHP的pcntl扩展","namespace":"","consts":{"IPC_NOWAIT":{"comment":"队列设置为非阻塞","type":"int","value":256}},"properties":{"pipe":{"access":"public","type":"unknown","comment":false,"isStatic":false},"callback":{"access":"public","type":"unknown","comment":false,"isStatic":false},"msgQueueId":{"access":"public","type":"unknown","comment":false,"isStatic":false},"msgQueueKey":{"access":"public","type":"unknown","comment":false,"isStatic":false},"pid":{"access":"public","type":"unknown","comment":false,"isStatic":false},"id":{"access":"public","type":"unknown","comment":false,"isStatic":false}},"methods":{"__construct":{"access":"public","comment":"创建子进程","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"子进程创建成功后要执行的函数","type":"callable","options":[]},"redirect_stdin_and_stdout":{"comment":"重定向子进程的标准输入和输出。启用此选项后,在子进程内输出内容将不是打印屏幕,而是写入到主进程管道。读取键盘输入将变为从管道中读取数据。默认为阻塞读取","type":"boolean","options":[]},"pipe_type":{"comment":"是否创建管道,启用$redirect_stdin_stdout后,此选项将忽略用户参数,强制为true。如果子进程内没有进程间通信,可以设置为 false","type":"boolean","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"wait":{"access":"public","comment":"回收结束运行的子进程。","isStatic":true,"return":"","example":"","parameters":{"blocking":{"comment":"指定是否阻塞等待,默认为阻塞","type":"boolean","options":[]}}},"signal":{"access":"public","comment":"设置异步信号监听","isStatic":true,"return":"","example":"","parameters":{"signal_no":{"comment":"信号量","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"alarm":{"access":"public","comment":"高精度定时器,是操作系统setitimer系统调用的封装,可以设置微秒级别的定时器","isStatic":true,"return":"","example":"","parameters":{"usec":{"comment":"定时器间隔时间,单位为微秒。如果为负数表示清除定时器","type":"int","options":[]}}},"kill":{"access":"public","comment":"向子进程发送信号","isStatic":true,"return":"","example":"","parameters":{"pid":{"comment":"进程ID","type":"int","options":[]},"signal_no":{"comment":"信号量(默认的信号为SIGTERM,表示终止进程)","type":"int","options":[]}}},"daemon":{"access":"public","comment":"使当前进程脱变为一个守护进程","isStatic":true,"return":"","example":"","parameters":{"nochdir":{"comment":"为true表示不要切换当前目录到根目录","type":"boolean","options":[]},"noclose":{"comment":"为true表示不要关闭标准输入输出文件描述符","type":"boolean","options":[]}}},"setaffinity":{"access":"public","comment":"设置CPU亲和性,可以将进程绑定到特定的CPU核上","isStatic":true,"return":"","example":"","parameters":{"cpu_settings":{"comment":"表示绑定哪些CPU核,如array(0,2,3)表示绑定CPU0\/CPU2\/CPU3","type":"array","options":[]}}},"setTimeout":{"access":"public","comment":"设置管道读写操作的超时时间","isStatic":false,"return":"","example":"","parameters":{"seconds":{"comment":"单位为秒,支持浮点型,如1.5表示1s+500ms","type":"double","options":[]}}},"useQueue":{"access":"public","comment":"启用消息队列作为进程间通信","isStatic":false,"return":"boolean","example":"","parameters":{"key":{"comment":"消息队列的key,默认会使用ftok(__FILE__, 1)作为KEY","type":"string","options":[]},"mode":{"comment":"通信模式,默认为2,表示争抢模式,所有创建的子进程都会从队列中取数据","type":"int","options":[]}}},"statQueue":{"access":"public","comment":"查看消息队列状态\n返回字段:\nqueue_num 队列中的任务数量;queue_bytes 队列数据的总字节数","isStatic":false,"return":"array","example":"","parameters":[]},"freeQueue":{"access":"public","comment":"删除队列","isStatic":false,"return":"","example":"","parameters":[]},"start":{"access":"public","comment":"执行fork系统调用,启动进程","isStatic":false,"return":"int","example":"","parameters":[]},"write":{"access":"public","comment":"向管道内写入数据","isStatic":false,"return":"int","example":"","parameters":{"data":{"comment":"写入的数据","type":"string","options":[]}}},"close":{"access":"public","comment":"用于关闭创建的好的管道","isStatic":false,"return":"boolean","example":"","parameters":[]},"read":{"access":"public","comment":"从管道中读取数据","isStatic":false,"return":"string | bool","example":"","parameters":{"size":{"comment":"是缓冲区的大小,默认为8192,最大不超过64K","type":"int","options":[]}}},"push":{"access":"public","comment":"向消息队列推送数据","isStatic":false,"return":"boolean","example":"","parameters":{"data":{"comment":"要投递的数据,长度受限与操作系统内核参数的限制。默认为8192,最大不超过65536","type":"string","options":[]}}},"pop":{"access":"public","comment":"从消息队列中获取数据","isStatic":false,"return":"string","example":"","parameters":{"size":{"comment":"表示获取数据的最大尺寸,默认为8192","type":"int","options":[]}}},"exit":{"access":"public","comment":"退出子进程","isStatic":false,"return":"int","example":"","parameters":{"exit_code":{"comment":"退出进程的状态码,如果为0表示正常结束,会继续执行PHP的shutdown_function,其他扩展的清理工作;如果$status不为0,表示异常退出,会立即终止进程。不再执行PHP的shutdown_function,其他扩展的清理工作","type":"int","options":[]}}},"exec":{"access":"public","comment":"执行一个外部程序,此函数是exec系统调用的封装","isStatic":false,"return":"boolean","example":"","parameters":{"exec_file":{"comment":"指定可执行文件的绝对路径,如 \/usr\/bin\/python","type":"string","options":[]},"args":{"comment":"参数列表,如 array('test.py', 123),相当与python test.py 123","type":"array","options":[]}}},"name":{"access":"public","comment":"修改进程名称","isStatic":false,"return":"boolean","example":"","parameters":{"process_name":{"comment":"进程名称","type":"string","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_redis.json b/src/swoole/swoole_redis.json deleted file mode 100644 index 4d92237..0000000 --- a/src/swoole/swoole_redis.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "object": { - "name": "Swoole\\Redis" - }, - "comment": "异步redis客户端", - "namespace": "Swoole", - "consts": [], - "properties": [], - "methods": { - "__construct": { - "access": "public", - "comment": "初始化函数", - "isStatic": false, - "return": "", - "example": "", - "parameters": [] - }, - "__destruct": { - "access": "public", - "comment": "析构函数", - "isStatic": false, - "return": "", - "example": "", - "parameters": [] - }, - "on": { - "access": "public", - "comment": "注册事件回调函数", - "isStatic": false, - "return": "", - "example": "", - "parameters": { - "event_name": { - "comment": "事件类型,目前只支持close和message", - "type": "string", - "options": [] - }, - "callback": { - "comment": "事件回调函数", - "type": "callable", - "options": [] - } - } - }, - "connect": { - "access": "public", - "comment": "连接redis服务器", - "isStatic": false, - "return": "", - "example": "", - "parameters": { - "host": { - "comment": "主机", - "type": "string", - "options": [] - }, - "port": { - "comment": "端口", - "type": "int", - "options": [] - }, - "callback": { - "comment": "连接回调函数", - "type": "callable", - "options": [] - } - } - }, - "close": { - "access": "public", - "comment": "关闭redis连接", - "isStatic": false, - "return": "", - "example": "", - "parameters": [] - }, - "__call": { - "access": "public", - "comment": "执行redis命令", - "isStatic": false, - "return": "", - "example": "", - "parameters": { - "command": { - "comment": "redis指令", - "type": "string", - "options": [] - }, - "params": { - "comment": "参数", - "type": "array", - "options": [] - } - } - } - } -} \ No newline at end of file diff --git a/src/swoole/swoole_redis_server.json b/src/swoole/swoole_redis_server.json deleted file mode 100644 index 339c0a3..0000000 --- a/src/swoole/swoole_redis_server.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_redis_server"},"comment":"Swoole实现的Redis Server","namespace":"","extends":"swoole_server","consts":{"NIL":{"comment":"nil类型","type":"int","value":1},"ERROR":{"comment":"错误","type":"int","value":0},"STATUS":{"comment":"状态","type":"int","value":2},"INT":{"comment":"整型","type":"int","value":3},"STRING":{"comment":"字符串型","type":"int","value":4},"SET":{"comment":"集合类型","type":"int","value":5},"MAP":{"comment":"映射类型","type":"int","value":6}},"properties":{"onConnect":{"access":"public","type":"callable","comment":"连接成功回调函数","isStatic":false},"onReceive":{"access":"public","type":"callable","comment":"接收到数据时回调此函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"TCP客户端连接关闭后,在worker进程中回调此函数","isStatic":false},"onPacket":{"access":"public","type":"callable","comment":"接收到UDP数据包时回调此函数,发生在worker进程中","isStatic":false},"onBufferFull":{"access":"public","type":"callable","comment":"当缓存区达到最高水位时触发此事件","isStatic":false},"onBufferEmpty":{"access":"public","type":"callable","comment":"当缓存区低于最低水位线时触发此事件","isStatic":false},"onStart":{"access":"public","type":"callable","comment":"Server启动在主进程的主线程回调此函数","isStatic":false},"onShutdown":{"access":"public","type":"callable","comment":"此事件在Server正常结束时发生","isStatic":false},"onWorkerStart":{"access":"public","type":"callable","comment":"此事件在Worker进程\/Task进程启动时发生","isStatic":false},"onWorkerStop":{"access":"public","type":"callable","comment":"此事件在worker进程终止时发生。在此函数中可以回收worker进程申请的各类资源","isStatic":false},"onWorkerExit":{"access":"public","type":"callable","comment":"仅在开启reload_async特性后有效。异步重启特性,会先创建新的Worker进程处理新请求,旧的Worker进程自行退出","isStatic":false},"onWorkerError":{"access":"public","type":"callable","comment":"当worker\/task_worker进程发生异常后会在Manager进程内回调此函数","isStatic":false},"onTask":{"access":"public","type":"callable","comment":"在task_worker进程内被调用","isStatic":false},"onFinish":{"access":"public","type":"callable","comment":"当worker进程投递的任务在task_worker中完成时,task进程会通过swoole_server->finish()方法将任务处理的结果发送给worker进程。","isStatic":false},"onManagerStart":{"access":"public","type":"callable","comment":"当管理进程启动时调用它","isStatic":false},"onManagerStop":{"access":"public","type":"callable","comment":"当管理进程结束时调用它","isStatic":false},"onPipeMessage":{"access":"public","type":"callable","comment":"当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件","isStatic":false},"setting":{"access":"public","type":"array","comment":"通过swoole_server:set()设置的参数会保存到setting属性上","isStatic":false},"connections":{"access":"public","type":"iterator","comment":"TCP连接迭代器","isStatic":false},"host":{"access":"public","type":"string","comment":"连接的主机","isStatic":false},"port":{"access":"public","type":"int","comment":"连接的主机的端口","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket的类型","isStatic":false,"value":0},"mode":{"access":"public","type":"int","comment":"运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式)","isStatic":false,"value":0},"ports":{"access":"public","type":"array","comment":"当监听多端口时的端口列表","isStatic":false},"master_pid":{"access":"public","type":"int","comment":"主进程ID","isStatic":false,"value":0},"manager_pid":{"access":"public","type":"int","comment":"管理进程ID","isStatic":false,"value":0},"worker_id":{"access":"public","type":"int","comment":"当前工作进程(包括worker进程和task进程)编号","isStatic":false,"value":0},"taskworker":{"access":"public","type":"boolean","comment":"当前进程是否是task工作进程","isStatic":false,"value":false},"worker_pid":{"access":"public","type":"int","comment":"当前工作进程ID(操作系统进程)","isStatic":false,"value":0}},"methods":{"start":{"access":"public","comment":"启动server","isStatic":false,"return":"","example":"","parameters":[]},"setHandler":{"access":"public","comment":"设置Redis命令字的处理器","isStatic":false,"return":"","example":"","parameters":{"command":{"comment":"命令的名称","type":"string","options":[]},"callback":{"comment":"命令的处理函数,回调函数返回字符串类型时会自动发送给客户端","type":"callable","options":[]},"number_of_string_param":{"comment":"字符串参数的长度","type":"int","options":[]},"type_of_array_param":{"comment":"数组参数元素的类型","type":"int","options":[]}}},"format":{"access":"public","comment":"格式化命令响应数据","isStatic":true,"return":"","example":"","parameters":{"type":{"comment":"表示数据类型,NIL类型不需要传入$value,ERROR和STATUS类型$value可选,INT、STRING、SET、MAP必选","type":"int","options":[]},"value":{"comment":"要处理的数据","type":"mixed","options":[]}}},"__construct":{"access":"public","comment":"swoole_server初始化方法","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"主机IP","type":"string","options":[]},"port":{"comment":"端口","type":"int","options":[]},"mode":{"comment":"运行模式","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"listen":{"access":"public","comment":"添加监听端口(是addlistener的别名)","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"addlistener":{"access":"public","comment":"添加监听端口","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}},"set":{"access":"public","comment":"设置swoole_server运行时的参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"send":{"access":"public","comment":"向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]},"reactor_id":{"comment":"UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意客户端发送UDP数据包","isStatic":false,"return":"","example":"","parameters":{"ip":{"comment":"IPv4字符串,如192.168.1.102。如果IP不合法会返回错误","type":"string","options":[]},"port":{"comment":"为 1-65535的网络端口号,如果端口错误发送会失败","type":"int","options":[]},"send_data":{"comment":"发送的数据内容,可以是文本或者二进制内容","type":"string","options":[]},"server_socket":{"comment":"服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包","type":"int","options":[]}}},"sendwait":{"access":"public","comment":"阻塞的向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"与客户端连接的句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]}}},"exist":{"access":"public","comment":"检测fd对应的连接是否存在","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"protect":{"access":"public","comment":"设置客户端连接为保护状态,不被心跳线程切断","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"要设置保护状态的客户端连接fd","type":"int","options":[]},"is_protected":{"comment":"设置的状态,true表示保护状态,false表示不保护","type":"boolean","options":[]}}},"sendfile":{"access":"public","comment":"向客户端发送文件","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"连接句柄","type":"int","options":[]},"filename":{"comment":"文件名","type":"string","options":[]},"offset":{"comment":"指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送","type":"int","options":[]},"length":{"comment":"指定发送的长度,默认为文件尺寸","type":"int","options":[]}}},"close":{"access":"public","comment":"关闭客户端连接","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"reset":{"comment":"设置为true会强制关闭连接,丢弃发送队列中的数据","type":"boolean","options":[]}}},"confirm":{"access":"public","comment":"确认连接,与enable_delay_receive或wait_for_bind配合使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"pause":{"access":"public","comment":"停止接收数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"resume":{"access":"public","comment":"恢复数据接收。与pause方法成对使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"task":{"access":"public","comment":"投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]},"finish_callback":{"comment":"完成后的回调函数","type":"callable","options":[]}}},"taskwait":{"access":"public","comment":"以阻塞的形式投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"timeout":{"comment":"超时时间","type":"float","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]}}},"taskWaitMulti":{"access":"public","comment":"并发执行多个Task","isStatic":false,"return":"","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"taskCo":{"access":"public","comment":"并发执行Task并进行协程调度","isStatic":false,"return":"array","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"finish":{"access":"public","comment":"用于在task进程中通知worker进程任务已完成","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要传递的数据","type":"string","options":[]}}},"reload":{"access":"public","comment":"重启所有工作进程","isStatic":false,"return":"boolean","example":"","parameters":[]},"shutdown":{"access":"public","comment":"关闭服务器","isStatic":false,"return":"","example":"","parameters":[]},"stop":{"access":"public","comment":"停止当前worker进程","isStatic":false,"return":"","example":"","parameters":{"worker_id":{"comment":"进程ID","type":"int","options":[]}}},"getLastError":{"access":"public","comment":"获取最近一次操作错误的错误码\n返回的错误码:\n1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据","isStatic":false,"return":"","example":"","parameters":[]},"heartbeat":{"access":"public","comment":"检测所有服务器连接,并找出已经超时的连接","isStatic":false,"return":"","example":"","parameters":{"reactor_id":{"comment":"是否关闭超时的连接,默认为true","type":"boolean","options":[]}}},"connection_info":{"access":"public","comment":"获取客户端连接信息","isStatic":false,"return":"from_id","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"connection_list":{"access":"public","comment":"用来遍历所有客户端连接","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"getClientInfo":{"access":"public","comment":"获取连接的信息,别名是swoole_server->connection_info","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"getClientList":{"access":"public","comment":"用来遍历所有客户端连接(server->connection_list的别名)","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"after":{"access":"public","comment":"在指定时间后执行某个回调函数","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]},"param":{"comment":"给回调函数传入的参数","type":"array","options":[]}}},"tick":{"access":"public","comment":"添加定时器","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"clearTimer":{"access":"public","comment":"清除定时器","isStatic":false,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}},"defer":{"access":"public","comment":"延迟执行一个PHP函数","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"执行的函数","type":"callable","options":[]}}},"sendMessage":{"access":"public","comment":"向任意worker进程或task进程发送消息","isStatic":false,"return":"","example":"","parameters":{"dst_worker_id":{"comment":"目标worker的ID","type":"int","options":[]},"data":{"comment":"发送的消息","type":"string","options":[]}}},"addProcess":{"access":"public","comment":"添加一个自定义的工作进程","isStatic":false,"return":"","example":"","parameters":{"process":{"comment":"进程对象","type":"Swoole\\Process","options":[]}}},"stats":{"access":"public","comment":"得到当前server的活动TCP连接数\narray (","isStatic":false,"return":"","example":"","parameters":[]},"bind":{"access":"public","comment":"将连接绑定到某个用户定义的ID","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"uid":{"comment":"用户定义的ID","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_serialize.json b/src/swoole/swoole_serialize.json deleted file mode 100644 index 07ced9a..0000000 --- a/src/swoole/swoole_serialize.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_serialize"},"comment":"一个高性能的序列化库,其特性如下:1、序列化后的结果为二进制格式,只适合机器读取,不适合人读;2、序列化性能更高,可节省大量CPU资源;3、序列化后的结果数据尺寸更小,可节省内存资源","namespace":"","consts":[],"properties":[],"methods":{"pack":{"access":"public","comment":"将PHP变量序列化","isStatic":true,"return":"string | boolean","example":"","parameters":{"data":{"comment":"为要进行序列化的变量,请注意function和resource类型的变量是不支持序列化的","type":"mixed","options":[]},"flag":{"comment":"是否启用快速模式,swoole_serialize默认会使用静态表保存关联数组的Key,设置此参数为SWOOLE_FAST_PACK后将不再保存数组key","type":"int","options":[]}}},"unpack":{"access":"public","comment":"反序列化","isStatic":true,"return":"mixed","example":"","parameters":{"string":{"comment":"序列化数据,必须是由pack函数生成","type":"string","options":[]},"args":{"comment":"反序列化附加参数,使用UNSERIALIZE_OBJECT_TO_ARRAY或UNSERIALIZE_OBJECT_TO_STDCLASS等常量","type":"int","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_server.json b/src/swoole/swoole_server.json deleted file mode 100644 index 8e0dd09..0000000 --- a/src/swoole/swoole_server.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_server"},"comment":"swoole TCP\/UDP服务器","namespace":"","consts":[],"properties":{"onConnect":{"access":"public","type":"callable","comment":"连接成功回调函数","isStatic":false},"onReceive":{"access":"public","type":"callable","comment":"接收到数据时回调此函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"TCP客户端连接关闭后,在worker进程中回调此函数","isStatic":false},"onPacket":{"access":"public","type":"callable","comment":"接收到UDP数据包时回调此函数,发生在worker进程中","isStatic":false},"onBufferFull":{"access":"public","type":"callable","comment":"当缓存区达到最高水位时触发此事件","isStatic":false},"onBufferEmpty":{"access":"public","type":"callable","comment":"当缓存区低于最低水位线时触发此事件","isStatic":false},"onStart":{"access":"public","type":"callable","comment":"Server启动在主进程的主线程回调此函数","isStatic":false},"onShutdown":{"access":"public","type":"callable","comment":"此事件在Server正常结束时发生","isStatic":false},"onWorkerStart":{"access":"public","type":"callable","comment":"此事件在Worker进程\/Task进程启动时发生","isStatic":false},"onWorkerStop":{"access":"public","type":"callable","comment":"此事件在worker进程终止时发生。在此函数中可以回收worker进程申请的各类资源","isStatic":false},"onWorkerExit":{"access":"public","type":"callable","comment":"仅在开启reload_async特性后有效。异步重启特性,会先创建新的Worker进程处理新请求,旧的Worker进程自行退出","isStatic":false},"onWorkerError":{"access":"public","type":"callable","comment":"当worker\/task_worker进程发生异常后会在Manager进程内回调此函数","isStatic":false},"onTask":{"access":"public","type":"callable","comment":"在task_worker进程内被调用","isStatic":false},"onFinish":{"access":"public","type":"callable","comment":"当worker进程投递的任务在task_worker中完成时,task进程会通过swoole_server->finish()方法将任务处理的结果发送给worker进程。","isStatic":false},"onManagerStart":{"access":"public","type":"callable","comment":"当管理进程启动时调用它","isStatic":false},"onManagerStop":{"access":"public","type":"callable","comment":"当管理进程结束时调用它","isStatic":false},"onPipeMessage":{"access":"public","type":"callable","comment":"当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件","isStatic":false},"setting":{"access":"public","type":"array","comment":"通过swoole_server:set()设置的参数会保存到setting属性上","isStatic":false},"connections":{"access":"public","type":"iterator","comment":"TCP连接迭代器","isStatic":false},"host":{"access":"public","type":"string","comment":"连接的主机","isStatic":false},"port":{"access":"public","type":"int","comment":"连接的主机的端口","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket的类型","isStatic":false,"value":0},"mode":{"access":"public","type":"int","comment":"运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式)","isStatic":false,"value":0},"ports":{"access":"public","type":"array","comment":"当监听多端口时的端口列表","isStatic":false},"master_pid":{"access":"public","type":"int","comment":"主进程ID","isStatic":false,"value":0},"manager_pid":{"access":"public","type":"int","comment":"管理进程ID","isStatic":false,"value":0},"worker_id":{"access":"public","type":"int","comment":"当前工作进程(包括worker进程和task进程)编号","isStatic":false,"value":0},"taskworker":{"access":"public","type":"boolean","comment":"当前进程是否是task工作进程","isStatic":false,"value":false},"worker_pid":{"access":"public","type":"int","comment":"当前工作进程ID(操作系统进程)","isStatic":false,"value":0}},"methods":{"__construct":{"access":"public","comment":"swoole_server初始化方法","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"主机IP","type":"string","options":[]},"port":{"comment":"端口","type":"int","options":[]},"mode":{"comment":"运行模式","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"listen":{"access":"public","comment":"添加监听端口(是addlistener的别名)","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"addlistener":{"access":"public","comment":"添加监听端口","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}},"set":{"access":"public","comment":"设置swoole_server运行时的参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"start":{"access":"public","comment":"启动server","isStatic":false,"return":"","example":"","parameters":[]},"send":{"access":"public","comment":"向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]},"reactor_id":{"comment":"UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意客户端发送UDP数据包","isStatic":false,"return":"","example":"","parameters":{"ip":{"comment":"IPv4字符串,如192.168.1.102。如果IP不合法会返回错误","type":"string","options":[]},"port":{"comment":"为 1-65535的网络端口号,如果端口错误发送会失败","type":"int","options":[]},"send_data":{"comment":"发送的数据内容,可以是文本或者二进制内容","type":"string","options":[]},"server_socket":{"comment":"服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包","type":"int","options":[]}}},"sendwait":{"access":"public","comment":"阻塞的向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"与客户端连接的句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]}}},"exist":{"access":"public","comment":"检测fd对应的连接是否存在","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"protect":{"access":"public","comment":"设置客户端连接为保护状态,不被心跳线程切断","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"要设置保护状态的客户端连接fd","type":"int","options":[]},"is_protected":{"comment":"设置的状态,true表示保护状态,false表示不保护","type":"boolean","options":[]}}},"sendfile":{"access":"public","comment":"向客户端发送文件","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"连接句柄","type":"int","options":[]},"filename":{"comment":"文件名","type":"string","options":[]},"offset":{"comment":"指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送","type":"int","options":[]},"length":{"comment":"指定发送的长度,默认为文件尺寸","type":"int","options":[]}}},"close":{"access":"public","comment":"关闭客户端连接","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"reset":{"comment":"设置为true会强制关闭连接,丢弃发送队列中的数据","type":"boolean","options":[]}}},"confirm":{"access":"public","comment":"确认连接,与enable_delay_receive或wait_for_bind配合使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"pause":{"access":"public","comment":"停止接收数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"resume":{"access":"public","comment":"恢复数据接收。与pause方法成对使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"task":{"access":"public","comment":"投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]},"finish_callback":{"comment":"完成后的回调函数","type":"callable","options":[]}}},"taskwait":{"access":"public","comment":"以阻塞的形式投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"timeout":{"comment":"超时时间","type":"float","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]}}},"taskWaitMulti":{"access":"public","comment":"并发执行多个Task","isStatic":false,"return":"","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"taskCo":{"access":"public","comment":"并发执行Task并进行协程调度","isStatic":false,"return":"array","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"finish":{"access":"public","comment":"用于在task进程中通知worker进程任务已完成","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要传递的数据","type":"string","options":[]}}},"reload":{"access":"public","comment":"重启所有工作进程","isStatic":false,"return":"boolean","example":"","parameters":[]},"shutdown":{"access":"public","comment":"关闭服务器","isStatic":false,"return":"","example":"","parameters":[]},"stop":{"access":"public","comment":"停止当前worker进程","isStatic":false,"return":"","example":"","parameters":{"worker_id":{"comment":"进程ID","type":"int","options":[]}}},"getLastError":{"access":"public","comment":"获取最近一次操作错误的错误码\n返回的错误码:\n1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据","isStatic":false,"return":"","example":"","parameters":[]},"heartbeat":{"access":"public","comment":"检测所有服务器连接,并找出已经超时的连接","isStatic":false,"return":"","example":"","parameters":{"reactor_id":{"comment":"是否关闭超时的连接,默认为true","type":"boolean","options":[]}}},"connection_info":{"access":"public","comment":"获取客户端连接信息","isStatic":false,"return":"from_id","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"connection_list":{"access":"public","comment":"用来遍历所有客户端连接","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"getClientInfo":{"access":"public","comment":"获取连接的信息,别名是swoole_server->connection_info","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"getClientList":{"access":"public","comment":"用来遍历所有客户端连接(server->connection_list的别名)","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"after":{"access":"public","comment":"在指定时间后执行某个回调函数","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]},"param":{"comment":"给回调函数传入的参数","type":"array","options":[]}}},"tick":{"access":"public","comment":"添加定时器","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"clearTimer":{"access":"public","comment":"清除定时器","isStatic":false,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}},"defer":{"access":"public","comment":"延迟执行一个PHP函数","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"执行的函数","type":"callable","options":[]}}},"sendMessage":{"access":"public","comment":"向任意worker进程或task进程发送消息","isStatic":false,"return":"","example":"","parameters":{"dst_worker_id":{"comment":"目标worker的ID","type":"int","options":[]},"data":{"comment":"发送的消息","type":"string","options":[]}}},"addProcess":{"access":"public","comment":"添加一个自定义的工作进程","isStatic":false,"return":"","example":"","parameters":{"process":{"comment":"进程对象","type":"Swoole\\Process","options":[]}}},"stats":{"access":"public","comment":"得到当前server的活动TCP连接数\narray (","isStatic":false,"return":"","example":"","parameters":[]},"bind":{"access":"public","comment":"将连接绑定到某个用户定义的ID","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"uid":{"comment":"用户定义的ID","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_server_port.json b/src/swoole/swoole_server_port.json deleted file mode 100644 index aaad5ba..0000000 --- a/src/swoole/swoole_server_port.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_server_port"},"comment":"TCP端口服务","namespace":"","consts":[],"properties":{"onConnect":{"access":"public","type":"callable","comment":"连接成功回调函数","isStatic":false},"onReceive":{"access":"public","type":"callable","comment":"接收到数据时回调此函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"TCP客户端连接关闭后,在worker进程中回调此函数","isStatic":false},"onPacket":{"access":"public","type":"callable","comment":"接收到UDP数据包时回调此函数,发生在worker进程中","isStatic":false},"onBufferFull":{"access":"public","type":"callable","comment":"当缓存区达到最高水位时触发此事件","isStatic":false},"onBufferEmpty":{"access":"public","type":"callable","comment":"当缓存区低于最低水位线时触发此事件","isStatic":false},"onRequest":{"access":"public","type":"callable","comment":"请求回调函数","isStatic":false},"onHandShake":{"access":"public","type":"unknown","comment":false,"isStatic":false},"onMessage":{"access":"public","type":"callable","comment":"当接收到消息时的回调函数","isStatic":false},"onOpen":{"access":"public","type":"callable","comment":"当连接打开时的回调函数","isStatic":false},"host":{"access":"public","type":"string","comment":"连接的主机","isStatic":false},"port":{"access":"public","type":"int","comment":"连接的主机的端口","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket的类型","isStatic":false,"value":0},"sock":{"access":"public","type":"int","comment":"连接句柄","isStatic":false,"value":0},"setting":{"access":"public","type":"array","comment":"通过swoole_server:set()设置的参数会保存到setting属性上","isStatic":false}},"methods":{"__construct":{"access":"private","comment":"初始化方法","isStatic":false,"return":"","example":"","parameters":[]},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置swoole_server运行时的参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_table.json b/src/swoole/swoole_table.json deleted file mode 100644 index 50414cc..0000000 --- a/src/swoole/swoole_table.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_table"},"comment":"个基于共享内存和锁实现的超高性能,并发数据结构。用于解决多进程\/多线程数据共享和同步加锁问题","namespace":"","consts":{"TYPE_INT":{"comment":"整型","type":"int","value":1},"TYPE_STRING":{"comment":"字符串","type":"int","value":7},"TYPE_FLOAT":{"comment":"浮点型","type":"int","value":6}},"properties":[],"methods":{"__construct":{"access":"public","comment":"创建内存表","isStatic":false,"return":"","example":"","parameters":{"table_size":{"comment":"定表格的最大行数,如果$size不是为2的N次方,如1024、8192,65536等,底层会自动调整为接近的一个数字","type":"int","options":[]},"conflict_proportion":{"comment":"预留作为hash冲突的比例","type":"float","options":[]}}},"column":{"access":"public","comment":"内存表增加一列","isStatic":false,"return":"bool","example":"","parameters":{"name":{"comment":"指定字段的名称","type":"string","options":[]},"type":{"comment":"指定字段类型,支持3种类型,Swoole\\Table::TYPE_INT, Swoole\\Table::TYPE_FLOAT, Swoole\\Table::TYPE_STRING","type":"int","options":[]},"size":{"comment":"指定字符串字段的最大长度,单位为字节","type":"int","options":[]}}},"create":{"access":"public","comment":"创建内存表(在使用column创建内存表结构时执行)","isStatic":false,"return":"","example":"","parameters":[]},"destroy":{"access":"public","comment":"销毁内存表","isStatic":false,"return":"","example":"","parameters":[]},"set":{"access":"public","comment":"设置行的数据","isStatic":false,"return":"","example":"$table->set('hello@qq.com', array('id' => 189, 'name' => 'rango3', 'num' => 3.1415));","parameters":{"key":{"comment":"数据的key,相同的$key对应同一行数据,如果set同一个key,会覆盖上一次的数据","type":"string","options":[]},"value":{"comment":"必须是一个数组,必须与字段定义的$name完全相同","type":"array","options":[]}}},"get":{"access":"public","comment":"获取一行数据","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"设置的key值","type":"string","options":[]},"field":{"comment":"字段值","type":"string","options":[]}}},"count":{"access":"public","comment":"获取数据行数","isStatic":false,"return":"int","example":"","parameters":[]},"del":{"access":"public","comment":"删除数据","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"要删除的键","type":"string","options":[]}}},"exist":{"access":"public","comment":"检查table中是否存在某一个key","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"","type":[],"options":[]}}},"incr":{"access":"public","comment":"原子自增操作","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"指定数据的key,如果$key对应的行不存在,默认列的值为0","type":"string","options":[]},"column":{"comment":"指定列名,仅支持浮点型和整型字段","type":"string","options":[]},"incrby":{"comment":"增量,默认为1。如果列为整形,$incrby必须为int型,如果列为浮点型,$incrby必须为float类型失败返回false,成功返回最终的结果数值","type":"mixed","options":[]}}},"decr":{"access":"public","comment":"原子自减操作","isStatic":false,"return":"","example":"","parameters":{"key":{"comment":"指定数据的key,如果$key对应的行不存在,默认列的值为0","type":"string","options":[]},"column":{"comment":"指定列名,仅支持浮点型和整型字段","type":"string","options":[]},"decrby":{"comment":"减量,默认为1。如果列为整形,$decrby必须为int型,如果列为浮点型,$decrby必须为float类型失败返回false,成功返回最终的结果数值","type":"mixed","options":[]}}},"getMemorySize":{"access":"public","comment":"获取table占用的内存大小","isStatic":false,"return":"int","example":"","parameters":[]},"offsetExists":{"access":"public","comment":"检查一个偏移位置是否存在","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"offsetGet":{"access":"public","comment":"取一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"offsetSet":{"access":"public","comment":"设置一个偏移位置的值(来自ArrayAccess接口)","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]},"value":{"comment":"需要设置的值","type":"mixed","options":[]}}},"offsetUnset":{"access":"public","comment":"复位一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"rewind":{"access":"public","comment":"返回到迭代器的第一个元素","isStatic":false,"return":"","example":"","parameters":[]},"next":{"access":"public","comment":"向前移动到下一个元素(此方法在 foreach 循环之后被调用)","isStatic":false,"return":"","example":"","parameters":[]},"current":{"access":"public","comment":"返回迭代器当前元素","isStatic":false,"return":"","example":"","parameters":[]},"key":{"access":"public","comment":"返回当前元素的键","isStatic":false,"return":"mixed","example":"","parameters":[]},"valid":{"access":"public","comment":"检查当前位置是否有效(迭代器方法,此方法在 Iterator::rewind() 和 Iterator::next() 方法之后被调用以此用来检查当前位置是否有效)","isStatic":false,"return":"boolean","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_table_row.json b/src/swoole/swoole_table_row.json deleted file mode 100644 index 4906d3a..0000000 --- a/src/swoole/swoole_table_row.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_table_row"},"comment":"内存表行","namespace":"","consts":[],"properties":{"key":{"access":"public","type":"string","comment":"行对应的键","isStatic":false},"value":{"access":"public","type":"mixed","comment":"行值","isStatic":false}},"methods":{"offsetExists":{"access":"public","comment":"检查一个偏移位置是否存在","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"offsetGet":{"access":"public","comment":"取一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"offsetSet":{"access":"public","comment":"设置一个偏移位置的值(来自ArrayAccess接口)","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]},"value":{"comment":"需要设置的值","type":"mixed","options":[]}}},"offsetUnset":{"access":"public","comment":"复位一个偏移位置的值","isStatic":false,"return":"","example":"","parameters":{"offset":{"comment":"偏移量","type":"int","options":[]}}},"__destruct":{"access":"public","comment":false,"isStatic":false,"return":"","example":"","parameters":[]}}} \ No newline at end of file diff --git a/src/swoole/swoole_timer.json b/src/swoole/swoole_timer.json deleted file mode 100644 index f0433bc..0000000 --- a/src/swoole/swoole_timer.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_timer"},"comment":"swoole定时器","namespace":"","consts":[],"properties":[],"methods":{"tick":{"access":"public","comment":"设置一个间隔时钟定时器,与after定时器不同的是tick定时器会持续触发,直到调用swoole_timer_clear清除","isStatic":true,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]},"param":{"comment":"用户参数, 该参数会被传递到$callback_function中. 如果有多个参数可以使用数组形式. 也可以使用匿名函数的use语法传递参数到回调函数中","type":"mixed","options":[]}}},"after":{"access":"public","comment":"在指定的时间后执行函数","isStatic":true,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"exists":{"access":"public","comment":"检查某个定时器是否存在","isStatic":true,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}},"clear":{"access":"public","comment":"删除指定的定时器","isStatic":true,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}}}} \ No newline at end of file diff --git a/src/swoole/swoole_websocket_frame.json b/src/swoole/swoole_websocket_frame.json deleted file mode 100644 index 3ac1cb2..0000000 --- a/src/swoole/swoole_websocket_frame.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_websocket_frame"},"comment":"swoole websocket 帧","namespace":"","consts":[],"properties":[],"methods":[]} \ No newline at end of file diff --git a/src/swoole/swoole_websocket_server.json b/src/swoole/swoole_websocket_server.json deleted file mode 100644 index 9839dad..0000000 --- a/src/swoole/swoole_websocket_server.json +++ /dev/null @@ -1 +0,0 @@ -{"object":{"name":"swoole_websocket_server"},"comment":"swoole websocket服务端","namespace":"","extends":"swoole_http_server","consts":[],"properties":{"onConnect":{"access":"public","type":"callable","comment":"连接成功回调函数","isStatic":false},"onReceive":{"access":"public","type":"callable","comment":"接收到数据时回调此函数","isStatic":false},"onClose":{"access":"public","type":"callable","comment":"TCP客户端连接关闭后,在worker进程中回调此函数","isStatic":false},"onPacket":{"access":"public","type":"callable","comment":"接收到UDP数据包时回调此函数,发生在worker进程中","isStatic":false},"onBufferFull":{"access":"public","type":"callable","comment":"当缓存区达到最高水位时触发此事件","isStatic":false},"onBufferEmpty":{"access":"public","type":"callable","comment":"当缓存区低于最低水位线时触发此事件","isStatic":false},"onStart":{"access":"public","type":"callable","comment":"Server启动在主进程的主线程回调此函数","isStatic":false},"onShutdown":{"access":"public","type":"callable","comment":"此事件在Server正常结束时发生","isStatic":false},"onWorkerStart":{"access":"public","type":"callable","comment":"此事件在Worker进程\/Task进程启动时发生","isStatic":false},"onWorkerStop":{"access":"public","type":"callable","comment":"此事件在worker进程终止时发生。在此函数中可以回收worker进程申请的各类资源","isStatic":false},"onWorkerExit":{"access":"public","type":"callable","comment":"仅在开启reload_async特性后有效。异步重启特性,会先创建新的Worker进程处理新请求,旧的Worker进程自行退出","isStatic":false},"onWorkerError":{"access":"public","type":"callable","comment":"当worker\/task_worker进程发生异常后会在Manager进程内回调此函数","isStatic":false},"onTask":{"access":"public","type":"callable","comment":"在task_worker进程内被调用","isStatic":false},"onFinish":{"access":"public","type":"callable","comment":"当worker进程投递的任务在task_worker中完成时,task进程会通过swoole_server->finish()方法将任务处理的结果发送给worker进程。","isStatic":false},"onManagerStart":{"access":"public","type":"callable","comment":"当管理进程启动时调用它","isStatic":false},"onManagerStop":{"access":"public","type":"callable","comment":"当管理进程结束时调用它","isStatic":false},"onPipeMessage":{"access":"public","type":"callable","comment":"当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件","isStatic":false},"connections":{"access":"public","type":"iterator","comment":"TCP连接迭代器","isStatic":false},"host":{"access":"public","type":"string","comment":"连接的主机","isStatic":false},"port":{"access":"public","type":"int","comment":"连接的主机的端口","isStatic":false,"value":0},"type":{"access":"public","type":"int","comment":"socket的类型","isStatic":false,"value":0},"mode":{"access":"public","type":"int","comment":"运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式)","isStatic":false,"value":0},"ports":{"access":"public","type":"array","comment":"当监听多端口时的端口列表","isStatic":false},"master_pid":{"access":"public","type":"int","comment":"主进程ID","isStatic":false,"value":0},"manager_pid":{"access":"public","type":"int","comment":"管理进程ID","isStatic":false,"value":0},"worker_id":{"access":"public","type":"int","comment":"当前工作进程(包括worker进程和task进程)编号","isStatic":false,"value":0},"taskworker":{"access":"public","type":"boolean","comment":"当前进程是否是task工作进程","isStatic":false,"value":false},"worker_pid":{"access":"public","type":"int","comment":"当前工作进程ID(操作系统进程)","isStatic":false,"value":0},"onRequest":{"access":"public","type":"callable","comment":"请求回调函数","isStatic":false},"onHandshake":{"access":"public","type":"callable","comment":"TCP握手时的回调函数","isStatic":false},"setting":{"access":"public","type":"array","comment":"通过swoole_server:set()设置的参数会保存到setting属性上","isStatic":false}},"methods":{"on":{"access":"public","comment":"绑定事件(为事件注册函数)","isStatic":false,"return":"","example":"","parameters":{"event_name":{"comment":"事件名称","type":"string","options":[]},"callback":{"comment":"事件对应的回调函数","type":"callable","options":[]}}},"push":{"access":"public","comment":"向websocket客户端连接推送数据,长度最大不得超过2M","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"客户端连接的ID,如果指定的$fd对应的TCP连接并非websocket客户端,将会发送失败","type":"int","options":[]},"data":{"comment":"要发送的数据内容","type":"string","options":[]},"opcode":{"comment":"指定发送数据内容的格式,默认为文本。发送二进制内容$opcode参数需要设置","type":"int","options":[]},"finish":{"comment":"帧是否完成","type":"boolean","options":[]}}},"exist":{"access":"public","comment":"检测fd对应的连接是否存在","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"pack":{"access":"public","comment":"打包数据","isStatic":true,"return":"","example":"","parameters":{"data":{"comment":"消息内容","type":"string","options":[]},"opcode":{"comment":"WebSocket的opcode指令类型,1表示文本,2表示二进制数据,9表示心跳ping","type":"int","options":[]},"finish":{"comment":"帧是否完成","type":"boolean","options":[]},"mask":{"comment":"是否设置掩码","type":"boolean","options":[]}}},"unpack":{"access":"public","comment":"参数据进行解包","isStatic":true,"return":"","example":"","parameters":{"data":{"comment":"解包的数据","type":"string","options":[]}}},"start":{"access":"public","comment":"启动server","isStatic":false,"return":"","example":"","parameters":[]},"__sleep":{"access":"public","comment":"序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)","isStatic":false,"return":"","example":"","parameters":[]},"__wakeup":{"access":"public","comment":"反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)","isStatic":false,"return":"","example":"","parameters":[]},"__construct":{"access":"public","comment":"swoole_server初始化方法","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"主机IP","type":"string","options":[]},"port":{"comment":"端口","type":"int","options":[]},"mode":{"comment":"运行模式","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"__destruct":{"access":"public","comment":"析构函数","isStatic":false,"return":"","example":"","parameters":[]},"listen":{"access":"public","comment":"添加监听端口(是addlistener的别名)","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"addlistener":{"access":"public","comment":"添加监听端口","isStatic":false,"return":"","example":"","parameters":{"host":{"comment":"监听的主机","type":"string","options":[]},"port":{"comment":"监听的端口号","type":"int","options":[]},"sock_type":{"comment":"socket类型","type":"int","options":[]}}},"set":{"access":"public","comment":"设置swoole_server运行时的参数","isStatic":false,"return":"","example":"","parameters":{"settings":{"comment":"配置选项","type":"array","options":[]}}},"send":{"access":"public","comment":"向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]},"reactor_id":{"comment":"UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port","type":"int","options":[]}}},"sendto":{"access":"public","comment":"向任意客户端发送UDP数据包","isStatic":false,"return":"","example":"","parameters":{"ip":{"comment":"IPv4字符串,如192.168.1.102。如果IP不合法会返回错误","type":"string","options":[]},"port":{"comment":"为 1-65535的网络端口号,如果端口错误发送会失败","type":"int","options":[]},"send_data":{"comment":"发送的数据内容,可以是文本或者二进制内容","type":"string","options":[]},"server_socket":{"comment":"服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包","type":"int","options":[]}}},"sendwait":{"access":"public","comment":"阻塞的向客户端发送数据","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"与客户端连接的句柄","type":"int","options":[]},"send_data":{"comment":"发送的数据","type":"string","options":[]}}},"protect":{"access":"public","comment":"设置客户端连接为保护状态,不被心跳线程切断","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"要设置保护状态的客户端连接fd","type":"int","options":[]},"is_protected":{"comment":"设置的状态,true表示保护状态,false表示不保护","type":"boolean","options":[]}}},"sendfile":{"access":"public","comment":"向客户端发送文件","isStatic":false,"return":"","example":"","parameters":{"conn_fd":{"comment":"连接句柄","type":"int","options":[]},"filename":{"comment":"文件名","type":"string","options":[]},"offset":{"comment":"指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送","type":"int","options":[]},"length":{"comment":"指定发送的长度,默认为文件尺寸","type":"int","options":[]}}},"close":{"access":"public","comment":"关闭客户端连接","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"reset":{"comment":"设置为true会强制关闭连接,丢弃发送队列中的数据","type":"boolean","options":[]}}},"confirm":{"access":"public","comment":"确认连接,与enable_delay_receive或wait_for_bind配合使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"pause":{"access":"public","comment":"停止接收数据","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"resume":{"access":"public","comment":"恢复数据接收。与pause方法成对使用","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]}}},"task":{"access":"public","comment":"投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]},"finish_callback":{"comment":"完成后的回调函数","type":"callable","options":[]}}},"taskwait":{"access":"public","comment":"以阻塞的形式投递一个任务到task_worker连接池中","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要投递的任务数据,可以为除资源类型之外的任意PHP变量","type":"mixed","options":[]},"timeout":{"comment":"超时时间","type":"float","options":[]},"worker_id":{"comment":"可以制定要给投递给哪个task进程,传入ID即可","type":"int","options":[]}}},"taskWaitMulti":{"access":"public","comment":"并发执行多个Task","isStatic":false,"return":"","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"taskCo":{"access":"public","comment":"并发执行Task并进行协程调度","isStatic":false,"return":"array","example":"","parameters":{"tasks":{"comment":"必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程","type":"array","options":[]},"timeout":{"comment":"超时时间","type":"double","options":[]}}},"finish":{"access":"public","comment":"用于在task进程中通知worker进程任务已完成","isStatic":false,"return":"","example":"","parameters":{"data":{"comment":"要传递的数据","type":"string","options":[]}}},"reload":{"access":"public","comment":"重启所有工作进程","isStatic":false,"return":"boolean","example":"","parameters":[]},"shutdown":{"access":"public","comment":"关闭服务器","isStatic":false,"return":"","example":"","parameters":[]},"stop":{"access":"public","comment":"停止当前worker进程","isStatic":false,"return":"","example":"","parameters":{"worker_id":{"comment":"进程ID","type":"int","options":[]}}},"getLastError":{"access":"public","comment":"获取最近一次操作错误的错误码\n返回的错误码:\n1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据","isStatic":false,"return":"","example":"","parameters":[]},"heartbeat":{"access":"public","comment":"检测所有服务器连接,并找出已经超时的连接","isStatic":false,"return":"","example":"","parameters":{"reactor_id":{"comment":"是否关闭超时的连接,默认为true","type":"boolean","options":[]}}},"connection_info":{"access":"public","comment":"获取客户端连接信息","isStatic":false,"return":"from_id","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"connection_list":{"access":"public","comment":"用来遍历所有客户端连接","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"getClientInfo":{"access":"public","comment":"获取连接的信息,别名是swoole_server->connection_info","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":[],"options":[]},"reactor_id":{"comment":"reactor线程id","type":"int","options":[]}}},"getClientList":{"access":"public","comment":"用来遍历所有客户端连接(server->connection_list的别名)","isStatic":false,"return":"","example":"","parameters":{"start_fd":{"comment":"起始fd","type":"int","options":[]},"find_count":{"comment":"每页取多少条","type":"int","options":[]}}},"after":{"access":"public","comment":"在指定时间后执行某个回调函数","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]},"param":{"comment":"给回调函数传入的参数","type":"array","options":[]}}},"tick":{"access":"public","comment":"添加定时器","isStatic":false,"return":"","example":"","parameters":{"ms":{"comment":"指定时间,单位为毫秒","type":"int","options":[]},"callback":{"comment":"回调函数","type":"callable","options":[]}}},"clearTimer":{"access":"public","comment":"清除定时器","isStatic":false,"return":"","example":"","parameters":{"timer_id":{"comment":"定时器ID","type":"int","options":[]}}},"defer":{"access":"public","comment":"延迟执行一个PHP函数","isStatic":false,"return":"","example":"","parameters":{"callback":{"comment":"执行的函数","type":"callable","options":[]}}},"sendMessage":{"access":"public","comment":"向任意worker进程或task进程发送消息","isStatic":false,"return":"","example":"","parameters":{"dst_worker_id":{"comment":"目标worker的ID","type":"int","options":[]},"data":{"comment":"发送的消息","type":"string","options":[]}}},"addProcess":{"access":"public","comment":"添加一个自定义的工作进程","isStatic":false,"return":"","example":"","parameters":{"process":{"comment":"进程对象","type":"Swoole\\Process","options":[]}}},"stats":{"access":"public","comment":"得到当前server的活动TCP连接数\narray (","isStatic":false,"return":"","example":"","parameters":[]},"bind":{"access":"public","comment":"将连接绑定到某个用户定义的ID","isStatic":false,"return":"","example":"","parameters":{"fd":{"comment":"连接句柄","type":"int","options":[]},"uid":{"comment":"用户定义的ID","type":"int","options":[]}}}}} \ No newline at end of file From 3c904f5d37906a1b889d7381e55724d396398beb Mon Sep 17 00:00:00 2001 From: shixinke Date: Thu, 28 Dec 2017 14:36:22 +0800 Subject: [PATCH 03/34] =?UTF-8?q?=E6=9B=B4=E6=96=B0redis=E6=96=87=E6=A1=A3?= =?UTF-8?q?=EF=BC=8Cswoole=E6=96=87=E6=A1=A3=E5=A2=9E=E5=8A=A0http2?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E5=92=8Cswoole=20redis=E5=8D=8F?= =?UTF-8?q?=E7=A8=8B=E5=AE=A2=E6=88=B7=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Redis/Redis.php | 1692 +++++++----- src/Redis/RedisArray.php | 218 +- src/Redis/RedisCluster.php | 1974 ++++++++++---- src/Redis/RedisClusterException.php | 66 +- src/Redis/RedisException.php | 66 +- src/Swoole/Async.php | 2 +- src/Swoole/Atomic.php | 2 +- src/Swoole/Atomic/Long.php | 2 +- src/Swoole/Buffer.php | 2 +- src/Swoole/Channel.php | 2 +- src/Swoole/Client.php | 80 +- src/Swoole/Connection/Iterator.php | 2 +- src/Swoole/Coroutine.php | 2 +- src/Swoole/Coroutine/Client.php | 2 +- src/Swoole/Coroutine/Http/Client.php | 2 +- src/Swoole/Coroutine/MySQL.php | 2 +- src/Swoole/Coroutine/MySQL/Exception.php | 2 +- src/Swoole/Coroutine/Redis.php | 1587 ++++++++++++ src/Swoole/Event.php | 2 +- src/Swoole/Exception.php | 2 +- src/Swoole/Http/Client.php | 2 +- src/Swoole/Http/Request.php | 2 +- src/Swoole/Http/Response.php | 15 +- src/Swoole/Http/Server.php | 2 +- src/Swoole/Http2/Client.php | 506 ++++ src/Swoole/Http2/Response.php | 36 + src/Swoole/Lock.php | 2 +- src/Swoole/Mmap.php | 2 +- src/Swoole/MySQL.php | 2 +- src/Swoole/MySQL/Exception.php | 2 +- src/Swoole/Process.php | 2 +- src/Swoole/Redis.php | 181 ++ src/Swoole/Redis/Server.php | 2 +- src/Swoole/Serialize.php | 2 +- src/Swoole/Server.php | 2 +- src/Swoole/Server/Port.php | 2 +- src/Swoole/Table.php | 2 +- src/Swoole/Table/Row.php | 2 +- src/Swoole/Timer.php | 2 +- src/Swoole/WebSocket/Frame.php | 2 +- src/Swoole/WebSocket/Server.php | 2 +- src/Swoole/swoole.namespace.php | 122 +- src/Swoole/swoole.php | 122 +- src/Swoole/swoole_async.php | 2 +- src/Swoole/swoole_atomic.php | 2 +- src/Swoole/swoole_atomic_long.php | 2 +- src/Swoole/swoole_buffer.php | 2 +- src/Swoole/swoole_channel.php | 2 +- src/Swoole/swoole_client.php | 80 +- src/Swoole/swoole_client_coro.php | 116 +- src/Swoole/swoole_connection_iterator.php | 2 +- src/Swoole/swoole_coroutine.php | 2 +- src/Swoole/swoole_event.php | 2 +- src/Swoole/swoole_exception.php | 2 +- src/Swoole/swoole_http2_client.php | 505 ++++ src/Swoole/swoole_http2_response.php | 35 + src/Swoole/swoole_http_client.php | 2 +- src/Swoole/swoole_http_client_coro.php | 2 +- src/Swoole/swoole_http_request.php | 2 +- src/Swoole/swoole_http_response.php | 15 +- src/Swoole/swoole_http_server.php | 2 +- src/Swoole/swoole_lock.php | 2 +- src/Swoole/swoole_mmap.php | 2 +- src/Swoole/swoole_mysql.php | 2 +- src/Swoole/swoole_mysql_coro.php | 93 +- src/Swoole/swoole_mysql_coro_exception.php | 2 +- src/Swoole/swoole_mysql_exception.php | 2 +- src/Swoole/swoole_process.php | 2 +- src/Swoole/swoole_redis.php | 180 ++ src/Swoole/swoole_redis_coro.php | 2723 ++++++++++++++++++++ src/Swoole/swoole_redis_server.php | 2 +- src/Swoole/swoole_serialize.php | 2 +- src/Swoole/swoole_server.php | 2 +- src/Swoole/swoole_server_port.php | 2 +- src/Swoole/swoole_table.php | 2 +- src/Swoole/swoole_table_row.php | 2 +- src/Swoole/swoole_timer.php | 2 +- src/Swoole/swoole_websocket_frame.php | 2 +- src/Swoole/swoole_websocket_server.php | 2 +- 79 files changed, 9031 insertions(+), 1497 deletions(-) create mode 100644 src/Swoole/Coroutine/Redis.php create mode 100644 src/Swoole/Http2/Client.php create mode 100644 src/Swoole/Http2/Response.php create mode 100644 src/Swoole/Redis.php create mode 100644 src/Swoole/swoole_http2_client.php create mode 100644 src/Swoole/swoole_http2_response.php create mode 100644 src/Swoole/swoole_redis.php create mode 100644 src/Swoole/swoole_redis_coro.php diff --git a/src/Redis/Redis.php b/src/Redis/Redis.php index 32a417e..14b3680 100644 --- a/src/Redis/Redis.php +++ b/src/Redis/Redis.php @@ -2,114 +2,145 @@ /** * Redis自动补全类(基于最新的3.0.0版本) * @author shixinke(http://www.shixinke.com) -* @modified 2016/12/08 +* @modified 2017/12/28 */ /** -* +*php操作Redis客户端 +*/ +/** + * php.ini配置选项: + + * + * redis.arrays.names= + + * + * redis.arrays.hosts= + + * + * redis.arrays.previous= + + * + * redis.arrays.functions= + + * + * redis.arrays.index= + + * + * redis.arrays.autorehash= + + * + * redis.clusters.seeds= + + * + * redis.clusters.timeout= + + * + * redis.clusters.read_timeout= + */ class Redis { /** - * + *未知类型 */ const REDIS_NOT_FOUND = 0; /** - * + *字符串类型 */ const REDIS_STRING = 1; /** - * + *集合类型 */ const REDIS_SET = 2; /** - * + *列表类型 */ const REDIS_LIST = 3; /** - * + *有序集合类型 */ const REDIS_ZSET = 4; /** - * + *字典类型 */ const REDIS_HASH = 5; /** - * + *管道模式 */ const PIPELINE = 2; /** - * + *原子操作模式 */ const ATOMIC = 0; /** - * + *事务模式 */ const MULTI = 1; /** - * + *序列化选项 */ const OPT_SERIALIZER = 1; /** - * + *前缀选项 */ const OPT_PREFIX = 2; /** - * + *读操作超时选项 */ const OPT_READ_TIMEOUT = 3; /** - * + *不实行序列化 */ const SERIALIZER_NONE = 0; /** - * + *PHP序列化 */ const SERIALIZER_PHP = 1; /** - * + *扫描选项 */ const OPT_SCAN = 4; /** - * + *重新扫描 */ const SCAN_RETRY = 1; /** - * + *不重新扫描 */ const SCAN_NORETRY = 0; /** - * + *后面位置 */ const AFTER = 'after'; /** - * + *前面位置 */ const BEFORE = 'before'; /** * - *Creates a Redis client + *创建一个redis客户端 * @example $redis = new Redis(); - * @return + * @return Object */ public function __construct() { @@ -117,7 +148,7 @@ public function __construct() /** * - * + *析构方法 * @example * @return */ @@ -127,7 +158,7 @@ public function __destruct() /** * - *Connects to a Redis instance. + *连接redis服务器 * @example *
      * $redis->connect('127.0.0.1', 6379);
@@ -135,31 +166,43 @@ public function __destruct()
      * $redis->connect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout.
      * $redis->connect('/tmp/redis.sock');      // unix domain socket.
      * 
+ * @param string $host 主机IP + * @param int $port 端口 + * @param float $timeout 连接超时时间(以秒为单位) + * @param mixed $reserved 当使用retry_interval时该值为NULL + * @param int $retry_interval 重试间隔 + * @param float $read_timeout 读操作超时时间 * @return bool */ - public function connect() + public function connect($host, $port, $timeout, $reserved, $retry_interval, $read_timeout) { } /** * - *Connects to a Redis instance or reuse a connection already established with pconnect/popen. + *连接redis(长连接),与connect用法一致 * @example *
-     * $redis->connect('127.0.0.1', 6379);
-     * $redis->connect('127.0.0.1');            // port 6379 by default
+     * $redis->pconnect('127.0.0.1', 6379);
+     * $redis->pconnect('127.0.0.1');            // port 6379 by default
      * $redis->connect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout.
      * $redis->connect('/tmp/redis.sock');      // unix domain socket.
      * 
+ * @param string $host 主机IP + * @param int $port 端口 + * @param float $timeout 连接超时时间(以秒为单位) + * @param mixed $reserved 当使用retry_interval时该值为NULL + * @param int $retry_interval 重试间隔 + * @param float $read_timeout 读操作超时时间 * @return bool */ - public function pconnect() + public function pconnect($host, $port, $timeout, $reserved, $retry_interval, $read_timeout) { } /** * - *Disconnects from the Redis instance, except when pconnect is used. + *关闭redis连接(长连接除外) * @example * @return */ @@ -169,7 +212,7 @@ public function close() /** * - *Check the current connection status + *检查当前redis连接状态(成功时返回PONG) * @example * @return string */ @@ -179,19 +222,20 @@ public function ping() /** * - * + *向redis发送一个字符串,而且redis服务器将返回一个相同的字符串 * @example - * @return + * @param string $str 发送的字符串 + * @return string */ - public function echo() + public function echo($str) { } /** * - *Get the value related to the specified key + *获取指定的key的值 * @example $redis->get('key'); - * @return string|bool: + * @return string|bool */ public function get() { @@ -199,72 +243,91 @@ public function get() /** * - *Set the string value in argument as value of the key. - * @example + *给指定的键设置值 + * @example 直接设置: + * $redis->set('key', 'value'); + * 带有效期的设置: + * $redis->set('key','value', 10); + * 当键不存在时,设置期有效期为10秒: + * $redis->set('key', 'value', Array('nx', 'ex'=>10)); + * 当键存在时,设置期有效期为1000毫秒: + * $redis->set('key', 'value', Array('xx', 'px'=>1000)); + * + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int|array $options 附加项,可以是超时时间或者一个选项数组 * @return bool */ - public function set() + public function set($key, $value, $options) { } /** * - *Set the string value in argument as value of the key, with a time to live. - * @example $redis->setex('key', 3600, 'value'); // sets key → value, with 1h TTL. - * @return bool: + *设置键值并设置有效期 + * @example $redis->setex('key', 3600, 'value'); + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int $ttl 有效期 + * @return bool */ - public function setex() + public function setex($key, $value, $ttl) { } /** * - * + *设置键值并设置有效期(毫秒为单位) * @example + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int $ttl 有效期(毫秒为单位) * @return */ - public function psetex() + public function psetex($key, $value, $ttl) { } /** * - *Set the string value in argument as value of the key if the key doesn't already exist in the database. + *当键不存在时设置其值 * @example - *
-     * $redis->setnx('key', 'value');   // return TRUE
-     * $redis->setnx('key', 'value');   // return FALSE
-     * 
+ * $redis->setnx('key', 'value'); + * + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 * @return bool: */ - public function setnx() + public function setnx($key, $value) { } /** * - *Sets a value and returns the previous entry at that key. + *设置键的值,并返回它的旧的缓存值 * @example *
      * $redis->set('x', '42');
      * $exValue = $redis->getSet('x', 'lol');   // return '42', replaces x by 'lol'
      * $newValue = $redis->get('x')'            // return 'lol'
      * 
+ * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 * @return string */ - public function getSet() + public function getSet($key, $value) { } /** * - *Returns a random key. + *返回一个随机的键 * @example *
      * $key = $redis->randomKey();
      * $surprise = $redis->get($key);  // who knows what's in there.
      * 
- * @return string: + * @return string */ public function randomKey() { @@ -272,34 +335,31 @@ public function randomKey() /** * - * + *给键重命名 * @example - * @return + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean */ - public function renameKey() + public function renameKey($srcKey, $dstKey) { } /** * - *Renames a key. + *当目标键名不存在时,给键重命名 * @example - *
-     * $redis->set('x', '42');
-     * $redis->rename('x', 'y');
-     * $redis->get('y');   // → 42
-     * $redis->get('x');   // → `FALSE`
-     * 
- * @return bool: + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean */ - public function renameNx() + public function renameNx($srcKey, $dstKey) { } /** * - *Get the values of all the specified keys. If one or more keys dont exist, the array will contain FALSE at the - *position of the key. + *批量获取键值 * @example *
      * $redis->set('key1', 'value1');
@@ -308,40 +368,44 @@ public function renameNx()
      * $redis->getMultiple(array('key1', 'key2', 'key3')); // array('value1', 'value2', 'value3');
      * $redis->getMultiple(array('key0', 'key1', 'key5')); // array(`FALSE`, 'value2', `FALSE`);
      * 
+ * @param array $keys 键名数组 * @return array */ - public function getMultiple() + public function getMultiple(Array $keys) { } /** * - *Verify if the specified key exists. + *判断键是否存在 * @example *
      * $redis->set('key', 'value');
      * $redis->exists('key');               //  TRUE
      * $redis->exists('NonExistingKey');    // FALSE
      * 
- * @return bool: + * @param string $key 键名 + * @return bool */ - public function exists() + public function exists($key) { } /** * - * - * @example + *删除一个或多个键 + * @example $redis->delete('key1', 'key2'); + * $redis->delete(array('key3', 'key4')); + * @param array|string $keys 键名 * @return int */ - public function delete() + public function delete($keys) { } /** * - *Increment the number stored at key by one. + *键值自增 * @example *
      * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
@@ -349,16 +413,16 @@ public function delete()
      * $redis->incr('key1'); // 3
      * $redis->incr('key1'); // 4
      * 
+ * @param string $key 键名 * @return int */ - public function incr() + public function incr($key) { } /** * - *Increment the number stored at key by one. If the second argument is filled, it will be used as the integer - *value of the increment. + *按指定步长自增 * @example *
      * $redis->incr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value 1
@@ -367,15 +431,17 @@ public function incr()
      * $redis->incr('key1');        // 4
      * $redis->incrBy('key1', 10);  // 14
      * 
+ * @param string $key 键名 + * @param int $step 自增步长 * @return int */ - public function incrBy() + public function incrBy($key, $step) { } /** * - *Increment the float value of a key by the given amount + *按指定步长自增 * @example *
      * $redis = new Redis();
@@ -385,31 +451,33 @@ public function incrBy()
      * // ! SIC
      * var_dump( $redis->get('x') );                // string(3) "4.5"
      * 
- * @return + * @param string $key 键名 + * @param float $step 自增步长 + * @return float */ - public function incrByFloat() + public function incrByFloat($key, $step) { } /** * - *Decrement the number stored at key by one. + *键值自减 * @example *
      * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
      * $redis->decr('key1'); // -2
      * $redis->decr('key1'); // -3
      * 
+ * @param string $key 键名 * @return int */ - public function decr() + public function decr($key) { } /** * - *Decrement the number stored at key by one. If the second argument is filled, it will be used as the integer - *value of the decrement. + *按指定步长自减 * @example *
      * $redis->decr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value -1
@@ -417,85 +485,98 @@ public function decr()
      * $redis->decr('key1');        // -3
      * $redis->decrBy('key1', 10);  // -13
      * 
+ * @param string $key 键名 + * @param float $step 自减步长 * @return int */ - public function decrBy() + public function decrBy($key, $step) { } /** * - *Returns the type of data pointed by a given key. + *获取指定键的数据类型(需要根据常量匹配) * @example $redis->type('key'); - * @return - + * @param string $key 键名 + * @return int */ - public function type() + public function type($key) { } /** * - *Append specified string to the string stored in specified key. + *将字符串追加到键值后(返回值的长度) * @example *
      * $redis->set('key', 'value1');
      * $redis->append('key', 'value2'); // 12
      * $redis->get('key');              // 'value1value2'
      * 
- * @return int: + * @param string $key 键名 + * @param string $value 追加的值 + * @return int */ - public function append() + public function append($key, $value) { } /** * - *Return a substring of a larger string + *获取一个键值的子字符串 * @example *
      * $redis->set('key', 'string value');
      * $redis->getRange('key', 0, 5);   // 'string'
      * $redis->getRange('key', -5, -1); // 'value'
      * 
+ * @param string $key 键名 + * @param int $start 开始位置 + * @param int $end 结束位置 * @return string: */ - public function getRange() + public function getRange($key, $start, $end) { } /** * - *Changes a substring of a larger string. + *修改某个键的某个位置的值 * @example *
      * $redis->set('key', 'Hello world');
      * $redis->setRange('key', 6, "redis"); // returns 11
      * $redis->get('key');                  // "Hello redis"
      * 
- * @return string: + * @param string $key 键名 + * @param int $offset 开始位置 + * @param string $value 被替换的子串的值 + * @return string */ - public function setRange() + public function setRange($key, $offset, $value) { } /** * - *Return a single bit out of a larger string + *获取某个键的某个位置的位值 * @example *
      * $redis->set('key', "\x7f");  // this is 0111 1111
      * $redis->getBit('key', 0);    // 0
      * $redis->getBit('key', 1);    // 1
      * 
- * @return int: + * @param string $key 键名 + * @param int $offset 所在位置 + * @return int */ - public function getBit() + public function getBit($key, $offset) { } /** * - *Changes a single bit of a string. + *修改某个键的某个位置的位值 * @example *
      * $redis->set('key', "*");     // ord("*") = 42 = 0x2f = "0010 1010"
@@ -503,39 +584,46 @@ public function getBit()
      * $redis->setBit('key', 7, 1); // returns 0
      * $redis->get('key');          // chr(0x2f) = "/" = b("0010 1111")
      * 
+ * @param string $key 键名 + * @param int $offset 开始位置 + * @param boolean|int $value 新值 * @return int: */ - public function setBit() + public function setBit($key, $offset, $value) { } /** * - *Get the length of a string value. + *获取键值的长度 * @example *
      * $redis->set('key', 'value');
      * $redis->strlen('key'); // 5
      * 
- * @return + * @param string $key 键名 + * @return int */ - public function strlen() + public function strlen($key) { } /** * - * + *根据匹配模式获取键名(如*) * @example - * @return + * $allKeys = $redis->keys('*'); + * $keyWithUserPrefix = $redis->keys('user*'); + * @param string $pattern 匹配模式 + * @return array */ - public function getKeys() + public function getKeys($pattern) { } /** * - *Sort + *给列表、集合或有序集合的元素排序 * @example *
      * $redis->delete('s');
@@ -548,56 +636,61 @@ public function getKeys()
      * var_dump($redis->sort('s', array('sort' => 'desc'))); // 5,4,3,2,1
      * var_dump($redis->sort('s', array('sort' => 'desc', 'store' => 'out'))); // (int)5
      * 
+ * @param string $key 键名 + * @param array $options 排序参数,如:array('sort' => 'desc') * @return An */ - public function sort() + public function sort($key, Array $options) { } /** * - * + *给列表、集合或有序集合的元素排序(自小到大顺序) * @example + * @param string $key 键名 * @return */ - public function sortAsc() + public function sortAsc($key) { } /** * - * + *给列表、集合或有序集合的元素排序(按字母顺序) * @example + * @param string $key 键名 * @return */ - public function sortAscAlpha() + public function sortAscAlpha($key) { } /** * - * + *给列表、集合或有序集合的元素排序(自大到小顺序) * @example + * @param string $key 键名 * @return */ - public function sortDesc() + public function sortDesc($key) { } /** * - * + *给列表、集合或有序集合的元素排序(按字母顺序倒序) * @example + * @param string $key 键名 * @return */ - public function sortDescAlpha() + public function sortDescAlpha($key) { } /** * - *Adds the string values to the head (left) of the list. Creates the list if the key didn't exist. - *If the key exists and is not a list, FALSE is returned. + *从左侧(头部)向列表插入元素 * @example *
      * $redis->lPush('l', 'v1', 'v2', 'v3', 'v4')   // int(4)
@@ -610,16 +703,17 @@ public function sortDescAlpha()
      * //   [3]=> string(2) "v1"
      * // }
      * 
+ * @param string $key 键名 + * @param string $value 元素值 * @return int */ - public function lPush() + public function lPush($key, $value) { } /** * - *Adds the string values to the tail (right) of the list. Creates the list if the key didn't exist. - *If the key exists and is not a list, FALSE is returned. + *从右侧(尾部)向列表插入元素 * @example *
      * $redis->rPush('l', 'v1', 'v2', 'v3', 'v4');    // int(4)
@@ -632,15 +726,17 @@ public function lPush()
      * //   [3]=> string(2) "v4"
      * // }
      * 
+ * @param string $key 键名 + * @param string $value 元素值 * @return int */ - public function rPush() + public function rPush($key, $value) { } /** * - *Adds the string value to the head (left) of the list if the list exists. + *如果列表存在,从左侧(头部)向列表插入元素 * @example *
      * $redis->delete('key1');
@@ -650,15 +746,17 @@ public function rPush()
      * $redis->lPushx('key1', 'C');     // returns 3
      * // key1 now points to the following list: [ 'A', 'B', 'C' ]
      * 
+ * @param string $key 键名 + * @param string $value 元素值 * @return int */ - public function lPushx() + public function lPushx($key, $value) { } /** * - *Adds the string value to the tail (right) of the list if the ist exists. FALSE in case of Failure. + *如果列表存在,从右侧(尾部)向列表插入元素 * @example *
      * $redis->delete('key1');
@@ -668,15 +766,17 @@ public function lPushx()
      * $redis->rPushx('key1', 'C'); // returns 3
      * // key1 now points to the following list: [ 'A', 'B', 'C' ]
      * 
+ * @param string $key 键名 + * @param string $value 元素值 * @return int */ - public function rPushx() + public function rPushx($key, $value) { } /** * - *Returns and removes the first element of the list. + *从列表左侧删除一个元素 * @example *
      * $redis->rPush('key1', 'A');
@@ -684,15 +784,16 @@ public function rPushx()
      * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
      * $redis->lPop('key1');        // key1 => [ 'B', 'C' ]
      * 
+ * @param string $key 键名 * @return string */ - public function lPop() + public function lPop($key) { } /** * - *Returns and removes the last element of the list. + *从列表右侧删除一个元素 * @example *
      * $redis->rPush('key1', 'A');
@@ -700,18 +801,16 @@ public function lPop()
      * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
      * $redis->rPop('key1');        // key1 => [ 'A', 'B' ]
      * 
+ * @param string $key 键名 * @return string */ - public function rPop() + public function rPop($key) { } /** * - *Is a blocking lPop primitive. If at least one of the lists contains at least one element, - *the element will be popped from the head of the list and returned to the caller. - *Il all the list identified by the keys passed in arguments are empty, blPop will block - *during the specified timeout until an element is pushed to one of those lists. This element will be popped. + *是一个阻塞lPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表头部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,blPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 * @example *
      * // Non blocking feature
@@ -733,19 +832,17 @@ public function rPop()
      * // process 1
      * // array('key1', 'A') is returned
      * 
+ * @param string|...|array $key 键名 + * @param int $timeout 超时时间 * @return array */ - public function blPop() + public function blPop($key, $timeout) { } /** * - *Is a blocking rPop primitive. If at least one of the lists contains at least one element, - *the element will be popped from the head of the list and returned to the caller. - *Il all the list identified by the keys passed in arguments are empty, brPop will - *block during the specified timeout until an element is pushed to one of those lists. T - *his element will be popped. + *是一个阻塞rPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表尾部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,brPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 * @example *
      * // Non blocking feature
@@ -767,65 +864,79 @@ public function blPop()
      * // process 1
      * // array('key1', 'A') is returned
      * 
+ * @param string|...|array $key 键名 + * @param int $timeout 超时时间 * @return array */ - public function brPop() + public function brPop($key, $timeout) { } /** * - * + *返回列表的长度 * @example - * @return + * @param string|...|array $key 键名 + * @return long | bool */ - public function lSize() + public function lSize($key) { } /** * - * + *从列表中删除指定值的元素。 如果count为零,则删除所有匹配的元素。 如果计数是负数,则元素从尾部移到头部。 * @example - * @return + * @param string $key 键名 + * @param string $value 元素值 + * @param int $count 删除的个数 + * @return long | bool */ - public function lRemove() + public function lRemove($key, $value, $count) { } /** * - * + *删除指定范围外的其他元素 * @example - * @return + * @param string $key 键名 + * @param int $start 开始索引 + * @param int $end 结束索引 + * @return array | boolean */ - public function listTrim() + public function listTrim($key, $start, $end) { } /** * - * + *获取列表中指定索引的值 * @example - * @return + * @param string $key 键名 + * @param int $index 索引值 + * @return string | boolean */ - public function lGet() + public function lGet($key, $index) { } /** * - * + *获取列表指定范围的值 * @example - * @return + * @param string $key 键名 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @return array */ - public function lGetRange() + public function lGetRange($key, $start, $end) { } /** * - *Set the list at index with the new value. + *给列表指定位置设置新值 * @example *
      * $redis->rPush('key1', 'A');
@@ -835,17 +946,18 @@ public function lGetRange()
      * $redis->lSet('key1', 0, 'X');
      * $redis->lGet('key1', 0);     // 'X'
      * 
- * @return is + * @param string $key 键名 + * @param int $index 索引值 + * @param string $value 新值 + * @return boolean */ - public function lSet() + public function lSet($key, $index, $value) { } /** * - *Insert value in the list before or after the pivot value. the parameter options - *specify the position of the insert (before or after). If the list didn't exists, - *or the pivot didn't exists, the value is not inserted. + *在列表中,在某个元素的前面或后面插入一个新值 * @example *
      * $redis->delete('key1');
@@ -859,60 +971,70 @@ public function lSet()
      * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C', 'Y')
      * $redis->lInsert('key1', Redis::AFTER, 'W', 'value'); // -1
      * 
+ * @param string $key 键名 + * @param string $position 位置(前面或后面,使用Redis::BEFORE | Redis::AFTER) + * @param string $element 元素 + * @param string $value 新值 * @return int */ - public function lInsert() + public function lInsert($key, $position, $element, $value) { } /** * - *Adds a values to the set value stored at key. - *If this value is already in the set, FALSE is returned. + *给集合添加元素 * @example *
      * $redis->sAdd('k', 'v1');                // int(1)
      * $redis->sAdd('k', 'v1', 'v2', 'v3');    // int(2)
      * 
+ * @param string $key 键名 + * @param string $value 元素值 * @return int */ - public function sAdd() + public function sAdd($key, $value) { } /** * - * + *给集合批量添加元素 * @example + * @param string $key 键名 + * @param array $value 元素值 * @return */ - public function sAddArray() + public function sAddArray($key, Array $value) { } /** * - * + *返回集合的元素个数 * @example - * @return + * @param string $key 键名 + * @return long */ - public function sSize() + public function sSize($key) { } /** * - * + *删除集合元素 * @example - * @return + * @param string $key 键名 + * @param string|... $member 成员 + * @return long */ - public function sRemove() + public function sRemove($key, $member) { } /** * - *Moves the specified member from the set at srcKey to the set at dstKey. + *将某个集合中的元素移动到另外一个集合中 * @example *
      * $redis->sAdd('key1' , 'set11');
@@ -923,15 +1045,18 @@ public function sRemove()
      * $redis->sMove('key1', 'key2', 'set13');  // 'key1' =>  {'set11', 'set12'}
      * // 'key2' =>  {'set21', 'set22', 'set13'}
      * 
- * @return If + * @param string $srcKey 原集合键名 + * @param string $dstKey 目标集合键名 + * @param string $member 成员 + * @return bool */ - public function sMove() + public function sMove($srcKey, $dstKey, $member) { } /** * - *Removes and returns a random element from the set value at Key. + *随机删除元素的某个或某些成员,并返回这个删除的成员. * @example *
      * $redis->sAdd('key1' , 'set1');
@@ -940,15 +1065,17 @@ public function sMove()
      * $redis->sPop('key1');            // 'set1', 'key1' => {'set3', 'set2'}
      * $redis->sPop('key1');            // 'set3', 'key1' => {'set2'}
      * 
- * @return bool + * @param string $key 键名 + * @param int $count 删除个数 + * @return string | bool */ - public function sPop() + public function sPop($key, $count) { } /** * - *Returns a random element(s) from the set value at Key, without removing it. + *随机返回一个集合的元素(不会删除它) * @example *
      * $redis->sAdd('key1' , 'one');
@@ -962,25 +1089,28 @@ public function sPop()
      * //   [1]=> string(2) "three"
      * // }
      * 
- * @return bool + * @param string $key 键名 + * @return string | bool */ - public function sRandMember() + public function sRandMember($key) { } /** * - * + *是否包含某个成员 * @example - * @return + * @param string $key 键名 + * @param string $member 成员值 + * @return boolean */ - public function sContains() + public function sContains($key, $member) { } /** * - *Returns the contents of a set. + *返回集合的所有成员 * @example *
      * $redis->delete('s');
@@ -999,17 +1129,16 @@ public function sContains()
      * //}
      * // The order is random and corresponds to redis' own internal representation of the set structure.
      * 
+ * @param string $key 键名 * @return array */ - public function sMembers() + public function sMembers($key) { } /** * - *Returns the members of a set resulting from the intersection of all the sets - *held at the specified keys. If just a single key is specified, then this command - *produces the members of this set. If one of the keys is missing, FALSE is returned. + *获取两个集合的交集 * @example *
      * $redis->sAdd('key1', 'val1');
@@ -1028,15 +1157,17 @@ public function sMembers()
      * //  string(4) "val3"
      * //}
      * 
- * @return If + * @param string $key1 键名1 + * @param string $key2 键名2 + * @return array | boolean */ - public function sInter() + public function sInter($key1, $key2) { } /** * - *Performs a sInter command and stores the result in a new set. + *获取多个集合的交集,并将结果存入到另外一个集合中 * @example *
      * $redis->sAdd('key1', 'val1');
@@ -1058,15 +1189,19 @@ public function sInter()
      * //  string(4) "val3"
      * //}
      * 
- * @return int: + * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int */ - public function sInterStore() + public function sInterStore($dstKey, $key1, $key2, $keyN) { } /** * - *Performs the union between N sets and returns it. + *获取集合的并集 * @example *
      * $redis->delete('s0', 's1', 's2');
@@ -1088,15 +1223,17 @@ public function sInterStore()
      * //  string(1) "2"
      * //}
      * 
+ * @param string $key1 键名1 + * @param string|... $key2 键名2 * @return array */ - public function sUnion() + public function sUnion($key1, $key2) { } /** * - *Performs the same action as sUnion, but stores the result in the first key + *获取多个集合的并集,并将结果存入到另外一个集合中 * @example *
      * $redis->delete('s0', 's1', 's2');
@@ -1120,15 +1257,19 @@ public function sUnion()
      * //  string(1) "2"
      * //}
      * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n * @return int */ - public function sUnionStore() + public function sUnionStore($dstKey, $key1, $key2, $keyN) { } /** * - *Performs the difference between N sets and returns it. + *获取多个集合的差集 * @example *
      * $redis->delete('s0', 's1', 's2');
@@ -1146,15 +1287,17 @@ public function sUnionStore()
      * //  string(1) "2"
      * //}
      * 
+ * @param string $key1 键名1 + * @param string|... $key2 键名2 * @return array */ - public function sDiff() + public function sDiff($key1, $key2) { } /** * - *Performs the same action as sDiff, but stores the result in the first key + *获取多个集合的差集,并将结果存入到一个新的集合中 * @example *
      * $redis->delete('s0', 's1', 's2');
@@ -1174,27 +1317,33 @@ public function sDiff()
      * //  string(1) "2"
      * //}
      * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n * @return int: */ - public function sDiffStore() + public function sDiffStore($dstKey, $key1, $key2, $keyN) { } /** * - * + *设置键的有效期 * @example - * @return + * @param string $key 键名 + * @param int $ttl 有效期(秒数) + * @return boolean */ - public function setTimeout() + public function setTimeout($key, $ttl) { } /** * - *Performs a synchronous save. + *将数据同步到硬盘上 * @example $redis->save(); - * @return If + * @return boolean */ public function save() { @@ -1202,7 +1351,7 @@ public function save() /** * - * + *将数据存入到硬盘上(异步操作) * @example * @return */ @@ -1212,9 +1361,9 @@ public function bgSave() /** * - *Returns the timestamp of the last disk save. + *获取上次数据同步到硬盘的时间 * @example $redis->lastSave(); - * @return int: + * @return int */ public function lastSave() { @@ -1222,9 +1371,9 @@ public function lastSave() /** * - *Removes all entries from the current database. + *删除当前数据库的所有键 * @example $redis->flushDB(); - * @return bool: + * @return bool */ public function flushDB() { @@ -1232,9 +1381,9 @@ public function flushDB() /** * - *Removes all entries from all databases. + *删除当前实例的所有键 * @example $redis->flushAll(); - * @return bool: + * @return bool */ public function flushAll() { @@ -1242,13 +1391,13 @@ public function flushAll() /** * - *Returns the current database's size. + *获取当前数据库的键的个数 * @example *
      * $count = $redis->dbSize();
      * echo "Redis has $count keys\n";
      * 
- * @return int: + * @return int */ public function dbSize() { @@ -1256,48 +1405,51 @@ public function dbSize() /** * - *Authenticate the connection using a password. - *Warning: The password is sent in plain-text over the network. + *设置连接的认证密码 * @example $redis->auth('foobared'); + * @param string $password 认证密码 * @return bool: */ - public function auth() + public function auth($password) { } /** * - *Returns the time to live left for a given key, in seconds. If the key doesn't exist, FALSE is returned. + *返回指定键的有效时间(秒) * @example $redis->ttl('key'); - * @return int, + * @param string $key 键名 + * @return long */ - public function ttl() + public function ttl($key) { } /** * - *Returns a time to live left for a given key, in milliseconds. + *返回指定键的有效时间(毫秒) * @example $redis->pttl('key'); - * @return int + * @param string $key 键名 + * @return long */ - public function pttl() + public function pttl($key) { } /** * - *Remove the expiration timer from a key. + *移除指定键的有效期,让它永久有效 * @example $redis->persist('key'); + * @param string $key 键名 * @return bool: */ - public function persist() + public function persist($key) { } /** * - *Returns an associative array of strings and integers + *获取Redis服务器的信息和统计数据 * @example *
      * $redis->info();
@@ -1305,7 +1457,7 @@ public function persist()
      * $redis->info("COMMANDSTATS"); //Information on the commands that have been run (>=2.6 only)
      * $redis->info("CPU"); // just CPU information from Redis INFO
      * 
- * @return + * @return array */ public function info() { @@ -1313,7 +1465,7 @@ public function info() /** * - *Switches to a given database. + *切换数据库 * @example *
      * $redis->select(0);       // switch to DB 0
@@ -1322,15 +1474,16 @@ public function info()
      * $redis->select(1);       // switch to DB 1
      * $redis->get('x');        // will return 42
      * 
+ * @param int $dbIndex 数据库编号 * @return bool */ - public function select() + public function select($dbIndex) { } /** * - *Moves a key to a different database. + *将某个键移动到其他数据库中 * @example *
      * $redis->select(0);       // switch to DB 0
@@ -1339,17 +1492,19 @@ public function select()
      * $redis->select(1);       // switch to DB 1
      * $redis->get('x');        // will return 42
      * 
- * @return bool: + * @param string $key 键名 + * @param int $dbIndex 数据库编号 + * @return bool */ - public function move() + public function move($key, $dbIndex) { } /** * - *Starts the background rewrite of AOF (Append-Only File) + *开启后台写AOF日志操作 * @example $redis->bgrewriteaof(); - * @return bool: + * @return bool */ public function bgrewriteaof() { @@ -1357,65 +1512,67 @@ public function bgrewriteaof() /** * - *Changes the slave status - *Either host and port, or no parameter to stop being a slave. + *修改从服务状态(参数为空时,表示停止当前从属关系) * @example *
      * $redis->slaveof('10.0.1.7', 6379);
      * // ...
      * $redis->slaveof();
      * 
+ * @param string $host 服务器 + * @param int $port 端口号 * @return bool: */ - public function slaveof() + public function slaveof($host, $port) { } /** * - *Describes the object pointed to by a key. - *The information to retrieve (string) and the key (string). - *Info can be one of the following: - *- "encoding" - *- "refcount" - *- "idletime" + *获取某个键的对象信息 * @example *
      * $redis->object("encoding", "l"); // → ziplist
      * $redis->object("refcount", "l"); // → 1
      * $redis->object("idletime", "l"); // → 400 (in seconds, with a precision of 10 seconds).
      * 
+ * @param string $info 获取的信息指标名称(有 encoding、refcount 、idletime 3种可选择) + * @param string $key 键名 * @return string */ - public function object() + public function object($info, $key) { } /** * - * + *多个键的位操作,并将结果存入到指定的键中 * @example - * @return + * @param string $operation 操作(有 AND, OR, NOT, XOR 4种可选择) + * @param string $dstKey 目标键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名N + * @return long */ - public function bitop() + public function bitop($operation, $dstKey, $key1, $key2, $keyN) { } /** * - * + *统计字符串的位数 * @example - * @return + * @param string $key 键名 + * @return long */ - public function bitcount() + public function bitcount($key) { } /** * - *Return the position of the first bit set to 1 or 0 in a string. The position is returned, thinking of the - *string as an array of bits from left to right, where the first byte's most significant bit is at position 0, - *the second byte's most significant bit is at position 8, and so forth. + *获取指定位置的位值 * @example *
      * $redis->set('key', '\xff\xff');
@@ -1426,16 +1583,19 @@ public function bitcount()
      * $redis->bitpos('key', 0, 1); // int(16)
      * $redis->bitpos('key', 0, 1, 5); // int(-1)
      * 
+ * @param string $key 键名 + * @param int $bit 位值 + * @param int $start 开始位置 + * @param int $end 结束位置 * @return function */ - public function bitpos() + public function bitpos($key, $bit, $start, $end) { } /** * - *Sets multiple key-value pairs in one atomic command. - *MSETNX only returns TRUE if all the keys were set (see SETNX). + *批量设置值 * @example *
      * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
@@ -1445,26 +1605,35 @@ public function bitpos()
      * // string(6) "value0"
      * // string(6) "value1"
      * 
+ * @param array $values 要设置的键值对 * @return bool */ - public function mset() + public function mset(Array $values) { } /** * - * + *批量设置值(当不存在时设置) * @example - * @return int + *
+     * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
+     * var_dump($redis->get('key0'));
+     * var_dump($redis->get('key1'));
+     * // Output:
+     * // string(6) "value0"
+     * // string(6) "value1"
+     * 
+ * @param array $values 要设置的键值对 + * @return bool */ - public function msetnx() + public function msetnx(Array $values) { } /** * - *Pops a value from the tail of a list, and pushes it to the front of another list. - *Also return this value. + *从一个队列的队尾删除一个元素,并将该元素插入到另一个队列的头部 * @example *
      * $redis->delete('x', 'y');
@@ -1492,25 +1661,29 @@ public function msetnx()
      * //  string(3) "123"
      * //}
      * 
+ * @param string $srcKey 要删除元素的队列键名 + * @param string $dstKey 要插入元素的队列的键名 * @return string */ - public function rpoplpush() + public function rpoplpush($srcKey, $dstKey) { } /** * - *A blocking version of rpoplpush, with an integral timeout in the third parameter. + *阻塞执行rpoplpush * @example + * @param string $srcKey 要删除元素的队列键名 + * @param string $dstKey 要插入元素的队列的键名 * @return string */ - public function brpoplpush() + public function brpoplpush($srcKey, $dstKey) { } /** * - *Adds the specified member with a given score to the sorted set stored at key. + *向有序集合插入元素 * @example *
      * 
@@ -1524,30 +1697,30 @@ public function brpoplpush()
      * // }
      * 
*
+ * @param string $key 集合键名 + * @param double $score 排序值 + * @param string $value 元素值 * @return int */ - public function zAdd() + public function zAdd($key, $score, $value) { } /** * - * + *删除有序集合中的某个成员 * @example + * @param string $key 集合键名 + * @param string $member 成员值 * @return int */ - public function zDelete() + public function zDelete($key, $member) { } /** * - *Returns a range of elements from the ordered set stored at the specified key, - *with values in the range [start, end]. start and stop are interpreted as zero-based indices: - *0 the first element, - *1 the second ... - *-1 the last element, - *-2 the penultimate ... + *获取有序集合中指定范围的成员 * @example *
      * $redis->zAdd('key1', 0, 'val0');
@@ -1557,20 +1730,19 @@ public function zDelete()
      * // with scores
      * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10)
      * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRange() + public function zRange($key, $start, $end, $withScores) { } /** * - *Returns the elements of the sorted set stored at the specified key in the range [start, end] - *in reverse order. start and stop are interpretated as zero-based indices: - *0 the first element, - *1 the second ... - *-1 the last element, - *-2 the penultimate ... + *获取有序集合中指定范围的成员(倒序排列) * @example *
      * $redis->zAdd('key', 0, 'val0');
@@ -1580,17 +1752,19 @@ public function zRange()
      * // with scores
      * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0)
      * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRevRange() + public function zRevRange($key, $start, $end, $withScores) { } /** * - *Returns the elements of the sorted set stored at the specified key which have scores in the - *range [start,end]. Adding a parenthesis before start or end excludes it from the range. - *+inf and -inf are also valid limits. + *获取有序集合中指定范围的成员(按排序值排列) * @example *
      * $redis->zAdd('key', 0, 'val0');
@@ -1602,28 +1776,43 @@ public function zRevRange()
      * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
      * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
      * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRangeByScore() + public function zRangeByScore($key, $start, $end, Array $options) { } /** * - * + *获取有序集合中指定范围的成员(按排序值倒序排列) * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) + * @return array */ - public function zRevRangeByScore() + public function zRevRangeByScore($key, $start, $end, Array $options) { } /** * - *Returns a lexigraphical range of members in a sorted set, assuming the members have the same score. The - *min and max values are required to start with '(' (exclusive), '[' (inclusive), or be exactly the values - *'-' (negative inf) or '+' (positive inf). The command must be called with either three *or* five - *arguments or will return FALSE. + *按字母字典的顺序返回成员 * @example *
      * foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g') as $char) {
@@ -1633,47 +1822,61 @@ public function zRevRangeByScore()
      * $redis->zRangeByLex('key', '-', '(c'); // array('a', 'b')
      * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c')
      * 
+ * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @param long $offset 索引开始值 + * @param long $limit 成员数 * @return array */ - public function zRangeByLex() + public function zRangeByLex($key, $min, $max, $offset, $limit) { } /** * - * + *按字母字典的顺序返回成员(倒序排序) * @example + * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @param long $offset 索引开始值 + * @param long $limit 成员数 * @return */ - public function zRevRangeByLex() + public function zRevRangeByLex($key, $min, $max, $offset, $limit) { } /** * - * + *获取指定字母范围的成员数 * @example - * @return + * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @return int */ - public function zLexCount() + public function zLexCount($key, $min, $max) { } /** * - * + *删除指定字母范围的成员 * @example - * @return + * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @return long */ - public function zRemRangeByLex() + public function zRemRangeByLex($key, $min, $max) { } /** * - *Returns the number of elements of the sorted set stored at the specified key which have - *scores in the range [start,end]. Adding a parenthesis before start or end excludes it - *from the range. +inf and -inf are also valid limits. + *获取指定排序范围的成员数. * @example *
      * $redis->zAdd('key', 0, 'val0');
@@ -1681,35 +1884,51 @@ public function zRemRangeByLex()
      * $redis->zAdd('key', 10, 'val10');
      * $redis->zCount('key', 0, 3); // 2, corresponding to array('val0', 'val2')
      * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 * @return int */ - public function zCount() + public function zCount($key, $start, $end) { } /** * - * + *根据排序值范围来删除成员 * @example - * @return + * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return long */ - public function zDeleteRangeByScore() + public function zDeleteRangeByScore($key, $start, $end) { } /** * - * + *根据排序范围删除成员 * @example - * @return + *
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zAdd('key', 3, 'three');
+     * $redis->zRemRangeByRank('key', 0, 1); // 2
+     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int */ - public function zDeleteRangeByRank() + public function zDeleteRangeByRank($key, $start, $end) { } /** * - *Returns the cardinality of an ordered set. + *获取有序集合的成员数 * @example *
      * $redis->zAdd('key', 0, 'val0');
@@ -1717,30 +1936,32 @@ public function zDeleteRangeByRank()
      * $redis->zAdd('key', 10, 'val10');
      * $redis->zCard('key');            // 3
      * 
+ * @param string $key 集合键名 * @return int */ - public function zCard() + public function zCard($key) { } /** * - *Returns the score of a given member in the specified sorted set. + *获取指定成员的排序值(分数) * @example *
      * $redis->zAdd('key', 2.5, 'val2');
      * $redis->zScore('key', 'val2'); // 2.5
      * 
- * @return + * @param string $key 集合键名 + * @param string $member 成员值 + * @return double */ - public function zScore() + public function zScore($key, $member) { } /** * - *Returns the rank of a given member in the specified sorted set, starting at 0 for the item - *with the smallest score. zRevRank starts at 0 for the item with the largest score. + *获取成员的排序值 * @example *
      * $redis->delete('z');
@@ -1751,30 +1972,29 @@ public function zScore()
      * $redis->zRevRank('key', 'one');  // 1
      * $redis->zRevRank('key', 'two');  // 0
      * 
+ * @param string $key 集合键名 + * @param string $member 成员值 * @return int */ - public function zRank() + public function zRank($key, $member) { } /** * - * + *获取成员的排位值(倒数) * @example + * @param string $key 集合键名 + * @param string $member 成员值 * @return int */ - public function zRevRank() + public function zRevRank($key, $member) { } /** * - *Creates an intersection of sorted sets given in second argument. - *The result of the union will be stored in the sorted set defined by the first argument. - *The third optional argument defines weights to apply to the sorted sets in input. - *In this case, the weights will be multiplied by the score of each element in the sorted set - *before applying the aggregation. The forth argument defines the AGGREGATE option which - *specify how the results of the union are aggregated. + *将两个有序集合的交集存入到一个指定的键中 * @example *
      * $redis->delete('k1');
@@ -1795,20 +2015,19 @@ public function zRevRank()
      * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
      * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
      * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zInter() + public function zInter($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) { } /** * - *Creates an union of sorted sets given in second argument. - *The result of the union will be stored in the sorted set defined by the first argument. - *The third optionnel argument defines weights to apply to the sorted sets in input. - *In this case, the weights will be multiplied by the score of each element in the sorted set - *before applying the aggregation. The forth argument defines the AGGREGATE option which - *specify how the results of the union are aggregated. + *将两个有序集合的并集存入到一个指定的键中 * @example *
      * $redis->delete('k1');
@@ -1826,15 +2045,19 @@ public function zInter()
      * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
      * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
      * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zUnion() + public function zUnion($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) { } /** * - *Increments the score of a member from a sorted set by a given amount. + *给有序集合成员增加排序值 * @example *
      * $redis->delete('key');
@@ -1842,15 +2065,18 @@ public function zUnion()
      * // before the increment and now has the value 2.5
      * $redis->zIncrBy('key', 1, 'member1');    // 3.5
      * 
+ * @param string $key 目标集合键名 + * @param double $step 增加的步长 + * @param string $member 成员 * @return float */ - public function zIncrBy() + public function zIncrBy($key, $step, $member) { } /** * - *Sets an expiration date (a timestamp) on an item. + *为某个键设置有效期为某个时间点 * @example *
      * $redis->set('x', '42');
@@ -1859,46 +2085,60 @@ public function zIncrBy()
      * sleep(5);                        // wait 5 seconds
      * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
      * 
+ * @param string $key 键名 + * @param int $expireTime 到期时间 * @return bool: */ - public function expireAt() + public function expireAt($key, $expireTime) { } /** * - * + *设置键的有效期(毫秒为单位) * @example - * @return + * @param string $key 键名 + * @param int $ttl 有效期(毫秒数) + * @return boolean */ - public function pexpire() + public function pexpire($key, $ttl) { } /** * - * + *为某个键设置有效期为某个时间点(精确到毫秒) * @example - * @return + *
+     * $redis->set('x', '42');
+     * $now = time(NULL);               // current timestamp
+     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
+     * sleep(5);                        // wait 5 seconds
+     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
+     * 
+ * @param string $key 键名 + * @param int $expireTime 到期时间 + * @return bool: */ - public function pexpireAt() + public function pexpireAt($key, $expireTime) { } /** * - *Gets a value from the hash stored at key. - *If the hash table doesn't exist, or the key doesn't exist, FALSE is returned. + *获取字典的某个字段的值 * @example + * @param string $key 键名 + * @param string $field 字段名 * @return string */ - public function hGet() + public function hGet($key, $field) { } /** * - *Adds a value to the hash stored at key. If this value is already in the hash, FALSE is returned. + *为字典的字段设置值 * @example *
      * $redis->delete('h')
@@ -1907,15 +2147,18 @@ public function hGet()
      * $redis->hSet('h', 'key1', 'plop');   // 0, value was replaced.
      * $redis->hGet('h', 'key1');           // returns "plop"
      * 
- * @return 0 + * @param string $key 键名 + * @param string $field 字段名 + * @param string $value 字段值 + * @return long */ - public function hSet() + public function hSet($key, $field, $value) { } /** * - *Adds a value to the hash stored at key only if this field isn't already in the hash. + *当字典的字段不存在时,为其设置值 * @example *
      * $redis->delete('h')
@@ -1923,16 +2166,18 @@ public function hSet()
      * $redis->hSetNx('h', 'key1', 'world'); // FALSE, 'key1' => 'hello' in the hash at "h". No change since the field
      * wasn't replaced.
      * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param string $value 字段值 * @return bool */ - public function hSetNx() + public function hSetNx($key, $field, $value) { } /** * - *Removes a values from the hash stored at key. - *If the hash table doesn't exist, or the key doesn't exist, FALSE is returned. + *删除字典的某个或某些字段 * @example *
      * $redis->hMSet('h',
@@ -1951,15 +2196,17 @@ public function hSetNx()
      * //    ["f4"]=> string(2) "v4"
      * //  }
      * 
+ * @param string $key 键名 + * @param string|array $fields 字段名 * @return int */ - public function hDel() + public function hDel($key, $fields) { } /** * - *Returns the length of a hash, in number of items + *获取字典的字段个数 * @example *
      * $redis->delete('h')
@@ -1967,15 +2214,16 @@ public function hDel()
      * $redis->hSet('h', 'key2', 'plop');
      * $redis->hLen('h'); // returns 2
      * 
+ * @param string $key 键名 * @return int */ - public function hLen() + public function hLen($key) { } /** * - *Returns the keys in a hash, as an array of strings. + *获取字典的字段名称列表. * @example *
      * $redis->delete('h');
@@ -1997,15 +2245,16 @@ public function hLen()
      * // }
      * // The order is random and corresponds to redis' own internal representation of the set structure.
      * 
+ * @param string $key 键名 * @return array */ - public function hKeys() + public function hKeys($key) { } /** * - *Returns the values in a hash, as an array of strings. + *获取字典的字段值列表 * @example *
      * $redis->delete('h');
@@ -2027,15 +2276,16 @@ public function hKeys()
      * // }
      * // The order is random and corresponds to redis' own internal representation of the set structure.
      * 
+ * @param string $key 键名 * @return array */ - public function hVals() + public function hVals($key) { } /** * - *Returns the whole hash, as an array of strings indexed by strings. + *获取字典所有字段键值对 * @example *
      * $redis->delete('h');
@@ -2057,45 +2307,51 @@ public function hVals()
      * // }
      * // The order is random and corresponds to redis' own internal representation of the set structure.
      * 
+ * @param string $key 键名 * @return array */ - public function hGetAll() + public function hGetAll($key) { } /** * - *Verify if the specified member exists in a key. + *判断字典的某个字段是否存在. * @example *
      * $redis->hSet('h', 'a', 'x');
      * $redis->hExists('h', 'a');               //  TRUE
      * $redis->hExists('h', 'NonExistingKey');  // FALSE
      * 
- * @return bool: + * @param string $key 键名 + * @param string $field 字段名 + * @return bool */ - public function hExists() + public function hExists($key, $field) { } /** * - *Increments the value of a member from a hash by a given amount. + *为指定字段增加指定的值. * @example *
      * $redis->delete('h');
      * $redis->hIncrBy('h', 'x', 2); // returns 2: h[x] = 2 now.
      * $redis->hIncrBy('h', 'x', 1); // h[x] ← 2 + 1. Returns 3
      * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param int $step 自增步长 * @return int */ - public function hIncrBy() + public function hIncrBy($key, $field, $step) { } /** * - *Increment the float value of a hash field by the given amount + *为指定字段增加指定的值 * @example *
      * $redis = new Redis();
@@ -2112,41 +2368,47 @@ public function hIncrBy()
      * string(1) "3"
      * }
      * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param double $step 自增步长 * @return */ - public function hIncrByFloat() + public function hIncrByFloat($key, $field, $step) { } /** * - *Fills in a whole hash. Non-string values are converted to string, using the standard (string) cast. - *NULL values are stored as empty strings + *批量设置字典字段的值 * @example *
      * $redis->delete('user:1');
      * $redis->hMset('user:1', array('name' => 'Joe', 'salary' => 2000));
      * $redis->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now.
      * 
- * @return + * @param string $key 键名 + * @param array $fields 字段键值对 + * @return boolean */ - public function hMset() + public function hMset($key, Array $fields) { } /** * - * + *批量获取字典的字段值 * @example - * @return + * @param string $key 键名 + * @param array $fields 字段名列表 + * @return array */ - public function hMget() + public function hMget($key, Array $fields) { } /** * - *Enter and exit transactional mode. + *开始一个事务. * @example *
      * $ret = $redis->multi()
@@ -2161,7 +2423,7 @@ public function hMget()
      * //    2 => TRUE,
      * //    3 => 'val2');
      * 
- * @return Once + * @return */ public function multi() { @@ -2169,7 +2431,7 @@ public function multi() /** * - * + *取消事务 * @example * @return */ @@ -2179,7 +2441,7 @@ public function discard() /** * - * + *执行事务 * @example * @return */ @@ -2189,7 +2451,7 @@ public function exec() /** * - * + *开启一个管道 * @example * @return */ @@ -2199,8 +2461,7 @@ public function pipeline() /** * - *Watches a key for modifications by another client. If the key is modified between WATCH and EXEC, - *the MULTI/EXEC transaction will fail (return FALSE). unwatch cancels all the watching of all keys by this client. + *观察某个键在其他客户端的变化情况. * @example *
      * $redis->watch('x');
@@ -2210,35 +2471,39 @@ public function pipeline()
      * ->exec();
      * // $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.
      * 
+ * @param string|array $keys 键名 * @return */ - public function watch() + public function watch($keys) { } /** * - * + *取消观察某个键在其他客户端的变化情况 * @example + * @param string|array $keys 键名 * @return */ - public function unwatch() + public function unwatch($keys) { } /** * - *Publish messages to channels. Warning: this function will probably change in the future. + *将消息发布到消息通道(队列). * @example $redis->publish('chan-1', 'hello, world!'); // send message. + * @param string $channel 消息频道 + * @param string $message 消息 * @return int */ - public function publish() + public function publish($channel, $message) { } /** * - *Subscribe to channels. Warning: this function will probably change in the future. + *订阅消息 * @example *
      * function f($redis, $chan, $msg) {
@@ -2256,15 +2521,18 @@ public function publish()
      * }
      * $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
      * 
+ * @param array $channels 订阅的消息频道 + * @param string|array $callback 回调函数名称 + * @param mixed $value 返回值 * @return mixed */ - public function subscribe() + public function subscribe(Array $channels, $callback, $value) { } /** * - *Subscribe to channels by pattern + *通过匹配模式来订阅这些匹配的消息频道 * @example *
      * function psubscribe($redis, $pattern, $chan, $msg) {
@@ -2273,35 +2541,40 @@ public function subscribe()
      * echo "Payload: $msg\n";
      * }
      * 
+ * @param array $patterns 匹配模式 + * @param string|array $callback 回调函数名称 + * @param mixed $value 返回值 * @return */ - public function psubscribe() + public function psubscribe(Array $patterns, $callback, $value) { } /** * - * + *取消订阅 * @example + * @param array $channels 订阅的消息频道 * @return */ - public function unsubscribe() + public function unsubscribe(Array $channels) { } /** * - * + *通过匹配模式来取消订阅这些匹配的消息频道 * @example + * @param array $patterns 匹配模式 * @return */ - public function punsubscribe() + public function punsubscribe(Array $patterns) { } /** * - *Return the current Redis server time. + *返回当前redis服务器时间. * @example *
      * var_dump( $redis->time() );
@@ -2310,7 +2583,7 @@ public function punsubscribe()
      * //   [1] => string(6) "253002"
      * // }
      * 
- * @return unix + * @return int */ public function time() { @@ -2318,9 +2591,9 @@ public function time() /** * - * + *返回当前连接的服务器的角色,如master、alone、slave、sentinel * @example - * @return + * @return string */ public function role() { @@ -2328,27 +2601,7 @@ public function role() /** * - * - * @example - * @return - */ - public function eval() - { - } - - /** - * - * - * @example - * @return - */ - public function evalsha() - { - } - - /** - * - *Execute the Redis SCRIPT command to perform various operations on the scripting subsystem. + *在脚本子系统上执行redis命令 * @example *
      * $redis->script('load', $script);
@@ -2360,15 +2613,17 @@ public function evalsha()
      * SCRIPT FLUSH should always return TRUE
      * SCRIPT KILL will return true if a script was able to be killed and false if not
      * SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script
+     * @param string $command redis命令
+     * @param string|... $script 脚本
      * @return 
      */
-    public function script()
+    public function script($command, $script)
     {
     }
 
     /**
      * 
-     *
+     *调试命令(不建议使用)
      * @example 
      * @return 
      */
@@ -2378,50 +2633,60 @@ public function debug()
 
     /**
      * 
-     *Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command.
-     *The data that comes out of DUMP is a binary representation of the key as Redis stores it.
+     *将某个键导出为一个二进制数据.
      * @example 
      * 
      * $redis->set('foo', 'bar');
      * $val = $redis->dump('foo'); // $val will be the Redis encoded key value
      * 
+ * @param string $key 键名 * @return string */ - public function dump() + public function dump($key) { } /** * - *Restore a key from the result of a DUMP operation. + *将dump导出的二进制数据恢复到可读的字符串. * @example *
      * $redis->set('foo', 'bar');
      * $val = $redis->dump('foo');
      * $redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo'
      * 
+ * @param string $key 键名 + * @param int $ttl 有效期 + * @param string $value dump导出的二进制数据 * @return */ - public function restore() + public function restore($key, $ttl, $value) { } /** * - *Migrates a key to a different Redis instance. + *将某个键迁移到其他的Redis实例中 * @example *
      * $redis->migrate('backup', 6379, 'foo', 0, 3600);
      * 
+ * @param string $host 目标主机 + * @param int $port 目标主机端口 + * @param string|array $keys 迁移的键 + * @param int $database 目标数据库 + * @param int $timeout 超时时间 + * @param boolean $copy 是否复制 + * @param boolean $replace 是否替换 * @return */ - public function migrate() + public function migrate($host, $port, $keys, $database, $timeout, $copy, $replace) { } /** * - *The last error message (if any) + *获取上次错误信息 * @example *
      * $redis->eval('this-is-not-lua');
@@ -2436,7 +2701,7 @@ public function getLastError()
 
     /**
      * 
-     *Clear the last error message
+     *清除上次错误信息
      * @example 
      * 
      * $redis->set('x', 'a');
@@ -2455,24 +2720,22 @@ public function clearLastError()
 
     /**
      * 
-     *A utility method to prefix the value with the prefix setting for phpredis.
+     *设置键前缀
      * @example 
      * 
      * $redis->setOption(Redis::OPT_PREFIX, 'my-prefix:');
      * $redis->_prefix('my-value'); // Will return 'my-prefix:my-value'
      * 
+ * @param string $prefix 前缀 * @return string */ - public function _prefix() + public function _prefix($prefix) { } /** * - *A utility method to serialize values manually. This method allows you to serialize a value with whatever - *serializer is configured, manually. This can be useful for serialization/unserialization of data going in - *and out of EVAL commands as phpredis can't automatically do this itself. Note that if no serializer is - *set, phpredis will change Array values to 'Array', and Objects to 'Object'. + *用于手动序列化. * @example *
      * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
@@ -2482,44 +2745,49 @@ public function _prefix()
      * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
      * $redis->_serialize("foo"); // Returns 's:3:"foo";'
      * 
+ * @param string $value 被序列化的值 * @return */ - public function _serialize() + public function _serialize($value) { } /** * - *A utility method to unserialize data with whatever serializer is set up. If there is no serializer set, the - *value will be returned unchanged. If there is a serializer set up, and the data passed in is malformed, an - *exception will be thrown. This can be useful if phpredis is serializing values, and you return something from - *redis in a LUA script that is serialized. + *反序列化方法. * @example *
      * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
      * $redis->_unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}'); // Will return Array(1,2,3)
      * 
+ * @param string $value 被反序列化的值 * @return */ - public function _unserialize() + public function _unserialize($value) { } /** * - * + *获取客户端相关参数或进行相关操作 * @example + * @param string $command 命令(CLIENT LIST +CLIENT GETNAME +CLIENT SETNAME [name] +CLIENT KILL [ip:port] +) + * @param string $args 参数 * @return */ - public function client() + public function client($command, $args) { } /** * - * + *获取所有命令列表 * @example - * @return + * @return array */ public function command() { @@ -2527,7 +2795,7 @@ public function command() /** * - *Scan the keyspace for keys. + *扫描键空间. * @example *
      * $iterator = null;
@@ -2537,9 +2805,9 @@ public function command()
      * }
      * }
      * 
- * @param mixed $i_iterator - * @param mixed $str_pattern - * @param mixed $i_count + * @param Long|NULL $i_iterator 迭代器 + * @param string $str_pattern 匹配的模式 + * @param int $i_count 每次迭代的长度 * @return array */ public function scan($i_iterator, $str_pattern, $i_count) @@ -2548,12 +2816,12 @@ public function scan($i_iterator, $str_pattern, $i_count) /** * - * + *扫描hash的键 * @example - * @param mixed $str_key - * @param mixed $i_iterator - * @param mixed $str_pattern - * @param mixed $i_count + * @param string $str_key 键值 + * @param Long|NULL $i_iterator 迭代器 + * @param string $str_pattern 匹配的模式 + * @param int $i_count 每次迭代的长度 * @return */ public function hscan($str_key, $i_iterator, $str_pattern, $i_count) @@ -2562,12 +2830,12 @@ public function hscan($str_key, $i_iterator, $str_pattern, $i_count) /** * - * + *扫描有序集合的键 * @example - * @param mixed $str_key - * @param mixed $i_iterator - * @param mixed $str_pattern - * @param mixed $i_count + * @param string $str_key 键值 + * @param Long|NULL $i_iterator 迭代器 + * @param string $str_pattern 匹配的模式 + * @param int $i_count 每次迭代的长度 * @return */ public function zscan($str_key, $i_iterator, $str_pattern, $i_count) @@ -2576,12 +2844,12 @@ public function zscan($str_key, $i_iterator, $str_pattern, $i_count) /** * - * + *扫描集合的键 * @example - * @param mixed $str_key - * @param mixed $i_iterator - * @param mixed $str_pattern - * @param mixed $i_count + * @param string $str_key 键值 + * @param Long|NULL $i_iterator 迭代器 + * @param string $str_pattern 匹配的模式 + * @param int $i_count 每次迭代的长度 * @return */ public function sscan($str_key, $i_iterator, $str_pattern, $i_count) @@ -2590,49 +2858,55 @@ public function sscan($str_key, $i_iterator, $str_pattern, $i_count) /** * - * + *将所有元素参数添加到 HyperLogLog 数据结构中 * @example + * @param string $key 键名 + * @param string|array|... $element 元素 * @return */ - public function pfadd() + public function pfadd($key, $element) { } /** * - * + *返回给定 HyperLogLog 的基数估算值 * @example + * @param string|array $keys 键名 * @return */ - public function pfcount() + public function pfcount($keys) { } /** * - * + *将多个 HyperLogLog 合并为一个 HyperLogLog ,合并后的 HyperLogLog 的基数估算值是通过对所有 给定 HyperLogLog 进行并集计算得出的 * @example + * @param string|array $dstKey 目标键名 + * @param string|array $sourceKeys 源键名 * @return */ - public function pfmerge() + public function pfmerge($dstKey, $sourceKeys) { } /** * - *Get client option + *获取客户端选项 * @example * // return Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP, or Redis::SERIALIZER_IGBINARY. * $redis->getOption(Redis::OPT_SERIALIZER); + * @param string $optionName 选项名 * @return int */ - public function getOption() + public function getOption($optionName) { } /** * - *Set client option. + *设置客户端选项. * @example *
      * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);        // don't serialize data
@@ -2640,49 +2914,58 @@ public function getOption()
      * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);    // use igBinary serialize/unserialize
      * $redis->setOption(Redis::OPT_PREFIX, 'myAppName:');                      // use custom prefix on all keys
      * 
+ * @param string $optionName 选项名 + * @param string $optionValue 选项值 * @return bool: */ - public function setOption() + public function setOption($optionName, $optionValue) { } /** * - *Get or Set the redis config keys. + *获取或设置配置项. * @example *
      * $redis->config("GET", "*max-*-entries*");
      * $redis->config("SET", "dir", "/var/run/redis/dumps/");
      * 
+ * @param string $operation 操作(SET或GET) + * @param string $key 配置项或配置项匹配模式 + * @param string $value 配置值 * @return array */ - public function config() + public function config($operation, $key, $value) { } /** * - * + *获取慢操作日志 * @example + * @param string $command 执行的命令 + * @param int $length 获取条目数 * @return */ - public function slowlog() + public function slowlog($command, $length) { } /** * - * + *在redis服务器上执行命令 * @example + * @param string $command 执行的命令 + * @param string|array $args 参数 * @return */ - public function rawcommand() + public function rawcommand($command, $args) { } /** * - * + *获取当前连接HOST * @example * @return */ @@ -2692,7 +2975,7 @@ public function getHost() /** * - * + *获取当前连接的端口 * @example * @return */ @@ -2702,7 +2985,7 @@ public function getPort() /** * - * + *获取数据库的数量 * @example * @return */ @@ -2712,7 +2995,7 @@ public function getDBNum() /** * - * + *获取连接超时时间 * @example * @return */ @@ -2722,7 +3005,7 @@ public function getTimeout() /** * - * + *获取读操作超时暗 * @example * @return */ @@ -2732,7 +3015,7 @@ public function getReadTimeout() /** * - * + *获取当前正在使用的持久化操作的ID * @example * @return */ @@ -2742,9 +3025,9 @@ public function getPersistentID() /** * - * + *获取验证的字符串 * @example - * @return + * @return string */ public function getAuth() { @@ -2752,7 +3035,7 @@ public function getAuth() /** * - *A method to determine if a phpredis object thinks it's connected to a server + *是否连接成功 * @example * @return bool */ @@ -2762,7 +3045,7 @@ public function isConnected() /** * - *Detect whether we're in ATOMIC/MULTI/PIPELINE mode. + *获取运行模式,如 ATOMIC/MULTI/PIPELINE * @example $redis->getMode(); * @return int */ @@ -2772,18 +3055,19 @@ public function getMode() /** * - *Blocks the current client until all the previous write commands are successfully transferred and - *acknowledged by at least the specified number of slaves. + *该命令将阻止当前客户端,直到所有先前的写入命令成功传输并至少由指定数量的从节点进行确认 * @example $redis->wait(2, 1000); + * @param int $count 从节点数量 + * @param int $timeout 超时时间 * @return context */ - public function wait() + public function wait($count, $timeout) { } /** * - *A command allowing you to get information on the Redis pub/sub system. + *查看订阅与发布系统状态,它由数个不同格式的子命令组成. * @example *
      * $redis->pubsub('channels'); // All channels
@@ -2791,64 +3075,88 @@ public function wait()
      * $redis->pubsub('numsub', array('chan1', 'chan2')); // Get subscriber counts for 'chan1' and 'chan2'
      * $redis->pubsub('numpat'); // Get the number of pattern subscribers
      * 
- * @return - + * @param string $subcommand 子命令(可以是channels, numsub, numpat) + * @param string|array $args 参数 + * @return array|int */ - public function pubsub() + public function pubsub($subcommand, $args) { } /** * - * + *连接redis服务器或打开一个已经连接的redis服务器 * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param float $timeout 连接超时时间(以秒为单位) + * @param mixed $reserved 当使用retry_interval时该值为NULL + * @param int $retry_interval 重试间隔 + * @param float $read_timeout 读操作超时时间 * @return */ - public function open() + public function open($host, $port, $timeout, $reserved, $retry_interval, $read_timeout) { } /** * - * + *连接redis服务器或打开一个已经连接的redis服务器(长连接) * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param float $timeout 连接超时时间(以秒为单位) + * @param mixed $reserved 当使用retry_interval时该值为NULL + * @param int $retry_interval 重试间隔 + * @param float $read_timeout 读操作超时时间 * @return */ - public function popen() + public function popen($host, $port, $timeout, $reserved, $retry_interval, $read_timeout) { } /** * - *Returns the size of a list identified by Key. If the list didn't exist or is empty, - *the command returns 0. If the data type identified by Key is not a list, the command return FALSE. + *返回列表的长度 * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->lLen('key1');       // 3
-     * $redis->rPop('key1');
-     * $redis->lLen('key1');       // 2
-     * 
- * @return bool + * @param string|...|array $key 键名 + * @return long | bool */ - public function lLen() + public function lLen($key) { } /** * - * + *返回集合的所有成员 * @example + *
+     * $redis->delete('s');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'b');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'c');
+     * var_dump($redis->sMembers('s'));
+     * //array(3) {
+     * //  [0]=>
+     * //  string(1) "c"
+     * //  [1]=>
+     * //  string(1) "a"
+     * //  [2]=>
+     * //  string(1) "b"
+     * //}
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 * @return array */ - public function sGetMembers() + public function sGetMembers($key) { } /** * - *Returns the values of all specified keys. + *批量获取键名 * @example *
      * $redis->delete('x', 'y', 'z', 'h');	// remove x y z
@@ -2867,107 +3175,141 @@ public function sGetMembers()
      * // bool(false)
      * // }
      * 
+ * @param array $keys 键名数组 * @return */ - public function mget() + public function mget(Array $keys) { } /** * - *Sets an expiration date (a timeout) on an item. + *设置键的有效期 * @example - *
-     * $redis->set('x', '42');
-     * $redis->setTimeout('x', 3);  // x will disappear in 3 seconds.
-     * sleep(5);                    // wait 5 seconds
-     * $redis->get('x');            // will return `FALSE`, as 'x' has expired.
-     * 
- * @return bool: + * @param string $key 键名 + * @param int $ttl 有效期(秒数) + * @return boolean */ - public function expire() + public function expire($key, $ttl) { } /** * - * + *将两个有序集合的并集存入到一个指定的键中 * @example - * @return + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k2', 2, 'val2');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
+     * // Weighted zUnion
+     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
+     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int */ - public function zunionstore() + public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) { } /** * - * + *将两个有序集合的交集存入到一个指定的键中 * @example - * @return + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->delete('ko4');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k1', 3, 'val3');
+     * $redis->zAdd('k2', 2, 'val1');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
+     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
+     * // Weighted zInter
+     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
+     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int */ - public function zinterstore() + public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) { } /** * - * + *删除有序集合中的某个成员 * @example - * @return + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int */ - public function zRemove() + public function zRemove($key, $member) { } /** * - *Deletes a specified member from the ordered set. + *删除有序集合中的某个成员 * @example - *
-     * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
-     * $redis->zRem('z', 'v2', 'v3');                           // int(2)
-     * var_dump( $redis->zRange('z', 0, -1) );
-     * //// Output:
-     * // array(2) {
-     * //   [0]=> string(2) "v1"
-     * //   [1]=> string(2) "v4"
-     * // }
-     * 
+ * @param string $key 集合键名 + * @param string $member 成员值 * @return int */ - public function zRem() + public function zRem($key, $member) { } /** * - * + *根据排序值范围来删除成员 * @example - * @return + * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return long */ - public function zRemoveRangeByScore() + public function zRemoveRangeByScore($key, $start, $end) { } /** * - *Deletes the elements of the sorted set stored at the specified key which have scores in the range [start,end]. + *根据排序值范围来删除成员 * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zRemRangeByScore('key', 0, 3); // 2
-     * 
- * @return int + * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return long */ - public function zRemRangeByScore() + public function zRemRangeByScore($key, $start, $end) { } /** * - *Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end]. + *根据排序范围删除成员 * @example *
      * $redis->zAdd('key', 1, 'one');
@@ -2976,187 +3318,259 @@ public function zRemRangeByScore()
      * $redis->zRemRangeByRank('key', 0, 1); // 2
      * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
      * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 * @return int */ - public function zRemRangeByRank() + public function zRemRangeByRank($key, $start, $end) { } /** * - * + *获取有序集合的成员数 * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCard('key');            // 3
+     * 
+ * @param string $key 集合键名 + * @return int */ - public function zSize() + public function zSize($key) { } /** * - *Return a substring of a larger string + *获取一个键值的子字符串 * @example - * @return + *
+     * $redis->set('key', 'string value');
+     * $redis->getRange('key', 0, 5);   // 'string'
+     * $redis->getRange('key', -5, -1); // 'value'
+     * 
+ * @param string $key 键名 + * @param int $start 开始位置 + * @param int $end 结束位置 + * @return string: */ - public function substr() + public function substr($key, $start, $end) { } /** * - *Renames a key. + *给键重命名 * @example - *
-     * $redis->set('x', '42');
-     * $redis->rename('x', 'y');
-     * $redis->get('y');   // → 42
-     * $redis->get('x');   // → `FALSE`
-     * 
- * @return bool: + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean */ - public function rename() + public function rename($srcKey, $dstKey) { } /** * - *Remove specified keys. - * @example - *
-     * $redis->set('key1', 'val1');
-     * $redis->set('key2', 'val2');
-     * $redis->set('key3', 'val3');
-     * $redis->set('key4', 'val4');
-     * $redis->delete('key1', 'key2');          // return 2
-     * $redis->delete(array('key3', 'key4'));   // return 2
-     * 
+ *删除一个或多个键 + * @example $redis->delete('key1', 'key2'); + * $redis->delete(array('key3', 'key4')); + * @param array|string $keys 键名 * @return int */ - public function del() + public function del($keys) { } /** * - *Returns the keys that match a certain pattern. + *根据匹配模式获取键名(如*) * @example - *
-     * $allKeys = $redis->keys('*');   // all keys will match this.
+     * $allKeys = $redis->keys('*');
      * $keyWithUserPrefix = $redis->keys('user*');
-     * 
+ * @param string $pattern 匹配模式 * @return array */ - public function keys() + public function keys($pattern) { } /** * - * + *从列表中删除指定值的元素。 如果count为零,则删除所有匹配的元素。 如果计数是负数,则元素从尾部移到头部。 * @example - * @return + * @param string $key 键名 + * @param string $value 元素值 + * @param int $count 删除的个数 + * @return long | bool */ - public function lrem() + public function lrem($key, $value, $count) { } /** * - * + *删除指定范围外的其他元素 * @example - * @return + * @param string $key 键名 + * @param int $start 开始索引 + * @param int $end 结束索引 + * @return array | boolean */ - public function ltrim() + public function ltrim($key, $start, $end) { } /** * - * + *获取列表中指定索引的值 * @example - * @return + * @param string $key 键名 + * @param int $index 索引值 + * @return string | boolean */ - public function lindex() + public function lindex($key, $index) { } /** * - * + *获取列表指定范围的值 * @example - * @return + * @param string $key 键名 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @return array */ - public function lrange() + public function lrange($key, $start, $end) { } /** * - * + *返回集合的元素个数 * @example - * @return + * @param string $key 键名 + * @return long */ - public function scard() + public function scard($key) { } /** * - * + *删除集合元素 * @example - * @return + * @param string $key 键名 + * @param string|... $member 成员 + * @return long */ - public function srem() + public function srem($key, $member) { } /** * - * + *是否包含某个成员 * @example - * @return + * @param string $key 键名 + * @param string $member 成员值 + * @return boolean */ - public function sismember() + public function sismember($key, $member) { } /** * - * + *获取有序集合中指定范围的成员(倒序排列) * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRevRange('key', 0, -1); // array('val10', 'val2', 'val0')
+     * // with scores
+     * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param boolean $withScores 是否返回成员的排序值 + * @return array */ - public function zReverseRange() + public function zReverseRange($key, $start, $end, $withScores) { } /** * - * + *向redis发送一个字符串,而且redis服务器将返回一个相同的字符串 * @example - * @return + * @param string $str 发送的字符串 + * @return string */ - public function sendEcho() + public function sendEcho($str) { } /** * - * + *执行lua脚本 * @example + * @param string $script 脚本 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 * @return mixed */ - public function evaluate() + public function evaluate($script, Array $args, $num_keys) { } /** * - * + *执行lua脚本 * @example + * @param string $script 脚本 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 + * @return mixed + */ + public function eval($script, Array $args, $num_keys) + { + } + + /** + * + *从脚本的SHA1散列而不是脚本本身执行LUA脚本 + * @example $script = 'return 1'; + * $sha = $redis->script('load', $script); + * $redis->evalSha($sha); // Returns 1 + * @param string $script_sha 脚本的散列值 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 + * @return + */ + public function evaluateSha($script_sha, Array $args, $num_keys) + { + } + + /** + * + *从脚本的SHA1散列而不是脚本本身执行LUA脚本 + * @example $script = 'return 1'; + * $sha = $redis->script('load', $script); + * $redis->evalSha($sha); // Returns 1 + * @param string $script_sha 脚本的散列值 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 * @return */ - public function evaluateSha() + public function evalSha($script_sha, Array $args, $num_keys) { } diff --git a/src/Redis/RedisArray.php b/src/Redis/RedisArray.php index a6480b5..617e20a 100644 --- a/src/Redis/RedisArray.php +++ b/src/Redis/RedisArray.php @@ -2,30 +2,31 @@ /** * Redis自动补全类(基于最新的3.0.0版本) * @author shixinke(http://www.shixinke.com) -* @modified 2016/12/08 +* @modified 2017/12/28 */ /** -* +*与key相关的redis数组 */ class RedisArray { /** * - *Constructor - * @example + *创建一个Redis数组 + * @example $ra = new RedisArray(array("host1", "host2:63792", "host2:6380")); //这里的host1/host2在php.ini中定义的 + * @param array $hosts redis节点数组 * @return */ - public function __construct() + public function __construct(Array $hosts) { } /** * - * + *方法不存在时调用的魔术方法 * @example - * @param mixed $function_name - * @param mixed $arguments + * @param string $function_name 方法名 + * @param mixed $arguments 参数 * @return */ public function __call($function_name, $arguments) @@ -34,7 +35,7 @@ public function __call($function_name, $arguments) /** * - * + *返回主机列表 * @example * @return array */ @@ -44,27 +45,29 @@ public function _hosts() /** * - * + *返回指定键分布的节点host * @example + * @param string $key 键名 * @return string */ - public function _target() + public function _target($key) { } /** * - * + *返回连接到指定host的实例 * @example + * @param string $host 主机 * @return */ - public function _instance() + public function _instance($host) { } /** * - * + *返回键分布使用的函数 * @example * @return string */ @@ -84,7 +87,7 @@ public function _distributor() /** * - *Use this function when a new node is added and keys need to be rehashed. + *重新对键进行hash分布 * @example * @return */ @@ -94,19 +97,33 @@ public function _rehash() /** * - * + *切换数据库 * @example - * @return + *
+     * $redis->select(0);       // switch to DB 0
+     * $redis->set('x', '42');  // write 42 to x
+     * $redis->move('x', 1);    // move to DB 1
+     * $redis->select(1);       // switch to DB 1
+     * $redis->get('x');        // will return 42
+     * 
+ * @param int $dbIndex 数据库编号 + * @return bool */ - public function select() + public function select($dbIndex) { } /** * - * + *获取Redis服务器的信息和统计数据 * @example - * @return + *
+     * $redis->info();
+     * or
+     * $redis->info("COMMANDSTATS"); //Information on the commands that have been run (>=2.6 only)
+     * $redis->info("CPU"); // just CPU information from Redis INFO
+     * 
+ * @return array */ public function info() { @@ -114,9 +131,9 @@ public function info() /** * - * + *检查当前redis连接状态(成功时返回PONG) * @example - * @return + * @return string */ public function ping() { @@ -124,89 +141,132 @@ public function ping() /** * - * - * @example - * @return + *删除当前数据库的所有键 + * @example $redis->flushDB(); + * @return bool */ - public function flushdb() + public function flushDB() { } /** * - * - * @example - * @return + *删除当前实例的所有键 + * @example $redis->flushAll(); + * @return bool */ - public function flushall() + public function flushAll() { } /** * - * + *批量获取键名 * @example + *
+     * $redis->delete('x', 'y', 'z', 'h');	// remove x y z
+     * $redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'));
+     * $redis->hset('h', 'field', 'value');
+     * var_dump($redis->mget(array('x', 'y', 'z', 'h')));
+     * // Output:
+     * // array(3) {
+     * // [0]=>
+     * // string(1) "a"
+     * // [1]=>
+     * // string(1) "b"
+     * // [2]=>
+     * // string(1) "c"
+     * // [3]=>
+     * // bool(false)
+     * // }
+     * 
+ * @param array $keys 键名数组 * @return */ - public function mget() + public function mget(Array $keys) { } /** * - * + *批量设置值 * @example - * @return + *
+     * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
+     * var_dump($redis->get('key0'));
+     * var_dump($redis->get('key1'));
+     * // Output:
+     * // string(6) "value0"
+     * // string(6) "value1"
+     * 
+ * @param array $values 要设置的键值对 + * @return bool */ - public function mset() + public function mset(Array $values) { } /** * - * - * @example - * @return + *删除一个或多个键 + * @example $redis->delete('key1', 'key2'); + * $redis->delete(array('key3', 'key4')); + * @param array|string $keys 键名 + * @return int */ - public function del() + public function del($keys) { } /** * - * + *获取客户端选项 * @example - * @return + * // return Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP, or Redis::SERIALIZER_IGBINARY. + * $redis->getOption(Redis::OPT_SERIALIZER); + * @param string $optionName 选项名 + * @return int */ - public function getOption() + public function getOption($optionName) { } /** * - * + *设置客户端选项. * @example - * @return + *
+     * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);        // don't serialize data
+     * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);         // use built-in serialize/unserialize
+     * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);    // use igBinary serialize/unserialize
+     * $redis->setOption(Redis::OPT_PREFIX, 'myAppName:');                      // use custom prefix on all keys
+     * 
+ * @param string $optionName 选项名 + * @param string $optionValue 选项值 + * @return bool: */ - public function setOption() + public function setOption($optionName, $optionValue) { } /** * - * + *根据匹配模式获取键名(如*) * @example - * @return + * $allKeys = $redis->keys('*'); + * $keyWithUserPrefix = $redis->keys('user*'); + * @param string $pattern 匹配模式 + * @return array */ - public function keys() + public function keys($pattern) { } /** * - * - * @example - * @return + *将数据同步到硬盘上 + * @example $redis->save(); + * @return boolean */ public function save() { @@ -214,18 +274,31 @@ public function save() /** * - * + *将数据存入到硬盘上(异步操作) * @example * @return */ - public function bgsave() + public function bgSave() { } /** * - * + *开始一个事务. * @example + *
+     * $ret = $redis->multi()
+     * ->set('key1', 'val1')
+     * ->get('key1')
+     * ->set('key2', 'val2')
+     * ->get('key2')
+     * ->exec();
+     * //$ret == array (
+     * //    0 => TRUE,
+     * //    1 => 'val1',
+     * //    2 => TRUE,
+     * //    3 => 'val2');
+     * 
* @return */ public function multi() @@ -234,51 +307,62 @@ public function multi() /** * - * + *取消事务 * @example * @return */ - public function exec() + public function discard() { } /** * - * + *执行事务 * @example * @return */ - public function discard() + public function exec() { } /** * - * + *取消观察某个键在其他客户端的变化情况 * @example + * @param string|array $keys 键名 * @return */ - public function unwatch() + public function unwatch($keys) { } /** * - * - * @example - * @return + *删除一个或多个键 + * @example $redis->delete('key1', 'key2'); + * $redis->delete(array('key3', 'key4')); + * @param array|string $keys 键名 + * @return int */ - public function delete() + public function delete($keys) { } /** * - * + *批量获取键值 * @example - * @return + *
+     * $redis->set('key1', 'value1');
+     * $redis->set('key2', 'value2');
+     * $redis->set('key3', 'value3');
+     * $redis->getMultiple(array('key1', 'key2', 'key3')); // array('value1', 'value2', 'value3');
+     * $redis->getMultiple(array('key0', 'key1', 'key5')); // array(`FALSE`, 'value2', `FALSE`);
+     * 
+ * @param array $keys 键名数组 + * @return array */ - public function getMultiple() + public function getMultiple(Array $keys) { } diff --git a/src/Redis/RedisCluster.php b/src/Redis/RedisCluster.php index a5ad7cd..68fb9e4 100644 --- a/src/Redis/RedisCluster.php +++ b/src/Redis/RedisCluster.php @@ -2,91 +2,91 @@ /** * Redis自动补全类(基于最新的3.0.0版本) * @author shixinke(http://www.shixinke.com) -* @modified 2016/12/08 +* @modified 2017/12/28 */ /** -*redisCluster +*redis集群客户端 */ class RedisCluster { /** - * + *未知类型 */ const REDIS_NOT_FOUND = 0; /** - * + *字符串类型 */ const REDIS_STRING = 1; /** - * + *集合类型 */ const REDIS_SET = 2; /** - * + *列表类型 */ const REDIS_LIST = 3; /** - * + *有序集合类型 */ const REDIS_ZSET = 4; /** - * + *字典类型 */ const REDIS_HASH = 5; /** - * + *原子操作模式 */ const ATOMIC = 0; /** - * + *事务模式 */ const MULTI = 1; /** - * + *序列化选项 */ const OPT_SERIALIZER = 1; /** - * + *前缀选项 */ const OPT_PREFIX = 2; /** - * + *读操作超时选项 */ const OPT_READ_TIMEOUT = 3; /** - * + *不实行序列化 */ const SERIALIZER_NONE = 0; /** - * + *PHP序列化 */ const SERIALIZER_PHP = 1; /** - * + *扫描选项 */ const OPT_SCAN = 4; /** - * + *重新扫描 */ const SCAN_RETRY = 1; /** - * + *不重新扫描 */ const SCAN_NORETRY = 0; @@ -96,43 +96,48 @@ class RedisCluster const OPT_SLAVE_FAILOVER = 5; /** - * + *不使用failover机制 */ const FAILOVER_NONE = 0; /** - * + *failover错误 */ const FAILOVER_ERROR = 1; /** - * + *使用分布式failover机制(failover是指一个master有N(N>=1)个slave,当master挂掉以后,能选出一个slave晋升成Master继续提供服务。Failover由失败判定和Leader选举两部分组成,Redis Cluster采用去中心化(Gossip)的设计,每个节点通过发送Ping(包括Gossip信息)/Pong心跳的方式来探测对方节点的存活,如果心跳超时则标记对方节点的状态为PFail,这个意思是说该节点认为对方节点可能失败了,有可能是网络闪断或者分区等其他原因导致通讯失败) */ const FAILOVER_DISTRIBUTE = 2; /** - * + *后面位置 */ const AFTER = 'after'; /** - * + *前面位置 */ const BEFORE = 'before'; /** * - *Creates a RedisCluster client + *创建一个集群对象 * @example $redis = new RedisCluster(null, array('127.0.0.1:6379', '127.0.0.1:6380')); + * @param string $name 集群名称(在php.ini配置文件或redis.ini配置文件中配置,不配置则为NULL) + * @param array $config 连接的集群节点配置项,如array('127.0.0.1:6379', '127.0.0.1:6380') + * @param float $timeout 连接超时时间 + * @param float $read_timeout 读操作超时时间 + * @param boolean $persistent 与每个节点持久化连接 * @return */ - public function __construct() + public function __construct($name, Array $config, $timeout, $read_timeout, $persistent) { } /** * - *Disconnects from the Redis instance, except when pconnect is used. + *关闭redis连接(长连接除外) * @example * @return */ @@ -142,9 +147,9 @@ public function close() /** * - *Get the value related to the specified key + *获取指定的key的值 * @example $redis->get('key'); - * @return string|bool: + * @return string|bool */ public function get() { @@ -152,17 +157,28 @@ public function get() /** * - *Set the string value in argument as value of the key. - * @example $redis->set('key', 'value'); - * @return bool: + *给指定的键设置值 + * @example 直接设置: + * $redis->set('key', 'value'); + * 带有效期的设置: + * $redis->set('key','value', 10); + * 当键不存在时,设置期有效期为10秒: + * $redis->set('key', 'value', Array('nx', 'ex'=>10)); + * 当键存在时,设置期有效期为1000毫秒: + * $redis->set('key', 'value', Array('xx', 'px'=>1000)); + * + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int|array $options 附加项,可以是超时时间或者一个选项数组 + * @return bool */ - public function set() + public function set($key, $value, $options) { } /** * - *Returns the values of all specified keys. + *批量获取键名 * @example *
      * $redis->delete('x', 'y', 'z', 'h');	// remove x y z
@@ -181,16 +197,16 @@ public function set()
      * // bool(false)
      * // }
      * 
+ * @param array $keys 键名数组 * @return */ - public function mget() + public function mget(Array $keys) { } /** * - *Sets multiple key-value pairs in one atomic command. - *MSETNX only returns TRUE if all the keys were set (see SETNX). + *批量设置值 * @example *
      * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
@@ -200,267 +216,419 @@ public function mget()
      * // string(6) "value0"
      * // string(6) "value1"
      * 
+ * @param array $values 要设置的键值对 * @return bool */ - public function mset() + public function mset(Array $values) { } /** * - * + *批量设置值(当不存在时设置) * @example - * @return int + *
+     * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
+     * var_dump($redis->get('key0'));
+     * var_dump($redis->get('key1'));
+     * // Output:
+     * // string(6) "value0"
+     * // string(6) "value1"
+     * 
+ * @param array $values 要设置的键值对 + * @return bool */ - public function msetnx() + public function msetnx(Array $values) { } /** * - *Remove specified keys. - * @example - *
-     * $redis->set('key1', 'val1');
-     * $redis->set('key2', 'val2');
-     * $redis->set('key3', 'val3');
-     * $redis->set('key4', 'val4');
-     * $redis->delete('key1', 'key2');          // return 2
-     * $redis->delete(array('key3', 'key4'));   // return 2
-     * 
+ *删除一个或多个键 + * @example $redis->delete('key1', 'key2'); + * $redis->delete(array('key3', 'key4')); + * @param array|string $keys 键名 * @return int */ - public function del() + public function del($keys) { } /** * - *Set the string value in argument as value of the key, with a time to live. - * @example $redis->setex('key', 3600, 'value'); // sets key �� value, with 1h TTL. - * @return bool: + *设置键值并设置有效期 + * @example $redis->setex('key', 3600, 'value'); + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int $ttl 有效期 + * @return bool */ - public function setex() + public function setex($key, $value, $ttl) { } /** * - *Set the string value in argument as value of the key, with a time to live. + *设置键值并设置有效期(毫秒为单位) * @example - * @return bool: + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int $ttl 有效期(毫秒为单位) + * @return */ - public function psetex() + public function psetex($key, $value, $ttl) { } /** * - *Set the string value in argument as value of the key if the key doesn't already exist in the database. + *当键不存在时设置其值 * @example - *
-     * $redis->setnx('key', 'value');   // return TRUE
-     * $redis->setnx('key', 'value');   // return FALSE
-     * 
+ * $redis->setnx('key', 'value'); + * + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 * @return bool: */ - public function setnx() + public function setnx($key, $value) { } /** * - * + *设置键的值,并返回它的旧的缓存值 * @example - * @return + *
+     * $redis->set('x', '42');
+     * $exValue = $redis->getSet('x', 'lol');   // return '42', replaces x by 'lol'
+     * $newValue = $redis->get('x')'            // return 'lol'
+     * 
+ * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @return string */ - public function getset() + public function getset($key, $value) { } /** * - *Verify if the specified key exists. + *判断键是否存在 * @example *
      * $redis->set('key', 'value');
      * $redis->exists('key');               //  TRUE
      * $redis->exists('NonExistingKey');    // FALSE
      * 
- * @return bool: + * @param string $key 键名 + * @return bool */ - public function exists() + public function exists($key) { } /** * - *Returns the keys that match a certain pattern. + *根据匹配模式获取键名(如*) * @example - *
-     * $allKeys = $redis->keys('*');   // all keys will match this.
+     * $allKeys = $redis->keys('*');
      * $keyWithUserPrefix = $redis->keys('user*');
-     * 
+ * @param string $pattern 匹配模式 * @return array */ - public function keys() + public function keys($pattern) { } /** * - *Returns the type of data pointed by a given key. + *获取指定键的数据类型(需要根据常量匹配) * @example $redis->type('key'); - * @return - - */ - public function type() - { - } - - /** - * - * - * @example - * @return + * @param string $key 键名 + * @return int */ - public function lpop() + public function type($key) { } /** * - * + *从列表左侧删除一个元素 * @example - * @return + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->lPop('key1');        // key1 => [ 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @return string */ - public function rpop() + public function lPop($key) { } /** * - * + *从列表右侧删除一个元素 * @example - * @return + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->rPop('key1');        // key1 => [ 'A', 'B' ]
+     * 
+ * @param string $key 键名 + * @return string */ - public function lset() + public function rPop($key) { } /** * - * + *给列表指定位置设置新值 * @example - * @return + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->lGet('key1', 0);     // 'A'
+     * $redis->lSet('key1', 0, 'X');
+     * $redis->lGet('key1', 0);     // 'X'
+     * 
+ * @param string $key 键名 + * @param int $index 索引值 + * @param string $value 新值 + * @return boolean */ - public function spop() + public function lset($key, $index, $value) { } /** * - * + *随机删除元素的某个或某些成员,并返回这个删除的成员. * @example - * @return + *
+     * $redis->sAdd('key1' , 'set1');
+     * $redis->sAdd('key1' , 'set2');
+     * $redis->sAdd('key1' , 'set3');   // 'key1' => {'set3', 'set1', 'set2'}
+     * $redis->sPop('key1');            // 'set1', 'key1' => {'set3', 'set2'}
+     * $redis->sPop('key1');            // 'set3', 'key1' => {'set2'}
+     * 
+ * @param string $key 键名 + * @param int $count 删除个数 + * @return string | bool */ - public function lpush() + public function spop($key, $count) { } /** * - * + *从左侧(头部)向列表插入元素 * @example - * @return + *
+     * $redis->lPush('l', 'v1', 'v2', 'v3', 'v4')   // int(4)
+     * var_dump( $redis->lRange('l', 0, -1) );
+     * //// Output:
+     * // array(4) {
+     * //   [0]=> string(2) "v4"
+     * //   [1]=> string(2) "v3"
+     * //   [2]=> string(2) "v2"
+     * //   [3]=> string(2) "v1"
+     * // }
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int */ - public function rpush() + public function lPush($key, $value) { } /** * - * + *从右侧(尾部)向列表插入元素 * @example - * @return + *
+     * $redis->rPush('l', 'v1', 'v2', 'v3', 'v4');    // int(4)
+     * var_dump( $redis->lRange('l', 0, -1) );
+     * //// Output:
+     * // array(4) {
+     * //   [0]=> string(2) "v1"
+     * //   [1]=> string(2) "v2"
+     * //   [2]=> string(2) "v3"
+     * //   [3]=> string(2) "v4"
+     * // }
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int */ - public function blpop() + public function rPush($key, $value) { } /** * - * + *是一个阻塞lPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表头部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,blPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 * @example - * @return + *
+     * // Non blocking feature
+     * $redis->lPush('key1', 'A');
+     * $redis->delete('key2');
+     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * // Blocking feature
+     * // process 1
+     * $redis->delete('key1');
+     * $redis->blPop('key1', 10);
+     * // blocking for 10 seconds
+     * // process 2
+     * $redis->lPush('key1', 'A');
+     * // process 1
+     * // array('key1', 'A') is returned
+     * 
+ * @param string|...|array $key 键名 + * @param int $timeout 超时时间 + * @return array */ - public function brpop() + public function blPop($key, $timeout) { } /** * - * + *是一个阻塞rPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表尾部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,brPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 * @example - * @return + *
+     * // Non blocking feature
+     * $redis->lPush('key1', 'A');
+     * $redis->delete('key2');
+     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * // Blocking feature
+     * // process 1
+     * $redis->delete('key1');
+     * $redis->blPop('key1', 10);
+     * // blocking for 10 seconds
+     * // process 2
+     * $redis->lPush('key1', 'A');
+     * // process 1
+     * // array('key1', 'A') is returned
+     * 
+ * @param string|...|array $key 键名 + * @param int $timeout 超时时间 + * @return array */ - public function rpushx() + public function brPop($key, $timeout) { } /** * - * + *如果列表存在,从左侧(头部)向列表插入元素 * @example - * @return + *
+     * $redis->delete('key1');
+     * $redis->lPushx('key1', 'A');     // returns 0
+     * $redis->lPush('key1', 'A');      // returns 1
+     * $redis->lPushx('key1', 'B');     // returns 2
+     * $redis->lPushx('key1', 'C');     // returns 3
+     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int */ - public function lpushx() + public function lPushx($key, $value) { } /** * - * + *如果列表存在,从右侧(尾部)向列表插入元素 * @example - * @return + *
+     * $redis->delete('key1');
+     * $redis->rPushx('key1', 'A'); // returns 0
+     * $redis->rPush('key1', 'A'); // returns 1
+     * $redis->rPushx('key1', 'B'); // returns 2
+     * $redis->rPushx('key1', 'C'); // returns 3
+     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int */ - public function linsert() + public function rPushx($key, $value) { } /** * - * + *在列表中,在某个元素的前面或后面插入一个新值 * @example - * @return + *
+     * $redis->delete('key1');
+     * $redis->lInsert('key1', Redis::AFTER, 'A', 'X');     // 0
+     * $redis->lPush('key1', 'A');
+     * $redis->lPush('key1', 'B');
+     * $redis->lPush('key1', 'C');
+     * $redis->lInsert('key1', Redis::BEFORE, 'C', 'X');    // 4
+     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C')
+     * $redis->lInsert('key1', Redis::AFTER, 'C', 'Y');     // 5
+     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C', 'Y')
+     * $redis->lInsert('key1', Redis::AFTER, 'W', 'value'); // -1
+     * 
+ * @param string $key 键名 + * @param string $position 位置(前面或后面,使用Redis::BEFORE | Redis::AFTER) + * @param string $element 元素 + * @param string $value 新值 + * @return int */ - public function lindex() + public function linsert($key, $position, $element, $value) { } /** * - * + *获取列表中指定索引的值 * @example - * @return + * @param string $key 键名 + * @param int $index 索引值 + * @return string | boolean */ - public function lrem() + public function lindex($key, $index) { } /** * - *A blocking version of rpoplpush, with an integral timeout in the third parameter. + *从列表中删除指定值的元素。 如果count为零,则删除所有匹配的元素。 如果计数是负数,则元素从尾部移到头部。 * @example - * @return string + * @param string $key 键名 + * @param string $value 元素值 + * @param int $count 删除的个数 + * @return long | bool */ - public function brpoplpush() + public function lrem($key, $value, $count) { } /** * - *Pops a value from the tail of a list, and pushes it to the front of another list. - *Also return this value. + *从一个队列的队尾删除一个元素,并将该元素插入到另一个队列的头部 * @example *
      * $redis->delete('x', 'y');
@@ -488,424 +656,832 @@ public function brpoplpush()
      * //  string(3) "123"
      * //}
      * 
+ * @param string $srcKey 要删除元素的队列键名 + * @param string $dstKey 要插入元素的队列的键名 * @return string */ - public function rpoplpush() + public function rpoplpush($srcKey, $dstKey) { } /** * - * + *阻塞执行rpoplpush * @example - * @return + * @param string $srcKey 要删除元素的队列键名 + * @param string $dstKey 要插入元素的队列的键名 + * @return string */ - public function llen() + public function brpoplpush($srcKey, $dstKey) { } /** * - * + *返回列表的长度 * @example - * @return + * @param string|...|array $key 键名 + * @return long | bool */ - public function scard() + public function llen($key) { } /** * - * + *返回集合的元素个数 * @example - * @return + * @param string $key 键名 + * @return long */ - public function smembers() + public function scard($key) { } /** * - * + *返回集合的所有成员 * @example - * @return + *
+     * $redis->delete('s');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'b');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'c');
+     * var_dump($redis->sMembers('s'));
+     * //array(3) {
+     * //  [0]=>
+     * //  string(1) "c"
+     * //  [1]=>
+     * //  string(1) "a"
+     * //  [2]=>
+     * //  string(1) "b"
+     * //}
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array */ - public function sismember() + public function smembers($key) { } /** * - * + *是否包含某个成员 * @example - * @return + * @param string $key 键名 + * @param string $member 成员值 + * @return boolean */ - public function sadd() + public function sismember($key, $member) { } /** * - * + *给集合添加元素 * @example - * @return + *
+     * $redis->sAdd('k', 'v1');                // int(1)
+     * $redis->sAdd('k', 'v1', 'v2', 'v3');    // int(2)
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int */ - public function saddarray() + public function sAdd($key, $value) { } /** * - * + *给集合批量添加元素 * @example + * @param string $key 键名 + * @param array $value 元素值 * @return */ - public function srem() + public function sAddArray($key, Array $value) { } /** * - * + *删除集合元素 * @example - * @return + * @param string $key 键名 + * @param string|... $member 成员 + * @return long */ - public function sunion() + public function srem($key, $member) { } /** * - * + *获取集合的并集 * @example - * @return + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s1', '3');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * $redis->sAdd('s2', '4');
+     * var_dump($redis->sUnion('s0', 's1', 's2'));
+     * array(4) {
+     * //  [0]=>
+     * //  string(1) "3"
+     * //  [1]=>
+     * //  string(1) "4"
+     * //  [2]=>
+     * //  string(1) "1"
+     * //  [3]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string|... $key2 键名2 + * @return array */ - public function sunionstore() + public function sUnion($key1, $key2) { } /** * - * + *获取多个集合的并集,并将结果存入到另外一个集合中 * @example - * @return + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s1', '3');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * $redis->sAdd('s2', '4');
+     * var_dump($redis->sUnionStore('dst', 's0', 's1', 's2'));
+     * var_dump($redis->sMembers('dst'));
+     * //int(4)
+     * //array(4) {
+     * //  [0]=>
+     * //  string(1) "3"
+     * //  [1]=>
+     * //  string(1) "4"
+     * //  [2]=>
+     * //  string(1) "1"
+     * //  [3]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int */ - public function sinter() + public function sUnionStore($dstKey, $key1, $key2, $keyN) { } /** * - * + *获取两个集合的交集 * @example - * @return + *
+     * $redis->sAdd('key1', 'val1');
+     * $redis->sAdd('key1', 'val2');
+     * $redis->sAdd('key1', 'val3');
+     * $redis->sAdd('key1', 'val4');
+     * $redis->sAdd('key2', 'val3');
+     * $redis->sAdd('key2', 'val4');
+     * $redis->sAdd('key3', 'val3');
+     * $redis->sAdd('key3', 'val4');
+     * var_dump($redis->sInter('key1', 'key2', 'key3'));
+     * //array(2) {
+     * //  [0]=>
+     * //  string(4) "val4"
+     * //  [1]=>
+     * //  string(4) "val3"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string $key2 键名2 + * @return array | boolean */ - public function sinterstore() + public function sInter($key1, $key2) { } /** * - * + *获取多个集合的交集,并将结果存入到另外一个集合中 * @example - * @return + *
+     * $redis->sAdd('key1', 'val1');
+     * $redis->sAdd('key1', 'val2');
+     * $redis->sAdd('key1', 'val3');
+     * $redis->sAdd('key1', 'val4');
+     * $redis->sAdd('key2', 'val3');
+     * $redis->sAdd('key2', 'val4');
+     * $redis->sAdd('key3', 'val3');
+     * $redis->sAdd('key3', 'val4');
+     * var_dump($redis->sInterStore('output', 'key1', 'key2', 'key3'));
+     * var_dump($redis->sMembers('output'));
+     * //int(2)
+     * //
+     * //array(2) {
+     * //  [0]=>
+     * //  string(4) "val4"
+     * //  [1]=>
+     * //  string(4) "val3"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int */ - public function sdiff() + public function sInterStore($dstKey, $key1, $key2, $keyN) { } /** * - * + *获取多个集合的差集 * @example - * @return + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s0', '3');
+     * $redis->sAdd('s0', '4');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * var_dump($redis->sDiff('s0', 's1', 's2'));
+     * //array(2) {
+     * //  [0]=>
+     * //  string(1) "4"
+     * //  [1]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string|... $key2 键名2 + * @return array */ - public function sdiffstore() + public function sDiff($key1, $key2) { } /** * - * + *获取多个集合的差集,并将结果存入到一个新的集合中 * @example - * @return + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s0', '3');
+     * $redis->sAdd('s0', '4');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * var_dump($redis->sDiffStore('dst', 's0', 's1', 's2'));
+     * var_dump($redis->sMembers('dst'));
+     * //int(2)
+     * //array(2) {
+     * //  [0]=>
+     * //  string(1) "4"
+     * //  [1]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int: */ - public function srandmember() + public function sDiffStore($dstKey, $key1, $key2, $keyN) { } /** * - *Get the length of a string value. + *随机返回一个集合的元素(不会删除它) + * @example + *
+     * $redis->sAdd('key1' , 'one');
+     * $redis->sAdd('key1' , 'two');
+     * $redis->sAdd('key1' , 'three');              // 'key1' => {'one', 'two', 'three'}
+     * var_dump( $redis->sRandMember('key1') );     // 'key1' => {'one', 'two', 'three'}
+     * // string(5) "three"
+     * var_dump( $redis->sRandMember('key1', 2) );  // 'key1' => {'one', 'two', 'three'}
+     * // array(2) {
+     * //   [0]=> string(2) "one"
+     * //   [1]=> string(2) "three"
+     * // }
+     * 
+ * @param string $key 键名 + * @return string | bool + */ + public function srandmember($key) + { + } + + /** + * + *获取键值的长度 * @example *
      * $redis->set('key', 'value');
      * $redis->strlen('key'); // 5
      * 
- * @return + * @param string $key 键名 + * @return int */ - public function strlen() + public function strlen($key) { } /** * - *Remove the expiration timer from a key. + *移除指定键的有效期,让它永久有效 * @example $redis->persist('key'); + * @param string $key 键名 * @return bool: */ - public function persist() + public function persist($key) { } /** * - *Returns the time to live left for a given key, in seconds. If the key doesn't exist, FALSE is returned. + *返回指定键的有效时间(秒) * @example $redis->ttl('key'); - * @return int, + * @param string $key 键名 + * @return long */ - public function ttl() + public function ttl($key) { } /** * - *Returns a time to live left for a given key, in milliseconds. + *返回指定键的有效时间(毫秒) * @example $redis->pttl('key'); - * @return int + * @param string $key 键名 + * @return long */ - public function pttl() + public function pttl($key) { } /** * - * + *获取有序集合的成员数 * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCard('key');            // 3
+     * 
+ * @param string $key 集合键名 + * @return int */ - public function zcard() + public function zcard($key) { } /** * - * + *获取指定排序范围的成员数. * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCount('key', 0, 3); // 2, corresponding to array('val0', 'val2')
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int */ - public function zcount() + public function zcount($key, $start, $end) { } /** * - * + *根据排序值范围来删除成员 * @example - * @return + * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return long */ - public function zremrangebyscore() + public function zremrangebyscore($key, $start, $end) { } /** * - * + *获取指定成员的排序值(分数) * @example - * @return + *
+     * $redis->zAdd('key', 2.5, 'val2');
+     * $redis->zScore('key', 'val2'); // 2.5
+     * 
+ * @param string $key 集合键名 + * @param string $member 成员值 + * @return double */ - public function zscore() + public function zscore($key, $member) { } /** * - * + *向有序集合插入元素 * @example - * @return + *
+     * 
+     * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
+     * $redis->zRem('z', 'v2', 'v3');                           // int(2)
+     * var_dump( $redis->zRange('z', 0, -1) );
+     * //// Output:
+     * // array(2) {
+     * //   [0]=> string(2) "v1"
+     * //   [1]=> string(2) "v4"
+     * // }
+     * 
+ *
+ * @param string $key 集合键名 + * @param double $score 排序值 + * @param string $value 元素值 + * @return int */ - public function zadd() + public function zadd($key, $score, $value) { } /** * - * + *给有序集合成员增加排序值 * @example - * @return + *
+     * $redis->delete('key');
+     * $redis->zIncrBy('key', 2.5, 'member1');  // key or member1 didn't exist, so member1's score is to 0
+     * // before the increment and now has the value 2.5
+     * $redis->zIncrBy('key', 1, 'member1');    // 3.5
+     * 
+ * @param string $key 目标集合键名 + * @param double $step 增加的步长 + * @param string $member 成员 + * @return float */ - public function zincrby() + public function zincrby($key, $step, $member) { } /** * - * + *获取字典的某个字段的值 * @example - * @return + * @param string $key 键名 + * @param string $field 字段名 + * @return string */ - public function hlen() + public function hGet($key, $field) { } /** * - * + *为字典的字段设置值 * @example - * @return + *
+     * $redis->delete('h')
+     * $redis->hSet('h', 'key1', 'hello');  // 1, 'key1' => 'hello' in the hash at "h"
+     * $redis->hGet('h', 'key1');           // returns "hello"
+     * $redis->hSet('h', 'key1', 'plop');   // 0, value was replaced.
+     * $redis->hGet('h', 'key1');           // returns "plop"
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param string $value 字段值 + * @return long */ - public function hkeys() + public function hSet($key, $field, $value) { } /** * - * + *当字典的字段不存在时,为其设置值 * @example - * @return + *
+     * $redis->delete('h')
+     * $redis->hSetNx('h', 'key1', 'hello'); // TRUE, 'key1' => 'hello' in the hash at "h"
+     * $redis->hSetNx('h', 'key1', 'world'); // FALSE, 'key1' => 'hello' in the hash at "h". No change since the field
+     * wasn't replaced.
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param string $value 字段值 + * @return bool */ - public function hvals() + public function hSetNx($key, $field, $value) { } /** * - * + *删除字典的某个或某些字段 * @example - * @return + *
+     * $redis->hMSet('h',
+     * array(
+     * 'f1' => 'v1',
+     * 'f2' => 'v2',
+     * 'f3' => 'v3',
+     * 'f4' => 'v4',
+     * ));
+     * var_dump( $redis->hDel('h', 'f1') );        // int(1)
+     * var_dump( $redis->hDel('h', 'f2', 'f3') );  // int(2)
+     * s
+     * var_dump( $redis->hGetAll('h') );
+     * //// Output:
+     * //  array(1) {
+     * //    ["f4"]=> string(2) "v4"
+     * //  }
+     * 
+ * @param string $key 键名 + * @param string|array $fields 字段名 + * @return int */ - public function hget() + public function hDel($key, $fields) { } /** * - * + *获取字典的字段个数 * @example - * @return + *
+     * $redis->delete('h')
+     * $redis->hSet('h', 'key1', 'hello');
+     * $redis->hSet('h', 'key2', 'plop');
+     * $redis->hLen('h'); // returns 2
+     * 
+ * @param string $key 键名 + * @return int */ - public function hgetall() + public function hLen($key) { } /** * - * + *获取字典的字段名称列表. * @example - * @return + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hKeys('h'));
+     * // Output:
+     * // array(4) {
+     * // [0]=>
+     * // string(1) "a"
+     * // [1]=>
+     * // string(1) "b"
+     * // [2]=>
+     * // string(1) "c"
+     * // [3]=>
+     * // string(1) "d"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array */ - public function hexists() + public function hKeys($key) { } /** * - * + *获取字典的字段值列表 * @example - * @return + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hVals('h'));
+     * // Output
+     * // array(4) {
+     * //   [0]=>
+     * //   string(1) "x"
+     * //   [1]=>
+     * //   string(1) "y"
+     * //   [2]=>
+     * //   string(1) "z"
+     * //   [3]=>
+     * //   string(1) "t"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array */ - public function hincrby() + public function hVals($key) { } /** * - * + *获取字典所有字段键值对 * @example - * @return + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hGetAll('h'));
+     * // Output:
+     * // array(4) {
+     * //   ["a"]=>
+     * //   string(1) "x"
+     * //   ["b"]=>
+     * //   string(1) "y"
+     * //   ["c"]=>
+     * //   string(1) "z"
+     * //   ["d"]=>
+     * //   string(1) "t"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array */ - public function hset() + public function hGetAll($key) { } /** * - * + *判断字典的某个字段是否存在. * @example - * @return + *
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hExists('h', 'a');               //  TRUE
+     * $redis->hExists('h', 'NonExistingKey');  // FALSE
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @return bool */ - public function hsetnx() + public function hExists($key, $field) { } /** * - * + *为指定字段增加指定的值. * @example - * @return + *
+     * $redis->delete('h');
+     * $redis->hIncrBy('h', 'x', 2); // returns 2: h[x] = 2 now.
+     * $redis->hIncrBy('h', 'x', 1); // h[x] ← 2 + 1. Returns 3
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param int $step 自增步长 + * @return int */ - public function hmget() + public function hIncrBy($key, $field, $step) { } /** * - * + *为指定字段增加指定的值 * @example + *
+     * $redis = new Redis();
+     * $redis->connect('127.0.0.1');
+     * $redis->hset('h', 'float', 3);
+     * $redis->hset('h', 'int',   3);
+     * var_dump( $redis->hIncrByFloat('h', 'float', 1.5) ); // float(4.5)
+     * var_dump( $redis->hGetAll('h') );
+     * // Output
+     * array(2) {
+     * ["float"]=>
+     * string(3) "4.5"
+     * ["int"]=>
+     * string(1) "3"
+     * }
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param double $step 自增步长 * @return */ - public function hmset() + public function hIncrByFloat($key, $field, $step) { } /** * - * + *批量设置字典字段的值 * @example - * @return + *
+     * $redis->delete('user:1');
+     * $redis->hMset('user:1', array('name' => 'Joe', 'salary' => 2000));
+     * $redis->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now.
+     * 
+ * @param string $key 键名 + * @param array $fields 字段键值对 + * @return boolean */ - public function hdel() + public function hMset($key, Array $fields) { } /** * - * + *批量获取字典的字段值 * @example - * @return + * @param string $key 键名 + * @param array $fields 字段名列表 + * @return array */ - public function hincrbyfloat() + public function hMget($key, Array $fields) { } /** * - *Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command. - *The data that comes out of DUMP is a binary representation of the key as Redis stores it. + *将某个键导出为一个二进制数据. * @example *
      * $redis->set('foo', 'bar');
      * $val = $redis->dump('foo'); // $val will be the Redis encoded key value
      * 
+ * @param string $key 键名 * @return string */ - public function dump() + public function dump($key) { } /** * - * + *获取成员的排序值 * @example - * @return + *
+     * $redis->delete('z');
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zRank('key', 'one');     // 0
+     * $redis->zRank('key', 'two');     // 1
+     * $redis->zRevRank('key', 'one');  // 1
+     * $redis->zRevRank('key', 'two');  // 0
+     * 
+ * @param string $key 集合键名 + * @param string $member 成员值 + * @return int */ - public function zrank() + public function zRank($key, $member) { } /** * - * + *获取成员的排位值(倒数) * @example - * @return + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int */ - public function zrevrank() + public function zRevRank($key, $member) { } /** * - *Increment the number stored at key by one. + *键值自增 * @example *
      * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
@@ -913,432 +1489,689 @@ public function zrevrank()
      * $redis->incr('key1'); // 3
      * $redis->incr('key1'); // 4
      * 
+ * @param string $key 键名 * @return int */ - public function incr() + public function incr($key) { } /** * - *Decrement the number stored at key by one. + *按指定步长自增 * @example *
-     * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
-     * $redis->decr('key1'); // -2
-     * $redis->decr('key1'); // -3
+     * $redis->incr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value 1
+     * $redis->incr('key1');        // 2
+     * $redis->incr('key1');        // 3
+     * $redis->incr('key1');        // 4
+     * $redis->incrBy('key1', 10);  // 14
      * 
+ * @param string $key 键名 + * @param int $step 自增步长 * @return int */ - public function decr() + public function incrBy($key, $step) { } /** * - * + *按指定步长自增 * @example - * @return + *
+     * $redis = new Redis();
+     * $redis->connect('127.0.0.1');
+     * $redis->set('x', 3);
+     * var_dump( $redis->incrByFloat('x', 1.5) );   // float(4.5)
+     * // ! SIC
+     * var_dump( $redis->get('x') );                // string(3) "4.5"
+     * 
+ * @param string $key 键名 + * @param float $step 自增步长 + * @return float */ - public function incrby() + public function incrByFloat($key, $step) { } /** * - * + *键值自减 * @example - * @return + *
+     * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
+     * $redis->decr('key1'); // -2
+     * $redis->decr('key1'); // -3
+     * 
+ * @param string $key 键名 + * @return int */ - public function decrby() + public function decr($key) { } /** * - * + *按指定步长自减 * @example - * @return + *
+     * $redis->decr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value -1
+     * $redis->decr('key1');        // -2
+     * $redis->decr('key1');        // -3
+     * $redis->decrBy('key1', 10);  // -13
+     * 
+ * @param string $key 键名 + * @param float $step 自减步长 + * @return int */ - public function incrbyfloat() + public function decrBy($key, $step) { } /** * - *Sets an expiration date (a timeout) on an item. + *设置键的有效期 * @example - *
-     * $redis->set('x', '42');
-     * $redis->setTimeout('x', 3);  // x will disappear in 3 seconds.
-     * sleep(5);                    // wait 5 seconds
-     * $redis->get('x');            // will return `FALSE`, as 'x' has expired.
-     * 
- * @return bool: + * @param string $key 键名 + * @param int $ttl 有效期(秒数) + * @return boolean */ - public function expire() + public function expire($key, $ttl) { } /** * - * + *为某个键设置有效期为某个时间点 * @example - * @return + *
+     * $redis->set('x', '42');
+     * $now = time(NULL);               // current timestamp
+     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
+     * sleep(5);                        // wait 5 seconds
+     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
+     * 
+ * @param string $key 键名 + * @param int $expireTime 到期时间 + * @return bool: */ - public function pexpire() + public function expireAt($key, $expireTime) { } /** * - * + *设置键的有效期(毫秒为单位) * @example - * @return + * @param string $key 键名 + * @param int $ttl 有效期(毫秒数) + * @return boolean */ - public function expireat() + public function pexpire($key, $ttl) { } /** * - * + *为某个键设置有效期为某个时间点(精确到毫秒) * @example - * @return + *
+     * $redis->set('x', '42');
+     * $now = time(NULL);               // current timestamp
+     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
+     * sleep(5);                        // wait 5 seconds
+     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
+     * 
+ * @param string $key 键名 + * @param int $expireTime 到期时间 + * @return bool: */ - public function pexpireat() + public function pexpireAt($key, $expireTime) { } /** * - *Append specified string to the string stored in specified key. + *将字符串追加到键值后(返回值的长度) * @example *
      * $redis->set('key', 'value1');
      * $redis->append('key', 'value2'); // 12
      * $redis->get('key');              // 'value1value2'
      * 
- * @return int: + * @param string $key 键名 + * @param string $value 追加的值 + * @return int */ - public function append() + public function append($key, $value) { } /** * - * + *获取某个键的某个位置的位值 * @example - * @return + *
+     * $redis->set('key', "\x7f");  // this is 0111 1111
+     * $redis->getBit('key', 0);    // 0
+     * $redis->getBit('key', 1);    // 1
+     * 
+ * @param string $key 键名 + * @param int $offset 所在位置 + * @return int */ - public function getbit() + public function getBit($key, $offset) { } /** * - * + *修改某个键的某个位置的位值 * @example - * @return + *
+     * $redis->set('key', "*");     // ord("*") = 42 = 0x2f = "0010 1010"
+     * $redis->setBit('key', 5, 1); // returns 0
+     * $redis->setBit('key', 7, 1); // returns 0
+     * $redis->get('key');          // chr(0x2f) = "/" = b("0010 1111")
+     * 
+ * @param string $key 键名 + * @param int $offset 开始位置 + * @param boolean|int $value 新值 + * @return int: */ - public function setbit() + public function setBit($key, $offset, $value) { } /** * - * + *多个键的位操作,并将结果存入到指定的键中 * @example - * @return + * @param string $operation 操作(有 AND, OR, NOT, XOR 4种可选择) + * @param string $dstKey 目标键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名N + * @return long */ - public function bitop() + public function bitop($operation, $dstKey, $key1, $key2, $keyN) { } /** * - * + *统计字符串的位数 * @example - * @return + * @param string $key 键名 + * @return long */ - public function bitpos() + public function bitcount($key) { } /** * - * + *获取指定位置的位值 * @example - * @return + *
+     * $redis->set('key', '\xff\xff');
+     * $redis->bitpos('key', 1); // int(0)
+     * $redis->bitpos('key', 1, 1); // int(8)
+     * $redis->bitpos('key', 1, 3); // int(-1)
+     * $redis->bitpos('key', 0); // int(16)
+     * $redis->bitpos('key', 0, 1); // int(16)
+     * $redis->bitpos('key', 0, 1, 5); // int(-1)
+     * 
+ * @param string $key 键名 + * @param int $bit 位值 + * @param int $start 开始位置 + * @param int $end 结束位置 + * @return function */ - public function bitcount() + public function bitpos($key, $bit, $start, $end) { } /** * - * + *获取列表中指定索引的值 * @example - * @return + * @param string $key 键名 + * @param int $index 索引值 + * @return string | boolean */ - public function lget() + public function lget($key, $index) { } /** * - * + *获取一个键值的子字符串 * @example - * @return + *
+     * $redis->set('key', 'string value');
+     * $redis->getRange('key', 0, 5);   // 'string'
+     * $redis->getRange('key', -5, -1); // 'value'
+     * 
+ * @param string $key 键名 + * @param int $start 开始位置 + * @param int $end 结束位置 + * @return string: */ - public function getrange() + public function getrange($key, $start, $end) { } /** * - * + *删除指定范围外的其他元素 * @example - * @return + * @param string $key 键名 + * @param int $start 开始索引 + * @param int $end 结束索引 + * @return array | boolean */ - public function ltrim() + public function ltrim($key, $start, $end) { } /** * - * + *获取列表指定范围的值 * @example - * @return + * @param string $key 键名 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @return array */ - public function lrange() + public function lrange($key, $start, $end) { } /** * - * + *根据排序范围删除成员 * @example - * @return + *
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zAdd('key', 3, 'three');
+     * $redis->zRemRangeByRank('key', 0, 1); // 2
+     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int */ - public function zremrangebyrank() + public function zremrangebyrank($key, $start, $end) { } /** * - *Publish messages to channels. Warning: this function will probably change in the future. + *将消息发布到消息通道(队列). * @example $redis->publish('chan-1', 'hello, world!'); // send message. + * @param string $channel 消息频道 + * @param string $message 消息 * @return int */ - public function publish() + public function publish($channel, $message) { } /** * - *Renames a key. + *给键重命名 * @example - *
-     * $redis->set('x', '42');
-     * $redis->rename('x', 'y');
-     * $redis->get('y');   // �� 42
-     * $redis->get('x');   // �� `FALSE`
-     * 
- * @return bool: + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean */ - public function rename() + public function rename($srcKey, $dstKey) { } /** * - * + *当目标键名不存在时,给键重命名 * @example - * @return + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean */ - public function renamenx() + public function renamenx($srcKey, $dstKey) { } /** * - * + *将所有元素参数添加到 HyperLogLog 数据结构中 * @example + * @param string $key 键名 + * @param string|array|... $element 元素 * @return */ - public function pfcount() + public function pfadd($key, $element) { } /** * - * + *返回给定 HyperLogLog 的基数估算值 * @example + * @param string|array $keys 键名 * @return */ - public function pfadd() + public function pfcount($keys) { } /** * - * + *将多个 HyperLogLog 合并为一个 HyperLogLog ,合并后的 HyperLogLog 的基数估算值是通过对所有 给定 HyperLogLog 进行并集计算得出的 * @example + * @param string|array $dstKey 目标键名 + * @param string|array $sourceKeys 源键名 * @return */ - public function pfmerge() + public function pfmerge($dstKey, $sourceKeys) { } /** * - * + *修改某个键的某个位置的值 * @example - * @return + *
+     * $redis->set('key', 'Hello world');
+     * $redis->setRange('key', 6, "redis"); // returns 11
+     * $redis->get('key');                  // "Hello redis"
+     * 
+ * @param string $key 键名 + * @param int $offset 开始位置 + * @param string $value 被替换的子串的值 + * @return string */ - public function setrange() + public function setrange($key, $offset, $value) { } /** * - *Restore a key from the result of a DUMP operation. + *将dump导出的二进制数据恢复到可读的字符串. * @example *
      * $redis->set('foo', 'bar');
      * $val = $redis->dump('foo');
      * $redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo'
      * 
+ * @param string $key 键名 + * @param int $ttl 有效期 + * @param string $value dump导出的二进制数据 * @return */ - public function restore() + public function restore($key, $ttl, $value) { } /** * - * + *将某个集合中的元素移动到另外一个集合中 * @example - * @return + *
+     * $redis->sAdd('key1' , 'set11');
+     * $redis->sAdd('key1' , 'set12');
+     * $redis->sAdd('key1' , 'set13');          // 'key1' => {'set11', 'set12', 'set13'}
+     * $redis->sAdd('key2' , 'set21');
+     * $redis->sAdd('key2' , 'set22');          // 'key2' => {'set21', 'set22'}
+     * $redis->sMove('key1', 'key2', 'set13');  // 'key1' =>  {'set11', 'set12'}
+     * // 'key2' =>  {'set21', 'set22', 'set13'}
+     * 
+ * @param string $srcKey 原集合键名 + * @param string $dstKey 目标集合键名 + * @param string $member 成员 + * @return bool */ - public function smove() + public function smove($srcKey, $dstKey, $member) { } /** * - * + *获取有序集合中指定范围的成员 * @example - * @return + *
+     * $redis->zAdd('key1', 0, 'val0');
+     * $redis->zAdd('key1', 2, 'val2');
+     * $redis->zAdd('key1', 10, 'val10');
+     * $redis->zRange('key1', 0, -1); // array('val0', 'val2', 'val10')
+     * // with scores
+     * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param boolean $withScores 是否返回成员的排序值 + * @return array */ - public function zrange() + public function zRange($key, $start, $end, $withScores) { } /** * - * + *获取有序集合中指定范围的成员(倒序排列) * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRevRange('key', 0, -1); // array('val10', 'val2', 'val0')
+     * // with scores
+     * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param boolean $withScores 是否返回成员的排序值 + * @return array */ - public function zrevrange() + public function zRevRange($key, $start, $end, $withScores) { } /** * - * + *获取有序集合中指定范围的成员(按排序值排列) * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) + * @return array */ - public function zrangebyscore() + public function zRangeByScore($key, $start, $end, Array $options) { } /** * - * + *获取有序集合中指定范围的成员(按排序值倒序排列) * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) + * @return array */ - public function zrevrangebyscore() + public function zRevRangeByScore($key, $start, $end, Array $options) { } /** * - * + *按字母字典的顺序返回成员 * @example - * @return + *
+     * foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g') as $char) {
+     * $redis->zAdd('key', $char);
+     * }
+     * $redis->zRangeByLex('key', '-', '[c'); // array('a', 'b', 'c')
+     * $redis->zRangeByLex('key', '-', '(c'); // array('a', 'b')
+     * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c')
+     * 
+ * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @param long $offset 索引开始值 + * @param long $limit 成员数 + * @return array */ - public function zrangebylex() + public function zRangeByLex($key, $min, $max, $offset, $limit) { } /** * - * + *按字母字典的顺序返回成员(倒序排序) * @example + * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @param long $offset 索引开始值 + * @param long $limit 成员数 * @return */ - public function zrevrangebylex() + public function zRevRangeByLex($key, $min, $max, $offset, $limit) { } /** * - * + *获取指定字母范围的成员数 * @example - * @return + * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @return int */ - public function zlexcount() + public function zlexcount($key, $min, $max) { } /** * - * + *删除指定字母范围的成员 * @example - * @return + * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @return long */ - public function zremrangebylex() + public function zremrangebylex($key, $min, $max) { } /** * - * + *将两个有序集合的并集存入到一个指定的键中 * @example - * @return + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k2', 2, 'val2');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
+     * // Weighted zUnion
+     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
+     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int */ - public function zunionstore() + public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) { } /** * - * + *将两个有序集合的交集存入到一个指定的键中 * @example - * @return + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->delete('ko4');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k1', 3, 'val3');
+     * $redis->zAdd('k2', 2, 'val1');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
+     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
+     * // Weighted zInter
+     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
+     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int */ - public function zinterstore() + public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) { } /** * - * + *删除有序集合中的某个成员 * @example - * @return + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int */ - public function zrem() + public function zrem($key, $member) { } /** * - *Sort + *给列表、集合或有序集合的元素排序 * @example *
      * $redis->delete('s');
@@ -1351,35 +2184,34 @@ public function zrem()
      * var_dump($redis->sort('s', array('sort' => 'desc'))); // 5,4,3,2,1
      * var_dump($redis->sort('s', array('sort' => 'desc', 'store' => 'out'))); // (int)5
      * 
+ * @param string $key 键名 + * @param array $options 排序参数,如:array('sort' => 'desc') * @return An */ - public function sort() + public function sort($key, Array $options) { } /** * - *Describes the object pointed to by a key. - *The information to retrieve (string) and the key (string). - *Info can be one of the following: - *- "encoding" - *- "refcount" - *- "idletime" + *获取某个键的对象信息 * @example *
-     * $redis->object("encoding", "l"); // �� ziplist
-     * $redis->object("refcount", "l"); // �� 1
-     * $redis->object("idletime", "l"); // �� 400 (in seconds, with a precision of 10 seconds).
+     * $redis->object("encoding", "l"); // → ziplist
+     * $redis->object("refcount", "l"); // → 1
+     * $redis->object("idletime", "l"); // → 400 (in seconds, with a precision of 10 seconds).
      * 
+ * @param string $info 获取的信息指标名称(有 encoding、refcount 、idletime 3种可选择) + * @param string $key 键名 * @return string */ - public function object() + public function object($info, $key) { } /** * - *Subscribe to channels. Warning: this function will probably change in the future. + *订阅消息 * @example *
      * function f($redis, $chan, $msg) {
@@ -1397,15 +2229,18 @@ public function object()
      * }
      * $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
      * 
- * @return + * @param array $channels 订阅的消息频道 + * @param string|array $callback 回调函数名称 + * @param mixed $value 返回值 + * @return mixed */ - public function subscribe() + public function subscribe(Array $channels, $callback, $value) { } /** * - *Subscribe to channels by pattern + *通过匹配模式来订阅这些匹配的消息频道 * @example *
      * function psubscribe($redis, $pattern, $chan, $msg) {
@@ -1414,98 +2249,108 @@ public function subscribe()
      * echo "Payload: $msg\n";
      * }
      * 
+ * @param array $patterns 匹配模式 + * @param string|array $callback 回调函数名称 + * @param mixed $value 返回值 * @return */ - public function psubscribe() + public function psubscribe(Array $patterns, $callback, $value) { } /** * - * + *取消订阅 * @example + * @param array $channels 订阅的消息频道 * @return */ - public function unsubscribe() + public function unsubscribe(Array $channels) { } /** * - * + *通过匹配模式来取消订阅这些匹配的消息频道 * @example + * @param array $patterns 匹配模式 * @return */ - public function punsubscribe() + public function punsubscribe(Array $patterns) { } /** * - *Evaluate a LUA script serverside + *执行lua脚本 * @example - *
-     * $redis->eval("return 1"); // Returns an integer: 1
-     * $redis->eval("return {1,2,3}"); // Returns Array(1,2,3)
-     * $redis->del('mylist');
-     * $redis->rpush('mylist','a');
-     * $redis->rpush('mylist','b');
-     * $redis->rpush('mylist','c');
-     * // Nested response:  Array(1,2,3,Array('a','b','c'));
-     * $redis->eval("return {1,2,3,redis.call('lrange','mylist',0,-1)}}");
-     * 
- * @return message + * @param string $script 脚本 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 + * @return mixed */ - public function eval() + public function eval($script, Array $args, $num_keys) { } /** * - * - * @example + *从脚本的SHA1散列而不是脚本本身执行LUA脚本 + * @example $script = 'return 1'; + * $sha = $redis->script('load', $script); + * $redis->evalSha($sha); // Returns 1 + * @param string $script_sha 脚本的散列值 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 * @return */ - public function evalsha() + public function evalsha($script_sha, Array $args, $num_keys) { } /** * - *Scan the keyspace for keys. + *扫描键空间. * @example - * @param mixed $i_iterator - * @param mixed $str_node - * @param mixed $str_pattern - * @param mixed $i_count - * @return array|bool + *
+     * $iterator = null;
+     * while($keys = $redis->scan($iterator)) {
+     * foreach($keys as $key) {
+     * echo $key . PHP_EOL;
+     * }
+     * }
+     * 
+ * @param Long|NULL $i_iterator 迭代器 + * @param string $str_pattern 匹配的模式 + * @param int $i_count 每次迭代的长度 + * @return array */ - public function scan($i_iterator, $str_node, $str_pattern, $i_count) + public function scan($i_iterator, $str_pattern, $i_count) { } /** * - * + *扫描hash的键 * @example - * @param mixed $str_key - * @param mixed $i_iterator - * @param mixed $str_pattern - * @param mixed $i_count + * @param string $str_key 键值 + * @param Long|NULL $i_iterator 迭代器 + * @param string $str_pattern 匹配的模式 + * @param int $i_count 每次迭代的长度 * @return */ - public function sscan($str_key, $i_iterator, $str_pattern, $i_count) + public function hscan($str_key, $i_iterator, $str_pattern, $i_count) { } /** * - * + *扫描有序集合的键 * @example - * @param mixed $str_key - * @param mixed $i_iterator - * @param mixed $str_pattern - * @param mixed $i_count + * @param string $str_key 键值 + * @param Long|NULL $i_iterator 迭代器 + * @param string $str_pattern 匹配的模式 + * @param int $i_count 每次迭代的长度 * @return */ public function zscan($str_key, $i_iterator, $str_pattern, $i_count) @@ -1514,23 +2359,23 @@ public function zscan($str_key, $i_iterator, $str_pattern, $i_count) /** * - * + *扫描集合的键 * @example - * @param mixed $str_key - * @param mixed $i_iterator - * @param mixed $str_pattern - * @param mixed $i_count + * @param string $str_key 键值 + * @param Long|NULL $i_iterator 迭代器 + * @param string $str_pattern 匹配的模式 + * @param int $i_count 每次迭代的长度 * @return */ - public function hscan($str_key, $i_iterator, $str_pattern, $i_count) + public function sscan($str_key, $i_iterator, $str_pattern, $i_count) { } /** * - * - * @example - * @return + *获取运行模式,如 ATOMIC/MULTI/PIPELINE + * @example $redis->getMode(); + * @return int */ public function getmode() { @@ -1538,90 +2383,125 @@ public function getmode() /** * - * + *获取上次错误信息 * @example - * @return + *
+     * $redis->eval('this-is-not-lua');
+     * $err = $redis->getLastError();
+     * // "ERR Error compiling script (new function): user_script:1: '=' expected near '-'"
+     * 
+ * @return string */ - public function getlasterror() + public function getLastError() { } /** * - * + *清除上次错误信息 * @example - * @return + *
+     * $redis->set('x', 'a');
+     * $redis->incr('x');
+     * $err = $redis->getLastError();
+     * // "ERR value is not an integer or out of range"
+     * $redis->clearLastError();
+     * $err = $redis->getLastError();
+     * // NULL
+     * 
+ * @return bool */ - public function clearlasterror() + public function clearLastError() { } /** * - * + *获取客户端选项 * @example - * @return + * // return Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP, or Redis::SERIALIZER_IGBINARY. + * $redis->getOption(Redis::OPT_SERIALIZER); + * @param string $optionName 选项名 + * @return int */ - public function getoption() + public function getOption($optionName) { } /** * - * + *设置客户端选项. * @example - * @return + *
+     * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);        // don't serialize data
+     * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);         // use built-in serialize/unserialize
+     * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);    // use igBinary serialize/unserialize
+     * $redis->setOption(Redis::OPT_PREFIX, 'myAppName:');                      // use custom prefix on all keys
+     * 
+ * @param string $optionName 选项名 + * @param string $optionValue 选项值 + * @return bool: */ - public function setoption() + public function setOption($optionName, $optionValue) { } /** * - *A utility method to prefix the value with the prefix setting for phpredis. + *设置键前缀 * @example *
      * $redis->setOption(Redis::OPT_PREFIX, 'my-prefix:');
      * $redis->_prefix('my-value'); // Will return 'my-prefix:my-value'
      * 
+ * @param string $prefix 前缀 * @return string */ - public function _prefix() + public function _prefix($prefix) { } /** * - * + *用于手动序列化. * @example + *
+     * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
+     * $redis->_serialize("foo"); // returns "foo"
+     * $redis->_serialize(Array()); // Returns "Array"
+     * $redis->_serialize(new stdClass()); // Returns "Object"
+     * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
+     * $redis->_serialize("foo"); // Returns 's:3:"foo";'
+     * 
+ * @param string $value 被序列化的值 * @return */ - public function _serialize() + public function _serialize($value) { } /** * - *A utility method to unserialize data with whatever serializer is set up. If there is no serializer set, the - *value will be returned unchanged. If there is a serializer set up, and the data passed in is malformed, an - *exception will be thrown. This can be useful if phpredis is serializing values, and you return something from - *redis in a LUA script that is serialized. + *反序列化方法. * @example *
      * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
      * $redis->_unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}'); // Will return Array(1,2,3)
      * 
+ * @param string $value 被反序列化的值 * @return */ - public function _unserialize() + public function _unserialize($value) { } /** * - * - * @example - * @return + *获取集群中的主服务器列表 + * @example foreach ($obj_cluster->_masters() as $arr_master) { + * $obj_cluster->echo($arr_master, "Hello: " . implode(':', $arr_master)); + * } + * @return array */ public function _masters() { @@ -1629,9 +2509,9 @@ public function _masters() /** * - * + *获取跳转的地址,格式为:host:port * @example - * @return + * @return string|NULL */ public function _redir() { @@ -1639,7 +2519,7 @@ public function _redir() /** * - *Enter and exit transactional mode. + *开始一个事务. * @example *
      * $ret = $redis->multi()
@@ -1654,7 +2534,7 @@ public function _redir()
      * //    2 => TRUE,
      * //    3 => 'val2');
      * 
- * @return Once + * @return */ public function multi() { @@ -1662,28 +2542,27 @@ public function multi() /** * - * + *取消事务 * @example * @return */ - public function exec() + public function discard() { } /** * - * + *执行事务 * @example * @return */ - public function discard() + public function exec() { } /** * - *Watches a key for modifications by another client. If the key is modified between WATCH and EXEC, - *the MULTI/EXEC transaction will fail (return FALSE). unwatch cancels all the watching of all keys by this client. + *观察某个键在其他客户端的变化情况. * @example *
      * $redis->watch('x');
@@ -1693,27 +2572,29 @@ public function discard()
      * ->exec();
      * // $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.
      * 
+ * @param string|array $keys 键名 * @return */ - public function watch() + public function watch($keys) { } /** * - * + *取消观察某个键在其他客户端的变化情况 * @example + * @param string|array $keys 键名 * @return */ - public function unwatch() + public function unwatch($keys) { } /** * - *Performs a synchronous save. + *将数据同步到硬盘上 * @example $redis->save(); - * @return If + * @return boolean */ public function save() { @@ -1721,19 +2602,19 @@ public function save() /** * - *Performs a background save. - * @example $redis->bgSave(); - * @return If + *将数据存入到硬盘上(异步操作) + * @example + * @return */ - public function bgsave() + public function bgSave() { } /** * - * - * @example - * @return + *删除当前数据库的所有键 + * @example $redis->flushDB(); + * @return bool */ public function flushdb() { @@ -1741,9 +2622,9 @@ public function flushdb() /** * - * - * @example - * @return + *删除当前实例的所有键 + * @example $redis->flushAll(); + * @return bool */ public function flushall() { @@ -1751,9 +2632,13 @@ public function flushall() /** * - * + *获取当前数据库的键的个数 * @example - * @return + *
+     * $count = $redis->dbSize();
+     * echo "Redis has $count keys\n";
+     * 
+ * @return int */ public function dbsize() { @@ -1761,9 +2646,9 @@ public function dbsize() /** * - *Starts the background rewrite of AOF (Append-Only File) + *开启后台写AOF日志操作 * @example $redis->bgrewriteaof(); - * @return bool: + * @return bool */ public function bgrewriteaof() { @@ -1771,9 +2656,9 @@ public function bgrewriteaof() /** * - * - * @example - * @return + *获取上次数据同步到硬盘的时间 + * @example $redis->lastSave(); + * @return int */ public function lastsave() { @@ -1781,7 +2666,7 @@ public function lastsave() /** * - *Returns an associative array of strings and integers + *获取Redis服务器的信息和统计数据 * @example *
      * $redis->info();
@@ -1789,7 +2674,7 @@ public function lastsave()
      * $redis->info("COMMANDSTATS"); //Information on the commands that have been run (>=2.6 only)
      * $redis->info("CPU"); // just CPU information from Redis INFO
      * 
- * @return + * @return array */ public function info() { @@ -1797,12 +2682,9 @@ public function info() /** * - *Provide information on the role of a Redis instance in the context of replication, by returning if the instance is currently a master, slave, or sentinel. + *返回当前连接的服务器的角色,如master、alone、slave、sentinel * @example - *
-     * $role = $redis->role();
-     * 
- * @return string: + * @return string */ public function role() { @@ -1810,9 +2692,16 @@ public function role() /** * - *Return the current Redis server time. + *返回当前redis服务器时间. * @example - * @return unix + *
+     * var_dump( $redis->time() );
+     * // array(2) {
+     * //   [0] => string(10) "1342364352"
+     * //   [1] => string(6) "253002"
+     * // }
+     * 
+ * @return int */ public function time() { @@ -1820,9 +2709,13 @@ public function time() /** * - * + *返回一个随机的键 * @example - * @return + *
+     * $key = $redis->randomKey();
+     * $surprise = $redis->get($key);  // who knows what's in there.
+     * 
+ * @return string */ public function randomkey() { @@ -1830,7 +2723,7 @@ public function randomkey() /** * - *Check the current connection status + *检查当前redis连接状态(成功时返回PONG) * @example * @return string */ @@ -1840,19 +2733,20 @@ public function ping() /** * - *echo string $string Sends a string to Redis, which replies with the same string - * @example $redis->echo('eeee'); - * @return + *向redis发送一个字符串,而且redis服务器将返回一个相同的字符串 + * @example + * @param string $str 发送的字符串 + * @return string */ - public function echo() + public function echo($str) { } /** * - * + *获取所有命令列表 * @example - * @return + * @return array */ public function command() { @@ -1860,61 +2754,81 @@ public function command() /** * - * + *在redis服务器上执行命令 * @example + * @param string $command 执行的命令 + * @param string|array $args 参数 * @return */ - public function rawcommand() + public function rawcommand($command, $args) { } /** * - * + *获取集群节点信息 * @example - * @return + * @param string $args 参数(目前只支持slots) + * @return array */ - public function cluster() + public function cluster($args) { } /** * - *Issue the CLIENT command with various arguments. + *获取客户端相关参数或进行相关操作 * @example + * @param string $command 命令(CLIENT LIST +CLIENT GETNAME +CLIENT SETNAME [name] +CLIENT KILL [ip:port] +) + * @param string $args 参数 * @return */ - public function client() + public function client($command, $args) { } /** * - *Get or Set the redis config keys. + *获取或设置配置项. * @example *
      * $redis->config("GET", "*max-*-entries*");
      * $redis->config("SET", "dir", "/var/run/redis/dumps/");
      * 
+ * @param string $operation 操作(SET或GET) + * @param string $key 配置项或配置项匹配模式 + * @param string $value 配置值 * @return array */ - public function config() + public function config($operation, $key, $value) { } /** * - * + *查看订阅与发布系统状态,它由数个不同格式的子命令组成. * @example - * @return + *
+     * $redis->pubsub('channels'); // All channels
+     * $redis->pubsub('channels', '*pattern*'); // Just channels matching your pattern
+     * $redis->pubsub('numsub', array('chan1', 'chan2')); // Get subscriber counts for 'chan1' and 'chan2'
+     * $redis->pubsub('numpat'); // Get the number of pattern subscribers
+     * 
+ * @param string $subcommand 子命令(可以是channels, numsub, numpat) + * @param string|array $args 参数 + * @return array|int */ - public function pubsub() + public function pubsub($subcommand, $args) { } /** * - *Execute the Redis SCRIPT command to perform various operations on the scripting subsystem. + *在脚本子系统上执行redis命令 * @example *
      * $redis->script('load', $script);
@@ -1926,19 +2840,23 @@ public function pubsub()
      * SCRIPT FLUSH should always return TRUE
      * SCRIPT KILL will return true if a script was able to be killed and false if not
      * SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script
+     * @param string $command redis命令
+     * @param string|... $script 脚本
      * @return 
      */
-    public function script()
+    public function script($command, $script)
     {
     }
 
     /**
      * 
-     *Access the Redis slow log.
+     *获取慢操作日志
      * @example 
+     * @param string $command 执行的命令
+     * @param int $length 获取条目数
      * @return 
      */
-    public function slowlog()
+    public function slowlog($command, $length)
     {
     }
 
diff --git a/src/Redis/RedisClusterException.php b/src/Redis/RedisClusterException.php
index e16c779..8c68fe5 100644
--- a/src/Redis/RedisClusterException.php
+++ b/src/Redis/RedisClusterException.php
@@ -2,41 +2,45 @@
 /**
 * Redis自动补全类(基于最新的3.0.0版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2016/12/08
+* @modified 2017/12/28
 */
 
 /**
-*
+*redis 集群异常类
 */
 class RedisClusterException extends RuntimeException
 {
     /**
-     * @var unknown $message 
-     * 
+     * @var string $message 
+     * 异常错误信息
      * @access protected
+     */
     protected $message    =    '';
 
     /**
-     * @var unknown $code 
-     * 
+     * @var int $code 
+     * 异常错误码
      * @access protected
+     */
     protected $code    =    0;
 
     /**
-     * @var unknown $file 
-     * 
+     * @var string $file 
+     * 错误文件位置
      * @access protected
+     */
     protected $file;
 
     /**
-     * @var unknown $line 
-     * 
+     * @var int $line 
+     * 错误文件行数
      * @access protected
+     */
     protected $line;
 
     /**
      * 
-     *
+     *克隆魔术方法(这里禁止克隆)
      * @example 
      * @return 
      */
@@ -46,11 +50,11 @@ private final  function __clone()
 
     /**
      * 
-     *
+     *异常初始化
      * @example 
-     * @param  mixed $message 
-     * @param  mixed $code 
-     * @param  mixed $previous 
+     * @param string $message 异常提示信息
+     * @param int $code 异常错误码
+     * @param Throwable $previous 异常链中的前一个异常
      * @return 
      */
     public function __construct($message, $code, $previous)
@@ -59,7 +63,7 @@ public function __construct($message, $code, $previous)
 
     /**
      * 
-     *
+     *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)
      * @example 
      * @return 
      */
@@ -69,9 +73,9 @@ public function __wakeup()
 
     /**
      * 
-     *
+     *获取异常提示信息
      * @example 
-     * @return 
+     * @return string
      */
     public final  function getMessage()
     {
@@ -79,9 +83,9 @@ public final  function getMessage()
 
     /**
      * 
-     *
+     *获取异常代码
      * @example 
-     * @return 
+     * @return int
      */
     public final  function getCode()
     {
@@ -89,9 +93,9 @@ public final  function getCode()
 
     /**
      * 
-     *
+     *创建异常时的程序文件名称
      * @example 
-     * @return 
+     * @return string
      */
     public final  function getFile()
     {
@@ -99,9 +103,9 @@ public final  function getFile()
 
     /**
      * 
-     *
+     *获取创建的异常所在文件中的行号
      * @example 
-     * @return 
+     * @return int
      */
     public final  function getLine()
     {
@@ -109,9 +113,9 @@ public final  function getLine()
 
     /**
      * 
-     *
+     *获取异常追踪信息
      * @example 
-     * @return 
+     * @return array
      */
     public final  function getTrace()
     {
@@ -119,9 +123,9 @@ public final  function getTrace()
 
     /**
      * 
-     *
+     *返回异常链中的前一个异常
      * @example 
-     * @return 
+     * @return Throwable
      */
     public final  function getPrevious()
     {
@@ -129,9 +133,9 @@ public final  function getPrevious()
 
     /**
      * 
-     *
+     *获取字符串类型的异常追踪信息
      * @example 
-     * @return 
+     * @return string
      */
     public final  function getTraceAsString()
     {
@@ -139,7 +143,7 @@ public final  function getTraceAsString()
 
     /**
      * 
-     *
+     *将异常信息转化为字符串
      * @example 
      * @return 
      */
diff --git a/src/Redis/RedisException.php b/src/Redis/RedisException.php
index 589c35d..89ae9b5 100644
--- a/src/Redis/RedisException.php
+++ b/src/Redis/RedisException.php
@@ -2,41 +2,45 @@
 /**
 * Redis自动补全类(基于最新的3.0.0版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2016/12/08
+* @modified 2017/12/28
 */
 
 /**
-*
+*redis 异常类
 */
 class RedisException extends RuntimeException
 {
     /**
-     * @var unknown $message 
-     * 
+     * @var string $message 
+     * 异常错误信息
      * @access protected
+     */
     protected $message    =    '';
 
     /**
-     * @var unknown $code 
-     * 
+     * @var int $code 
+     * 异常错误码
      * @access protected
+     */
     protected $code    =    0;
 
     /**
-     * @var unknown $file 
-     * 
+     * @var string $file 
+     * 错误文件位置
      * @access protected
+     */
     protected $file;
 
     /**
-     * @var unknown $line 
-     * 
+     * @var int $line 
+     * 错误文件行数
      * @access protected
+     */
     protected $line;
 
     /**
      * 
-     *
+     *克隆魔术方法(这里禁止克隆)
      * @example 
      * @return 
      */
@@ -46,11 +50,11 @@ private final  function __clone()
 
     /**
      * 
-     *
+     *异常初始化
      * @example 
-     * @param  mixed $message 
-     * @param  mixed $code 
-     * @param  mixed $previous 
+     * @param string $message 异常提示信息
+     * @param int $code 异常错误码
+     * @param Throwable $previous 异常链中的前一个异常
      * @return 
      */
     public function __construct($message, $code, $previous)
@@ -59,7 +63,7 @@ public function __construct($message, $code, $previous)
 
     /**
      * 
-     *
+     *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)
      * @example 
      * @return 
      */
@@ -69,9 +73,9 @@ public function __wakeup()
 
     /**
      * 
-     *
+     *获取异常提示信息
      * @example 
-     * @return 
+     * @return string
      */
     public final  function getMessage()
     {
@@ -79,9 +83,9 @@ public final  function getMessage()
 
     /**
      * 
-     *
+     *获取异常代码
      * @example 
-     * @return 
+     * @return int
      */
     public final  function getCode()
     {
@@ -89,9 +93,9 @@ public final  function getCode()
 
     /**
      * 
-     *
+     *创建异常时的程序文件名称
      * @example 
-     * @return 
+     * @return string
      */
     public final  function getFile()
     {
@@ -99,9 +103,9 @@ public final  function getFile()
 
     /**
      * 
-     *
+     *获取创建的异常所在文件中的行号
      * @example 
-     * @return 
+     * @return int
      */
     public final  function getLine()
     {
@@ -109,9 +113,9 @@ public final  function getLine()
 
     /**
      * 
-     *
+     *获取异常追踪信息
      * @example 
-     * @return 
+     * @return array
      */
     public final  function getTrace()
     {
@@ -119,9 +123,9 @@ public final  function getTrace()
 
     /**
      * 
-     *
+     *返回异常链中的前一个异常
      * @example 
-     * @return 
+     * @return Throwable
      */
     public final  function getPrevious()
     {
@@ -129,9 +133,9 @@ public final  function getPrevious()
 
     /**
      * 
-     *
+     *获取字符串类型的异常追踪信息
      * @example 
-     * @return 
+     * @return string
      */
     public final  function getTraceAsString()
     {
@@ -139,7 +143,7 @@ public final  function getTraceAsString()
 
     /**
      * 
-     *
+     *将异常信息转化为字符串
      * @example 
      * @return 
      */
diff --git a/src/Swoole/Async.php b/src/Swoole/Async.php
index b17078e..a1fbf77 100644
--- a/src/Swoole/Async.php
+++ b/src/Swoole/Async.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/Atomic.php b/src/Swoole/Atomic.php
index 66ec9c0..e529163 100644
--- a/src/Swoole/Atomic.php
+++ b/src/Swoole/Atomic.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/Atomic/Long.php b/src/Swoole/Atomic/Long.php
index 5134eed..1dcf846 100644
--- a/src/Swoole/Atomic/Long.php
+++ b/src/Swoole/Atomic/Long.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/Buffer.php b/src/Swoole/Buffer.php
index ddab56c..94864e9 100644
--- a/src/Swoole/Buffer.php
+++ b/src/Swoole/Buffer.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/Channel.php b/src/Swoole/Channel.php
index e58de12..ceea4f6 100644
--- a/src/Swoole/Channel.php
+++ b/src/Swoole/Channel.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/Client.php b/src/Swoole/Client.php
index 9ed12c0..2efc2b0 100644
--- a/src/Swoole/Client.php
+++ b/src/Swoole/Client.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
@@ -60,68 +60,75 @@ class Client
     public $reuseCount    =    0;
 
     /**
-     * @var unknown $type 
-     * 
+     * @var int $type 
+     * 连接的类型
      * @access public
      */
     public $type    =    0;
 
     /**
-     * @var unknown $id 
-     * 
+     * @var int $id 
+     * 客户端连接ID
      * @access public
      */
     public $id    =    0;
 
     /**
-     * @var unknown $setting 
-     * 
+     * @var array $setting 
+     * 配置选项
      * @access public
      */
     public $setting;
 
     /**
-     * @var unknown $onConnect 
-     * 
+     * @var callable $onConnect 
+     * 连接的回调函数
      * @access public
      */
     public $onConnect;
 
     /**
-     * @var unknown $onError 
-     * 
+     * @var callable $onError 
+     * 发生错误时的回调函数
      * @access public
      */
     public $onError;
 
     /**
-     * @var unknown $onReceive 
-     * 
+     * @var callable $onReceive 
+     * 客户端收到来自于服务器端的数据时会回调此函数
      * @access public
      */
     public $onReceive;
 
     /**
-     * @var unknown $onClose 
-     * 
+     * @var callable $onClose 
+     * 连接被关闭时回调此函数
      * @access public
      */
     public $onClose;
 
     /**
-     * @var unknown $onBufferFull 
-     * 
+     * @var callable $onBufferFull 
+     * 当缓存区达到最高水位时触发此事件
      * @access public
      */
     public $onBufferFull;
 
     /**
-     * @var unknown $onBufferEmpty 
-     * 
+     * @var callable $onBufferEmpty 
+     * 当缓存区低于最低水位线时触发此事件
      * @access public
      */
     public $onBufferEmpty;
 
+    /**
+     * @var callable $onSSLReady 
+     * 当SSL连接就绪时的回调函数
+     * @access public
+     */
+    public $onSSLReady;
+
     /**
      * 
      *创建tcp客户端对象
@@ -195,9 +202,9 @@ public function send($data, $flag)
 
     /**
      * 
-     *
+     *将客户端收到的数据重定向到另外一个文件描述符,可以是服务器的连接fd、stream资源、sockets资源、其他Swoole_Client、Swoole_Process的管道
      * @example 
-     * @param  mixed $dst_socket 
+     * @param int $dst_socket 目标文件描述符
      * @return 
      */
     public function pipe($dst_socket)
@@ -270,6 +277,37 @@ public function resume()
     {
     }
 
+    /**
+     * 
+     *动态开启SSL隧道加密。客户端在建立连接时使用明文通信,中途希望改为SSL隧道加密通信,可以使用enableSSL方法来实现
+     * @example 
+     * @param callable $callback 启用后的回调函数
+     * @return 
+     */
+    public function enableSSL(Callable $callback)
+    {
+    }
+
+    /**
+     * 
+     *获取服务器端证书信息
+     * @example 
+     * @return string | bool
+     */
+    public function getPeerCert()
+    {
+    }
+
+    /**
+     * 
+     *验证服务端证书信息
+     * @example 
+     * @return 
+     */
+    public function verifyPeerCert()
+    {
+    }
+
     /**
      * 
      *返回swoole_client的连接状态
diff --git a/src/Swoole/Connection/Iterator.php b/src/Swoole/Connection/Iterator.php
index 7c9e631..8595e45 100644
--- a/src/Swoole/Connection/Iterator.php
+++ b/src/Swoole/Connection/Iterator.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/Coroutine.php b/src/Swoole/Coroutine.php
index 1e9ff74..d6dc196 100644
--- a/src/Swoole/Coroutine.php
+++ b/src/Swoole/Coroutine.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/Coroutine/Client.php b/src/Swoole/Coroutine/Client.php
index 7c0ab91..5484417 100644
--- a/src/Swoole/Coroutine/Client.php
+++ b/src/Swoole/Coroutine/Client.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/Coroutine/Http/Client.php b/src/Swoole/Coroutine/Http/Client.php
index 58b7046..a1dd79a 100644
--- a/src/Swoole/Coroutine/Http/Client.php
+++ b/src/Swoole/Coroutine/Http/Client.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/Coroutine/MySQL.php b/src/Swoole/Coroutine/MySQL.php
index f4c992c..246f522 100644
--- a/src/Swoole/Coroutine/MySQL.php
+++ b/src/Swoole/Coroutine/MySQL.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/Coroutine/MySQL/Exception.php b/src/Swoole/Coroutine/MySQL/Exception.php
index 6c651d2..6880554 100644
--- a/src/Swoole/Coroutine/MySQL/Exception.php
+++ b/src/Swoole/Coroutine/MySQL/Exception.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/Coroutine/Redis.php b/src/Swoole/Coroutine/Redis.php
new file mode 100644
index 0000000..0303f0a
--- /dev/null
+++ b/src/Swoole/Coroutine/Redis.php
@@ -0,0 +1,1587 @@
+ '192.168.56.102',
+     *     'user' => 'test',
+     *     'password' => 'test',
+     *     'database' => 'test',
+     *     'charset' => 'utf8',
+     * );
+     * 回调函数:function onConnect(swoole_mysql $db, bool $result);
+     * @param array $server_config 连接配置信息
      * @return 
      */
     public function connect(Array $server_config)
@@ -106,11 +113,11 @@ public function connect(Array $server_config)
 
     /**
      * 
-     *
+     *执行sql语句
      * @example 
-     * @param  mixed $sql 
-     * @param  mixed $timeout 
-     * @return 
+     * @param string $sql 要执行的sql语句
+     * @param double $timeout 超时时间,超时的话会断开MySQL连接,0表示不设置超时时间
+     * @return array | bool
      */
     public function query($sql, $timeout)
     {
@@ -118,17 +125,19 @@ public function query($sql, $timeout)
 
     /**
      * 
-     *
+     *从服务器端接收数据
      * @example 
-     * @return 
+     * @param int $size 接收数据的缓存区最大长度,此参数不要设置过大,否则会占用较大内存
+     * @param boolean $flag 是否等待所有数据到达后返回
+     * @return string
      */
-    public function recv()
+    public function recv($size, $flag)
     {
     }
 
     /**
      * 
-     *
+     *启动事务
      * @example 
      * @return 
      */
@@ -138,7 +147,7 @@ public function begin()
 
     /**
      * 
-     *
+     *提交事务
      * @example 
      * @return 
      */
@@ -148,7 +157,7 @@ public function commit()
 
     /**
      * 
-     *
+     *回滚事务(必须先调用begin启动事务才能调用rollback否则底层会抛出异常)
      * @example 
      * @return 
      */
@@ -158,9 +167,9 @@ public function rollback()
 
     /**
      * 
-     *
+     *设置是否延迟
      * @example 
-     * @param  mixed $defer 
+     * @param boolean $defer bool值,为true时,表明该Client要延迟收包,为false时,表明该Client非延迟收包,默认值为true
      * @return 
      */
     public function setDefer($defer)
@@ -169,9 +178,9 @@ public function setDefer($defer)
 
     /**
      * 
-     *
+     *返回当前设置的defer
      * @example 
-     * @return 
+     * @return boolean
      */
     public function getDefer()
     {
@@ -179,7 +188,7 @@ public function getDefer()
 
     /**
      * 
-     *
+     *关闭mysql连接
      * @example 
      * @return 
      */
@@ -189,7 +198,7 @@ public function close()
 
     /**
      * 
-     *
+     *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化)
      * @example 
      * @return 
      */
@@ -199,7 +208,7 @@ public function __sleep()
 
     /**
      * 
-     *
+     *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务)
      * @example 
      * @return 
      */
diff --git a/src/Swoole/swoole_mysql_coro_exception.php b/src/Swoole/swoole_mysql_coro_exception.php
index a525e50..7ef287c 100644
--- a/src/Swoole/swoole_mysql_coro_exception.php
+++ b/src/Swoole/swoole_mysql_coro_exception.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/swoole_mysql_exception.php b/src/Swoole/swoole_mysql_exception.php
index 50662d6..09ea6d7 100644
--- a/src/Swoole/swoole_mysql_exception.php
+++ b/src/Swoole/swoole_mysql_exception.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/swoole_process.php b/src/Swoole/swoole_process.php
index da1a74d..2f471aa 100644
--- a/src/Swoole/swoole_process.php
+++ b/src/Swoole/swoole_process.php
@@ -2,7 +2,7 @@
 /**
 * Swoole自动补全类(基于最新的2.0.10版本)
 * @author shixinke(http://www.shixinke.com)
-* @modified 2017/12/26
+* @modified 2017/12/28
 */
 
 /**
diff --git a/src/Swoole/swoole_redis.php b/src/Swoole/swoole_redis.php
new file mode 100644
index 0000000..d03098e
--- /dev/null
+++ b/src/Swoole/swoole_redis.php
@@ -0,0 +1,180 @@
+set('key', 'value');
+     * 带有效期的设置:
+     * $redis->set('key','value', 10);
+     * 当键不存在时,设置期有效期为10秒:
+     * $redis->set('key', 'value', Array('nx', 'ex'=>10));
+     * 当键存在时,设置期有效期为1000毫秒:
+     * $redis->set('key', 'value', Array('xx', 'px'=>1000));
+     * 
+     * @param string $key 设置的缓存键
+     * @param string $value 设置的缓存值
+     * @param int|array $options 附加项,可以是超时时间或者一个选项数组
+     * @return bool
+     */
+    public function set($key, $value, $options)
+    {
+    }
+
+    /**
+     * 
+     *修改某个键的某个位置的位值
+     * @example 
+     * 
+     * $redis->set('key', "*");     // ord("*") = 42 = 0x2f = "0010 1010"
+     * $redis->setBit('key', 5, 1); // returns 0
+     * $redis->setBit('key', 7, 1); // returns 0
+     * $redis->get('key');          // chr(0x2f) = "/" = b("0010 1111")
+     * 
+ * @param string $key 键名 + * @param int $offset 开始位置 + * @param boolean|int $value 新值 + * @return int: + */ + public function setBit($key, $offset, $value) + { + } + + /** + * + *设置键值并设置有效期 + * @example $redis->setex('key', 3600, 'value'); + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int $ttl 有效期 + * @return bool + */ + public function setEx($key, $value, $ttl) + { + } + + /** + * + *设置键值并设置有效期(毫秒为单位) + * @example + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int $ttl 有效期(毫秒为单位) + * @return + */ + public function psetEx($key, $value, $ttl) + { + } + + /** + * + *给列表指定位置设置新值 + * @example + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->lGet('key1', 0);     // 'A'
+     * $redis->lSet('key1', 0, 'X');
+     * $redis->lGet('key1', 0);     // 'X'
+     * 
+ * @param string $key 键名 + * @param int $index 索引值 + * @param string $value 新值 + * @return boolean + */ + public function lSet($key, $index, $value) + { + } + + /** + * + *获取指定的key的值 + * @example $redis->get('key'); + * @return string|bool + */ + public function get() + { + } + + /** + * + *批量获取键名 + * @example + *
+     * $redis->delete('x', 'y', 'z', 'h');	// remove x y z
+     * $redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'));
+     * $redis->hset('h', 'field', 'value');
+     * var_dump($redis->mget(array('x', 'y', 'z', 'h')));
+     * // Output:
+     * // array(3) {
+     * // [0]=>
+     * // string(1) "a"
+     * // [1]=>
+     * // string(1) "b"
+     * // [2]=>
+     * // string(1) "c"
+     * // [3]=>
+     * // bool(false)
+     * // }
+     * 
+ * @param array $keys 键名数组 + * @return + */ + public function mGet(Array $keys) + { + } + + /** + * + *删除一个或多个键 + * @example $redis->delete('key1', 'key2'); + * $redis->delete(array('key3', 'key4')); + * @param array|string $keys 键名 + * @return int + */ + public function del($keys) + { + } + + /** + * + *删除字典的某个或某些字段 + * @example + *
+     * $redis->hMSet('h',
+     * array(
+     * 'f1' => 'v1',
+     * 'f2' => 'v2',
+     * 'f3' => 'v3',
+     * 'f4' => 'v4',
+     * ));
+     * var_dump( $redis->hDel('h', 'f1') );        // int(1)
+     * var_dump( $redis->hDel('h', 'f2', 'f3') );  // int(2)
+     * s
+     * var_dump( $redis->hGetAll('h') );
+     * //// Output:
+     * //  array(1) {
+     * //    ["f4"]=> string(2) "v4"
+     * //  }
+     * 
+ * @param string $key 键名 + * @param string|array $fields 字段名 + * @return int + */ + public function hDel($key, $fields) + { + } + + /** + * + *为字典的字段设置值 + * @example + *
+     * $redis->delete('h')
+     * $redis->hSet('h', 'key1', 'hello');  // 1, 'key1' => 'hello' in the hash at "h"
+     * $redis->hGet('h', 'key1');           // returns "hello"
+     * $redis->hSet('h', 'key1', 'plop');   // 0, value was replaced.
+     * $redis->hGet('h', 'key1');           // returns "plop"
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param string $value 字段值 + * @return long + */ + public function hSet($key, $field, $value) + { + } + + /** + * + *批量设置字典字段的值 + * @example + *
+     * $redis->delete('user:1');
+     * $redis->hMset('user:1', array('name' => 'Joe', 'salary' => 2000));
+     * $redis->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now.
+     * 
+ * @param string $key 键名 + * @param array $fields 字段键值对 + * @return boolean + */ + public function hMSet($key, Array $fields) + { + } + + /** + * + *当字典的字段不存在时,为其设置值 + * @example + *
+     * $redis->delete('h')
+     * $redis->hSetNx('h', 'key1', 'hello'); // TRUE, 'key1' => 'hello' in the hash at "h"
+     * $redis->hSetNx('h', 'key1', 'world'); // FALSE, 'key1' => 'hello' in the hash at "h". No change since the field
+     * wasn't replaced.
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param string $value 字段值 + * @return bool + */ + public function hSetNx($key, $field, $value) + { + } + + /** + * + *删除一个或多个键 + * @example $redis->delete('key1', 'key2'); + * $redis->delete(array('key3', 'key4')); + * @param array|string $keys 键名 + * @return int + */ + public function delete($keys) + { + } + + /** + * + *批量设置值 + * @example + *
+     * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
+     * var_dump($redis->get('key0'));
+     * var_dump($redis->get('key1'));
+     * // Output:
+     * // string(6) "value0"
+     * // string(6) "value1"
+     * 
+ * @param array $values 要设置的键值对 + * @return bool + */ + public function mSet(Array $values) + { + } + + /** + * + *批量设置值(当不存在时设置) + * @example + *
+     * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
+     * var_dump($redis->get('key0'));
+     * var_dump($redis->get('key1'));
+     * // Output:
+     * // string(6) "value0"
+     * // string(6) "value1"
+     * 
+ * @param array $values 要设置的键值对 + * @return bool + */ + public function mSetNx(Array $values) + { + } + + /** + * + *根据匹配模式获取键名(如*) + * @example + * $allKeys = $redis->keys('*'); + * $keyWithUserPrefix = $redis->keys('user*'); + * @param string $pattern 匹配模式 + * @return array + */ + public function getKeys($pattern) + { + } + + /** + * + *根据匹配模式获取键名(如*) + * @example + * $allKeys = $redis->keys('*'); + * $keyWithUserPrefix = $redis->keys('user*'); + * @param string $pattern 匹配模式 + * @return array + */ + public function keys($pattern) + { + } + + /** + * + *判断键是否存在 + * @example + *
+     * $redis->set('key', 'value');
+     * $redis->exists('key');               //  TRUE
+     * $redis->exists('NonExistingKey');    // FALSE
+     * 
+ * @param string $key 键名 + * @return bool + */ + public function exists($key) + { + } + + /** + * + *获取指定键的数据类型(需要根据常量匹配) + * @example $redis->type('key'); + * @param string $key 键名 + * @return int + */ + public function type($key) + { + } + + /** + * + *获取键值的长度 + * @example + *
+     * $redis->set('key', 'value');
+     * $redis->strlen('key'); // 5
+     * 
+ * @param string $key 键名 + * @return int + */ + public function strLen($key) + { + } + + /** + * + *从列表左侧删除一个元素 + * @example + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->lPop('key1');        // key1 => [ 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @return string + */ + public function lPop($key) + { + } + + /** + * + *是一个阻塞lPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表头部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,blPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 + * @example + *
+     * // Non blocking feature
+     * $redis->lPush('key1', 'A');
+     * $redis->delete('key2');
+     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * // Blocking feature
+     * // process 1
+     * $redis->delete('key1');
+     * $redis->blPop('key1', 10);
+     * // blocking for 10 seconds
+     * // process 2
+     * $redis->lPush('key1', 'A');
+     * // process 1
+     * // array('key1', 'A') is returned
+     * 
+ * @param string|...|array $key 键名 + * @param int $timeout 超时时间 + * @return array + */ + public function blPop($key, $timeout) + { + } + + /** + * + *从列表右侧删除一个元素 + * @example + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->rPop('key1');        // key1 => [ 'A', 'B' ]
+     * 
+ * @param string $key 键名 + * @return string + */ + public function rPop($key) + { + } + + /** + * + *是一个阻塞rPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表尾部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,brPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 + * @example + *
+     * // Non blocking feature
+     * $redis->lPush('key1', 'A');
+     * $redis->delete('key2');
+     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * // Blocking feature
+     * // process 1
+     * $redis->delete('key1');
+     * $redis->blPop('key1', 10);
+     * // blocking for 10 seconds
+     * // process 2
+     * $redis->lPush('key1', 'A');
+     * // process 1
+     * // array('key1', 'A') is returned
+     * 
+ * @param string|...|array $key 键名 + * @param int $timeout 超时时间 + * @return array + */ + public function brPop($key, $timeout) + { + } + + /** + * + *阻塞执行rpoplpush + * @example + * @param string $srcKey 要删除元素的队列键名 + * @param string $dstKey 要插入元素的队列的键名 + * @return string + */ + public function bRPopLPush($srcKey, $dstKey) + { + } + + /** + * + *返回列表的长度 + * @example + * @param string|...|array $key 键名 + * @return long | bool + */ + public function lSize($key) + { + } + + /** + * + *返回列表的长度 + * @example + * @param string|...|array $key 键名 + * @return long | bool + */ + public function lLen($key) + { + } + + /** + * + *返回集合的元素个数 + * @example + * @param string $key 键名 + * @return long + */ + public function sSize($key) + { + } + + /** + * + *返回集合的元素个数 + * @example + * @param string $key 键名 + * @return long + */ + public function scard($key) + { + } + + /** + * + *随机删除元素的某个或某些成员,并返回这个删除的成员. + * @example + *
+     * $redis->sAdd('key1' , 'set1');
+     * $redis->sAdd('key1' , 'set2');
+     * $redis->sAdd('key1' , 'set3');   // 'key1' => {'set3', 'set1', 'set2'}
+     * $redis->sPop('key1');            // 'set1', 'key1' => {'set3', 'set2'}
+     * $redis->sPop('key1');            // 'set3', 'key1' => {'set2'}
+     * 
+ * @param string $key 键名 + * @param int $count 删除个数 + * @return string | bool + */ + public function sPop($key, $count) + { + } + + /** + * + *返回集合的所有成员 + * @example + *
+     * $redis->delete('s');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'b');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'c');
+     * var_dump($redis->sMembers('s'));
+     * //array(3) {
+     * //  [0]=>
+     * //  string(1) "c"
+     * //  [1]=>
+     * //  string(1) "a"
+     * //  [2]=>
+     * //  string(1) "b"
+     * //}
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array + */ + public function sMembers($key) + { + } + + /** + * + *返回集合的所有成员 + * @example + *
+     * $redis->delete('s');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'b');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'c');
+     * var_dump($redis->sMembers('s'));
+     * //array(3) {
+     * //  [0]=>
+     * //  string(1) "c"
+     * //  [1]=>
+     * //  string(1) "a"
+     * //  [2]=>
+     * //  string(1) "b"
+     * //}
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array + */ + public function sGetMembers($key) + { + } + + /** + * + *随机返回一个集合的元素(不会删除它) + * @example + *
+     * $redis->sAdd('key1' , 'one');
+     * $redis->sAdd('key1' , 'two');
+     * $redis->sAdd('key1' , 'three');              // 'key1' => {'one', 'two', 'three'}
+     * var_dump( $redis->sRandMember('key1') );     // 'key1' => {'one', 'two', 'three'}
+     * // string(5) "three"
+     * var_dump( $redis->sRandMember('key1', 2) );  // 'key1' => {'one', 'two', 'three'}
+     * // array(2) {
+     * //   [0]=> string(2) "one"
+     * //   [1]=> string(2) "three"
+     * // }
+     * 
+ * @param string $key 键名 + * @return string | bool + */ + public function sRandMember($key) + { + } + + /** + * + *移除指定键的有效期,让它永久有效 + * @example $redis->persist('key'); + * @param string $key 键名 + * @return bool: + */ + public function persist($key) + { + } + + /** + * + *返回指定键的有效时间(秒) + * @example $redis->ttl('key'); + * @param string $key 键名 + * @return long + */ + public function ttl($key) + { + } + + /** + * + *返回指定键的有效时间(毫秒) + * @example $redis->pttl('key'); + * @param string $key 键名 + * @return long + */ + public function pttl($key) + { + } + + /** + * + *获取有序集合的成员数 + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCard('key');            // 3
+     * 
+ * @param string $key 集合键名 + * @return int + */ + public function zCard($key) + { + } + + /** + * + *获取有序集合的成员数 + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCard('key');            // 3
+     * 
+ * @param string $key 集合键名 + * @return int + */ + public function zSize($key) + { + } + + /** + * + *获取字典的字段个数 + * @example + *
+     * $redis->delete('h')
+     * $redis->hSet('h', 'key1', 'hello');
+     * $redis->hSet('h', 'key2', 'plop');
+     * $redis->hLen('h'); // returns 2
+     * 
+ * @param string $key 键名 + * @return int + */ + public function hLen($key) + { + } + + /** + * + *获取字典的字段名称列表. + * @example + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hKeys('h'));
+     * // Output:
+     * // array(4) {
+     * // [0]=>
+     * // string(1) "a"
+     * // [1]=>
+     * // string(1) "b"
+     * // [2]=>
+     * // string(1) "c"
+     * // [3]=>
+     * // string(1) "d"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array + */ + public function hKeys($key) + { + } + + /** + * + *获取字典的字段值列表 + * @example + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hVals('h'));
+     * // Output
+     * // array(4) {
+     * //   [0]=>
+     * //   string(1) "x"
+     * //   [1]=>
+     * //   string(1) "y"
+     * //   [2]=>
+     * //   string(1) "z"
+     * //   [3]=>
+     * //   string(1) "t"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array + */ + public function hVals($key) + { + } + + /** + * + *获取字典所有字段键值对 + * @example + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hGetAll('h'));
+     * // Output:
+     * // array(4) {
+     * //   ["a"]=>
+     * //   string(1) "x"
+     * //   ["b"]=>
+     * //   string(1) "y"
+     * //   ["c"]=>
+     * //   string(1) "z"
+     * //   ["d"]=>
+     * //   string(1) "t"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array + */ + public function hGetAll($key) + { + } + + /** + * + *调试命令(不建议使用) + * @example + * @return + */ + public function debug() + { + } + + /** + * + *将dump导出的二进制数据恢复到可读的字符串. + * @example + *
+     * $redis->set('foo', 'bar');
+     * $val = $redis->dump('foo');
+     * $redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo'
+     * 
+ * @param string $key 键名 + * @param int $ttl 有效期 + * @param string $value dump导出的二进制数据 + * @return + */ + public function restore($key, $ttl, $value) + { + } + + /** + * + *将某个键导出为一个二进制数据. + * @example + *
+     * $redis->set('foo', 'bar');
+     * $val = $redis->dump('foo'); // $val will be the Redis encoded key value
+     * 
+ * @param string $key 键名 + * @return string + */ + public function dump($key) + { + } + + /** + * + *给键重命名 + * @example + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean + */ + public function renameKey($srcKey, $dstKey) + { + } + + /** + * + *给键重命名 + * @example + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean + */ + public function rename($srcKey, $dstKey) + { + } + + /** + * + *当目标键名不存在时,给键重命名 + * @example + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean + */ + public function renameNx($srcKey, $dstKey) + { + } + + /** + * + *从一个队列的队尾删除一个元素,并将该元素插入到另一个队列的头部 + * @example + *
+     * $redis->delete('x', 'y');
+     * $redis->lPush('x', 'abc');
+     * $redis->lPush('x', 'def');
+     * $redis->lPush('y', '123');
+     * $redis->lPush('y', '456');
+     * // move the last of x to the front of y.
+     * var_dump($redis->rpoplpush('x', 'y'));
+     * var_dump($redis->lRange('x', 0, -1));
+     * var_dump($redis->lRange('y', 0, -1));
+     * //Output:
+     * //
+     * //string(3) "abc"
+     * //array(1) {
+     * //  [0]=>
+     * //  string(3) "def"
+     * //}
+     * //array(3) {
+     * //  [0]=>
+     * //  string(3) "abc"
+     * //  [1]=>
+     * //  string(3) "456"
+     * //  [2]=>
+     * //  string(3) "123"
+     * //}
+     * 
+ * @param string $srcKey 要删除元素的队列键名 + * @param string $dstKey 要插入元素的队列的键名 + * @return string + */ + public function rpoplpush($srcKey, $dstKey) + { + } + + /** + * + *返回一个随机的键 + * @example + *
+     * $key = $redis->randomKey();
+     * $surprise = $redis->get($key);  // who knows what's in there.
+     * 
+ * @return string + */ + public function randomKey() + { + } + + /** + * + *检查当前redis连接状态(成功时返回PONG) + * @example + * @return string + */ + public function ping() + { + } + + /** + * + *设置连接的认证密码 + * @example $redis->auth('foobared'); + * @param string $password 认证密码 + * @return bool: + */ + public function auth($password) + { + } + + /** + * + *取消观察某个键在其他客户端的变化情况 + * @example + * @param string|array $keys 键名 + * @return + */ + public function unwatch($keys) + { + } + + /** + * + *观察某个键在其他客户端的变化情况. + * @example + *
+     * $redis->watch('x');
+     * // long code here during the execution of which other clients could well modify `x`
+     * $ret = $redis->multi()
+     * ->incr('x')
+     * ->exec();
+     * // $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.
+     * 
+ * @param string|array $keys 键名 + * @return + */ + public function watch($keys) + { + } + + /** + * + *将数据同步到硬盘上 + * @example $redis->save(); + * @return boolean + */ + public function save() + { + } + + /** + * + *将数据存入到硬盘上(异步操作) + * @example + * @return + */ + public function bgSave() + { + } + + /** + * + *获取上次数据同步到硬盘的时间 + * @example $redis->lastSave(); + * @return int + */ + public function lastSave() + { + } + + /** + * + *删除当前数据库的所有键 + * @example $redis->flushDB(); + * @return bool + */ + public function flushDB() + { + } + + /** + * + *删除当前实例的所有键 + * @example $redis->flushAll(); + * @return bool + */ + public function flushAll() + { + } + + /** + * + *获取当前数据库的键的个数 + * @example + *
+     * $count = $redis->dbSize();
+     * echo "Redis has $count keys\n";
+     * 
+ * @return int + */ + public function dbSize() + { + } + + /** + * + *开启后台写AOF日志操作 + * @example $redis->bgrewriteaof(); + * @return bool + */ + public function bgrewriteaof() + { + } + + /** + * + *返回当前redis服务器时间. + * @example + *
+     * var_dump( $redis->time() );
+     * // array(2) {
+     * //   [0] => string(10) "1342364352"
+     * //   [1] => string(6) "253002"
+     * // }
+     * 
+ * @return int + */ + public function time() + { + } + + /** + * + *返回当前连接的服务器的角色,如master、alone、slave、sentinel + * @example + * @return string + */ + public function role() + { + } + + /** + * + *修改某个键的某个位置的值 + * @example + *
+     * $redis->set('key', 'Hello world');
+     * $redis->setRange('key', 6, "redis"); // returns 11
+     * $redis->get('key');                  // "Hello redis"
+     * 
+ * @param string $key 键名 + * @param int $offset 开始位置 + * @param string $value 被替换的子串的值 + * @return string + */ + public function setRange($key, $offset, $value) + { + } + + /** + * + *当键不存在时设置其值 + * @example + * $redis->setnx('key', 'value'); + * + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @return bool: + */ + public function setNx($key, $value) + { + } + + /** + * + *设置键的值,并返回它的旧的缓存值 + * @example + *
+     * $redis->set('x', '42');
+     * $exValue = $redis->getSet('x', 'lol');   // return '42', replaces x by 'lol'
+     * $newValue = $redis->get('x')'            // return 'lol'
+     * 
+ * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @return string + */ + public function getSet($key, $value) + { + } + + /** + * + *将字符串追加到键值后(返回值的长度) + * @example + *
+     * $redis->set('key', 'value1');
+     * $redis->append('key', 'value2'); // 12
+     * $redis->get('key');              // 'value1value2'
+     * 
+ * @param string $key 键名 + * @param string $value 追加的值 + * @return int + */ + public function append($key, $value) + { + } + + /** + * + *如果列表存在,从左侧(头部)向列表插入元素 + * @example + *
+     * $redis->delete('key1');
+     * $redis->lPushx('key1', 'A');     // returns 0
+     * $redis->lPush('key1', 'A');      // returns 1
+     * $redis->lPushx('key1', 'B');     // returns 2
+     * $redis->lPushx('key1', 'C');     // returns 3
+     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int + */ + public function lPushx($key, $value) + { + } + + /** + * + *从左侧(头部)向列表插入元素 + * @example + *
+     * $redis->lPush('l', 'v1', 'v2', 'v3', 'v4')   // int(4)
+     * var_dump( $redis->lRange('l', 0, -1) );
+     * //// Output:
+     * // array(4) {
+     * //   [0]=> string(2) "v4"
+     * //   [1]=> string(2) "v3"
+     * //   [2]=> string(2) "v2"
+     * //   [3]=> string(2) "v1"
+     * // }
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int + */ + public function lPush($key, $value) + { + } + + /** + * + *从右侧(尾部)向列表插入元素 + * @example + *
+     * $redis->rPush('l', 'v1', 'v2', 'v3', 'v4');    // int(4)
+     * var_dump( $redis->lRange('l', 0, -1) );
+     * //// Output:
+     * // array(4) {
+     * //   [0]=> string(2) "v1"
+     * //   [1]=> string(2) "v2"
+     * //   [2]=> string(2) "v3"
+     * //   [3]=> string(2) "v4"
+     * // }
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int + */ + public function rPush($key, $value) + { + } + + /** + * + *如果列表存在,从右侧(尾部)向列表插入元素 + * @example + *
+     * $redis->delete('key1');
+     * $redis->rPushx('key1', 'A'); // returns 0
+     * $redis->rPush('key1', 'A'); // returns 1
+     * $redis->rPushx('key1', 'B'); // returns 2
+     * $redis->rPushx('key1', 'C'); // returns 3
+     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int + */ + public function rPushx($key, $value) + { + } + + /** + * + *是否包含某个成员 + * @example + * @param string $key 键名 + * @param string $member 成员值 + * @return boolean + */ + public function sContains($key, $member) + { + } + + /** + * + *是否包含某个成员 + * @example + * @param string $key 键名 + * @param string $member 成员值 + * @return boolean + */ + public function sismember($key, $member) + { + } + + /** + * + *获取指定成员的排序值(分数) + * @example + *
+     * $redis->zAdd('key', 2.5, 'val2');
+     * $redis->zScore('key', 'val2'); // 2.5
+     * 
+ * @param string $key 集合键名 + * @param string $member 成员值 + * @return double + */ + public function zScore($key, $member) + { + } + + /** + * + *获取成员的排序值 + * @example + *
+     * $redis->delete('z');
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zRank('key', 'one');     // 0
+     * $redis->zRank('key', 'two');     // 1
+     * $redis->zRevRank('key', 'one');  // 1
+     * $redis->zRevRank('key', 'two');  // 0
+     * 
+ * @param string $key 集合键名 + * @param string $member 成员值 + * @return int + */ + public function zRank($key, $member) + { + } + + /** + * + *获取成员的排位值(倒数) + * @example + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int + */ + public function zRevRank($key, $member) + { + } + + /** + * + *获取字典的某个字段的值 + * @example + * @param string $key 键名 + * @param string $field 字段名 + * @return string + */ + public function hGet($key, $field) + { + } + + /** + * + *批量获取字典的字段值 + * @example + * @param string $key 键名 + * @param array $fields 字段名列表 + * @return array + */ + public function hMGet($key, Array $fields) + { + } + + /** + * + *判断字典的某个字段是否存在. + * @example + *
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hExists('h', 'a');               //  TRUE
+     * $redis->hExists('h', 'NonExistingKey');  // FALSE
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @return bool + */ + public function hExists($key, $field) + { + } + + /** + * + *将消息发布到消息通道(队列). + * @example $redis->publish('chan-1', 'hello, world!'); // send message. + * @param string $channel 消息频道 + * @param string $message 消息 + * @return int + */ + public function publish($channel, $message) + { + } + + /** + * + *给有序集合成员增加排序值 + * @example + *
+     * $redis->delete('key');
+     * $redis->zIncrBy('key', 2.5, 'member1');  // key or member1 didn't exist, so member1's score is to 0
+     * // before the increment and now has the value 2.5
+     * $redis->zIncrBy('key', 1, 'member1');    // 3.5
+     * 
+ * @param string $key 目标集合键名 + * @param double $step 增加的步长 + * @param string $member 成员 + * @return float + */ + public function zIncrBy($key, $step, $member) + { + } + + /** + * + *向有序集合插入元素 + * @example + *
+     * 
+     * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
+     * $redis->zRem('z', 'v2', 'v3');                           // int(2)
+     * var_dump( $redis->zRange('z', 0, -1) );
+     * //// Output:
+     * // array(2) {
+     * //   [0]=> string(2) "v1"
+     * //   [1]=> string(2) "v4"
+     * // }
+     * 
+ *
+ * @param string $key 集合键名 + * @param double $score 排序值 + * @param string $value 元素值 + * @return int + */ + public function zAdd($key, $score, $value) + { + } + + /** + * + *根据排序值范围来删除成员 + * @example + * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return long + */ + public function zDeleteRangeByScore($key, $start, $end) + { + } + + /** + * + *根据排序值范围来删除成员 + * @example + * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return long + */ + public function zRemRangeByScore($key, $start, $end) + { + } + + /** + * + *获取指定排序范围的成员数. + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCount('key', 0, 3); // 2, corresponding to array('val0', 'val2')
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int + */ + public function zCount($key, $start, $end) + { + } + + /** + * + *获取有序集合中指定范围的成员 + * @example + *
+     * $redis->zAdd('key1', 0, 'val0');
+     * $redis->zAdd('key1', 2, 'val2');
+     * $redis->zAdd('key1', 10, 'val10');
+     * $redis->zRange('key1', 0, -1); // array('val0', 'val2', 'val10')
+     * // with scores
+     * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param boolean $withScores 是否返回成员的排序值 + * @return array + */ + public function zRange($key, $start, $end, $withScores) + { + } + + /** + * + *获取有序集合中指定范围的成员(倒序排列) + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRevRange('key', 0, -1); // array('val10', 'val2', 'val0')
+     * // with scores
+     * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param boolean $withScores 是否返回成员的排序值 + * @return array + */ + public function zRevRange($key, $start, $end, $withScores) + { + } + + /** + * + *获取有序集合中指定范围的成员(按排序值排列) + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) + * @return array + */ + public function zRangeByScore($key, $start, $end, Array $options) + { + } + + /** + * + *获取有序集合中指定范围的成员(按排序值倒序排列) + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) + * @return array + */ + public function zRevRangeByScore($key, $start, $end, Array $options) + { + } + + /** + * + *按字母字典的顺序返回成员 + * @example + *
+     * foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g') as $char) {
+     * $redis->zAdd('key', $char);
+     * }
+     * $redis->zRangeByLex('key', '-', '[c'); // array('a', 'b', 'c')
+     * $redis->zRangeByLex('key', '-', '(c'); // array('a', 'b')
+     * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c')
+     * 
+ * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @param long $offset 索引开始值 + * @param long $limit 成员数 + * @return array + */ + public function zRangeByLex($key, $min, $max, $offset, $limit) + { + } + + /** + * + *按字母字典的顺序返回成员(倒序排序) + * @example + * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @param long $offset 索引开始值 + * @param long $limit 成员数 + * @return + */ + public function zRevRangeByLex($key, $min, $max, $offset, $limit) + { + } + + /** + * + *将两个有序集合的交集存入到一个指定的键中 + * @example + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->delete('ko4');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k1', 3, 'val3');
+     * $redis->zAdd('k2', 2, 'val1');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
+     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
+     * // Weighted zInter
+     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
+     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int + */ + public function zInter($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + { + } + + /** + * + *将两个有序集合的交集存入到一个指定的键中 + * @example + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->delete('ko4');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k1', 3, 'val3');
+     * $redis->zAdd('k2', 2, 'val1');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
+     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
+     * // Weighted zInter
+     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
+     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int + */ + public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + { + } + + /** + * + *将两个有序集合的并集存入到一个指定的键中 + * @example + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k2', 2, 'val2');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
+     * // Weighted zUnion
+     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
+     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int + */ + public function zUnion($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + { + } + + /** + * + *将两个有序集合的并集存入到一个指定的键中 + * @example + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k2', 2, 'val2');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
+     * // Weighted zUnion
+     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
+     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int + */ + public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + { + } + + /** + * + *按指定步长自增 + * @example + *
+     * $redis->incr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value 1
+     * $redis->incr('key1');        // 2
+     * $redis->incr('key1');        // 3
+     * $redis->incr('key1');        // 4
+     * $redis->incrBy('key1', 10);  // 14
+     * 
+ * @param string $key 键名 + * @param int $step 自增步长 + * @return int + */ + public function incrBy($key, $step) + { + } + + /** + * + *为指定字段增加指定的值. + * @example + *
+     * $redis->delete('h');
+     * $redis->hIncrBy('h', 'x', 2); // returns 2: h[x] = 2 now.
+     * $redis->hIncrBy('h', 'x', 1); // h[x] ← 2 + 1. Returns 3
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param int $step 自增步长 + * @return int + */ + public function hIncrBy($key, $field, $step) + { + } + + /** + * + *键值自增 + * @example + *
+     * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
+     * $redis->incr('key1'); // 2
+     * $redis->incr('key1'); // 3
+     * $redis->incr('key1'); // 4
+     * 
+ * @param string $key 键名 + * @return int + */ + public function incr($key) + { + } + + /** + * + *按指定步长自减 + * @example + *
+     * $redis->decr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value -1
+     * $redis->decr('key1');        // -2
+     * $redis->decr('key1');        // -3
+     * $redis->decrBy('key1', 10);  // -13
+     * 
+ * @param string $key 键名 + * @param float $step 自减步长 + * @return int + */ + public function decrBy($key, $step) + { + } + + /** + * + *键值自减 + * @example + *
+     * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
+     * $redis->decr('key1'); // -2
+     * $redis->decr('key1'); // -3
+     * 
+ * @param string $key 键名 + * @return int + */ + public function decr($key) + { + } + + /** + * + *获取某个键的某个位置的位值 + * @example + *
+     * $redis->set('key', "\x7f");  // this is 0111 1111
+     * $redis->getBit('key', 0);    // 0
+     * $redis->getBit('key', 1);    // 1
+     * 
+ * @param string $key 键名 + * @param int $offset 所在位置 + * @return int + */ + public function getBit($key, $offset) + { + } + + /** + * + *在列表中,在某个元素的前面或后面插入一个新值 + * @example + *
+     * $redis->delete('key1');
+     * $redis->lInsert('key1', Redis::AFTER, 'A', 'X');     // 0
+     * $redis->lPush('key1', 'A');
+     * $redis->lPush('key1', 'B');
+     * $redis->lPush('key1', 'C');
+     * $redis->lInsert('key1', Redis::BEFORE, 'C', 'X');    // 4
+     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C')
+     * $redis->lInsert('key1', Redis::AFTER, 'C', 'Y');     // 5
+     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C', 'Y')
+     * $redis->lInsert('key1', Redis::AFTER, 'W', 'value'); // -1
+     * 
+ * @param string $key 键名 + * @param string $position 位置(前面或后面,使用Redis::BEFORE | Redis::AFTER) + * @param string $element 元素 + * @param string $value 新值 + * @return int + */ + public function lInsert($key, $position, $element, $value) + { + } + + /** + * + *获取列表中指定索引的值 + * @example + * @param string $key 键名 + * @param int $index 索引值 + * @return string | boolean + */ + public function lGet($key, $index) + { + } + + /** + * + *获取列表中指定索引的值 + * @example + * @param string $key 键名 + * @param int $index 索引值 + * @return string | boolean + */ + public function lIndex($key, $index) + { + } + + /** + * + *设置键的有效期 + * @example + * @param string $key 键名 + * @param int $ttl 有效期(秒数) + * @return boolean + */ + public function setTimeout($key, $ttl) + { + } + + /** + * + *设置键的有效期 + * @example + * @param string $key 键名 + * @param int $ttl 有效期(秒数) + * @return boolean + */ + public function expire($key, $ttl) + { + } + + /** + * + *设置键的有效期(毫秒为单位) + * @example + * @param string $key 键名 + * @param int $ttl 有效期(毫秒数) + * @return boolean + */ + public function pexpire($key, $ttl) + { + } + + /** + * + *为某个键设置有效期为某个时间点 + * @example + *
+     * $redis->set('x', '42');
+     * $now = time(NULL);               // current timestamp
+     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
+     * sleep(5);                        // wait 5 seconds
+     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
+     * 
+ * @param string $key 键名 + * @param int $expireTime 到期时间 + * @return bool: + */ + public function expireAt($key, $expireTime) + { + } + + /** + * + *为某个键设置有效期为某个时间点(精确到毫秒) + * @example + *
+     * $redis->set('x', '42');
+     * $now = time(NULL);               // current timestamp
+     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
+     * sleep(5);                        // wait 5 seconds
+     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
+     * 
+ * @param string $key 键名 + * @param int $expireTime 到期时间 + * @return bool: + */ + public function pexpireAt($key, $expireTime) + { + } + + /** + * + *将某个键移动到其他数据库中 + * @example + *
+     * $redis->select(0);       // switch to DB 0
+     * $redis->set('x', '42');  // write 42 to x
+     * $redis->move('x', 1);    // move to DB 1
+     * $redis->select(1);       // switch to DB 1
+     * $redis->get('x');        // will return 42
+     * 
+ * @param string $key 键名 + * @param int $dbIndex 数据库编号 + * @return bool + */ + public function move($key, $dbIndex) + { + } + + /** + * + *切换数据库 + * @example + *
+     * $redis->select(0);       // switch to DB 0
+     * $redis->set('x', '42');  // write 42 to x
+     * $redis->move('x', 1);    // move to DB 1
+     * $redis->select(1);       // switch to DB 1
+     * $redis->get('x');        // will return 42
+     * 
+ * @param int $dbIndex 数据库编号 + * @return bool + */ + public function select($dbIndex) + { + } + + /** + * + *获取一个键值的子字符串 + * @example + *
+     * $redis->set('key', 'string value');
+     * $redis->getRange('key', 0, 5);   // 'string'
+     * $redis->getRange('key', -5, -1); // 'value'
+     * 
+ * @param string $key 键名 + * @param int $start 开始位置 + * @param int $end 结束位置 + * @return string: + */ + public function getRange($key, $start, $end) + { + } + + /** + * + *删除指定范围外的其他元素 + * @example + * @param string $key 键名 + * @param int $start 开始索引 + * @param int $end 结束索引 + * @return array | boolean + */ + public function listTrim($key, $start, $end) + { + } + + /** + * + *删除指定范围外的其他元素 + * @example + * @param string $key 键名 + * @param int $start 开始索引 + * @param int $end 结束索引 + * @return array | boolean + */ + public function ltrim($key, $start, $end) + { + } + + /** + * + *获取列表指定范围的值 + * @example + * @param string $key 键名 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @return array + */ + public function lGetRange($key, $start, $end) + { + } + + /** + * + *获取列表指定范围的值 + * @example + * @param string $key 键名 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @return array + */ + public function lRange($key, $start, $end) + { + } + + /** + * + *从列表中删除指定值的元素。 如果count为零,则删除所有匹配的元素。 如果计数是负数,则元素从尾部移到头部。 + * @example + * @param string $key 键名 + * @param string $value 元素值 + * @param int $count 删除的个数 + * @return long | bool + */ + public function lRem($key, $value, $count) + { + } + + /** + * + *从列表中删除指定值的元素。 如果count为零,则删除所有匹配的元素。 如果计数是负数,则元素从尾部移到头部。 + * @example + * @param string $key 键名 + * @param string $value 元素值 + * @param int $count 删除的个数 + * @return long | bool + */ + public function lRemove($key, $value, $count) + { + } + + /** + * + *根据排序范围删除成员 + * @example + *
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zAdd('key', 3, 'three');
+     * $redis->zRemRangeByRank('key', 0, 1); // 2
+     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int + */ + public function zDeleteRangeByRank($key, $start, $end) + { + } + + /** + * + *根据排序范围删除成员 + * @example + *
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zAdd('key', 3, 'three');
+     * $redis->zRemRangeByRank('key', 0, 1); // 2
+     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int + */ + public function zRemRangeByRank($key, $start, $end) + { + } + + /** + * + *按指定步长自增 + * @example + *
+     * $redis = new Redis();
+     * $redis->connect('127.0.0.1');
+     * $redis->set('x', 3);
+     * var_dump( $redis->incrByFloat('x', 1.5) );   // float(4.5)
+     * // ! SIC
+     * var_dump( $redis->get('x') );                // string(3) "4.5"
+     * 
+ * @param string $key 键名 + * @param float $step 自增步长 + * @return float + */ + public function incrByFloat($key, $step) + { + } + + /** + * + *为指定字段增加指定的值 + * @example + *
+     * $redis = new Redis();
+     * $redis->connect('127.0.0.1');
+     * $redis->hset('h', 'float', 3);
+     * $redis->hset('h', 'int',   3);
+     * var_dump( $redis->hIncrByFloat('h', 'float', 1.5) ); // float(4.5)
+     * var_dump( $redis->hGetAll('h') );
+     * // Output
+     * array(2) {
+     * ["float"]=>
+     * string(3) "4.5"
+     * ["int"]=>
+     * string(1) "3"
+     * }
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param double $step 自增步长 + * @return + */ + public function hIncrByFloat($key, $field, $step) + { + } + + /** + * + *统计字符串的位数 + * @example + * @param string $key 键名 + * @return long + */ + public function bitCount($key) + { + } + + /** + * + *多个键的位操作,并将结果存入到指定的键中 + * @example + * @param string $operation 操作(有 AND, OR, NOT, XOR 4种可选择) + * @param string $dstKey 目标键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名N + * @return long + */ + public function bitOp($operation, $dstKey, $key1, $key2, $keyN) + { + } + + /** + * + *给集合添加元素 + * @example + *
+     * $redis->sAdd('k', 'v1');                // int(1)
+     * $redis->sAdd('k', 'v1', 'v2', 'v3');    // int(2)
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int + */ + public function sAdd($key, $value) + { + } + + /** + * + *将某个集合中的元素移动到另外一个集合中 + * @example + *
+     * $redis->sAdd('key1' , 'set11');
+     * $redis->sAdd('key1' , 'set12');
+     * $redis->sAdd('key1' , 'set13');          // 'key1' => {'set11', 'set12', 'set13'}
+     * $redis->sAdd('key2' , 'set21');
+     * $redis->sAdd('key2' , 'set22');          // 'key2' => {'set21', 'set22'}
+     * $redis->sMove('key1', 'key2', 'set13');  // 'key1' =>  {'set11', 'set12'}
+     * // 'key2' =>  {'set21', 'set22', 'set13'}
+     * 
+ * @param string $srcKey 原集合键名 + * @param string $dstKey 目标集合键名 + * @param string $member 成员 + * @return bool + */ + public function sMove($srcKey, $dstKey, $member) + { + } + + /** + * + *获取多个集合的差集 + * @example + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s0', '3');
+     * $redis->sAdd('s0', '4');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * var_dump($redis->sDiff('s0', 's1', 's2'));
+     * //array(2) {
+     * //  [0]=>
+     * //  string(1) "4"
+     * //  [1]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string|... $key2 键名2 + * @return array + */ + public function sDiff($key1, $key2) + { + } + + /** + * + *获取多个集合的差集,并将结果存入到一个新的集合中 + * @example + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s0', '3');
+     * $redis->sAdd('s0', '4');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * var_dump($redis->sDiffStore('dst', 's0', 's1', 's2'));
+     * var_dump($redis->sMembers('dst'));
+     * //int(2)
+     * //array(2) {
+     * //  [0]=>
+     * //  string(1) "4"
+     * //  [1]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int: + */ + public function sDiffStore($dstKey, $key1, $key2, $keyN) + { + } + + /** + * + *获取集合的并集 + * @example + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s1', '3');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * $redis->sAdd('s2', '4');
+     * var_dump($redis->sUnion('s0', 's1', 's2'));
+     * array(4) {
+     * //  [0]=>
+     * //  string(1) "3"
+     * //  [1]=>
+     * //  string(1) "4"
+     * //  [2]=>
+     * //  string(1) "1"
+     * //  [3]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string|... $key2 键名2 + * @return array + */ + public function sUnion($key1, $key2) + { + } + + /** + * + *获取多个集合的并集,并将结果存入到另外一个集合中 + * @example + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s1', '3');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * $redis->sAdd('s2', '4');
+     * var_dump($redis->sUnionStore('dst', 's0', 's1', 's2'));
+     * var_dump($redis->sMembers('dst'));
+     * //int(4)
+     * //array(4) {
+     * //  [0]=>
+     * //  string(1) "3"
+     * //  [1]=>
+     * //  string(1) "4"
+     * //  [2]=>
+     * //  string(1) "1"
+     * //  [3]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int + */ + public function sUnionStore($dstKey, $key1, $key2, $keyN) + { + } + + /** + * + *获取两个集合的交集 + * @example + *
+     * $redis->sAdd('key1', 'val1');
+     * $redis->sAdd('key1', 'val2');
+     * $redis->sAdd('key1', 'val3');
+     * $redis->sAdd('key1', 'val4');
+     * $redis->sAdd('key2', 'val3');
+     * $redis->sAdd('key2', 'val4');
+     * $redis->sAdd('key3', 'val3');
+     * $redis->sAdd('key3', 'val4');
+     * var_dump($redis->sInter('key1', 'key2', 'key3'));
+     * //array(2) {
+     * //  [0]=>
+     * //  string(4) "val4"
+     * //  [1]=>
+     * //  string(4) "val3"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string $key2 键名2 + * @return array | boolean + */ + public function sInter($key1, $key2) + { + } + + /** + * + *获取多个集合的交集,并将结果存入到另外一个集合中 + * @example + *
+     * $redis->sAdd('key1', 'val1');
+     * $redis->sAdd('key1', 'val2');
+     * $redis->sAdd('key1', 'val3');
+     * $redis->sAdd('key1', 'val4');
+     * $redis->sAdd('key2', 'val3');
+     * $redis->sAdd('key2', 'val4');
+     * $redis->sAdd('key3', 'val3');
+     * $redis->sAdd('key3', 'val4');
+     * var_dump($redis->sInterStore('output', 'key1', 'key2', 'key3'));
+     * var_dump($redis->sMembers('output'));
+     * //int(2)
+     * //
+     * //array(2) {
+     * //  [0]=>
+     * //  string(4) "val4"
+     * //  [1]=>
+     * //  string(4) "val3"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int + */ + public function sInterStore($dstKey, $key1, $key2, $keyN) + { + } + + /** + * + *删除集合元素 + * @example + * @param string $key 键名 + * @param string|... $member 成员 + * @return long + */ + public function sRemove($key, $member) + { + } + + /** + * + *删除集合元素 + * @example + * @param string $key 键名 + * @param string|... $member 成员 + * @return long + */ + public function srem($key, $member) + { + } + + /** + * + *删除有序集合中的某个成员 + * @example + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int + */ + public function zDelete($key, $member) + { + } + + /** + * + *删除有序集合中的某个成员 + * @example + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int + */ + public function zRemove($key, $member) + { + } + + /** + * + *删除有序集合中的某个成员 + * @example + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int + */ + public function zRem($key, $member) + { + } + + /** + * + *通过匹配模式来订阅这些匹配的消息频道 + * @example + *
+     * function psubscribe($redis, $pattern, $chan, $msg) {
+     * echo "Pattern: $pattern\n";
+     * echo "Channel: $chan\n";
+     * echo "Payload: $msg\n";
+     * }
+     * 
+ * @param array $patterns 匹配模式 + * @param string|array $callback 回调函数名称 + * @param mixed $value 返回值 + * @return + */ + public function pSubscribe(Array $patterns, $callback, $value) + { + } + + /** + * + *订阅消息 + * @example + *
+     * function f($redis, $chan, $msg) {
+     * switch($chan) {
+     * case 'chan-1':
+     * ...
+     * break;
+     * case 'chan-2':
+     * ...
+     * break;
+     * case 'chan-2':
+     * ...
+     * break;
+     * }
+     * }
+     * $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
+     * 
+ * @param array $channels 订阅的消息频道 + * @param string|array $callback 回调函数名称 + * @param mixed $value 返回值 + * @return mixed + */ + public function subscribe(Array $channels, $callback, $value) + { + } + + /** + * + *开始一个事务. + * @example + *
+     * $ret = $redis->multi()
+     * ->set('key1', 'val1')
+     * ->get('key1')
+     * ->set('key2', 'val2')
+     * ->get('key2')
+     * ->exec();
+     * //$ret == array (
+     * //    0 => TRUE,
+     * //    1 => 'val1',
+     * //    2 => TRUE,
+     * //    3 => 'val2');
+     * 
+ * @return + */ + public function multi() + { + } + + /** + * + *执行事务 + * @example + * @return + */ + public function exec() + { + } + + /** + * + *执行lua脚本 + * @example + * @param string $script 脚本 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 + * @return mixed + */ + public function eval($script, Array $args, $num_keys) + { + } + + /** + * + *从脚本的SHA1散列而不是脚本本身执行LUA脚本 + * @example $script = 'return 1'; + * $sha = $redis->script('load', $script); + * $redis->evalSha($sha); // Returns 1 + * @param string $script_sha 脚本的散列值 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 + * @return + */ + public function evalSha($script_sha, Array $args, $num_keys) + { + } + + /** + * + *在脚本子系统上执行redis命令 + * @example + *
+     * $redis->script('load', $script);
+     * $redis->script('flush');
+     * $redis->script('kill');
+     * $redis->script('exists', $script1, [$script2, $script3, ...]);
+     * 
+ * SCRIPT LOAD will return the SHA1 hash of the passed script on success, and FALSE on failure. + * SCRIPT FLUSH should always return TRUE + * SCRIPT KILL will return true if a script was able to be killed and false if not + * SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script + * @param string $command redis命令 + * @param string|... $script 脚本 + * @return + */ + public function script($command, $script) + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + +} + diff --git a/src/Swoole/swoole_redis_server.php b/src/Swoole/swoole_redis_server.php index b5b01b9..9ff4756 100644 --- a/src/Swoole/swoole_redis_server.php +++ b/src/Swoole/swoole_redis_server.php @@ -2,7 +2,7 @@ /** * Swoole自动补全类(基于最新的2.0.10版本) * @author shixinke(http://www.shixinke.com) -* @modified 2017/12/26 +* @modified 2017/12/28 */ /** diff --git a/src/Swoole/swoole_serialize.php b/src/Swoole/swoole_serialize.php index 42e68ce..c816375 100644 --- a/src/Swoole/swoole_serialize.php +++ b/src/Swoole/swoole_serialize.php @@ -2,7 +2,7 @@ /** * Swoole自动补全类(基于最新的2.0.10版本) * @author shixinke(http://www.shixinke.com) -* @modified 2017/12/26 +* @modified 2017/12/28 */ /** diff --git a/src/Swoole/swoole_server.php b/src/Swoole/swoole_server.php index 51f0ef8..cefd492 100644 --- a/src/Swoole/swoole_server.php +++ b/src/Swoole/swoole_server.php @@ -2,7 +2,7 @@ /** * Swoole自动补全类(基于最新的2.0.10版本) * @author shixinke(http://www.shixinke.com) -* @modified 2017/12/26 +* @modified 2017/12/28 */ /** diff --git a/src/Swoole/swoole_server_port.php b/src/Swoole/swoole_server_port.php index 532650a..a68eccd 100644 --- a/src/Swoole/swoole_server_port.php +++ b/src/Swoole/swoole_server_port.php @@ -2,7 +2,7 @@ /** * Swoole自动补全类(基于最新的2.0.10版本) * @author shixinke(http://www.shixinke.com) -* @modified 2017/12/26 +* @modified 2017/12/28 */ /** diff --git a/src/Swoole/swoole_table.php b/src/Swoole/swoole_table.php index 7f15282..b89dac6 100644 --- a/src/Swoole/swoole_table.php +++ b/src/Swoole/swoole_table.php @@ -2,7 +2,7 @@ /** * Swoole自动补全类(基于最新的2.0.10版本) * @author shixinke(http://www.shixinke.com) -* @modified 2017/12/26 +* @modified 2017/12/28 */ /** diff --git a/src/Swoole/swoole_table_row.php b/src/Swoole/swoole_table_row.php index 3cbc2c1..83a3ce6 100644 --- a/src/Swoole/swoole_table_row.php +++ b/src/Swoole/swoole_table_row.php @@ -2,7 +2,7 @@ /** * Swoole自动补全类(基于最新的2.0.10版本) * @author shixinke(http://www.shixinke.com) -* @modified 2017/12/26 +* @modified 2017/12/28 */ /** diff --git a/src/Swoole/swoole_timer.php b/src/Swoole/swoole_timer.php index 5b4c034..da33dc0 100644 --- a/src/Swoole/swoole_timer.php +++ b/src/Swoole/swoole_timer.php @@ -2,7 +2,7 @@ /** * Swoole自动补全类(基于最新的2.0.10版本) * @author shixinke(http://www.shixinke.com) -* @modified 2017/12/26 +* @modified 2017/12/28 */ /** diff --git a/src/Swoole/swoole_websocket_frame.php b/src/Swoole/swoole_websocket_frame.php index 2b2953c..a42ae7b 100644 --- a/src/Swoole/swoole_websocket_frame.php +++ b/src/Swoole/swoole_websocket_frame.php @@ -2,7 +2,7 @@ /** * Swoole自动补全类(基于最新的2.0.10版本) * @author shixinke(http://www.shixinke.com) -* @modified 2017/12/26 +* @modified 2017/12/28 */ /** diff --git a/src/Swoole/swoole_websocket_server.php b/src/Swoole/swoole_websocket_server.php index 6beb24b..88c4a76 100644 --- a/src/Swoole/swoole_websocket_server.php +++ b/src/Swoole/swoole_websocket_server.php @@ -2,7 +2,7 @@ /** * Swoole自动补全类(基于最新的2.0.10版本) * @author shixinke(http://www.shixinke.com) -* @modified 2017/12/26 +* @modified 2017/12/28 */ /** From f8f5a67ab351a46b42a40e8bdefc3a654f03b4eb Mon Sep 17 00:00:00 2001 From: shixinke Date: Thu, 28 Dec 2017 14:40:03 +0800 Subject: [PATCH 04/34] =?UTF-8?q?=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 05255e5..59c692c 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 5、Redis(包括RedisCluster) -6、swoole扩展 +6、swoole扩展(支持swoole 2.0.10) 7、SeasLog From 9ee9ecd24b7533f17fc197f5f34dd9c93001c8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E6=96=B9=E6=B6=9B?= Date: Wed, 31 Jan 2018 18:40:51 +0800 Subject: [PATCH 05/34] =?UTF-8?q?=E6=B7=BB=E5=8A=A0FastDFS=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 + src/Fastdfs_client/FastDFS.php | 1029 +++++++++++++++++++++ src/Fastdfs_client/FastDFSException.php | 155 ++++ src/Fastdfs_client/fastdfs_client.php | 1127 +++++++++++++++++++++++ 4 files changed, 2313 insertions(+) create mode 100644 src/Fastdfs_client/FastDFS.php create mode 100644 src/Fastdfs_client/FastDFSException.php create mode 100644 src/Fastdfs_client/fastdfs_client.php diff --git a/README.md b/README.md index 59c692c..34dc55e 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 9、Xhprof +10、FastDFS + ## 使用说明 1、下载源文件并解压,将src文件夹下面的内容放到任意一个位置(我习惯将它放到我的phpstorm安装路径下的plugins\php\lib下面,然后建立一个vendor文件夹,如C:\Program Files (x86)\JetBrains\PhpStorm 9.0.2\plugins\php\lib\vendor) diff --git a/src/Fastdfs_client/FastDFS.php b/src/Fastdfs_client/FastDFS.php new file mode 100644 index 0000000..444fcc9 --- /dev/null +++ b/src/Fastdfs_client/FastDFS.php @@ -0,0 +1,1029 @@ +1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将本地文件上传到远程服务器(成功返回一个包括文件ID) + * @example + * @param string $local_filename 本地文件 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过文件内容将文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param string $file_buf 文件内容 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过文件内容将文件上传到远程服务器(成功返回文件ID) + * @example + * @param string $file_buf 文件内容 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_by_filebuff1($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传文件到远程服务器(成功返回文件ID) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param string $local_filename 文件名 + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_filename($local_filename, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param string $local_filename 文件名 + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_filename1($local_filename, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param string $file_buff 文件内容 + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_filebuff($file_buff, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param string $file_buff 文件内容 + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_filebuff1($file_buff, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_callback(Array $callback_array, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_callback1(Array $callback_array, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过本地文件修改追加的文件 + * @example + * @param string $local_filename 本地文件名 + * @param int $file_offset 文件位置 + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_filename($local_filename, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过本地文件修改追加的文件 + * @example + * @param string $local_filename 本地文件名 + * @param int $file_offset 文件位置 + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_filename1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过本地文件修改追加的文件 + * @example + * @param string $file_buff 本地文件内容 + * @param int $file_offset 文件位置 + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_filebuff($file_buff, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过本地文件修改追加的文件 + * @example + * @param string $local_filename 本地文件名 + * @param int $file_offset 文件位置 + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_filebuff1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数修改追加的文件 + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param int $file_offset 文件位置 + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_callback(Array $callback_array, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数修改追加的文件 + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param int $file_offset 文件位置 + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_callback1(Array $callback_array, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将本地文件作为副加文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param string $local_filename 本地文件 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_appender_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将本地文件作为附加文件上传到远程服务器(成功返回文件ID) + * @example + * @param string $local_filename 本地文件 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_appender_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通本地文件内容上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param string $file_buf 文件内容 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_appender_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过文件内容将本地文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param string $file_buff 文件内容 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_appender_by_filebuff1($file_buff, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_appender_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传文件到远程服务器(成功返回文件ID) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_appender_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) + * @example + * @param string $local_filename 本地文件名 + * @param string $group_name 分组名 + * @param string $master_filename 主文件名 + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_slave_by_filename($local_filename, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *上传本地文件到存储服务器(从文件模式,成功返回文件ID) + * @example + * @param string $local_filename 本地文件名 + * @param string $master_file_id 主文件ID + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_slave_by_filename1($local_filename, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) + * @example + * @param string $file_buff 本地文件内容 + * @param string $group_name 分组名 + * @param string $master_filename 主文件名 + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_slave_by_filebuff($file_buff, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *上传本地文件到存储服务器(从文件模式,成功返回文件ID) + * @example + * @param string $file_buff 本地文件内容 + * @param string $master_file_id 主文件ID + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_slave_by_filebuff1($file_buff, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $group_name 分组名 + * @param string $master_filename 主文件名 + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_slave_by_callback(Array $callback_array, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传本地文件到存储服务器(从文件模式,成功返回文件ID) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $master_file_id 主文件ID + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_slave_by_callback1(Array $callback_array, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *删除存储服务器上的文件 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_delete_file($group_name, $remote_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *删除存储服务器上的文件 + * @example + * @param string $remote_file_id 文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_delete_file1($remote_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *根据指定的大小截取文件 + * @example + * @param string $group_name 分组名 + * @param string $appender_filename 被截取的文件名 + * @param int $truncated_file_size 截取大小 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_truncate_file($group_name, $appender_filename, $truncated_file_size, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *根据指定的大小截取文件 + * @example + * @param string $appender_file_id 被截取的文件ID + * @param int $truncated_file_size 截取大小 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_truncate_file1($appender_file_id, $truncated_file_size, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *获取服务器上的文件内容 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 文件名 + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_download_file_to_buff($group_name, $remote_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *获取服务器上的文件内容 + * @example + * @param string $remote_file_id 文件ID + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_download_file_to_buff1($remote_file_id, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将服务器上的文件下载到本地,存储为本地文件 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 服务器上文件名 + * @param string $local_filename 本地文件名 + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_download_file_to_file($group_name, $remote_filename, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将服务器上的文件下载到本地,存储为本地文件 + * @example + * @param string $remote_file_id 服务器上文件ID + * @param string $local_filename 本地文件名 + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_download_file_to_file1($remote_file_id, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数处理将服务器上的下载的文件 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 服务器上文件名 + * @param array $download_callback 回调函数(应包括callback和args两个元素) + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_download_file_to_callback($group_name, $remote_filename, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数处理将服务器上的下载的文件 + * @example + * @param string $remote_file_id 服务器上文件ID + * @param array $download_callback 回调函数(应包括callback和args两个元素) + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_download_file_to_callback1($remote_file_id, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *设置文件元数据 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 服务器上文件名 + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $op_type 操作标识(共有以下两个可选项: + FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 + FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_set_metadata($group_name, $remote_filename, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *设置文件元数据 + * @example + * @param string $remote_file_id 服务器上文件ID + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $op_type 操作标识(共有以下两个可选项: + FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 + FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_set_metadata1($remote_file_id, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 服务器上文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_get_metadata($group_name, $remote_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) + * @example + * @param string $remote_file_id 服务器上文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_get_metadata1($remote_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过文件名等检查文件是否存在 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_file_exist($group_name, $remote_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过文件ID检查文件是否存在 + * @example + * @param string $file_id 文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_file_exist1($file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *获取上次错误码 + * @example + * @return int + */ + public function get_last_error_no() + { + } + + /** + * + *获取上次错误信息 + * @example + * @return string + */ + public function get_last_error_info() + { + } + + /** + * + *生成针对http下载防止盗用链接的token + * @example + * @param string $remote_filename 下载的文件地址(不包含group的名称) + * @param int $timestamp 时间戳 + * @return string | boolean + */ + public function http_gen_token($remote_filename, $timestamp) + { + } + + /** + * + *获取文件信息(返回值包括3个信息: + * create_timestamp:文件创建时间; + * file_size: 文件大小 (字节) + * source_ip_addr: 文件存储原始的IP地址) + * @example + * @param string $group_name 分组名称 + * @param string $filename 文件名 + * @return array|boolean + */ + public function get_file_info($group_name, $filename) + { + } + + /** + * + *获取文件ID获取文件信息(返回值包括3个信息: + * create_timestamp:文件创建时间; + * file_size: 文件大小 (字节) + * source_ip_addr: 文件存储原始的IP地址) + * @example + * @param string $file_id 文件ID + * @return array|boolean + */ + public function get_file_info1($file_id) + { + } + + /** + * + *向指定的连接发送数据 + * @example + * @param int $sock 连接描述符 + * @param string $buff 发送的数据 + * @return boolean + */ + public function send_data($sock, $buff) + { + } + + /** + * + *通过主文件,文件前缀和文件扩展名生成从文件 + * @example + * @param string $master_filename 主文件 + * @param string $suffix 文件前缀 + * @param string $extension 文件扩展名 + * @return string | boolean + */ + public function gen_slave_filename($master_filename, $suffix, $extension) + { + } + + /** + * + *关闭与跟踪服务器的连接 + * @example + * @return + */ + public function close() + { + } + +} + diff --git a/src/Fastdfs_client/FastDFSException.php b/src/Fastdfs_client/FastDFSException.php new file mode 100644 index 0000000..1ab858c --- /dev/null +++ b/src/Fastdfs_client/FastDFSException.php @@ -0,0 +1,155 @@ +1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将本地文件上传到远程服务器(成功返回一个包括文件ID) +* @example +* +* @param string $local_filename:本地文件 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过文件内容将文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param string $file_buf:文件内容 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过文件内容将文件上传到远程服务器(成功返回文件ID) +* @example +* +* @param string $file_buf:文件内容 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_by_filebuff1($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传文件到远程服务器(成功返回文件ID) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param string $local_filename:文件名 +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_filename($local_filename, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param string $local_filename:文件名 +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_filename1($local_filename, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param string $file_buff:文件内容 +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_filebuff($file_buff, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param string $file_buff:文件内容 +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_filebuff1($file_buff, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_callback(Array $callback_array, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_callback1(Array $callback_array, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过本地文件修改追加的文件 +* @example +* +* @param string $local_filename:本地文件名 +* @param int $file_offset:文件位置 +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_filename($local_filename, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过本地文件修改追加的文件 +* @example +* +* @param string $local_filename:本地文件名 +* @param int $file_offset:文件位置 +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_filename1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过本地文件修改追加的文件 +* @example +* +* @param string $file_buff:本地文件内容 +* @param int $file_offset:文件位置 +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_filebuff($file_buff, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过本地文件修改追加的文件 +* @example +* +* @param string $local_filename:本地文件名 +* @param int $file_offset:文件位置 +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_filebuff1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数修改追加的文件 +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param int $file_offset:文件位置 +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_callback(Array $callback_array, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数修改追加的文件 +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param int $file_offset:文件位置 +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_callback1(Array $callback_array, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将本地文件作为副加文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param string $local_filename:本地文件 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_appender_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将本地文件作为附加文件上传到远程服务器(成功返回文件ID) +* @example +* +* @param string $local_filename:本地文件 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_appender_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通本地文件内容上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param string $file_buf:文件内容 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_appender_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过文件内容将本地文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param string $file_buff:文件内容 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_appender_by_filebuff1($file_buff, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_appender_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传文件到远程服务器(成功返回文件ID) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_appender_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) +* @example +* +* @param string $local_filename:本地文件名 +* @param string $group_name:分组名 +* @param string $master_filename:主文件名 +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_slave_by_filename($local_filename, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*上传本地文件到存储服务器(从文件模式,成功返回文件ID) +* @example +* +* @param string $local_filename:本地文件名 +* @param string $master_file_id:主文件ID +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_slave_by_filename1($local_filename, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) +* @example +* +* @param string $file_buff:本地文件内容 +* @param string $group_name:分组名 +* @param string $master_filename:主文件名 +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_slave_by_filebuff($file_buff, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*上传本地文件到存储服务器(从文件模式,成功返回文件ID) +* @example +* +* @param string $file_buff:本地文件内容 +* @param string $master_file_id:主文件ID +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_slave_by_filebuff1($file_buff, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $group_name:分组名 +* @param string $master_filename:主文件名 +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_slave_by_callback(Array $callback_array, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传本地文件到存储服务器(从文件模式,成功返回文件ID) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $master_file_id:主文件ID +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_slave_by_callback1(Array $callback_array, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*删除存储服务器上的文件 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_delete_file($group_name, $remote_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*删除存储服务器上的文件 +* @example +* +* @param string $remote_file_id:文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_delete_file1($remote_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*根据指定的大小截取文件 +* @example +* +* @param string $group_name:分组名 +* @param string $appender_filename:被截取的文件名 +* @param int $truncated_file_size:截取大小 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_truncate_file($group_name, $appender_filename, $truncated_file_size, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*根据指定的大小截取文件 +* @example +* +* @param string $appender_file_id:被截取的文件ID +* @param int $truncated_file_size:截取大小 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_truncate_file1($appender_file_id, $truncated_file_size, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*获取服务器上的文件内容 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:文件名 +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_download_file_to_buff($group_name, $remote_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*获取服务器上的文件内容 +* @example +* +* @param string $remote_file_id:文件ID +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_download_file_to_buff1($remote_file_id, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将服务器上的文件下载到本地,存储为本地文件 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:服务器上文件名 +* @param string $local_filename:本地文件名 +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_download_file_to_file($group_name, $remote_filename, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将服务器上的文件下载到本地,存储为本地文件 +* @example +* +* @param string $remote_file_id:服务器上文件ID +* @param string $local_filename:本地文件名 +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_download_file_to_file1($remote_file_id, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数处理将服务器上的下载的文件 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:服务器上文件名 +* @param array $download_callback:回调函数(应包括callback和args两个元素) +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_download_file_to_callback($group_name, $remote_filename, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数处理将服务器上的下载的文件 +* @example +* +* @param string $remote_file_id:服务器上文件ID +* @param array $download_callback:回调函数(应包括callback和args两个元素) +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_download_file_to_callback1($remote_file_id, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*设置文件元数据 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:服务器上文件名 +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $op_type:操作标识(共有以下两个可选项: + FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 + FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_set_metadata($group_name, $remote_filename, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*设置文件元数据 +* @example +* +* @param string $remote_file_id:服务器上文件ID +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $op_type:操作标识(共有以下两个可选项: + FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 + FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_set_metadata1($remote_file_id, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:服务器上文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_get_metadata($group_name, $remote_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) +* @example +* +* @param string $remote_file_id:服务器上文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_get_metadata1($remote_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*生成针对http下载防止盗用链接的token +* @example +* +* @param string $remote_filename:下载的文件地址(不包含group的名称) +* @param int $timestamp:时间戳 +* @return string | boolean +*/ +function fastdfs_http_gen_token($remote_filename, $timestamp) +{ +} + +/** +* +*获取文件信息(返回值包括3个信息: +* create_timestamp:文件创建时间; +* file_size: 文件大小 (字节) +* source_ip_addr: 文件存储原始的IP地址) +* @example +* +* @param string $group_name:分组名称 +* @param string $filename:文件名 +* @return array|boolean +*/ +function fastdfs_get_file_info($group_name, $filename) +{ +} + +/** +* +*获取文件ID获取文件信息(返回值包括3个信息: +* create_timestamp:文件创建时间; +* file_size: 文件大小 (字节) +* source_ip_addr: 文件存储原始的IP地址) +* @example +* +* @param string $file_id:文件ID +* @return array|boolean +*/ +function fastdfs_get_file_info1($file_id) +{ +} + +/** +* +*通过文件名等检查文件是否存在 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_file_exist($group_name, $remote_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过文件ID检查文件是否存在 +* @example +* +* @param string $file_id:文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_file_exist1($file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过主文件,文件前缀和文件扩展名生成从文件 +* @example +* +* @param string $master_filename:主文件 +* @param string $suffix:文件前缀 +* @param string $extension:文件扩展名 +* @return string | boolean +*/ +function fastdfs_gen_slave_filename($master_filename, $suffix, $extension) +{ +} + +/** +* +*向指定的连接发送数据 +* @example +* +* @param int $sock:连接描述符 +* @param string $buff:发送的数据 +* @return boolean +*/ +function fastdfs_send_data($sock, $buff) +{ +} + From 6c062d42e85907e3e86d3f1a0035c23d1f29ba34 Mon Sep 17 00:00:00 2001 From: shixinke Date: Wed, 31 Jan 2018 18:42:42 +0800 Subject: [PATCH 06/34] =?UTF-8?q?=E6=B7=BB=E5=8A=A0FastDFS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34dc55e..feee5f1 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 9、Xhprof -10、FastDFS +10、FastDFS(FastDFS 1.00) ## 使用说明 From 622ec46678dca5000b68699e7576e479dbb86ffc Mon Sep 17 00:00:00 2001 From: shixinke Date: Wed, 31 Jan 2018 18:43:25 +0800 Subject: [PATCH 07/34] =?UTF-8?q?=E6=B7=BB=E5=8A=A0FastDFS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Fastdfs_client/FastDFS.php | 1029 --------------------- src/Fastdfs_client/FastDFSException.php | 155 ---- src/Fastdfs_client/fastdfs_client.php | 1127 ----------------------- 3 files changed, 2311 deletions(-) delete mode 100644 src/Fastdfs_client/FastDFS.php delete mode 100644 src/Fastdfs_client/FastDFSException.php delete mode 100644 src/Fastdfs_client/fastdfs_client.php diff --git a/src/Fastdfs_client/FastDFS.php b/src/Fastdfs_client/FastDFS.php deleted file mode 100644 index 444fcc9..0000000 --- a/src/Fastdfs_client/FastDFS.php +++ /dev/null @@ -1,1029 +0,0 @@ -1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_upload_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *将本地文件上传到远程服务器(成功返回一个包括文件ID) - * @example - * @param string $local_filename 本地文件 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return string | boolean - */ - public function storage_upload_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过文件内容将文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) - * @example - * @param string $file_buf 文件内容 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_upload_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过文件内容将文件上传到远程服务器(成功返回文件ID) - * @example - * @param string $file_buf 文件内容 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return string | boolean - */ - public function storage_upload_by_filebuff1($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) - * @example - * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_upload_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过回调函数上传文件到远程服务器(成功返回文件ID) - * @example - * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return string | boolean - */ - public function storage_upload_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *将文件追加到存储服务器中的文件中(一般用于断点续传) - * @example - * @param string $local_filename 文件名 - * @param string $group_name 分组名 - * @param string $appender_filename 被追加的文件名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_append_by_filename($local_filename, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *将文件追加到存储服务器中的文件中(一般用于断点续传) - * @example - * @param string $local_filename 文件名 - * @param string $appender_file_id 被追加的文件ID - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_append_by_filename1($local_filename, $appender_file_id, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *将文件追加到存储服务器中的文件中(一般用于断点续传) - * @example - * @param string $file_buff 文件内容 - * @param string $group_name 分组名 - * @param string $appender_filename 被追加的文件名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_append_by_filebuff($file_buff, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *将文件追加到存储服务器中的文件中(一般用于断点续传) - * @example - * @param string $file_buff 文件内容 - * @param string $appender_file_id 被追加的文件ID - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_append_by_filebuff1($file_buff, $appender_file_id, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过回调函数将文件追加到存储服务器中的文件中(一般用于断点续传) - * @example - * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) - * @param string $group_name 分组名 - * @param string $appender_filename 被追加的文件名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_append_by_callback(Array $callback_array, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *将文件追加到存储服务器中的文件中(一般用于断点续传) - * @example - * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) - * @param string $appender_file_id 被追加的文件ID - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_append_by_callback1(Array $callback_array, $appender_file_id, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过本地文件修改追加的文件 - * @example - * @param string $local_filename 本地文件名 - * @param int $file_offset 文件位置 - * @param string $group_name 分组名 - * @param string $appender_filename 被追加的文件 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_modify_by_filename($local_filename, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过本地文件修改追加的文件 - * @example - * @param string $local_filename 本地文件名 - * @param int $file_offset 文件位置 - * @param string $appender_file_id 被追加的文件ID - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_modify_by_filename1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过本地文件修改追加的文件 - * @example - * @param string $file_buff 本地文件内容 - * @param int $file_offset 文件位置 - * @param string $group_name 分组名 - * @param string $appender_filename 被追加的文件 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_modify_by_filebuff($file_buff, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过本地文件修改追加的文件 - * @example - * @param string $local_filename 本地文件名 - * @param int $file_offset 文件位置 - * @param string $appender_file_id 被追加的文件ID - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_modify_by_filebuff1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过回调函数修改追加的文件 - * @example - * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) - * @param int $file_offset 文件位置 - * @param string $group_name 分组名 - * @param string $appender_filename 被追加的文件 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_modify_by_callback(Array $callback_array, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过回调函数修改追加的文件 - * @example - * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) - * @param int $file_offset 文件位置 - * @param string $appender_file_id 被追加的文件ID - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_modify_by_callback1(Array $callback_array, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *将本地文件作为副加文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) - * @example - * @param string $local_filename 本地文件 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_upload_appender_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *将本地文件作为附加文件上传到远程服务器(成功返回文件ID) - * @example - * @param string $local_filename 本地文件 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return string | boolean - */ - public function storage_upload_appender_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通本地文件内容上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) - * @example - * @param string $file_buf 文件内容 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_upload_appender_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过文件内容将本地文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) - * @example - * @param string $file_buff 文件内容 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return string | boolean - */ - public function storage_upload_appender_by_filebuff1($file_buff, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) - * @example - * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_upload_appender_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过回调函数上传文件到远程服务器(成功返回文件ID) - * @example - * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $group_name 分组名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return string | boolean - */ - public function storage_upload_appender_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) - * @example - * @param string $local_filename 本地文件名 - * @param string $group_name 分组名 - * @param string $master_filename 主文件名 - * @param string $prefix_name 前缀名 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_upload_slave_by_filename($local_filename, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *上传本地文件到存储服务器(从文件模式,成功返回文件ID) - * @example - * @param string $local_filename 本地文件名 - * @param string $master_file_id 主文件ID - * @param string $prefix_name 前缀名 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_upload_slave_by_filename1($local_filename, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) - * @example - * @param string $file_buff 本地文件内容 - * @param string $group_name 分组名 - * @param string $master_filename 主文件名 - * @param string $prefix_name 前缀名 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_upload_slave_by_filebuff($file_buff, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *上传本地文件到存储服务器(从文件模式,成功返回文件ID) - * @example - * @param string $file_buff 本地文件内容 - * @param string $master_file_id 主文件ID - * @param string $prefix_name 前缀名 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_upload_slave_by_filebuff1($file_buff, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过回调函数上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) - * @example - * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) - * @param string $group_name 分组名 - * @param string $master_filename 主文件名 - * @param string $prefix_name 前缀名 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_upload_slave_by_callback(Array $callback_array, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过回调函数上传本地文件到存储服务器(从文件模式,成功返回文件ID) - * @example - * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) - * @param string $master_file_id 主文件ID - * @param string $prefix_name 前缀名 - * @param string $file_ext_name 文件扩展名(不包括.) - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return string | boolean - */ - public function storage_upload_slave_by_callback1(Array $callback_array, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *删除存储服务器上的文件 - * @example - * @param string $group_name 分组名 - * @param string $remote_filename 文件名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_delete_file($group_name, $remote_filename, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *删除存储服务器上的文件 - * @example - * @param string $remote_file_id 文件ID - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_delete_file1($remote_file_id, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *根据指定的大小截取文件 - * @example - * @param string $group_name 分组名 - * @param string $appender_filename 被截取的文件名 - * @param int $truncated_file_size 截取大小 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_truncate_file($group_name, $appender_filename, $truncated_file_size, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *根据指定的大小截取文件 - * @example - * @param string $appender_file_id 被截取的文件ID - * @param int $truncated_file_size 截取大小 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_truncate_file1($appender_file_id, $truncated_file_size, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *获取服务器上的文件内容 - * @example - * @param string $group_name 分组名 - * @param string $remote_filename 文件名 - * @param int $file_offset 文件位置 - * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return string | boolean - */ - public function storage_download_file_to_buff($group_name, $remote_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *获取服务器上的文件内容 - * @example - * @param string $remote_file_id 文件ID - * @param int $file_offset 文件位置 - * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return string | boolean - */ - public function storage_download_file_to_buff1($remote_file_id, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *将服务器上的文件下载到本地,存储为本地文件 - * @example - * @param string $group_name 分组名 - * @param string $remote_filename 服务器上文件名 - * @param string $local_filename 本地文件名 - * @param int $file_offset 文件位置 - * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_download_file_to_file($group_name, $remote_filename, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *将服务器上的文件下载到本地,存储为本地文件 - * @example - * @param string $remote_file_id 服务器上文件ID - * @param string $local_filename 本地文件名 - * @param int $file_offset 文件位置 - * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_download_file_to_file1($remote_file_id, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过回调函数处理将服务器上的下载的文件 - * @example - * @param string $group_name 分组名 - * @param string $remote_filename 服务器上文件名 - * @param array $download_callback 回调函数(应包括callback和args两个元素) - * @param int $file_offset 文件位置 - * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_download_file_to_callback($group_name, $remote_filename, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过回调函数处理将服务器上的下载的文件 - * @example - * @param string $remote_file_id 服务器上文件ID - * @param array $download_callback 回调函数(应包括callback和args两个元素) - * @param int $file_offset 文件位置 - * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_download_file_to_callback1($remote_file_id, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *设置文件元数据 - * @example - * @param string $group_name 分组名 - * @param string $remote_filename 服务器上文件名 - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $op_type 操作标识(共有以下两个可选项: - FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 - FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_set_metadata($group_name, $remote_filename, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *设置文件元数据 - * @example - * @param string $remote_file_id 服务器上文件ID - * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) - * @param string $op_type 操作标识(共有以下两个可选项: - FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 - FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_set_metadata1($remote_file_id, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) - * @example - * @param string $group_name 分组名 - * @param string $remote_filename 服务器上文件名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_get_metadata($group_name, $remote_filename, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) - * @example - * @param string $remote_file_id 服务器上文件ID - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return array | boolean - */ - public function storage_get_metadata1($remote_file_id, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过文件名等检查文件是否存在 - * @example - * @param string $group_name 分组名 - * @param string $remote_filename 文件名 - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_file_exist($group_name, $remote_filename, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *通过文件ID检查文件是否存在 - * @example - * @param string $file_id 文件ID - * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) - * @return boolean - */ - public function storage_file_exist1($file_id, Array $track_servers, Array $storage_servers) - { - } - - /** - * - *获取上次错误码 - * @example - * @return int - */ - public function get_last_error_no() - { - } - - /** - * - *获取上次错误信息 - * @example - * @return string - */ - public function get_last_error_info() - { - } - - /** - * - *生成针对http下载防止盗用链接的token - * @example - * @param string $remote_filename 下载的文件地址(不包含group的名称) - * @param int $timestamp 时间戳 - * @return string | boolean - */ - public function http_gen_token($remote_filename, $timestamp) - { - } - - /** - * - *获取文件信息(返回值包括3个信息: - * create_timestamp:文件创建时间; - * file_size: 文件大小 (字节) - * source_ip_addr: 文件存储原始的IP地址) - * @example - * @param string $group_name 分组名称 - * @param string $filename 文件名 - * @return array|boolean - */ - public function get_file_info($group_name, $filename) - { - } - - /** - * - *获取文件ID获取文件信息(返回值包括3个信息: - * create_timestamp:文件创建时间; - * file_size: 文件大小 (字节) - * source_ip_addr: 文件存储原始的IP地址) - * @example - * @param string $file_id 文件ID - * @return array|boolean - */ - public function get_file_info1($file_id) - { - } - - /** - * - *向指定的连接发送数据 - * @example - * @param int $sock 连接描述符 - * @param string $buff 发送的数据 - * @return boolean - */ - public function send_data($sock, $buff) - { - } - - /** - * - *通过主文件,文件前缀和文件扩展名生成从文件 - * @example - * @param string $master_filename 主文件 - * @param string $suffix 文件前缀 - * @param string $extension 文件扩展名 - * @return string | boolean - */ - public function gen_slave_filename($master_filename, $suffix, $extension) - { - } - - /** - * - *关闭与跟踪服务器的连接 - * @example - * @return - */ - public function close() - { - } - -} - diff --git a/src/Fastdfs_client/FastDFSException.php b/src/Fastdfs_client/FastDFSException.php deleted file mode 100644 index 1ab858c..0000000 --- a/src/Fastdfs_client/FastDFSException.php +++ /dev/null @@ -1,155 +0,0 @@ -1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_upload_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*将本地文件上传到远程服务器(成功返回一个包括文件ID) -* @example -* -* @param string $local_filename:本地文件 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return string | boolean -*/ -function fastdfs_storage_upload_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过文件内容将文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) -* @example -* -* @param string $file_buf:文件内容 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_upload_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过文件内容将文件上传到远程服务器(成功返回文件ID) -* @example -* -* @param string $file_buf:文件内容 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return string | boolean -*/ -function fastdfs_storage_upload_by_filebuff1($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) -* @example -* -* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_upload_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过回调函数上传文件到远程服务器(成功返回文件ID) -* @example -* -* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return string | boolean -*/ -function fastdfs_storage_upload_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*将文件追加到存储服务器中的文件中(一般用于断点续传) -* @example -* -* @param string $local_filename:文件名 -* @param string $group_name:分组名 -* @param string $appender_filename:被追加的文件名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_append_by_filename($local_filename, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*将文件追加到存储服务器中的文件中(一般用于断点续传) -* @example -* -* @param string $local_filename:文件名 -* @param string $appender_file_id:被追加的文件ID -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_append_by_filename1($local_filename, $appender_file_id, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*将文件追加到存储服务器中的文件中(一般用于断点续传) -* @example -* -* @param string $file_buff:文件内容 -* @param string $group_name:分组名 -* @param string $appender_filename:被追加的文件名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_append_by_filebuff($file_buff, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*将文件追加到存储服务器中的文件中(一般用于断点续传) -* @example -* -* @param string $file_buff:文件内容 -* @param string $appender_file_id:被追加的文件ID -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_append_by_filebuff1($file_buff, $appender_file_id, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过回调函数将文件追加到存储服务器中的文件中(一般用于断点续传) -* @example -* -* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) -* @param string $group_name:分组名 -* @param string $appender_filename:被追加的文件名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_append_by_callback(Array $callback_array, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*将文件追加到存储服务器中的文件中(一般用于断点续传) -* @example -* -* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) -* @param string $appender_file_id:被追加的文件ID -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_append_by_callback1(Array $callback_array, $appender_file_id, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过本地文件修改追加的文件 -* @example -* -* @param string $local_filename:本地文件名 -* @param int $file_offset:文件位置 -* @param string $group_name:分组名 -* @param string $appender_filename:被追加的文件 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_modify_by_filename($local_filename, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过本地文件修改追加的文件 -* @example -* -* @param string $local_filename:本地文件名 -* @param int $file_offset:文件位置 -* @param string $appender_file_id:被追加的文件ID -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_modify_by_filename1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过本地文件修改追加的文件 -* @example -* -* @param string $file_buff:本地文件内容 -* @param int $file_offset:文件位置 -* @param string $group_name:分组名 -* @param string $appender_filename:被追加的文件 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_modify_by_filebuff($file_buff, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过本地文件修改追加的文件 -* @example -* -* @param string $local_filename:本地文件名 -* @param int $file_offset:文件位置 -* @param string $appender_file_id:被追加的文件ID -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_modify_by_filebuff1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过回调函数修改追加的文件 -* @example -* -* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) -* @param int $file_offset:文件位置 -* @param string $group_name:分组名 -* @param string $appender_filename:被追加的文件 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_modify_by_callback(Array $callback_array, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过回调函数修改追加的文件 -* @example -* -* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) -* @param int $file_offset:文件位置 -* @param string $appender_file_id:被追加的文件ID -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_modify_by_callback1(Array $callback_array, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*将本地文件作为副加文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) -* @example -* -* @param string $local_filename:本地文件 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_upload_appender_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*将本地文件作为附加文件上传到远程服务器(成功返回文件ID) -* @example -* -* @param string $local_filename:本地文件 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return string | boolean -*/ -function fastdfs_storage_upload_appender_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通本地文件内容上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) -* @example -* -* @param string $file_buf:文件内容 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_upload_appender_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过文件内容将本地文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) -* @example -* -* @param string $file_buff:文件内容 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return string | boolean -*/ -function fastdfs_storage_upload_appender_by_filebuff1($file_buff, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) -* @example -* -* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_upload_appender_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过回调函数上传文件到远程服务器(成功返回文件ID) -* @example -* -* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $group_name:分组名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return string | boolean -*/ -function fastdfs_storage_upload_appender_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) -* @example -* -* @param string $local_filename:本地文件名 -* @param string $group_name:分组名 -* @param string $master_filename:主文件名 -* @param string $prefix_name:前缀名 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_upload_slave_by_filename($local_filename, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*上传本地文件到存储服务器(从文件模式,成功返回文件ID) -* @example -* -* @param string $local_filename:本地文件名 -* @param string $master_file_id:主文件ID -* @param string $prefix_name:前缀名 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_upload_slave_by_filename1($local_filename, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) -* @example -* -* @param string $file_buff:本地文件内容 -* @param string $group_name:分组名 -* @param string $master_filename:主文件名 -* @param string $prefix_name:前缀名 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_upload_slave_by_filebuff($file_buff, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*上传本地文件到存储服务器(从文件模式,成功返回文件ID) -* @example -* -* @param string $file_buff:本地文件内容 -* @param string $master_file_id:主文件ID -* @param string $prefix_name:前缀名 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_upload_slave_by_filebuff1($file_buff, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过回调函数上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) -* @example -* -* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) -* @param string $group_name:分组名 -* @param string $master_filename:主文件名 -* @param string $prefix_name:前缀名 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_upload_slave_by_callback(Array $callback_array, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过回调函数上传本地文件到存储服务器(从文件模式,成功返回文件ID) -* @example -* -* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) -* @param string $master_file_id:主文件ID -* @param string $prefix_name:前缀名 -* @param string $file_ext_name:文件扩展名(不包括.) -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return string | boolean -*/ -function fastdfs_storage_upload_slave_by_callback1(Array $callback_array, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*删除存储服务器上的文件 -* @example -* -* @param string $group_name:分组名 -* @param string $remote_filename:文件名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_delete_file($group_name, $remote_filename, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*删除存储服务器上的文件 -* @example -* -* @param string $remote_file_id:文件ID -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_delete_file1($remote_file_id, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*根据指定的大小截取文件 -* @example -* -* @param string $group_name:分组名 -* @param string $appender_filename:被截取的文件名 -* @param int $truncated_file_size:截取大小 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_truncate_file($group_name, $appender_filename, $truncated_file_size, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*根据指定的大小截取文件 -* @example -* -* @param string $appender_file_id:被截取的文件ID -* @param int $truncated_file_size:截取大小 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_truncate_file1($appender_file_id, $truncated_file_size, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*获取服务器上的文件内容 -* @example -* -* @param string $group_name:分组名 -* @param string $remote_filename:文件名 -* @param int $file_offset:文件位置 -* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return string | boolean -*/ -function fastdfs_storage_download_file_to_buff($group_name, $remote_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*获取服务器上的文件内容 -* @example -* -* @param string $remote_file_id:文件ID -* @param int $file_offset:文件位置 -* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return string | boolean -*/ -function fastdfs_storage_download_file_to_buff1($remote_file_id, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*将服务器上的文件下载到本地,存储为本地文件 -* @example -* -* @param string $group_name:分组名 -* @param string $remote_filename:服务器上文件名 -* @param string $local_filename:本地文件名 -* @param int $file_offset:文件位置 -* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_download_file_to_file($group_name, $remote_filename, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*将服务器上的文件下载到本地,存储为本地文件 -* @example -* -* @param string $remote_file_id:服务器上文件ID -* @param string $local_filename:本地文件名 -* @param int $file_offset:文件位置 -* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_download_file_to_file1($remote_file_id, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过回调函数处理将服务器上的下载的文件 -* @example -* -* @param string $group_name:分组名 -* @param string $remote_filename:服务器上文件名 -* @param array $download_callback:回调函数(应包括callback和args两个元素) -* @param int $file_offset:文件位置 -* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_download_file_to_callback($group_name, $remote_filename, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过回调函数处理将服务器上的下载的文件 -* @example -* -* @param string $remote_file_id:服务器上文件ID -* @param array $download_callback:回调函数(应包括callback和args两个元素) -* @param int $file_offset:文件位置 -* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_download_file_to_callback1($remote_file_id, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*设置文件元数据 -* @example -* -* @param string $group_name:分组名 -* @param string $remote_filename:服务器上文件名 -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $op_type:操作标识(共有以下两个可选项: - FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 - FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_set_metadata($group_name, $remote_filename, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*设置文件元数据 -* @example -* -* @param string $remote_file_id:服务器上文件ID -* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) -* @param string $op_type:操作标识(共有以下两个可选项: - FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 - FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_set_metadata1($remote_file_id, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) -* @example -* -* @param string $group_name:分组名 -* @param string $remote_filename:服务器上文件名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_get_metadata($group_name, $remote_filename, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) -* @example -* -* @param string $remote_file_id:服务器上文件ID -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return array | boolean -*/ -function fastdfs_storage_get_metadata1($remote_file_id, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*生成针对http下载防止盗用链接的token -* @example -* -* @param string $remote_filename:下载的文件地址(不包含group的名称) -* @param int $timestamp:时间戳 -* @return string | boolean -*/ -function fastdfs_http_gen_token($remote_filename, $timestamp) -{ -} - -/** -* -*获取文件信息(返回值包括3个信息: -* create_timestamp:文件创建时间; -* file_size: 文件大小 (字节) -* source_ip_addr: 文件存储原始的IP地址) -* @example -* -* @param string $group_name:分组名称 -* @param string $filename:文件名 -* @return array|boolean -*/ -function fastdfs_get_file_info($group_name, $filename) -{ -} - -/** -* -*获取文件ID获取文件信息(返回值包括3个信息: -* create_timestamp:文件创建时间; -* file_size: 文件大小 (字节) -* source_ip_addr: 文件存储原始的IP地址) -* @example -* -* @param string $file_id:文件ID -* @return array|boolean -*/ -function fastdfs_get_file_info1($file_id) -{ -} - -/** -* -*通过文件名等检查文件是否存在 -* @example -* -* @param string $group_name:分组名 -* @param string $remote_filename:文件名 -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_file_exist($group_name, $remote_filename, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过文件ID检查文件是否存在 -* @example -* -* @param string $file_id:文件ID -* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) -* @return boolean -*/ -function fastdfs_storage_file_exist1($file_id, Array $track_servers, Array $storage_servers) -{ -} - -/** -* -*通过主文件,文件前缀和文件扩展名生成从文件 -* @example -* -* @param string $master_filename:主文件 -* @param string $suffix:文件前缀 -* @param string $extension:文件扩展名 -* @return string | boolean -*/ -function fastdfs_gen_slave_filename($master_filename, $suffix, $extension) -{ -} - -/** -* -*向指定的连接发送数据 -* @example -* -* @param int $sock:连接描述符 -* @param string $buff:发送的数据 -* @return boolean -*/ -function fastdfs_send_data($sock, $buff) -{ -} - From cabcf0cbcbd44aa6981f2e10de3ce890c818d88d Mon Sep 17 00:00:00 2001 From: shixinke Date: Wed, 31 Jan 2018 18:43:51 +0800 Subject: [PATCH 08/34] =?UTF-8?q?=E6=B7=BB=E5=8A=A0FastDFS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Fastdfs_client/FastDFS.php | 1029 +++++++++++++++++++++ src/Fastdfs_client/FastDFSException.php | 155 ++++ src/Fastdfs_client/fastdfs_client.php | 1127 +++++++++++++++++++++++ 3 files changed, 2311 insertions(+) create mode 100644 src/Fastdfs_client/FastDFS.php create mode 100644 src/Fastdfs_client/FastDFSException.php create mode 100644 src/Fastdfs_client/fastdfs_client.php diff --git a/src/Fastdfs_client/FastDFS.php b/src/Fastdfs_client/FastDFS.php new file mode 100644 index 0000000..444fcc9 --- /dev/null +++ b/src/Fastdfs_client/FastDFS.php @@ -0,0 +1,1029 @@ +1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将本地文件上传到远程服务器(成功返回一个包括文件ID) + * @example + * @param string $local_filename 本地文件 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过文件内容将文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param string $file_buf 文件内容 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过文件内容将文件上传到远程服务器(成功返回文件ID) + * @example + * @param string $file_buf 文件内容 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_by_filebuff1($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传文件到远程服务器(成功返回文件ID) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param string $local_filename 文件名 + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_filename($local_filename, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param string $local_filename 文件名 + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_filename1($local_filename, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param string $file_buff 文件内容 + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_filebuff($file_buff, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param string $file_buff 文件内容 + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_filebuff1($file_buff, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_callback(Array $callback_array, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将文件追加到存储服务器中的文件中(一般用于断点续传) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_append_by_callback1(Array $callback_array, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过本地文件修改追加的文件 + * @example + * @param string $local_filename 本地文件名 + * @param int $file_offset 文件位置 + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_filename($local_filename, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过本地文件修改追加的文件 + * @example + * @param string $local_filename 本地文件名 + * @param int $file_offset 文件位置 + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_filename1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过本地文件修改追加的文件 + * @example + * @param string $file_buff 本地文件内容 + * @param int $file_offset 文件位置 + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_filebuff($file_buff, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过本地文件修改追加的文件 + * @example + * @param string $local_filename 本地文件名 + * @param int $file_offset 文件位置 + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_filebuff1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数修改追加的文件 + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param int $file_offset 文件位置 + * @param string $group_name 分组名 + * @param string $appender_filename 被追加的文件 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_callback(Array $callback_array, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数修改追加的文件 + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param int $file_offset 文件位置 + * @param string $appender_file_id 被追加的文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_modify_by_callback1(Array $callback_array, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将本地文件作为副加文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param string $local_filename 本地文件 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_appender_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将本地文件作为附加文件上传到远程服务器(成功返回文件ID) + * @example + * @param string $local_filename 本地文件 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_appender_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通本地文件内容上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param string $file_buf 文件内容 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_appender_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过文件内容将本地文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param string $file_buff 文件内容 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_appender_by_filebuff1($file_buff, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_appender_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传文件到远程服务器(成功返回文件ID) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $group_name 分组名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_appender_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) + * @example + * @param string $local_filename 本地文件名 + * @param string $group_name 分组名 + * @param string $master_filename 主文件名 + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_slave_by_filename($local_filename, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *上传本地文件到存储服务器(从文件模式,成功返回文件ID) + * @example + * @param string $local_filename 本地文件名 + * @param string $master_file_id 主文件ID + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_slave_by_filename1($local_filename, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) + * @example + * @param string $file_buff 本地文件内容 + * @param string $group_name 分组名 + * @param string $master_filename 主文件名 + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_slave_by_filebuff($file_buff, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *上传本地文件到存储服务器(从文件模式,成功返回文件ID) + * @example + * @param string $file_buff 本地文件内容 + * @param string $master_file_id 主文件ID + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_slave_by_filebuff1($file_buff, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $group_name 分组名 + * @param string $master_filename 主文件名 + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_upload_slave_by_callback(Array $callback_array, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数上传本地文件到存储服务器(从文件模式,成功返回文件ID) + * @example + * @param array $callback_array 回调函数(应包括callback, file_size和args三个元素) + * @param string $master_file_id 主文件ID + * @param string $prefix_name 前缀名 + * @param string $file_ext_name 文件扩展名(不包括.) + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_upload_slave_by_callback1(Array $callback_array, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *删除存储服务器上的文件 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_delete_file($group_name, $remote_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *删除存储服务器上的文件 + * @example + * @param string $remote_file_id 文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_delete_file1($remote_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *根据指定的大小截取文件 + * @example + * @param string $group_name 分组名 + * @param string $appender_filename 被截取的文件名 + * @param int $truncated_file_size 截取大小 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_truncate_file($group_name, $appender_filename, $truncated_file_size, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *根据指定的大小截取文件 + * @example + * @param string $appender_file_id 被截取的文件ID + * @param int $truncated_file_size 截取大小 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_truncate_file1($appender_file_id, $truncated_file_size, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *获取服务器上的文件内容 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 文件名 + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_download_file_to_buff($group_name, $remote_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *获取服务器上的文件内容 + * @example + * @param string $remote_file_id 文件ID + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return string | boolean + */ + public function storage_download_file_to_buff1($remote_file_id, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将服务器上的文件下载到本地,存储为本地文件 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 服务器上文件名 + * @param string $local_filename 本地文件名 + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_download_file_to_file($group_name, $remote_filename, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *将服务器上的文件下载到本地,存储为本地文件 + * @example + * @param string $remote_file_id 服务器上文件ID + * @param string $local_filename 本地文件名 + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_download_file_to_file1($remote_file_id, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数处理将服务器上的下载的文件 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 服务器上文件名 + * @param array $download_callback 回调函数(应包括callback和args两个元素) + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_download_file_to_callback($group_name, $remote_filename, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过回调函数处理将服务器上的下载的文件 + * @example + * @param string $remote_file_id 服务器上文件ID + * @param array $download_callback 回调函数(应包括callback和args两个元素) + * @param int $file_offset 文件位置 + * @param int $download_bytes 下载的字节数(默认为0,表示下载整个文件) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_download_file_to_callback1($remote_file_id, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *设置文件元数据 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 服务器上文件名 + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $op_type 操作标识(共有以下两个可选项: + FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 + FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_set_metadata($group_name, $remote_filename, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *设置文件元数据 + * @example + * @param string $remote_file_id 服务器上文件ID + * @param array $meta_list 文件相关数据,如:array('width'=>1024, 'height'=>768) + * @param string $op_type 操作标识(共有以下两个可选项: + FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 + FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_set_metadata1($remote_file_id, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 服务器上文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_get_metadata($group_name, $remote_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) + * @example + * @param string $remote_file_id 服务器上文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return array | boolean + */ + public function storage_get_metadata1($remote_file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过文件名等检查文件是否存在 + * @example + * @param string $group_name 分组名 + * @param string $remote_filename 文件名 + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_file_exist($group_name, $remote_filename, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *通过文件ID检查文件是否存在 + * @example + * @param string $file_id 文件ID + * @param array $track_servers 指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @param array $storage_servers 指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) + * @return boolean + */ + public function storage_file_exist1($file_id, Array $track_servers, Array $storage_servers) + { + } + + /** + * + *获取上次错误码 + * @example + * @return int + */ + public function get_last_error_no() + { + } + + /** + * + *获取上次错误信息 + * @example + * @return string + */ + public function get_last_error_info() + { + } + + /** + * + *生成针对http下载防止盗用链接的token + * @example + * @param string $remote_filename 下载的文件地址(不包含group的名称) + * @param int $timestamp 时间戳 + * @return string | boolean + */ + public function http_gen_token($remote_filename, $timestamp) + { + } + + /** + * + *获取文件信息(返回值包括3个信息: + * create_timestamp:文件创建时间; + * file_size: 文件大小 (字节) + * source_ip_addr: 文件存储原始的IP地址) + * @example + * @param string $group_name 分组名称 + * @param string $filename 文件名 + * @return array|boolean + */ + public function get_file_info($group_name, $filename) + { + } + + /** + * + *获取文件ID获取文件信息(返回值包括3个信息: + * create_timestamp:文件创建时间; + * file_size: 文件大小 (字节) + * source_ip_addr: 文件存储原始的IP地址) + * @example + * @param string $file_id 文件ID + * @return array|boolean + */ + public function get_file_info1($file_id) + { + } + + /** + * + *向指定的连接发送数据 + * @example + * @param int $sock 连接描述符 + * @param string $buff 发送的数据 + * @return boolean + */ + public function send_data($sock, $buff) + { + } + + /** + * + *通过主文件,文件前缀和文件扩展名生成从文件 + * @example + * @param string $master_filename 主文件 + * @param string $suffix 文件前缀 + * @param string $extension 文件扩展名 + * @return string | boolean + */ + public function gen_slave_filename($master_filename, $suffix, $extension) + { + } + + /** + * + *关闭与跟踪服务器的连接 + * @example + * @return + */ + public function close() + { + } + +} + diff --git a/src/Fastdfs_client/FastDFSException.php b/src/Fastdfs_client/FastDFSException.php new file mode 100644 index 0000000..1ab858c --- /dev/null +++ b/src/Fastdfs_client/FastDFSException.php @@ -0,0 +1,155 @@ +1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将本地文件上传到远程服务器(成功返回一个包括文件ID) +* @example +* +* @param string $local_filename:本地文件 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过文件内容将文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param string $file_buf:文件内容 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过文件内容将文件上传到远程服务器(成功返回文件ID) +* @example +* +* @param string $file_buf:文件内容 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_by_filebuff1($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传文件到远程服务器(成功返回文件ID) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param string $local_filename:文件名 +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_filename($local_filename, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param string $local_filename:文件名 +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_filename1($local_filename, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param string $file_buff:文件内容 +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_filebuff($file_buff, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param string $file_buff:文件内容 +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_filebuff1($file_buff, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_callback(Array $callback_array, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将文件追加到存储服务器中的文件中(一般用于断点续传) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_append_by_callback1(Array $callback_array, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过本地文件修改追加的文件 +* @example +* +* @param string $local_filename:本地文件名 +* @param int $file_offset:文件位置 +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_filename($local_filename, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过本地文件修改追加的文件 +* @example +* +* @param string $local_filename:本地文件名 +* @param int $file_offset:文件位置 +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_filename1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过本地文件修改追加的文件 +* @example +* +* @param string $file_buff:本地文件内容 +* @param int $file_offset:文件位置 +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_filebuff($file_buff, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过本地文件修改追加的文件 +* @example +* +* @param string $local_filename:本地文件名 +* @param int $file_offset:文件位置 +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_filebuff1($local_filename, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数修改追加的文件 +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param int $file_offset:文件位置 +* @param string $group_name:分组名 +* @param string $appender_filename:被追加的文件 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_callback(Array $callback_array, $file_offset, $group_name, $appender_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数修改追加的文件 +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param int $file_offset:文件位置 +* @param string $appender_file_id:被追加的文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_modify_by_callback1(Array $callback_array, $file_offset, $appender_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将本地文件作为副加文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param string $local_filename:本地文件 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_appender_by_filename($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将本地文件作为附加文件上传到远程服务器(成功返回文件ID) +* @example +* +* @param string $local_filename:本地文件 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_appender_by_filename1($local_filename, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通本地文件内容上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param string $file_buf:文件内容 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_appender_by_filebuff($file_buf, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过文件内容将本地文件上传到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param string $file_buff:文件内容 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_appender_by_filebuff1($file_buff, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传文件到远程服务器(成功返回一个包括group_name和filename信息的关联数组) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_appender_by_callback(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传文件到远程服务器(成功返回文件ID) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $group_name:分组名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_appender_by_callback1(Array $callback_array, $file_ext_name, Array $meta_list, $group_name, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) +* @example +* +* @param string $local_filename:本地文件名 +* @param string $group_name:分组名 +* @param string $master_filename:主文件名 +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_slave_by_filename($local_filename, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*上传本地文件到存储服务器(从文件模式,成功返回文件ID) +* @example +* +* @param string $local_filename:本地文件名 +* @param string $master_file_id:主文件ID +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_slave_by_filename1($local_filename, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) +* @example +* +* @param string $file_buff:本地文件内容 +* @param string $group_name:分组名 +* @param string $master_filename:主文件名 +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_slave_by_filebuff($file_buff, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*上传本地文件到存储服务器(从文件模式,成功返回文件ID) +* @example +* +* @param string $file_buff:本地文件内容 +* @param string $master_file_id:主文件ID +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_slave_by_filebuff1($file_buff, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传本地文件到存储服务器(从文件模式,成功返回一个包含 group_name和filename的关联数组) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $group_name:分组名 +* @param string $master_filename:主文件名 +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_upload_slave_by_callback(Array $callback_array, $group_name, $master_filename, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数上传本地文件到存储服务器(从文件模式,成功返回文件ID) +* @example +* +* @param array $callback_array:回调函数(应包括callback, file_size和args三个元素) +* @param string $master_file_id:主文件ID +* @param string $prefix_name:前缀名 +* @param string $file_ext_name:文件扩展名(不包括.) +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_upload_slave_by_callback1(Array $callback_array, $master_file_id, $prefix_name, $file_ext_name, Array $meta_list, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*删除存储服务器上的文件 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_delete_file($group_name, $remote_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*删除存储服务器上的文件 +* @example +* +* @param string $remote_file_id:文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_delete_file1($remote_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*根据指定的大小截取文件 +* @example +* +* @param string $group_name:分组名 +* @param string $appender_filename:被截取的文件名 +* @param int $truncated_file_size:截取大小 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_truncate_file($group_name, $appender_filename, $truncated_file_size, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*根据指定的大小截取文件 +* @example +* +* @param string $appender_file_id:被截取的文件ID +* @param int $truncated_file_size:截取大小 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_truncate_file1($appender_file_id, $truncated_file_size, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*获取服务器上的文件内容 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:文件名 +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_download_file_to_buff($group_name, $remote_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*获取服务器上的文件内容 +* @example +* +* @param string $remote_file_id:文件ID +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return string | boolean +*/ +function fastdfs_storage_download_file_to_buff1($remote_file_id, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将服务器上的文件下载到本地,存储为本地文件 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:服务器上文件名 +* @param string $local_filename:本地文件名 +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_download_file_to_file($group_name, $remote_filename, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*将服务器上的文件下载到本地,存储为本地文件 +* @example +* +* @param string $remote_file_id:服务器上文件ID +* @param string $local_filename:本地文件名 +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_download_file_to_file1($remote_file_id, $local_filename, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数处理将服务器上的下载的文件 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:服务器上文件名 +* @param array $download_callback:回调函数(应包括callback和args两个元素) +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_download_file_to_callback($group_name, $remote_filename, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过回调函数处理将服务器上的下载的文件 +* @example +* +* @param string $remote_file_id:服务器上文件ID +* @param array $download_callback:回调函数(应包括callback和args两个元素) +* @param int $file_offset:文件位置 +* @param int $download_bytes:下载的字节数(默认为0,表示下载整个文件) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_download_file_to_callback1($remote_file_id, Array $download_callback, $file_offset, $download_bytes, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*设置文件元数据 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:服务器上文件名 +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $op_type:操作标识(共有以下两个可选项: + FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 + FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_set_metadata($group_name, $remote_filename, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*设置文件元数据 +* @example +* +* @param string $remote_file_id:服务器上文件ID +* @param array $meta_list:文件相关数据,如:array('width'=>1024, 'height'=>768) +* @param string $op_type:操作标识(共有以下两个可选项: + FDFS_STORAGE_SET_METADATA_FLAG_MERGE: 与旧元数据合并 + FDFS_STORAGE_SET_METADATA_FLAG_OVERWRITE: 覆盖旧元数据) +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_set_metadata1($remote_file_id, Array $meta_list, $op_type, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:服务器上文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_get_metadata($group_name, $remote_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*获取文件元数据(成功返回如:array('width' => 1024, 'height' => 768)) +* @example +* +* @param string $remote_file_id:服务器上文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return array | boolean +*/ +function fastdfs_storage_get_metadata1($remote_file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*生成针对http下载防止盗用链接的token +* @example +* +* @param string $remote_filename:下载的文件地址(不包含group的名称) +* @param int $timestamp:时间戳 +* @return string | boolean +*/ +function fastdfs_http_gen_token($remote_filename, $timestamp) +{ +} + +/** +* +*获取文件信息(返回值包括3个信息: +* create_timestamp:文件创建时间; +* file_size: 文件大小 (字节) +* source_ip_addr: 文件存储原始的IP地址) +* @example +* +* @param string $group_name:分组名称 +* @param string $filename:文件名 +* @return array|boolean +*/ +function fastdfs_get_file_info($group_name, $filename) +{ +} + +/** +* +*获取文件ID获取文件信息(返回值包括3个信息: +* create_timestamp:文件创建时间; +* file_size: 文件大小 (字节) +* source_ip_addr: 文件存储原始的IP地址) +* @example +* +* @param string $file_id:文件ID +* @return array|boolean +*/ +function fastdfs_get_file_info1($file_id) +{ +} + +/** +* +*通过文件名等检查文件是否存在 +* @example +* +* @param string $group_name:分组名 +* @param string $remote_filename:文件名 +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_file_exist($group_name, $remote_filename, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过文件ID检查文件是否存在 +* @example +* +* @param string $file_id:文件ID +* @param array $track_servers:指定跟踪的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @param array $storage_servers:指定存储的服务器(每个数组元素包括ip_addr, port 和 sock三个子元素) +* @return boolean +*/ +function fastdfs_storage_file_exist1($file_id, Array $track_servers, Array $storage_servers) +{ +} + +/** +* +*通过主文件,文件前缀和文件扩展名生成从文件 +* @example +* +* @param string $master_filename:主文件 +* @param string $suffix:文件前缀 +* @param string $extension:文件扩展名 +* @return string | boolean +*/ +function fastdfs_gen_slave_filename($master_filename, $suffix, $extension) +{ +} + +/** +* +*向指定的连接发送数据 +* @example +* +* @param int $sock:连接描述符 +* @param string $buff:发送的数据 +* @return boolean +*/ +function fastdfs_send_data($sock, $buff) +{ +} + From 93d4d67e388892089015cbf0305056b9fe240131 Mon Sep 17 00:00:00 2001 From: shixinke Date: Wed, 31 Jan 2018 20:27:31 +0800 Subject: [PATCH 09/34] =?UTF-8?q?=E6=9B=B4=E6=96=B0seaslog=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Seaslog/SeasLog.php | 253 ++++++++++++++++++++++++++-------------- 1 file changed, 164 insertions(+), 89 deletions(-) diff --git a/src/Seaslog/SeasLog.php b/src/Seaslog/SeasLog.php index 1072519..94c931a 100644 --- a/src/Seaslog/SeasLog.php +++ b/src/Seaslog/SeasLog.php @@ -1,125 +1,138 @@ Date: Wed, 31 Jan 2018 20:28:13 +0800 Subject: [PATCH 10/34] =?UTF-8?q?=E6=9B=B4=E6=96=B0seaslog=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index feee5f1..572937f 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 6、swoole扩展(支持swoole 2.0.10) -7、SeasLog +7、SeasLog(1.7.6) 8、MsgPack(beta) From 852252392b264870349f18478f0930e2961b3e04 Mon Sep 17 00:00:00 2001 From: shixinke Date: Thu, 1 Mar 2018 19:21:02 +0800 Subject: [PATCH 11/34] =?UTF-8?q?swoole=E6=9B=B4=E6=96=B0=E5=88=B02.1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/Swoole/Async.php | 4 +- src/Swoole/Atomic.php | 4 +- src/Swoole/Atomic/Long.php | 4 +- src/Swoole/Buffer.php | 4 +- src/Swoole/Chan.php | 120 + src/Swoole/Channel.php | 4 +- src/Swoole/Client.php | 19 +- src/Swoole/Co.php | 166 ++ src/Swoole/Co/Channel.php | 120 + src/Swoole/Co/Client.php | 216 ++ src/Swoole/Co/Http/Client.php | 279 +++ src/Swoole/Co/Http/Server.php | 712 ++++++ src/Swoole/Co/Http2/Client.php | 166 ++ src/Swoole/Co/Http2/Request.php | 51 + src/Swoole/Co/MySQL.php | 218 ++ src/Swoole/Co/MySQL/Exception.php | 156 ++ src/Swoole/Co/MySQL/Statement.php | 84 + src/Swoole/Co/Redis.php | 2724 ++++++++++++++++++++++ src/Swoole/Co/Redis/Server.php | 759 ++++++ src/Swoole/Co/Server.php | 698 ++++++ src/Swoole/Co/WebSocket/Server.php | 751 ++++++ src/Swoole/Connection/Iterator.php | 4 +- src/Swoole/Coroutine.php | 92 +- src/Swoole/Coroutine/Channel.php | 120 + src/Swoole/Coroutine/Client.php | 4 +- src/Swoole/Coroutine/Http/Client.php | 4 +- src/Swoole/Coroutine/Http2/Client.php | 166 ++ src/Swoole/Coroutine/Http2/Request.php | 51 + src/Swoole/Coroutine/MySQL.php | 4 +- src/Swoole/Coroutine/MySQL/Exception.php | 4 +- src/Swoole/Coroutine/MySQL/Statement.php | 84 + src/Swoole/Coroutine/Redis.php | 2047 ++++++++++++---- src/Swoole/Event.php | 4 +- src/Swoole/Exception.php | 4 +- src/Swoole/Http/Client.php | 4 +- src/Swoole/Http/Request.php | 4 +- src/Swoole/Http/Response.php | 4 +- src/Swoole/Http/Server.php | 4 +- src/Swoole/Http2/Client.php | 19 +- src/Swoole/Http2/Response.php | 11 +- src/Swoole/Lock.php | 4 +- src/Swoole/Mmap.php | 4 +- src/Swoole/MySQL.php | 8 +- src/Swoole/MySQL/Exception.php | 4 +- src/Swoole/Process.php | 46 +- src/Swoole/Redis.php | 4 +- src/Swoole/Redis/Server.php | 4 +- src/Swoole/RingQueue.php | 67 + src/Swoole/Serialize.php | 4 +- src/Swoole/Server.php | 4 +- src/Swoole/Server/Port.php | 15 +- src/Swoole/Table.php | 4 +- src/Swoole/Table/Row.php | 4 +- src/Swoole/Timer.php | 4 +- src/Swoole/WebSocket/Frame.php | 4 +- src/Swoole/WebSocket/Server.php | 4 +- src/Swoole/swoole.namespace.php | 244 +- 58 files changed, 9769 insertions(+), 554 deletions(-) create mode 100644 src/Swoole/Chan.php create mode 100644 src/Swoole/Co.php create mode 100644 src/Swoole/Co/Channel.php create mode 100644 src/Swoole/Co/Client.php create mode 100644 src/Swoole/Co/Http/Client.php create mode 100644 src/Swoole/Co/Http/Server.php create mode 100644 src/Swoole/Co/Http2/Client.php create mode 100644 src/Swoole/Co/Http2/Request.php create mode 100644 src/Swoole/Co/MySQL.php create mode 100644 src/Swoole/Co/MySQL/Exception.php create mode 100644 src/Swoole/Co/MySQL/Statement.php create mode 100644 src/Swoole/Co/Redis.php create mode 100644 src/Swoole/Co/Redis/Server.php create mode 100644 src/Swoole/Co/Server.php create mode 100644 src/Swoole/Co/WebSocket/Server.php create mode 100644 src/Swoole/Coroutine/Channel.php create mode 100644 src/Swoole/Coroutine/Http2/Client.php create mode 100644 src/Swoole/Coroutine/Http2/Request.php create mode 100644 src/Swoole/Coroutine/MySQL/Statement.php create mode 100644 src/Swoole/RingQueue.php diff --git a/README.md b/README.md index 572937f..1ee67b9 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 5、Redis(包括RedisCluster) -6、swoole扩展(支持swoole 2.0.10) +6、swoole扩展(支持swoole 2.1.0) 7、SeasLog(1.7.6) diff --git a/src/Swoole/Async.php b/src/Swoole/Async.php index a1fbf77..173122f 100644 --- a/src/Swoole/Async.php +++ b/src/Swoole/Async.php @@ -1,8 +1,8 @@ finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * @var callable $onRequest + * 请求回调函数 + * @access public + */ + public $onRequest; + + /** + * @var callable $onHandshake + * TCP握手时的回调函数 + * @access public + */ + public $onHandshake; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *启动HTTP server + * @example + * @return + */ + public function start() + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param mixed $data + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 工作进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + +} + diff --git a/src/Swoole/Co/Http2/Client.php b/src/Swoole/Co/Http2/Client.php new file mode 100644 index 0000000..ed80e93 --- /dev/null +++ b/src/Swoole/Co/Http2/Client.php @@ -0,0 +1,166 @@ + '192.168.56.102', + * 'user' => 'test', + * 'password' => 'test', + * 'database' => 'test', + * 'charset' => 'utf8', + * ); + * @param array $server_config 连接配置信息 + * @return + */ + public function connect(Array $server_config) + { + } + + /** + * + *执行sql语句 + * @example + * @param string $sql 要执行的sql语句 + * @param double $timeout 超时时间,超时的话会断开MySQL连接,0表示不设置超时时间 + * @return array|boolean + */ + public function query($sql, $timeout) + { + } + + /** + * + *接收包(获取延迟收包的结果,当没有进行延迟收包或者收包超时,返回false) + * @example + * @return mixed + */ + public function recv() + { + } + + /** + * + *启动事务 + * @example + * @return + */ + public function begin() + { + } + + /** + * + *提交事务 + * @example + * @return + */ + public function commit() + { + } + + /** + * + *回滚事务(必须先调用begin启动事务才能调用rollback否则底层会抛出异常) + * @example + * @return + */ + public function rollback() + { + } + + /** + * + *设置是否延迟 + * @example + * @param boolean $defer 为true时,表明该Client要延迟收包,为false时,表明该Client非延迟收包,默认值为true + * @return boolean + */ + public function setDefer($defer) + { + } + + /** + * + *返回当前设置的defer + * @example + * @return boolean + */ + public function getDefer() + { + } + + /** + * + *关闭连接 + * @example + * @return + */ + public function close() + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + +} + diff --git a/src/Swoole/Co/MySQL/Exception.php b/src/Swoole/Co/MySQL/Exception.php new file mode 100644 index 0000000..f9573c8 --- /dev/null +++ b/src/Swoole/Co/MySQL/Exception.php @@ -0,0 +1,156 @@ +set('key', 'value'); + * 带有效期的设置: + * $redis->set('key','value', 10); + * 当键不存在时,设置期有效期为10秒: + * $redis->set('key', 'value', Array('nx', 'ex'=>10)); + * 当键存在时,设置期有效期为1000毫秒: + * $redis->set('key', 'value', Array('xx', 'px'=>1000)); + * + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int|array $options 附加项,可以是超时时间或者一个选项数组 + * @return bool + */ + public function set($key, $value, $options) + { + } + + /** + * + *修改某个键的某个位置的位值 + * @example + *
+     * $redis->set('key', "*");     // ord("*") = 42 = 0x2f = "0010 1010"
+     * $redis->setBit('key', 5, 1); // returns 0
+     * $redis->setBit('key', 7, 1); // returns 0
+     * $redis->get('key');          // chr(0x2f) = "/" = b("0010 1111")
+     * 
+ * @param string $key 键名 + * @param int $offset 开始位置 + * @param boolean|int $value 新值 + * @return int: + */ + public function setBit($key, $offset, $value) + { + } + + /** + * + *设置键值并设置有效期 + * @example $redis->setex('key', 3600, 'value'); + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int $ttl 有效期 + * @return bool + */ + public function setEx($key, $value, $ttl) + { + } + + /** + * + *设置键值并设置有效期(毫秒为单位) + * @example + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int $ttl 有效期(毫秒为单位) + * @return + */ + public function psetEx($key, $value, $ttl) + { + } + + /** + * + *给列表指定位置设置新值 + * @example + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->lGet('key1', 0);     // 'A'
+     * $redis->lSet('key1', 0, 'X');
+     * $redis->lGet('key1', 0);     // 'X'
+     * 
+ * @param string $key 键名 + * @param int $index 索引值 + * @param string $value 新值 + * @return boolean + */ + public function lSet($key, $index, $value) + { + } + + /** + * + *获取指定的key的值 + * @example $redis->get('key'); + * @return string|bool + */ + public function get() + { + } + + /** + * + *批量获取键名 + * @example + *
+     * $redis->delete('x', 'y', 'z', 'h');	// remove x y z
+     * $redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'));
+     * $redis->hset('h', 'field', 'value');
+     * var_dump($redis->mget(array('x', 'y', 'z', 'h')));
+     * // Output:
+     * // array(3) {
+     * // [0]=>
+     * // string(1) "a"
+     * // [1]=>
+     * // string(1) "b"
+     * // [2]=>
+     * // string(1) "c"
+     * // [3]=>
+     * // bool(false)
+     * // }
+     * 
+ * @param array $keys 键名数组 + * @return + */ + public function mGet(Array $keys) + { + } + + /** + * + *删除一个或多个键 + * @example $redis->delete('key1', 'key2'); + * $redis->delete(array('key3', 'key4')); + * @param array|string $keys 键名 + * @return int + */ + public function del($keys) + { + } + + /** + * + *删除字典的某个或某些字段 + * @example + *
+     * $redis->hMSet('h',
+     * array(
+     * 'f1' => 'v1',
+     * 'f2' => 'v2',
+     * 'f3' => 'v3',
+     * 'f4' => 'v4',
+     * ));
+     * var_dump( $redis->hDel('h', 'f1') );        // int(1)
+     * var_dump( $redis->hDel('h', 'f2', 'f3') );  // int(2)
+     * s
+     * var_dump( $redis->hGetAll('h') );
+     * //// Output:
+     * //  array(1) {
+     * //    ["f4"]=> string(2) "v4"
+     * //  }
+     * 
+ * @param string $key 键名 + * @param string|array $fields 字段名 + * @return int + */ + public function hDel($key, $fields) + { + } + + /** + * + *为字典的字段设置值 + * @example + *
+     * $redis->delete('h')
+     * $redis->hSet('h', 'key1', 'hello');  // 1, 'key1' => 'hello' in the hash at "h"
+     * $redis->hGet('h', 'key1');           // returns "hello"
+     * $redis->hSet('h', 'key1', 'plop');   // 0, value was replaced.
+     * $redis->hGet('h', 'key1');           // returns "plop"
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param string $value 字段值 + * @return long + */ + public function hSet($key, $field, $value) + { + } + + /** + * + *批量设置字典字段的值 + * @example + *
+     * $redis->delete('user:1');
+     * $redis->hMset('user:1', array('name' => 'Joe', 'salary' => 2000));
+     * $redis->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now.
+     * 
+ * @param string $key 键名 + * @param array $fields 字段键值对 + * @return boolean + */ + public function hMSet($key, Array $fields) + { + } + + /** + * + *当字典的字段不存在时,为其设置值 + * @example + *
+     * $redis->delete('h')
+     * $redis->hSetNx('h', 'key1', 'hello'); // TRUE, 'key1' => 'hello' in the hash at "h"
+     * $redis->hSetNx('h', 'key1', 'world'); // FALSE, 'key1' => 'hello' in the hash at "h". No change since the field
+     * wasn't replaced.
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param string $value 字段值 + * @return bool + */ + public function hSetNx($key, $field, $value) + { + } + + /** + * + *删除一个或多个键 + * @example $redis->delete('key1', 'key2'); + * $redis->delete(array('key3', 'key4')); + * @param array|string $keys 键名 + * @return int + */ + public function delete($keys) + { + } + + /** + * + *批量设置值 + * @example + *
+     * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
+     * var_dump($redis->get('key0'));
+     * var_dump($redis->get('key1'));
+     * // Output:
+     * // string(6) "value0"
+     * // string(6) "value1"
+     * 
+ * @param array $values 要设置的键值对 + * @return bool + */ + public function mSet(Array $values) + { + } + + /** + * + *批量设置值(当不存在时设置) + * @example + *
+     * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
+     * var_dump($redis->get('key0'));
+     * var_dump($redis->get('key1'));
+     * // Output:
+     * // string(6) "value0"
+     * // string(6) "value1"
+     * 
+ * @param array $values 要设置的键值对 + * @return bool + */ + public function mSetNx(Array $values) + { + } + + /** + * + *根据匹配模式获取键名(如*) + * @example + * $allKeys = $redis->keys('*'); + * $keyWithUserPrefix = $redis->keys('user*'); + * @param string $pattern 匹配模式 + * @return array + */ + public function getKeys($pattern) + { + } + + /** + * + *根据匹配模式获取键名(如*) + * @example + * $allKeys = $redis->keys('*'); + * $keyWithUserPrefix = $redis->keys('user*'); + * @param string $pattern 匹配模式 + * @return array + */ + public function keys($pattern) + { + } + + /** + * + *判断键是否存在 + * @example + *
+     * $redis->set('key', 'value');
+     * $redis->exists('key');               //  TRUE
+     * $redis->exists('NonExistingKey');    // FALSE
+     * 
+ * @param string $key 键名 + * @return bool + */ + public function exists($key) + { + } + + /** + * + *获取指定键的数据类型(需要根据常量匹配) + * @example $redis->type('key'); + * @param string $key 键名 + * @return int + */ + public function type($key) + { + } + + /** + * + *获取键值的长度 + * @example + *
+     * $redis->set('key', 'value');
+     * $redis->strlen('key'); // 5
+     * 
+ * @param string $key 键名 + * @return int + */ + public function strLen($key) + { + } + + /** + * + *从列表左侧删除一个元素 + * @example + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->lPop('key1');        // key1 => [ 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @return string + */ + public function lPop($key) + { + } + + /** + * + *是一个阻塞lPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表头部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,blPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 + * @example + *
+     * // Non blocking feature
+     * $redis->lPush('key1', 'A');
+     * $redis->delete('key2');
+     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * // Blocking feature
+     * // process 1
+     * $redis->delete('key1');
+     * $redis->blPop('key1', 10);
+     * // blocking for 10 seconds
+     * // process 2
+     * $redis->lPush('key1', 'A');
+     * // process 1
+     * // array('key1', 'A') is returned
+     * 
+ * @param string|...|array $key 键名 + * @param int $timeout 超时时间 + * @return array + */ + public function blPop($key, $timeout) + { + } + + /** + * + *从列表右侧删除一个元素 + * @example + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->rPop('key1');        // key1 => [ 'A', 'B' ]
+     * 
+ * @param string $key 键名 + * @return string + */ + public function rPop($key) + { + } + + /** + * + *是一个阻塞rPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表尾部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,brPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 + * @example + *
+     * // Non blocking feature
+     * $redis->lPush('key1', 'A');
+     * $redis->delete('key2');
+     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * // Blocking feature
+     * // process 1
+     * $redis->delete('key1');
+     * $redis->blPop('key1', 10);
+     * // blocking for 10 seconds
+     * // process 2
+     * $redis->lPush('key1', 'A');
+     * // process 1
+     * // array('key1', 'A') is returned
+     * 
+ * @param string|...|array $key 键名 + * @param int $timeout 超时时间 + * @return array + */ + public function brPop($key, $timeout) + { + } + + /** + * + *阻塞执行rpoplpush + * @example + * @param string $srcKey 要删除元素的队列键名 + * @param string $dstKey 要插入元素的队列的键名 + * @return string + */ + public function bRPopLPush($srcKey, $dstKey) + { + } + + /** + * + *返回列表的长度 + * @example + * @param string|...|array $key 键名 + * @return long | bool + */ + public function lSize($key) + { + } + + /** + * + *返回列表的长度 + * @example + * @param string|...|array $key 键名 + * @return long | bool + */ + public function lLen($key) + { + } + + /** + * + *返回集合的元素个数 + * @example + * @param string $key 键名 + * @return long + */ + public function sSize($key) + { + } + + /** + * + *返回集合的元素个数 + * @example + * @param string $key 键名 + * @return long + */ + public function scard($key) + { + } + + /** + * + *随机删除元素的某个或某些成员,并返回这个删除的成员. + * @example + *
+     * $redis->sAdd('key1' , 'set1');
+     * $redis->sAdd('key1' , 'set2');
+     * $redis->sAdd('key1' , 'set3');   // 'key1' => {'set3', 'set1', 'set2'}
+     * $redis->sPop('key1');            // 'set1', 'key1' => {'set3', 'set2'}
+     * $redis->sPop('key1');            // 'set3', 'key1' => {'set2'}
+     * 
+ * @param string $key 键名 + * @param int $count 删除个数 + * @return string | bool + */ + public function sPop($key, $count) + { + } + + /** + * + *返回集合的所有成员 + * @example + *
+     * $redis->delete('s');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'b');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'c');
+     * var_dump($redis->sMembers('s'));
+     * //array(3) {
+     * //  [0]=>
+     * //  string(1) "c"
+     * //  [1]=>
+     * //  string(1) "a"
+     * //  [2]=>
+     * //  string(1) "b"
+     * //}
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array + */ + public function sMembers($key) + { + } + + /** + * + *返回集合的所有成员 + * @example + *
+     * $redis->delete('s');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'b');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'c');
+     * var_dump($redis->sMembers('s'));
+     * //array(3) {
+     * //  [0]=>
+     * //  string(1) "c"
+     * //  [1]=>
+     * //  string(1) "a"
+     * //  [2]=>
+     * //  string(1) "b"
+     * //}
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array + */ + public function sGetMembers($key) + { + } + + /** + * + *随机返回一个集合的元素(不会删除它) + * @example + *
+     * $redis->sAdd('key1' , 'one');
+     * $redis->sAdd('key1' , 'two');
+     * $redis->sAdd('key1' , 'three');              // 'key1' => {'one', 'two', 'three'}
+     * var_dump( $redis->sRandMember('key1') );     // 'key1' => {'one', 'two', 'three'}
+     * // string(5) "three"
+     * var_dump( $redis->sRandMember('key1', 2) );  // 'key1' => {'one', 'two', 'three'}
+     * // array(2) {
+     * //   [0]=> string(2) "one"
+     * //   [1]=> string(2) "three"
+     * // }
+     * 
+ * @param string $key 键名 + * @return string | bool + */ + public function sRandMember($key) + { + } + + /** + * + *移除指定键的有效期,让它永久有效 + * @example $redis->persist('key'); + * @param string $key 键名 + * @return bool: + */ + public function persist($key) + { + } + + /** + * + *返回指定键的有效时间(秒) + * @example $redis->ttl('key'); + * @param string $key 键名 + * @return long + */ + public function ttl($key) + { + } + + /** + * + *返回指定键的有效时间(毫秒) + * @example $redis->pttl('key'); + * @param string $key 键名 + * @return long + */ + public function pttl($key) + { + } + + /** + * + *获取有序集合的成员数 + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCard('key');            // 3
+     * 
+ * @param string $key 集合键名 + * @return int + */ + public function zCard($key) + { + } + + /** + * + *获取有序集合的成员数 + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCard('key');            // 3
+     * 
+ * @param string $key 集合键名 + * @return int + */ + public function zSize($key) + { + } + + /** + * + *获取字典的字段个数 + * @example + *
+     * $redis->delete('h')
+     * $redis->hSet('h', 'key1', 'hello');
+     * $redis->hSet('h', 'key2', 'plop');
+     * $redis->hLen('h'); // returns 2
+     * 
+ * @param string $key 键名 + * @return int + */ + public function hLen($key) + { + } + + /** + * + *获取字典的字段名称列表. + * @example + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hKeys('h'));
+     * // Output:
+     * // array(4) {
+     * // [0]=>
+     * // string(1) "a"
+     * // [1]=>
+     * // string(1) "b"
+     * // [2]=>
+     * // string(1) "c"
+     * // [3]=>
+     * // string(1) "d"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array + */ + public function hKeys($key) + { + } + + /** + * + *获取字典的字段值列表 + * @example + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hVals('h'));
+     * // Output
+     * // array(4) {
+     * //   [0]=>
+     * //   string(1) "x"
+     * //   [1]=>
+     * //   string(1) "y"
+     * //   [2]=>
+     * //   string(1) "z"
+     * //   [3]=>
+     * //   string(1) "t"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array + */ + public function hVals($key) + { + } + + /** + * + *获取字典所有字段键值对 + * @example + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hGetAll('h'));
+     * // Output:
+     * // array(4) {
+     * //   ["a"]=>
+     * //   string(1) "x"
+     * //   ["b"]=>
+     * //   string(1) "y"
+     * //   ["c"]=>
+     * //   string(1) "z"
+     * //   ["d"]=>
+     * //   string(1) "t"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array + */ + public function hGetAll($key) + { + } + + /** + * + *调试命令(不建议使用) + * @example + * @return + */ + public function debug() + { + } + + /** + * + *将dump导出的二进制数据恢复到可读的字符串. + * @example + *
+     * $redis->set('foo', 'bar');
+     * $val = $redis->dump('foo');
+     * $redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo'
+     * 
+ * @param string $key 键名 + * @param int $ttl 有效期 + * @param string $value dump导出的二进制数据 + * @return + */ + public function restore($key, $ttl, $value) + { + } + + /** + * + *将某个键导出为一个二进制数据. + * @example + *
+     * $redis->set('foo', 'bar');
+     * $val = $redis->dump('foo'); // $val will be the Redis encoded key value
+     * 
+ * @param string $key 键名 + * @return string + */ + public function dump($key) + { + } + + /** + * + *给键重命名 + * @example + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean + */ + public function renameKey($srcKey, $dstKey) + { + } + + /** + * + *给键重命名 + * @example + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean + */ + public function rename($srcKey, $dstKey) + { + } + + /** + * + *当目标键名不存在时,给键重命名 + * @example + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean + */ + public function renameNx($srcKey, $dstKey) + { + } + + /** + * + *从一个队列的队尾删除一个元素,并将该元素插入到另一个队列的头部 + * @example + *
+     * $redis->delete('x', 'y');
+     * $redis->lPush('x', 'abc');
+     * $redis->lPush('x', 'def');
+     * $redis->lPush('y', '123');
+     * $redis->lPush('y', '456');
+     * // move the last of x to the front of y.
+     * var_dump($redis->rpoplpush('x', 'y'));
+     * var_dump($redis->lRange('x', 0, -1));
+     * var_dump($redis->lRange('y', 0, -1));
+     * //Output:
+     * //
+     * //string(3) "abc"
+     * //array(1) {
+     * //  [0]=>
+     * //  string(3) "def"
+     * //}
+     * //array(3) {
+     * //  [0]=>
+     * //  string(3) "abc"
+     * //  [1]=>
+     * //  string(3) "456"
+     * //  [2]=>
+     * //  string(3) "123"
+     * //}
+     * 
+ * @param string $srcKey 要删除元素的队列键名 + * @param string $dstKey 要插入元素的队列的键名 + * @return string + */ + public function rpoplpush($srcKey, $dstKey) + { + } + + /** + * + *返回一个随机的键 + * @example + *
+     * $key = $redis->randomKey();
+     * $surprise = $redis->get($key);  // who knows what's in there.
+     * 
+ * @return string + */ + public function randomKey() + { + } + + /** + * + *检查当前redis连接状态(成功时返回PONG) + * @example + * @return string + */ + public function ping() + { + } + + /** + * + *设置连接的认证密码 + * @example $redis->auth('foobared'); + * @param string $password 认证密码 + * @return bool: + */ + public function auth($password) + { + } + + /** + * + *取消观察某个键在其他客户端的变化情况 + * @example + * @param string|array $keys 键名 + * @return + */ + public function unwatch($keys) + { + } + + /** + * + *观察某个键在其他客户端的变化情况. + * @example + *
+     * $redis->watch('x');
+     * // long code here during the execution of which other clients could well modify `x`
+     * $ret = $redis->multi()
+     * ->incr('x')
+     * ->exec();
+     * // $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.
+     * 
+ * @param string|array $keys 键名 + * @return + */ + public function watch($keys) + { + } + + /** + * + *将数据同步到硬盘上 + * @example $redis->save(); + * @return boolean + */ + public function save() + { + } + + /** + * + *将数据存入到硬盘上(异步操作) + * @example + * @return + */ + public function bgSave() + { + } + + /** + * + *获取上次数据同步到硬盘的时间 + * @example $redis->lastSave(); + * @return int + */ + public function lastSave() + { + } + + /** + * + *删除当前数据库的所有键 + * @example $redis->flushDB(); + * @return bool + */ + public function flushDB() + { + } + + /** + * + *删除当前实例的所有键 + * @example $redis->flushAll(); + * @return bool + */ + public function flushAll() + { + } + + /** + * + *获取当前数据库的键的个数 + * @example + *
+     * $count = $redis->dbSize();
+     * echo "Redis has $count keys\n";
+     * 
+ * @return int + */ + public function dbSize() + { + } + + /** + * + *开启后台写AOF日志操作 + * @example $redis->bgrewriteaof(); + * @return bool + */ + public function bgrewriteaof() + { + } + + /** + * + *返回当前redis服务器时间. + * @example + *
+     * var_dump( $redis->time() );
+     * // array(2) {
+     * //   [0] => string(10) "1342364352"
+     * //   [1] => string(6) "253002"
+     * // }
+     * 
+ * @return int + */ + public function time() + { + } + + /** + * + *返回当前连接的服务器的角色,如master、alone、slave、sentinel + * @example + * @return string + */ + public function role() + { + } + + /** + * + *修改某个键的某个位置的值 + * @example + *
+     * $redis->set('key', 'Hello world');
+     * $redis->setRange('key', 6, "redis"); // returns 11
+     * $redis->get('key');                  // "Hello redis"
+     * 
+ * @param string $key 键名 + * @param int $offset 开始位置 + * @param string $value 被替换的子串的值 + * @return string + */ + public function setRange($key, $offset, $value) + { + } + + /** + * + *当键不存在时设置其值 + * @example + * $redis->setnx('key', 'value'); + * + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @return bool: + */ + public function setNx($key, $value) + { + } + + /** + * + *设置键的值,并返回它的旧的缓存值 + * @example + *
+     * $redis->set('x', '42');
+     * $exValue = $redis->getSet('x', 'lol');   // return '42', replaces x by 'lol'
+     * $newValue = $redis->get('x')'            // return 'lol'
+     * 
+ * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @return string + */ + public function getSet($key, $value) + { + } + + /** + * + *将字符串追加到键值后(返回值的长度) + * @example + *
+     * $redis->set('key', 'value1');
+     * $redis->append('key', 'value2'); // 12
+     * $redis->get('key');              // 'value1value2'
+     * 
+ * @param string $key 键名 + * @param string $value 追加的值 + * @return int + */ + public function append($key, $value) + { + } + + /** + * + *如果列表存在,从左侧(头部)向列表插入元素 + * @example + *
+     * $redis->delete('key1');
+     * $redis->lPushx('key1', 'A');     // returns 0
+     * $redis->lPush('key1', 'A');      // returns 1
+     * $redis->lPushx('key1', 'B');     // returns 2
+     * $redis->lPushx('key1', 'C');     // returns 3
+     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int + */ + public function lPushx($key, $value) + { + } + + /** + * + *从左侧(头部)向列表插入元素 + * @example + *
+     * $redis->lPush('l', 'v1', 'v2', 'v3', 'v4')   // int(4)
+     * var_dump( $redis->lRange('l', 0, -1) );
+     * //// Output:
+     * // array(4) {
+     * //   [0]=> string(2) "v4"
+     * //   [1]=> string(2) "v3"
+     * //   [2]=> string(2) "v2"
+     * //   [3]=> string(2) "v1"
+     * // }
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int + */ + public function lPush($key, $value) + { + } + + /** + * + *从右侧(尾部)向列表插入元素 + * @example + *
+     * $redis->rPush('l', 'v1', 'v2', 'v3', 'v4');    // int(4)
+     * var_dump( $redis->lRange('l', 0, -1) );
+     * //// Output:
+     * // array(4) {
+     * //   [0]=> string(2) "v1"
+     * //   [1]=> string(2) "v2"
+     * //   [2]=> string(2) "v3"
+     * //   [3]=> string(2) "v4"
+     * // }
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int + */ + public function rPush($key, $value) + { + } + + /** + * + *如果列表存在,从右侧(尾部)向列表插入元素 + * @example + *
+     * $redis->delete('key1');
+     * $redis->rPushx('key1', 'A'); // returns 0
+     * $redis->rPush('key1', 'A'); // returns 1
+     * $redis->rPushx('key1', 'B'); // returns 2
+     * $redis->rPushx('key1', 'C'); // returns 3
+     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int + */ + public function rPushx($key, $value) + { + } + + /** + * + *是否包含某个成员 + * @example + * @param string $key 键名 + * @param string $member 成员值 + * @return boolean + */ + public function sContains($key, $member) + { + } + + /** + * + *是否包含某个成员 + * @example + * @param string $key 键名 + * @param string $member 成员值 + * @return boolean + */ + public function sismember($key, $member) + { + } + + /** + * + *获取指定成员的排序值(分数) + * @example + *
+     * $redis->zAdd('key', 2.5, 'val2');
+     * $redis->zScore('key', 'val2'); // 2.5
+     * 
+ * @param string $key 集合键名 + * @param string $member 成员值 + * @return double + */ + public function zScore($key, $member) + { + } + + /** + * + *获取成员的排序值 + * @example + *
+     * $redis->delete('z');
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zRank('key', 'one');     // 0
+     * $redis->zRank('key', 'two');     // 1
+     * $redis->zRevRank('key', 'one');  // 1
+     * $redis->zRevRank('key', 'two');  // 0
+     * 
+ * @param string $key 集合键名 + * @param string $member 成员值 + * @return int + */ + public function zRank($key, $member) + { + } + + /** + * + *获取成员的排位值(倒数) + * @example + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int + */ + public function zRevRank($key, $member) + { + } + + /** + * + *获取字典的某个字段的值 + * @example + * @param string $key 键名 + * @param string $field 字段名 + * @return string + */ + public function hGet($key, $field) + { + } + + /** + * + *批量获取字典的字段值 + * @example + * @param string $key 键名 + * @param array $fields 字段名列表 + * @return array + */ + public function hMGet($key, Array $fields) + { + } + + /** + * + *判断字典的某个字段是否存在. + * @example + *
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hExists('h', 'a');               //  TRUE
+     * $redis->hExists('h', 'NonExistingKey');  // FALSE
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @return bool + */ + public function hExists($key, $field) + { + } + + /** + * + *将消息发布到消息通道(队列). + * @example $redis->publish('chan-1', 'hello, world!'); // send message. + * @param string $channel 消息频道 + * @param string $message 消息 + * @return int + */ + public function publish($channel, $message) + { + } + + /** + * + *给有序集合成员增加排序值 + * @example + *
+     * $redis->delete('key');
+     * $redis->zIncrBy('key', 2.5, 'member1');  // key or member1 didn't exist, so member1's score is to 0
+     * // before the increment and now has the value 2.5
+     * $redis->zIncrBy('key', 1, 'member1');    // 3.5
+     * 
+ * @param string $key 目标集合键名 + * @param double $step 增加的步长 + * @param string $member 成员 + * @return float + */ + public function zIncrBy($key, $step, $member) + { + } + + /** + * + *向有序集合插入元素 + * @example + *
+     * 
+     * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
+     * $redis->zRem('z', 'v2', 'v3');                           // int(2)
+     * var_dump( $redis->zRange('z', 0, -1) );
+     * //// Output:
+     * // array(2) {
+     * //   [0]=> string(2) "v1"
+     * //   [1]=> string(2) "v4"
+     * // }
+     * 
+ *
+ * @param string $key 集合键名 + * @param double $score 排序值 + * @param string $value 元素值 + * @return int + */ + public function zAdd($key, $score, $value) + { + } + + /** + * + *根据排序值范围来删除成员 + * @example + * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return long + */ + public function zDeleteRangeByScore($key, $start, $end) + { + } + + /** + * + *根据排序值范围来删除成员 + * @example + * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return long + */ + public function zRemRangeByScore($key, $start, $end) + { + } + + /** + * + *获取指定排序范围的成员数. + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCount('key', 0, 3); // 2, corresponding to array('val0', 'val2')
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int + */ + public function zCount($key, $start, $end) + { + } + + /** + * + *获取有序集合中指定范围的成员 + * @example + *
+     * $redis->zAdd('key1', 0, 'val0');
+     * $redis->zAdd('key1', 2, 'val2');
+     * $redis->zAdd('key1', 10, 'val10');
+     * $redis->zRange('key1', 0, -1); // array('val0', 'val2', 'val10')
+     * // with scores
+     * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param boolean $withScores 是否返回成员的排序值 + * @return array + */ + public function zRange($key, $start, $end, $withScores) + { + } + + /** + * + *获取有序集合中指定范围的成员(倒序排列) + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRevRange('key', 0, -1); // array('val10', 'val2', 'val0')
+     * // with scores
+     * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param boolean $withScores 是否返回成员的排序值 + * @return array + */ + public function zRevRange($key, $start, $end, $withScores) + { + } + + /** + * + *获取有序集合中指定范围的成员(按排序值排列) + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) + * @return array + */ + public function zRangeByScore($key, $start, $end, Array $options) + { + } + + /** + * + *获取有序集合中指定范围的成员(按排序值倒序排列) + * @example + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) + * @return array + */ + public function zRevRangeByScore($key, $start, $end, Array $options) + { + } + + /** + * + *按字母字典的顺序返回成员 + * @example + *
+     * foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g') as $char) {
+     * $redis->zAdd('key', $char);
+     * }
+     * $redis->zRangeByLex('key', '-', '[c'); // array('a', 'b', 'c')
+     * $redis->zRangeByLex('key', '-', '(c'); // array('a', 'b')
+     * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c')
+     * 
+ * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @param long $offset 索引开始值 + * @param long $limit 成员数 + * @return array + */ + public function zRangeByLex($key, $min, $max, $offset, $limit) + { + } + + /** + * + *按字母字典的顺序返回成员(倒序排序) + * @example + * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @param long $offset 索引开始值 + * @param long $limit 成员数 + * @return + */ + public function zRevRangeByLex($key, $min, $max, $offset, $limit) + { + } + + /** + * + *将两个有序集合的交集存入到一个指定的键中 + * @example + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->delete('ko4');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k1', 3, 'val3');
+     * $redis->zAdd('k2', 2, 'val1');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
+     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
+     * // Weighted zInter
+     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
+     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int + */ + public function zInter($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + { + } + + /** + * + *将两个有序集合的交集存入到一个指定的键中 + * @example + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->delete('ko4');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k1', 3, 'val3');
+     * $redis->zAdd('k2', 2, 'val1');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
+     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
+     * // Weighted zInter
+     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
+     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int + */ + public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + { + } + + /** + * + *将两个有序集合的并集存入到一个指定的键中 + * @example + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k2', 2, 'val2');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
+     * // Weighted zUnion
+     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
+     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int + */ + public function zUnion($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + { + } + + /** + * + *将两个有序集合的并集存入到一个指定的键中 + * @example + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k2', 2, 'val2');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
+     * // Weighted zUnion
+     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
+     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int + */ + public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + { + } + + /** + * + *按指定步长自增 + * @example + *
+     * $redis->incr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value 1
+     * $redis->incr('key1');        // 2
+     * $redis->incr('key1');        // 3
+     * $redis->incr('key1');        // 4
+     * $redis->incrBy('key1', 10);  // 14
+     * 
+ * @param string $key 键名 + * @param int $step 自增步长 + * @return int + */ + public function incrBy($key, $step) + { + } + + /** + * + *为指定字段增加指定的值. + * @example + *
+     * $redis->delete('h');
+     * $redis->hIncrBy('h', 'x', 2); // returns 2: h[x] = 2 now.
+     * $redis->hIncrBy('h', 'x', 1); // h[x] ← 2 + 1. Returns 3
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param int $step 自增步长 + * @return int + */ + public function hIncrBy($key, $field, $step) + { + } + + /** + * + *键值自增 + * @example + *
+     * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
+     * $redis->incr('key1'); // 2
+     * $redis->incr('key1'); // 3
+     * $redis->incr('key1'); // 4
+     * 
+ * @param string $key 键名 + * @return int + */ + public function incr($key) + { + } + + /** + * + *按指定步长自减 + * @example + *
+     * $redis->decr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value -1
+     * $redis->decr('key1');        // -2
+     * $redis->decr('key1');        // -3
+     * $redis->decrBy('key1', 10);  // -13
+     * 
+ * @param string $key 键名 + * @param float $step 自减步长 + * @return int + */ + public function decrBy($key, $step) + { + } + + /** + * + *键值自减 + * @example + *
+     * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
+     * $redis->decr('key1'); // -2
+     * $redis->decr('key1'); // -3
+     * 
+ * @param string $key 键名 + * @return int + */ + public function decr($key) + { + } + + /** + * + *获取某个键的某个位置的位值 + * @example + *
+     * $redis->set('key', "\x7f");  // this is 0111 1111
+     * $redis->getBit('key', 0);    // 0
+     * $redis->getBit('key', 1);    // 1
+     * 
+ * @param string $key 键名 + * @param int $offset 所在位置 + * @return int + */ + public function getBit($key, $offset) + { + } + + /** + * + *在列表中,在某个元素的前面或后面插入一个新值 + * @example + *
+     * $redis->delete('key1');
+     * $redis->lInsert('key1', Redis::AFTER, 'A', 'X');     // 0
+     * $redis->lPush('key1', 'A');
+     * $redis->lPush('key1', 'B');
+     * $redis->lPush('key1', 'C');
+     * $redis->lInsert('key1', Redis::BEFORE, 'C', 'X');    // 4
+     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C')
+     * $redis->lInsert('key1', Redis::AFTER, 'C', 'Y');     // 5
+     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C', 'Y')
+     * $redis->lInsert('key1', Redis::AFTER, 'W', 'value'); // -1
+     * 
+ * @param string $key 键名 + * @param string $position 位置(前面或后面,使用Redis::BEFORE | Redis::AFTER) + * @param string $element 元素 + * @param string $value 新值 + * @return int + */ + public function lInsert($key, $position, $element, $value) + { + } + + /** + * + *获取列表中指定索引的值 + * @example + * @param string $key 键名 + * @param int $index 索引值 + * @return string | boolean + */ + public function lGet($key, $index) + { + } + + /** + * + *获取列表中指定索引的值 + * @example + * @param string $key 键名 + * @param int $index 索引值 + * @return string | boolean + */ + public function lIndex($key, $index) + { + } + + /** + * + *设置键的有效期 + * @example + * @param string $key 键名 + * @param int $ttl 有效期(秒数) + * @return boolean + */ + public function setTimeout($key, $ttl) + { + } + + /** + * + *设置键的有效期 + * @example + * @param string $key 键名 + * @param int $ttl 有效期(秒数) + * @return boolean + */ + public function expire($key, $ttl) + { + } + + /** + * + *设置键的有效期(毫秒为单位) + * @example + * @param string $key 键名 + * @param int $ttl 有效期(毫秒数) + * @return boolean + */ + public function pexpire($key, $ttl) + { + } + + /** + * + *为某个键设置有效期为某个时间点 + * @example + *
+     * $redis->set('x', '42');
+     * $now = time(NULL);               // current timestamp
+     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
+     * sleep(5);                        // wait 5 seconds
+     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
+     * 
+ * @param string $key 键名 + * @param int $expireTime 到期时间 + * @return bool: + */ + public function expireAt($key, $expireTime) + { + } + + /** + * + *为某个键设置有效期为某个时间点(精确到毫秒) + * @example + *
+     * $redis->set('x', '42');
+     * $now = time(NULL);               // current timestamp
+     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
+     * sleep(5);                        // wait 5 seconds
+     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
+     * 
+ * @param string $key 键名 + * @param int $expireTime 到期时间 + * @return bool: + */ + public function pexpireAt($key, $expireTime) + { + } + + /** + * + *将某个键移动到其他数据库中 + * @example + *
+     * $redis->select(0);       // switch to DB 0
+     * $redis->set('x', '42');  // write 42 to x
+     * $redis->move('x', 1);    // move to DB 1
+     * $redis->select(1);       // switch to DB 1
+     * $redis->get('x');        // will return 42
+     * 
+ * @param string $key 键名 + * @param int $dbIndex 数据库编号 + * @return bool + */ + public function move($key, $dbIndex) + { + } + + /** + * + *切换数据库 + * @example + *
+     * $redis->select(0);       // switch to DB 0
+     * $redis->set('x', '42');  // write 42 to x
+     * $redis->move('x', 1);    // move to DB 1
+     * $redis->select(1);       // switch to DB 1
+     * $redis->get('x');        // will return 42
+     * 
+ * @param int $dbIndex 数据库编号 + * @return bool + */ + public function select($dbIndex) + { + } + + /** + * + *获取一个键值的子字符串 + * @example + *
+     * $redis->set('key', 'string value');
+     * $redis->getRange('key', 0, 5);   // 'string'
+     * $redis->getRange('key', -5, -1); // 'value'
+     * 
+ * @param string $key 键名 + * @param int $start 开始位置 + * @param int $end 结束位置 + * @return string: + */ + public function getRange($key, $start, $end) + { + } + + /** + * + *删除指定范围外的其他元素 + * @example + * @param string $key 键名 + * @param int $start 开始索引 + * @param int $end 结束索引 + * @return array | boolean + */ + public function listTrim($key, $start, $end) + { + } + + /** + * + *删除指定范围外的其他元素 + * @example + * @param string $key 键名 + * @param int $start 开始索引 + * @param int $end 结束索引 + * @return array | boolean + */ + public function ltrim($key, $start, $end) + { + } + + /** + * + *获取列表指定范围的值 + * @example + * @param string $key 键名 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @return array + */ + public function lGetRange($key, $start, $end) + { + } + + /** + * + *获取列表指定范围的值 + * @example + * @param string $key 键名 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @return array + */ + public function lRange($key, $start, $end) + { + } + + /** + * + *从列表中删除指定值的元素。 如果count为零,则删除所有匹配的元素。 如果计数是负数,则元素从尾部移到头部。 + * @example + * @param string $key 键名 + * @param string $value 元素值 + * @param int $count 删除的个数 + * @return long | bool + */ + public function lRem($key, $value, $count) + { + } + + /** + * + *从列表中删除指定值的元素。 如果count为零,则删除所有匹配的元素。 如果计数是负数,则元素从尾部移到头部。 + * @example + * @param string $key 键名 + * @param string $value 元素值 + * @param int $count 删除的个数 + * @return long | bool + */ + public function lRemove($key, $value, $count) + { + } + + /** + * + *根据排序范围删除成员 + * @example + *
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zAdd('key', 3, 'three');
+     * $redis->zRemRangeByRank('key', 0, 1); // 2
+     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int + */ + public function zDeleteRangeByRank($key, $start, $end) + { + } + + /** + * + *根据排序范围删除成员 + * @example + *
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zAdd('key', 3, 'three');
+     * $redis->zRemRangeByRank('key', 0, 1); // 2
+     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int + */ + public function zRemRangeByRank($key, $start, $end) + { + } + + /** + * + *按指定步长自增 + * @example + *
+     * $redis = new Redis();
+     * $redis->connect('127.0.0.1');
+     * $redis->set('x', 3);
+     * var_dump( $redis->incrByFloat('x', 1.5) );   // float(4.5)
+     * // ! SIC
+     * var_dump( $redis->get('x') );                // string(3) "4.5"
+     * 
+ * @param string $key 键名 + * @param float $step 自增步长 + * @return float + */ + public function incrByFloat($key, $step) + { + } + + /** + * + *为指定字段增加指定的值 + * @example + *
+     * $redis = new Redis();
+     * $redis->connect('127.0.0.1');
+     * $redis->hset('h', 'float', 3);
+     * $redis->hset('h', 'int',   3);
+     * var_dump( $redis->hIncrByFloat('h', 'float', 1.5) ); // float(4.5)
+     * var_dump( $redis->hGetAll('h') );
+     * // Output
+     * array(2) {
+     * ["float"]=>
+     * string(3) "4.5"
+     * ["int"]=>
+     * string(1) "3"
+     * }
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param double $step 自增步长 + * @return + */ + public function hIncrByFloat($key, $field, $step) + { + } + + /** + * + *统计字符串的位数 + * @example + * @param string $key 键名 + * @return long + */ + public function bitCount($key) + { + } + + /** + * + *多个键的位操作,并将结果存入到指定的键中 + * @example + * @param string $operation 操作(有 AND, OR, NOT, XOR 4种可选择) + * @param string $dstKey 目标键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名N + * @return long + */ + public function bitOp($operation, $dstKey, $key1, $key2, $keyN) + { + } + + /** + * + *给集合添加元素 + * @example + *
+     * $redis->sAdd('k', 'v1');                // int(1)
+     * $redis->sAdd('k', 'v1', 'v2', 'v3');    // int(2)
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int + */ + public function sAdd($key, $value) + { + } + + /** + * + *将某个集合中的元素移动到另外一个集合中 + * @example + *
+     * $redis->sAdd('key1' , 'set11');
+     * $redis->sAdd('key1' , 'set12');
+     * $redis->sAdd('key1' , 'set13');          // 'key1' => {'set11', 'set12', 'set13'}
+     * $redis->sAdd('key2' , 'set21');
+     * $redis->sAdd('key2' , 'set22');          // 'key2' => {'set21', 'set22'}
+     * $redis->sMove('key1', 'key2', 'set13');  // 'key1' =>  {'set11', 'set12'}
+     * // 'key2' =>  {'set21', 'set22', 'set13'}
+     * 
+ * @param string $srcKey 原集合键名 + * @param string $dstKey 目标集合键名 + * @param string $member 成员 + * @return bool + */ + public function sMove($srcKey, $dstKey, $member) + { + } + + /** + * + *获取多个集合的差集 + * @example + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s0', '3');
+     * $redis->sAdd('s0', '4');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * var_dump($redis->sDiff('s0', 's1', 's2'));
+     * //array(2) {
+     * //  [0]=>
+     * //  string(1) "4"
+     * //  [1]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string|... $key2 键名2 + * @return array + */ + public function sDiff($key1, $key2) + { + } + + /** + * + *获取多个集合的差集,并将结果存入到一个新的集合中 + * @example + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s0', '3');
+     * $redis->sAdd('s0', '4');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * var_dump($redis->sDiffStore('dst', 's0', 's1', 's2'));
+     * var_dump($redis->sMembers('dst'));
+     * //int(2)
+     * //array(2) {
+     * //  [0]=>
+     * //  string(1) "4"
+     * //  [1]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int: + */ + public function sDiffStore($dstKey, $key1, $key2, $keyN) + { + } + + /** + * + *获取集合的并集 + * @example + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s1', '3');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * $redis->sAdd('s2', '4');
+     * var_dump($redis->sUnion('s0', 's1', 's2'));
+     * array(4) {
+     * //  [0]=>
+     * //  string(1) "3"
+     * //  [1]=>
+     * //  string(1) "4"
+     * //  [2]=>
+     * //  string(1) "1"
+     * //  [3]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string|... $key2 键名2 + * @return array + */ + public function sUnion($key1, $key2) + { + } + + /** + * + *获取多个集合的并集,并将结果存入到另外一个集合中 + * @example + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s1', '3');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * $redis->sAdd('s2', '4');
+     * var_dump($redis->sUnionStore('dst', 's0', 's1', 's2'));
+     * var_dump($redis->sMembers('dst'));
+     * //int(4)
+     * //array(4) {
+     * //  [0]=>
+     * //  string(1) "3"
+     * //  [1]=>
+     * //  string(1) "4"
+     * //  [2]=>
+     * //  string(1) "1"
+     * //  [3]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int + */ + public function sUnionStore($dstKey, $key1, $key2, $keyN) + { + } + + /** + * + *获取两个集合的交集 + * @example + *
+     * $redis->sAdd('key1', 'val1');
+     * $redis->sAdd('key1', 'val2');
+     * $redis->sAdd('key1', 'val3');
+     * $redis->sAdd('key1', 'val4');
+     * $redis->sAdd('key2', 'val3');
+     * $redis->sAdd('key2', 'val4');
+     * $redis->sAdd('key3', 'val3');
+     * $redis->sAdd('key3', 'val4');
+     * var_dump($redis->sInter('key1', 'key2', 'key3'));
+     * //array(2) {
+     * //  [0]=>
+     * //  string(4) "val4"
+     * //  [1]=>
+     * //  string(4) "val3"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string $key2 键名2 + * @return array | boolean + */ + public function sInter($key1, $key2) + { + } + + /** + * + *获取多个集合的交集,并将结果存入到另外一个集合中 + * @example + *
+     * $redis->sAdd('key1', 'val1');
+     * $redis->sAdd('key1', 'val2');
+     * $redis->sAdd('key1', 'val3');
+     * $redis->sAdd('key1', 'val4');
+     * $redis->sAdd('key2', 'val3');
+     * $redis->sAdd('key2', 'val4');
+     * $redis->sAdd('key3', 'val3');
+     * $redis->sAdd('key3', 'val4');
+     * var_dump($redis->sInterStore('output', 'key1', 'key2', 'key3'));
+     * var_dump($redis->sMembers('output'));
+     * //int(2)
+     * //
+     * //array(2) {
+     * //  [0]=>
+     * //  string(4) "val4"
+     * //  [1]=>
+     * //  string(4) "val3"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int + */ + public function sInterStore($dstKey, $key1, $key2, $keyN) + { + } + + /** + * + *删除集合元素 + * @example + * @param string $key 键名 + * @param string|... $member 成员 + * @return long + */ + public function sRemove($key, $member) + { + } + + /** + * + *删除集合元素 + * @example + * @param string $key 键名 + * @param string|... $member 成员 + * @return long + */ + public function srem($key, $member) + { + } + + /** + * + *删除有序集合中的某个成员 + * @example + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int + */ + public function zDelete($key, $member) + { + } + + /** + * + *删除有序集合中的某个成员 + * @example + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int + */ + public function zRemove($key, $member) + { + } + + /** + * + *删除有序集合中的某个成员 + * @example + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int + */ + public function zRem($key, $member) + { + } + + /** + * + *通过匹配模式来订阅这些匹配的消息频道 + * @example + *
+     * function psubscribe($redis, $pattern, $chan, $msg) {
+     * echo "Pattern: $pattern\n";
+     * echo "Channel: $chan\n";
+     * echo "Payload: $msg\n";
+     * }
+     * 
+ * @param array $patterns 匹配模式 + * @param string|array $callback 回调函数名称 + * @param mixed $value 返回值 + * @return + */ + public function pSubscribe(Array $patterns, $callback, $value) + { + } + + /** + * + *订阅消息 + * @example + *
+     * function f($redis, $chan, $msg) {
+     * switch($chan) {
+     * case 'chan-1':
+     * ...
+     * break;
+     * case 'chan-2':
+     * ...
+     * break;
+     * case 'chan-2':
+     * ...
+     * break;
+     * }
+     * }
+     * $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
+     * 
+ * @param array $channels 订阅的消息频道 + * @param string|array $callback 回调函数名称 + * @param mixed $value 返回值 + * @return mixed + */ + public function subscribe(Array $channels, $callback, $value) + { + } + + /** + * + *开始一个事务. + * @example + *
+     * $ret = $redis->multi()
+     * ->set('key1', 'val1')
+     * ->get('key1')
+     * ->set('key2', 'val2')
+     * ->get('key2')
+     * ->exec();
+     * //$ret == array (
+     * //    0 => TRUE,
+     * //    1 => 'val1',
+     * //    2 => TRUE,
+     * //    3 => 'val2');
+     * 
+ * @return + */ + public function multi() + { + } + + /** + * + *执行事务 + * @example + * @return + */ + public function exec() + { + } + + /** + * + *执行lua脚本 + * @example + * @param string $script 脚本 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 + * @return mixed + */ + public function eval($script, Array $args, $num_keys) + { + } + + /** + * + *从脚本的SHA1散列而不是脚本本身执行LUA脚本 + * @example $script = 'return 1'; + * $sha = $redis->script('load', $script); + * $redis->evalSha($sha); // Returns 1 + * @param string $script_sha 脚本的散列值 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 + * @return + */ + public function evalSha($script_sha, Array $args, $num_keys) + { + } + + /** + * + *在脚本子系统上执行redis命令 + * @example + *
+     * $redis->script('load', $script);
+     * $redis->script('flush');
+     * $redis->script('kill');
+     * $redis->script('exists', $script1, [$script2, $script3, ...]);
+     * 
+ * SCRIPT LOAD will return the SHA1 hash of the passed script on success, and FALSE on failure. + * SCRIPT FLUSH should always return TRUE + * SCRIPT KILL will return true if a script was able to be killed and false if not + * SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script + * @param string $command redis命令 + * @param string|... $script 脚本 + * @return + */ + public function script($command, $script) + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + +} + diff --git a/src/Swoole/Co/Redis/Server.php b/src/Swoole/Co/Redis/Server.php new file mode 100644 index 0000000..e34783f --- /dev/null +++ b/src/Swoole/Co/Redis/Server.php @@ -0,0 +1,759 @@ +finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * + *启动server + * @example + * @return + */ + public function start() + { + } + + /** + * + *设置Redis命令字的处理器 + * @example + * @param string $command 命令的名称 + * @param callable $callback 命令的处理函数,回调函数返回字符串类型时会自动发送给客户端 + * @param int $number_of_string_param 字符串参数的长度 + * @param int $type_of_array_param 数组参数元素的类型 + * @return + */ + public function setHandler($command, Callable $callback, $number_of_string_param, $type_of_array_param) + { + } + + /** + * + *格式化命令响应数据 + * @example + * @param int $type 表示数据类型,NIL类型不需要传入$value,ERROR和STATUS类型$value可选,INT、STRING、SET、MAP必选 + * @param mixed $value 要处理的数据 + * @return + */ + public static function format($type, $value) + { + } + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param string $data 要传递的数据 + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return boolean + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + +} + diff --git a/src/Swoole/Co/Server.php b/src/Swoole/Co/Server.php new file mode 100644 index 0000000..708bb49 --- /dev/null +++ b/src/Swoole/Co/Server.php @@ -0,0 +1,698 @@ +finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *启动server + * @example + * @return + */ + public function start() + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param string $data 要传递的数据 + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return boolean + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + +} + diff --git a/src/Swoole/Co/WebSocket/Server.php b/src/Swoole/Co/WebSocket/Server.php new file mode 100644 index 0000000..a41f509 --- /dev/null +++ b/src/Swoole/Co/WebSocket/Server.php @@ -0,0 +1,751 @@ +finish()方法将任务处理的结果发送给worker进程。 + * @access public + */ + public $onFinish; + + /** + * @var callable $onManagerStart + * 当管理进程启动时调用它 + * @access public + */ + public $onManagerStart; + + /** + * @var callable $onManagerStop + * 当管理进程结束时调用它 + * @access public + */ + public $onManagerStop; + + /** + * @var callable $onPipeMessage + * 当工作进程收到由 sendMessage 发送的管道消息时会触发onPipeMessage事件 + * @access public + */ + public $onPipeMessage; + + /** + * @var iterator $connections + * TCP连接迭代器 + * @access public + */ + public $connections; + + /** + * @var string $host + * 连接的主机 + * @access public + */ + public $host; + + /** + * @var int $port + * 连接的主机的端口 + * @access public + */ + public $port = 0; + + /** + * @var int $type + * socket的类型 + * @access public + */ + public $type = 0; + + /** + * @var int $mode + * 运行模式(swoole提供了3种运行模式,默认为SWOOLE_PROCESS多进程模式) + * @access public + */ + public $mode = 0; + + /** + * @var array $ports + * 当监听多端口时的端口列表 + * @access public + */ + public $ports; + + /** + * @var int $master_pid + * 主进程ID + * @access public + */ + public $master_pid = 0; + + /** + * @var int $manager_pid + * 管理进程ID + * @access public + */ + public $manager_pid = 0; + + /** + * @var int $worker_id + * 当前工作进程(包括worker进程和task进程)编号 + * @access public + */ + public $worker_id = 0; + + /** + * @var boolean $taskworker + * 当前进程是否是task工作进程 + * @access public + */ + public $taskworker = ''; + + /** + * @var int $worker_pid + * 当前工作进程ID(操作系统进程) + * @access public + */ + public $worker_pid = 0; + + /** + * @var callable $onRequest + * 请求回调函数 + * @access public + */ + public $onRequest; + + /** + * @var callable $onHandshake + * TCP握手时的回调函数 + * @access public + */ + public $onHandshake; + + /** + * @var array $setting + * 通过swoole_server:set()设置的参数会保存到setting属性上 + * @access public + */ + public $setting; + + /** + * + *绑定事件(为事件注册函数) + * @example + * @param string $event_name 事件名称 + * @param callable $callback 事件对应的回调函数 + * @return + */ + public function on($event_name, Callable $callback) + { + } + + /** + * + *向websocket客户端连接推送数据,长度最大不得超过2M + * @example + * @param int $fd 客户端连接的ID,如果指定的$fd对应的TCP连接并非websocket客户端,将会发送失败 + * @param string $data 要发送的数据内容 + * @param int $opcode 指定发送数据内容的格式,默认为文本。发送二进制内容$opcode参数需要设置 + * @param boolean $finish 帧是否完成 + * @return + */ + public function push($fd, $data, $opcode, $finish) + { + } + + /** + * + *检测fd对应的连接是否存在 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function exist($fd) + { + } + + /** + * + *打包数据 + * @example + * @param string $data 消息内容 + * @param int $opcode WebSocket的opcode指令类型,1表示文本,2表示二进制数据,9表示心跳ping + * @param boolean $finish 帧是否完成 + * @param boolean $mask 是否设置掩码 + * @return + */ + public static function pack($data, $opcode, $finish, $mask) + { + } + + /** + * + *参数据进行解包 + * @example + * @param string $data 解包的数据 + * @return + */ + public static function unpack($data) + { + } + + /** + * + *启动server + * @example + * @return + */ + public function start() + { + } + + /** + * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) + * @example + * @return + */ + public function __sleep() + { + } + + /** + * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) + * @example + * @return + */ + public function __wakeup() + { + } + + /** + * + *swoole_server初始化方法 + * @example + * @param string $host 主机IP + * @param int $port 端口 + * @param int $mode 运行模式 + * @param int $sock_type socket类型 + * @return + */ + public function __construct($host, $port, $mode, $sock_type) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + + /** + * + *添加监听端口(是addlistener的别名) + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function listen($host, $port, $sock_type) + { + } + + /** + * + *添加监听端口 + * @example + * @param string $host 监听的主机 + * @param int $port 监听的端口号 + * @param int $sock_type socket类型 + * @return + */ + public function addlistener($host, $port, $sock_type) + { + } + + /** + * + *设置swoole_server运行时的参数 + * @example + * @param array $settings 配置选项 + * @return + */ + public function set(Array $settings) + { + } + + /** + * + *向客户端发送数据 + * @example + * @param int $fd 连接句柄 + * @param string $send_data 发送的数据 + * @param int $reactor_id UDP服务器使用$fd保存客户端IP,$extraData保存server_fd和port + * @return + */ + public function send($fd, $send_data, $reactor_id) + { + } + + /** + * + *向任意客户端发送UDP数据包 + * @example + * @param string $ip IPv4字符串,如192.168.1.102。如果IP不合法会返回错误 + * @param int $port 为 1-65535的网络端口号,如果端口错误发送会失败 + * @param string $send_data 发送的数据内容,可以是文本或者二进制内容 + * @param int $server_socket 服务器可能会同时监听多个UDP端口,此参数可以指定使用哪个端口发送数据包 + * @return + */ + public function sendto($ip, $port, $send_data, $server_socket) + { + } + + /** + * + *阻塞的向客户端发送数据 + * @example + * @param int $conn_fd 与客户端连接的句柄 + * @param string $send_data 发送的数据 + * @return + */ + public function sendwait($conn_fd, $send_data) + { + } + + /** + * + *设置客户端连接为保护状态,不被心跳线程切断 + * @example + * @param int $fd 要设置保护状态的客户端连接fd + * @param boolean $is_protected 设置的状态,true表示保护状态,false表示不保护 + * @return + */ + public function protect($fd, $is_protected) + { + } + + /** + * + *向客户端发送文件 + * @example + * @param int $conn_fd 连接句柄 + * @param string $filename 文件名 + * @param int $offset 指定文件偏移量,可以从文件的某个位置起发送数据。默认为0,表示从文件头部开始发送 + * @param int $length 指定发送的长度,默认为文件尺寸 + * @return + */ + public function sendfile($conn_fd, $filename, $offset, $length) + { + } + + /** + * + *关闭客户端连接 + * @example + * @param int $fd 连接句柄 + * @param boolean $reset 设置为true会强制关闭连接,丢弃发送队列中的数据 + * @return + */ + public function close($fd, $reset) + { + } + + /** + * + *确认连接,与enable_delay_receive或wait_for_bind配合使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function confirm($fd) + { + } + + /** + * + *停止接收数据 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function pause($fd) + { + } + + /** + * + *恢复数据接收。与pause方法成对使用 + * @example + * @param int $fd 连接句柄 + * @return + */ + public function resume($fd) + { + } + + /** + * + *投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @param callable $finish_callback 完成后的回调函数 + * @return + */ + public function task($data, $worker_id, Callable $finish_callback) + { + } + + /** + * + *以阻塞的形式投递一个任务到task_worker连接池中 + * @example + * @param mixed $data 要投递的任务数据,可以为除资源类型之外的任意PHP变量 + * @param float $timeout 超时时间 + * @param int $worker_id 可以制定要给投递给哪个task进程,传入ID即可 + * @return + */ + public function taskwait($data, $timeout, $worker_id) + { + } + + /** + * + *并发执行多个Task + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return + */ + public function taskWaitMulti(Array $tasks, $timeout) + { + } + + /** + * + *并发执行Task并进行协程调度 + * @example + * @param array $tasks 必须为数字索引数组,不支持关联索引数组,底层会遍历$tasks将任务逐个投递到Task进程 + * @param double $timeout 超时时间 + * @return array + */ + public function taskCo(Array $tasks, $timeout) + { + } + + /** + * + *用于在task进程中通知worker进程任务已完成 + * @example + * @param string $data 要传递的数据 + * @return + */ + public function finish($data) + { + } + + /** + * + *重启所有工作进程 + * @example + * @return boolean + */ + public function reload() + { + } + + /** + * + *关闭服务器 + * @example + * @return + */ + public function shutdown() + { + } + + /** + * + *停止当前worker进程 + * @example + * @param int $worker_id 进程ID + * @return + */ + public function stop($worker_id) + { + } + + /** + * + *获取最近一次操作错误的错误码 + *返回的错误码: + *1001 连接已经被Server端关闭了,出现这个错误一般是代码中已经执行了$serv->close()关闭了某个连接,但仍然调用$serv->send()向这个连接发送数据 + * @example + * @return + */ + public function getLastError() + { + } + + /** + * + *检测所有服务器连接,并找出已经超时的连接 + * @example + * @param boolean $reactor_id 是否关闭超时的连接,默认为true + * @return + */ + public function heartbeat($reactor_id) + { + } + + /** + * + *获取客户端连接信息 + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return from_id + */ + public function connection_info($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接 + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function connection_list($start_fd, $find_count) + { + } + + /** + * + *获取连接的信息,别名是swoole_server->connection_info + * @example + * @param mixed $fd 连接句柄 + * @param int $reactor_id reactor线程id + * @return + */ + public function getClientInfo($fd, $reactor_id) + { + } + + /** + * + *用来遍历所有客户端连接(server->connection_list的别名) + * @example + * @param int $start_fd 起始fd + * @param int $find_count 每页取多少条 + * @return + */ + public function getClientList($start_fd, $find_count) + { + } + + /** + * + *在指定时间后执行某个回调函数 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @param array $param 给回调函数传入的参数 + * @return + */ + public function after($ms, Callable $callback, Array $param) + { + } + + /** + * + *添加定时器 + * @example + * @param int $ms 指定时间,单位为毫秒 + * @param callable $callback 回调函数 + * @return + */ + public function tick($ms, Callable $callback) + { + } + + /** + * + *清除定时器 + * @example + * @param int $timer_id 定时器ID + * @return + */ + public function clearTimer($timer_id) + { + } + + /** + * + *延迟执行一个PHP函数 + * @example + * @param callable $callback 执行的函数 + * @return + */ + public function defer(Callable $callback) + { + } + + /** + * + *向任意worker进程或task进程发送消息 + * @example + * @param int $dst_worker_id 目标worker的ID + * @param string $data 发送的消息 + * @return + */ + public function sendMessage($dst_worker_id, $data) + { + } + + /** + * + *添加一个自定义的工作进程 + * @example + * @param Swoole\Process $process 进程对象 + * @return + */ + public function addProcess($process) + { + } + + /** + * + *得到当前server的活动TCP连接数 + *array ( + * @example + * @return + */ + public function stats() + { + } + + /** + * + *将连接绑定到某个用户定义的ID + * @example + * @param int $fd 连接句柄 + * @param int $uid 用户定义的ID + * @return + */ + public function bind($fd, $uid) + { + } + +} + diff --git a/src/Swoole/Connection/Iterator.php b/src/Swoole/Connection/Iterator.php index 8595e45..f5cea64 100644 --- a/src/Swoole/Connection/Iterator.php +++ b/src/Swoole/Connection/Iterator.php @@ -1,8 +1,8 @@ set('key', 'value'); + * 带有效期的设置: + * $redis->set('key','value', 10); + * 当键不存在时,设置期有效期为10秒: + * $redis->set('key', 'value', Array('nx', 'ex'=>10)); + * 当键存在时,设置期有效期为1000毫秒: + * $redis->set('key', 'value', Array('xx', 'px'=>1000)); + * + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int|array $options 附加项,可以是超时时间或者一个选项数组 + * @return bool */ - public function set() + public function set($key, $value, $options) { } /** * - * + *修改某个键的某个位置的位值 * @example - * @return + *
+     * $redis->set('key', "*");     // ord("*") = 42 = 0x2f = "0010 1010"
+     * $redis->setBit('key', 5, 1); // returns 0
+     * $redis->setBit('key', 7, 1); // returns 0
+     * $redis->get('key');          // chr(0x2f) = "/" = b("0010 1111")
+     * 
+ * @param string $key 键名 + * @param int $offset 开始位置 + * @param boolean|int $value 新值 + * @return int: */ - public function setBit() + public function setBit($key, $offset, $value) { } /** * - * - * @example - * @return + *设置键值并设置有效期 + * @example $redis->setex('key', 3600, 'value'); + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int $ttl 有效期 + * @return bool */ - public function setEx() + public function setEx($key, $value, $ttl) { } /** * - * + *设置键值并设置有效期(毫秒为单位) * @example + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @param int $ttl 有效期(毫秒为单位) * @return */ - public function psetEx() + public function psetEx($key, $value, $ttl) { } /** * - * + *给列表指定位置设置新值 * @example - * @return + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->lGet('key1', 0);     // 'A'
+     * $redis->lSet('key1', 0, 'X');
+     * $redis->lGet('key1', 0);     // 'X'
+     * 
+ * @param string $key 键名 + * @param int $index 索引值 + * @param string $value 新值 + * @return boolean */ - public function lSet() + public function lSet($key, $index, $value) { } /** * - * - * @example - * @return + *获取指定的key的值 + * @example $redis->get('key'); + * @return string|bool */ public function get() { @@ -185,367 +227,679 @@ public function get() /** * - * + *批量获取键名 * @example + *
+     * $redis->delete('x', 'y', 'z', 'h');	// remove x y z
+     * $redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'));
+     * $redis->hset('h', 'field', 'value');
+     * var_dump($redis->mget(array('x', 'y', 'z', 'h')));
+     * // Output:
+     * // array(3) {
+     * // [0]=>
+     * // string(1) "a"
+     * // [1]=>
+     * // string(1) "b"
+     * // [2]=>
+     * // string(1) "c"
+     * // [3]=>
+     * // bool(false)
+     * // }
+     * 
+ * @param array $keys 键名数组 * @return */ - public function mGet() + public function mGet(Array $keys) { } /** * - * - * @example - * @return + *删除一个或多个键 + * @example $redis->delete('key1', 'key2'); + * $redis->delete(array('key3', 'key4')); + * @param array|string $keys 键名 + * @return int */ - public function del() + public function del($keys) { } /** * - * + *删除字典的某个或某些字段 * @example - * @return + *
+     * $redis->hMSet('h',
+     * array(
+     * 'f1' => 'v1',
+     * 'f2' => 'v2',
+     * 'f3' => 'v3',
+     * 'f4' => 'v4',
+     * ));
+     * var_dump( $redis->hDel('h', 'f1') );        // int(1)
+     * var_dump( $redis->hDel('h', 'f2', 'f3') );  // int(2)
+     * s
+     * var_dump( $redis->hGetAll('h') );
+     * //// Output:
+     * //  array(1) {
+     * //    ["f4"]=> string(2) "v4"
+     * //  }
+     * 
+ * @param string $key 键名 + * @param string|array $fields 字段名 + * @return int */ - public function hDel() + public function hDel($key, $fields) { } /** * - * + *为字典的字段设置值 * @example - * @return + *
+     * $redis->delete('h')
+     * $redis->hSet('h', 'key1', 'hello');  // 1, 'key1' => 'hello' in the hash at "h"
+     * $redis->hGet('h', 'key1');           // returns "hello"
+     * $redis->hSet('h', 'key1', 'plop');   // 0, value was replaced.
+     * $redis->hGet('h', 'key1');           // returns "plop"
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param string $value 字段值 + * @return long */ - public function hSet() + public function hSet($key, $field, $value) { } /** * - * + *批量设置字典字段的值 * @example - * @return + *
+     * $redis->delete('user:1');
+     * $redis->hMset('user:1', array('name' => 'Joe', 'salary' => 2000));
+     * $redis->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now.
+     * 
+ * @param string $key 键名 + * @param array $fields 字段键值对 + * @return boolean */ - public function hMSet() + public function hMSet($key, Array $fields) { } /** * - * + *当字典的字段不存在时,为其设置值 * @example - * @return + *
+     * $redis->delete('h')
+     * $redis->hSetNx('h', 'key1', 'hello'); // TRUE, 'key1' => 'hello' in the hash at "h"
+     * $redis->hSetNx('h', 'key1', 'world'); // FALSE, 'key1' => 'hello' in the hash at "h". No change since the field
+     * wasn't replaced.
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param string $value 字段值 + * @return bool */ - public function hSetNx() + public function hSetNx($key, $field, $value) { } /** * - * - * @example - * @return + *删除一个或多个键 + * @example $redis->delete('key1', 'key2'); + * $redis->delete(array('key3', 'key4')); + * @param array|string $keys 键名 + * @return int */ - public function delete() + public function delete($keys) { } /** * - * + *批量设置值 * @example - * @return + *
+     * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
+     * var_dump($redis->get('key0'));
+     * var_dump($redis->get('key1'));
+     * // Output:
+     * // string(6) "value0"
+     * // string(6) "value1"
+     * 
+ * @param array $values 要设置的键值对 + * @return bool */ - public function mSet() + public function mSet(Array $values) { } /** * - * + *批量设置值(当不存在时设置) * @example - * @return + *
+     * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
+     * var_dump($redis->get('key0'));
+     * var_dump($redis->get('key1'));
+     * // Output:
+     * // string(6) "value0"
+     * // string(6) "value1"
+     * 
+ * @param array $values 要设置的键值对 + * @return bool */ - public function mSetNx() + public function mSetNx(Array $values) { } /** * - * + *根据匹配模式获取键名(如*) * @example - * @return + * $allKeys = $redis->keys('*'); + * $keyWithUserPrefix = $redis->keys('user*'); + * @param string $pattern 匹配模式 + * @return array */ - public function getKeys() + public function getKeys($pattern) { } /** * - * + *根据匹配模式获取键名(如*) * @example - * @return + * $allKeys = $redis->keys('*'); + * $keyWithUserPrefix = $redis->keys('user*'); + * @param string $pattern 匹配模式 + * @return array */ - public function keys() + public function keys($pattern) { } /** * - * + *判断键是否存在 * @example - * @return + *
+     * $redis->set('key', 'value');
+     * $redis->exists('key');               //  TRUE
+     * $redis->exists('NonExistingKey');    // FALSE
+     * 
+ * @param string $key 键名 + * @return bool */ - public function exists() + public function exists($key) { } /** * - * - * @example - * @return + *获取指定键的数据类型(需要根据常量匹配) + * @example $redis->type('key'); + * @param string $key 键名 + * @return int */ - public function type() + public function type($key) { } /** * - * + *获取键值的长度 * @example - * @return + *
+     * $redis->set('key', 'value');
+     * $redis->strlen('key'); // 5
+     * 
+ * @param string $key 键名 + * @return int */ - public function strLen() + public function strLen($key) { } /** * - * + *从列表左侧删除一个元素 * @example - * @return + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->lPop('key1');        // key1 => [ 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @return string */ - public function lPop() + public function lPop($key) { } /** * - * + *是一个阻塞lPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表头部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,blPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 * @example - * @return + *
+     * // Non blocking feature
+     * $redis->lPush('key1', 'A');
+     * $redis->delete('key2');
+     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * // Blocking feature
+     * // process 1
+     * $redis->delete('key1');
+     * $redis->blPop('key1', 10);
+     * // blocking for 10 seconds
+     * // process 2
+     * $redis->lPush('key1', 'A');
+     * // process 1
+     * // array('key1', 'A') is returned
+     * 
+ * @param string|...|array $key 键名 + * @param int $timeout 超时时间 + * @return array */ - public function blPop() + public function blPop($key, $timeout) { } /** * - * + *从列表右侧删除一个元素 * @example - * @return + *
+     * $redis->rPush('key1', 'A');
+     * $redis->rPush('key1', 'B');
+     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
+     * $redis->rPop('key1');        // key1 => [ 'A', 'B' ]
+     * 
+ * @param string $key 键名 + * @return string */ - public function rPop() + public function rPop($key) { } /** * - * + *是一个阻塞rPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表尾部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,brPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 * @example - * @return + *
+     * // Non blocking feature
+     * $redis->lPush('key1', 'A');
+     * $redis->delete('key2');
+     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
+     * // OR
+     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
+     * // Blocking feature
+     * // process 1
+     * $redis->delete('key1');
+     * $redis->blPop('key1', 10);
+     * // blocking for 10 seconds
+     * // process 2
+     * $redis->lPush('key1', 'A');
+     * // process 1
+     * // array('key1', 'A') is returned
+     * 
+ * @param string|...|array $key 键名 + * @param int $timeout 超时时间 + * @return array */ - public function brPop() + public function brPop($key, $timeout) { } /** * - * + *阻塞执行rpoplpush * @example - * @return + * @param string $srcKey 要删除元素的队列键名 + * @param string $dstKey 要插入元素的队列的键名 + * @return string */ - public function bRPopLPush() + public function bRPopLPush($srcKey, $dstKey) { } /** * - * + *返回列表的长度 * @example - * @return + * @param string|...|array $key 键名 + * @return long | bool */ - public function lSize() + public function lSize($key) { } /** * - * + *返回列表的长度 * @example - * @return + * @param string|...|array $key 键名 + * @return long | bool */ - public function lLen() + public function lLen($key) { } /** * - * + *返回集合的元素个数 * @example - * @return + * @param string $key 键名 + * @return long */ - public function sSize() + public function sSize($key) { } /** * - * + *返回集合的元素个数 * @example - * @return + * @param string $key 键名 + * @return long */ - public function scard() + public function scard($key) { } /** * - * + *随机删除元素的某个或某些成员,并返回这个删除的成员. * @example - * @return + *
+     * $redis->sAdd('key1' , 'set1');
+     * $redis->sAdd('key1' , 'set2');
+     * $redis->sAdd('key1' , 'set3');   // 'key1' => {'set3', 'set1', 'set2'}
+     * $redis->sPop('key1');            // 'set1', 'key1' => {'set3', 'set2'}
+     * $redis->sPop('key1');            // 'set3', 'key1' => {'set2'}
+     * 
+ * @param string $key 键名 + * @param int $count 删除个数 + * @return string | bool */ - public function sPop() + public function sPop($key, $count) { } /** * - * + *返回集合的所有成员 * @example - * @return + *
+     * $redis->delete('s');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'b');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'c');
+     * var_dump($redis->sMembers('s'));
+     * //array(3) {
+     * //  [0]=>
+     * //  string(1) "c"
+     * //  [1]=>
+     * //  string(1) "a"
+     * //  [2]=>
+     * //  string(1) "b"
+     * //}
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array */ - public function sMembers() + public function sMembers($key) { } /** * - * + *返回集合的所有成员 * @example - * @return + *
+     * $redis->delete('s');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'b');
+     * $redis->sAdd('s', 'a');
+     * $redis->sAdd('s', 'c');
+     * var_dump($redis->sMembers('s'));
+     * //array(3) {
+     * //  [0]=>
+     * //  string(1) "c"
+     * //  [1]=>
+     * //  string(1) "a"
+     * //  [2]=>
+     * //  string(1) "b"
+     * //}
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array */ - public function sGetMembers() + public function sGetMembers($key) { } /** * - * + *随机返回一个集合的元素(不会删除它) * @example - * @return + *
+     * $redis->sAdd('key1' , 'one');
+     * $redis->sAdd('key1' , 'two');
+     * $redis->sAdd('key1' , 'three');              // 'key1' => {'one', 'two', 'three'}
+     * var_dump( $redis->sRandMember('key1') );     // 'key1' => {'one', 'two', 'three'}
+     * // string(5) "three"
+     * var_dump( $redis->sRandMember('key1', 2) );  // 'key1' => {'one', 'two', 'three'}
+     * // array(2) {
+     * //   [0]=> string(2) "one"
+     * //   [1]=> string(2) "three"
+     * // }
+     * 
+ * @param string $key 键名 + * @return string | bool */ - public function sRandMember() + public function sRandMember($key) { } /** * - * - * @example - * @return + *移除指定键的有效期,让它永久有效 + * @example $redis->persist('key'); + * @param string $key 键名 + * @return bool: */ - public function persist() + public function persist($key) { } /** * - * - * @example - * @return + *返回指定键的有效时间(秒) + * @example $redis->ttl('key'); + * @param string $key 键名 + * @return long */ - public function ttl() + public function ttl($key) { } /** * - * - * @example - * @return + *返回指定键的有效时间(毫秒) + * @example $redis->pttl('key'); + * @param string $key 键名 + * @return long */ - public function pttl() + public function pttl($key) { } /** * - * + *获取有序集合的成员数 * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCard('key');            // 3
+     * 
+ * @param string $key 集合键名 + * @return int */ - public function zCard() + public function zCard($key) { } /** * - * + *获取有序集合的成员数 * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCard('key');            // 3
+     * 
+ * @param string $key 集合键名 + * @return int */ - public function zSize() + public function zSize($key) { } /** * - * + *获取字典的字段个数 * @example - * @return + *
+     * $redis->delete('h')
+     * $redis->hSet('h', 'key1', 'hello');
+     * $redis->hSet('h', 'key2', 'plop');
+     * $redis->hLen('h'); // returns 2
+     * 
+ * @param string $key 键名 + * @return int */ - public function hLen() + public function hLen($key) { } /** * - * + *获取字典的字段名称列表. * @example - * @return + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hKeys('h'));
+     * // Output:
+     * // array(4) {
+     * // [0]=>
+     * // string(1) "a"
+     * // [1]=>
+     * // string(1) "b"
+     * // [2]=>
+     * // string(1) "c"
+     * // [3]=>
+     * // string(1) "d"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array */ - public function hKeys() + public function hKeys($key) { } /** * - * + *获取字典的字段值列表 * @example - * @return + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hVals('h'));
+     * // Output
+     * // array(4) {
+     * //   [0]=>
+     * //   string(1) "x"
+     * //   [1]=>
+     * //   string(1) "y"
+     * //   [2]=>
+     * //   string(1) "z"
+     * //   [3]=>
+     * //   string(1) "t"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array */ - public function hVals() + public function hVals($key) { } /** * - * + *获取字典所有字段键值对 * @example - * @return + *
+     * $redis->delete('h');
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hSet('h', 'b', 'y');
+     * $redis->hSet('h', 'c', 'z');
+     * $redis->hSet('h', 'd', 't');
+     * var_dump($redis->hGetAll('h'));
+     * // Output:
+     * // array(4) {
+     * //   ["a"]=>
+     * //   string(1) "x"
+     * //   ["b"]=>
+     * //   string(1) "y"
+     * //   ["c"]=>
+     * //   string(1) "z"
+     * //   ["d"]=>
+     * //   string(1) "t"
+     * // }
+     * // The order is random and corresponds to redis' own internal representation of the set structure.
+     * 
+ * @param string $key 键名 + * @return array */ - public function hGetAll() + public function hGetAll($key) { } /** * - * + *调试命令(不建议使用) * @example * @return */ @@ -555,69 +909,120 @@ public function debug() /** * - * + *将dump导出的二进制数据恢复到可读的字符串. * @example + *
+     * $redis->set('foo', 'bar');
+     * $val = $redis->dump('foo');
+     * $redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo'
+     * 
+ * @param string $key 键名 + * @param int $ttl 有效期 + * @param string $value dump导出的二进制数据 * @return */ - public function restore() + public function restore($key, $ttl, $value) { } /** * - * + *将某个键导出为一个二进制数据. * @example - * @return + *
+     * $redis->set('foo', 'bar');
+     * $val = $redis->dump('foo'); // $val will be the Redis encoded key value
+     * 
+ * @param string $key 键名 + * @return string */ - public function dump() + public function dump($key) { } /** * - * + *给键重命名 * @example - * @return + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean */ - public function renameKey() + public function renameKey($srcKey, $dstKey) { } /** * - * + *给键重命名 * @example - * @return + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean */ - public function rename() + public function rename($srcKey, $dstKey) { } /** * - * + *当目标键名不存在时,给键重命名 * @example - * @return + * @param string $srcKey 旧键名 + * @param string $dstKey 新键名 + * @return boolean */ - public function renameNx() + public function renameNx($srcKey, $dstKey) { } /** * - * + *从一个队列的队尾删除一个元素,并将该元素插入到另一个队列的头部 * @example - * @return + *
+     * $redis->delete('x', 'y');
+     * $redis->lPush('x', 'abc');
+     * $redis->lPush('x', 'def');
+     * $redis->lPush('y', '123');
+     * $redis->lPush('y', '456');
+     * // move the last of x to the front of y.
+     * var_dump($redis->rpoplpush('x', 'y'));
+     * var_dump($redis->lRange('x', 0, -1));
+     * var_dump($redis->lRange('y', 0, -1));
+     * //Output:
+     * //
+     * //string(3) "abc"
+     * //array(1) {
+     * //  [0]=>
+     * //  string(3) "def"
+     * //}
+     * //array(3) {
+     * //  [0]=>
+     * //  string(3) "abc"
+     * //  [1]=>
+     * //  string(3) "456"
+     * //  [2]=>
+     * //  string(3) "123"
+     * //}
+     * 
+ * @param string $srcKey 要删除元素的队列键名 + * @param string $dstKey 要插入元素的队列的键名 + * @return string */ - public function rpoplpush() + public function rpoplpush($srcKey, $dstKey) { } /** * - * + *返回一个随机的键 * @example - * @return + *
+     * $key = $redis->randomKey();
+     * $surprise = $redis->get($key);  // who knows what's in there.
+     * 
+ * @return string */ public function randomKey() { @@ -625,9 +1030,9 @@ public function randomKey() /** * - * + *检查当前redis连接状态(成功时返回PONG) * @example - * @return + * @return string */ public function ping() { @@ -635,39 +1040,50 @@ public function ping() /** * - * - * @example - * @return + *设置连接的认证密码 + * @example $redis->auth('foobared'); + * @param string $password 认证密码 + * @return bool: */ - public function auth() + public function auth($password) { } /** * - * + *取消观察某个键在其他客户端的变化情况 * @example + * @param string|array $keys 键名 * @return */ - public function unwatch() + public function unwatch($keys) { } /** * - * + *观察某个键在其他客户端的变化情况. * @example + *
+     * $redis->watch('x');
+     * // long code here during the execution of which other clients could well modify `x`
+     * $ret = $redis->multi()
+     * ->incr('x')
+     * ->exec();
+     * // $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.
+     * 
+ * @param string|array $keys 键名 * @return */ - public function watch() + public function watch($keys) { } /** * - * - * @example - * @return + *将数据同步到硬盘上 + * @example $redis->save(); + * @return boolean */ public function save() { @@ -675,7 +1091,7 @@ public function save() /** * - * + *将数据存入到硬盘上(异步操作) * @example * @return */ @@ -685,9 +1101,9 @@ public function bgSave() /** * - * - * @example - * @return + *获取上次数据同步到硬盘的时间 + * @example $redis->lastSave(); + * @return int */ public function lastSave() { @@ -695,9 +1111,9 @@ public function lastSave() /** * - * - * @example - * @return + *删除当前数据库的所有键 + * @example $redis->flushDB(); + * @return bool */ public function flushDB() { @@ -705,9 +1121,9 @@ public function flushDB() /** * - * - * @example - * @return + *删除当前实例的所有键 + * @example $redis->flushAll(); + * @return bool */ public function flushAll() { @@ -715,9 +1131,13 @@ public function flushAll() /** * - * + *获取当前数据库的键的个数 * @example - * @return + *
+     * $count = $redis->dbSize();
+     * echo "Redis has $count keys\n";
+     * 
+ * @return int */ public function dbSize() { @@ -725,9 +1145,9 @@ public function dbSize() /** * - * - * @example - * @return + *开启后台写AOF日志操作 + * @example $redis->bgrewriteaof(); + * @return bool */ public function bgrewriteaof() { @@ -735,9 +1155,16 @@ public function bgrewriteaof() /** * - * + *返回当前redis服务器时间. * @example - * @return + *
+     * var_dump( $redis->time() );
+     * // array(2) {
+     * //   [0] => string(10) "1342364352"
+     * //   [1] => string(6) "253002"
+     * // }
+     * 
+ * @return int */ public function time() { @@ -745,9 +1172,9 @@ public function time() /** * - * + *返回当前连接的服务器的角色,如master、alone、slave、sentinel * @example - * @return + * @return string */ public function role() { @@ -755,768 +1182,1458 @@ public function role() /** * - * + *修改某个键的某个位置的值 * @example - * @return + *
+     * $redis->set('key', 'Hello world');
+     * $redis->setRange('key', 6, "redis"); // returns 11
+     * $redis->get('key');                  // "Hello redis"
+     * 
+ * @param string $key 键名 + * @param int $offset 开始位置 + * @param string $value 被替换的子串的值 + * @return string */ - public function setRange() + public function setRange($key, $offset, $value) { } /** * - * + *当键不存在时设置其值 * @example - * @return - */ - public function setNx() - { - } - - /** + * $redis->setnx('key', 'value'); * - * - * @example - * @return + * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @return bool: */ - public function getSet() + public function setNx($key, $value) { } /** * - * + *设置键的值,并返回它的旧的缓存值 * @example - * @return + *
+     * $redis->set('x', '42');
+     * $exValue = $redis->getSet('x', 'lol');   // return '42', replaces x by 'lol'
+     * $newValue = $redis->get('x')'            // return 'lol'
+     * 
+ * @param string $key 设置的缓存键 + * @param string $value 设置的缓存值 + * @return string */ - public function append() + public function getSet($key, $value) { } /** * - * + *将字符串追加到键值后(返回值的长度) * @example - * @return + *
+     * $redis->set('key', 'value1');
+     * $redis->append('key', 'value2'); // 12
+     * $redis->get('key');              // 'value1value2'
+     * 
+ * @param string $key 键名 + * @param string $value 追加的值 + * @return int */ - public function lPushx() + public function append($key, $value) { } /** * - * + *如果列表存在,从左侧(头部)向列表插入元素 * @example - * @return + *
+     * $redis->delete('key1');
+     * $redis->lPushx('key1', 'A');     // returns 0
+     * $redis->lPush('key1', 'A');      // returns 1
+     * $redis->lPushx('key1', 'B');     // returns 2
+     * $redis->lPushx('key1', 'C');     // returns 3
+     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int */ - public function lPush() + public function lPushx($key, $value) { } /** * - * + *从左侧(头部)向列表插入元素 * @example - * @return + *
+     * $redis->lPush('l', 'v1', 'v2', 'v3', 'v4')   // int(4)
+     * var_dump( $redis->lRange('l', 0, -1) );
+     * //// Output:
+     * // array(4) {
+     * //   [0]=> string(2) "v4"
+     * //   [1]=> string(2) "v3"
+     * //   [2]=> string(2) "v2"
+     * //   [3]=> string(2) "v1"
+     * // }
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int */ - public function rPush() + public function lPush($key, $value) { } /** * - * + *从右侧(尾部)向列表插入元素 * @example - * @return + *
+     * $redis->rPush('l', 'v1', 'v2', 'v3', 'v4');    // int(4)
+     * var_dump( $redis->lRange('l', 0, -1) );
+     * //// Output:
+     * // array(4) {
+     * //   [0]=> string(2) "v1"
+     * //   [1]=> string(2) "v2"
+     * //   [2]=> string(2) "v3"
+     * //   [3]=> string(2) "v4"
+     * // }
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int */ - public function rPushx() + public function rPush($key, $value) { } /** * - * + *如果列表存在,从右侧(尾部)向列表插入元素 * @example - * @return + *
+     * $redis->delete('key1');
+     * $redis->rPushx('key1', 'A'); // returns 0
+     * $redis->rPush('key1', 'A'); // returns 1
+     * $redis->rPushx('key1', 'B'); // returns 2
+     * $redis->rPushx('key1', 'C'); // returns 3
+     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int */ - public function sContains() + public function rPushx($key, $value) { } /** * - * + *是否包含某个成员 * @example - * @return + * @param string $key 键名 + * @param string $member 成员值 + * @return boolean */ - public function sismember() + public function sContains($key, $member) { } /** * - * + *是否包含某个成员 * @example - * @return + * @param string $key 键名 + * @param string $member 成员值 + * @return boolean */ - public function zScore() + public function sismember($key, $member) { } /** * - * + *获取指定成员的排序值(分数) * @example - * @return + *
+     * $redis->zAdd('key', 2.5, 'val2');
+     * $redis->zScore('key', 'val2'); // 2.5
+     * 
+ * @param string $key 集合键名 + * @param string $member 成员值 + * @return double */ - public function zRank() + public function zScore($key, $member) { } /** * - * + *获取成员的排序值 * @example - * @return + *
+     * $redis->delete('z');
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zRank('key', 'one');     // 0
+     * $redis->zRank('key', 'two');     // 1
+     * $redis->zRevRank('key', 'one');  // 1
+     * $redis->zRevRank('key', 'two');  // 0
+     * 
+ * @param string $key 集合键名 + * @param string $member 成员值 + * @return int */ - public function zRevRank() + public function zRank($key, $member) { } /** * - * + *获取成员的排位值(倒数) * @example - * @return + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int */ - public function hGet() + public function zRevRank($key, $member) { } /** * - * + *获取字典的某个字段的值 * @example - * @return + * @param string $key 键名 + * @param string $field 字段名 + * @return string */ - public function hMGet() + public function hGet($key, $field) { } /** * - * + *批量获取字典的字段值 * @example - * @return + * @param string $key 键名 + * @param array $fields 字段名列表 + * @return array */ - public function hExists() + public function hMGet($key, Array $fields) { } /** * - * + *判断字典的某个字段是否存在. * @example - * @return + *
+     * $redis->hSet('h', 'a', 'x');
+     * $redis->hExists('h', 'a');               //  TRUE
+     * $redis->hExists('h', 'NonExistingKey');  // FALSE
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @return bool */ - public function publish() + public function hExists($key, $field) { } /** * - * - * @example - * @return + *将消息发布到消息通道(队列). + * @example $redis->publish('chan-1', 'hello, world!'); // send message. + * @param string $channel 消息频道 + * @param string $message 消息 + * @return int */ - public function zIncrBy() + public function publish($channel, $message) { } /** * - * + *给有序集合成员增加排序值 * @example - * @return + *
+     * $redis->delete('key');
+     * $redis->zIncrBy('key', 2.5, 'member1');  // key or member1 didn't exist, so member1's score is to 0
+     * // before the increment and now has the value 2.5
+     * $redis->zIncrBy('key', 1, 'member1');    // 3.5
+     * 
+ * @param string $key 目标集合键名 + * @param double $step 增加的步长 + * @param string $member 成员 + * @return float */ - public function zAdd() + public function zIncrBy($key, $step, $member) { } /** * - * + *向有序集合插入元素 * @example - * @return + *
+     * 
+     * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
+     * $redis->zRem('z', 'v2', 'v3');                           // int(2)
+     * var_dump( $redis->zRange('z', 0, -1) );
+     * //// Output:
+     * // array(2) {
+     * //   [0]=> string(2) "v1"
+     * //   [1]=> string(2) "v4"
+     * // }
+     * 
+ *
+ * @param string $key 集合键名 + * @param double $score 排序值 + * @param string $value 元素值 + * @return int */ - public function zDeleteRangeByScore() + public function zAdd($key, $score, $value) { } /** * - * + *根据排序值范围来删除成员 * @example - * @return + * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return long */ - public function zRemRangeByScore() + public function zDeleteRangeByScore($key, $start, $end) { } /** * - * + *根据排序值范围来删除成员 * @example - * @return + * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return long */ - public function zCount() + public function zRemRangeByScore($key, $start, $end) { } /** * - * + *获取指定排序范围的成员数. * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zCount('key', 0, 3); // 2, corresponding to array('val0', 'val2')
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int */ - public function zRange() + public function zCount($key, $start, $end) { } /** * - * + *获取有序集合中指定范围的成员 * @example - * @return + *
+     * $redis->zAdd('key1', 0, 'val0');
+     * $redis->zAdd('key1', 2, 'val2');
+     * $redis->zAdd('key1', 10, 'val10');
+     * $redis->zRange('key1', 0, -1); // array('val0', 'val2', 'val10')
+     * // with scores
+     * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param boolean $withScores 是否返回成员的排序值 + * @return array */ - public function zRevRange() + public function zRange($key, $start, $end, $withScores) { } /** * - * + *获取有序集合中指定范围的成员(倒序排列) * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRevRange('key', 0, -1); // array('val10', 'val2', 'val0')
+     * // with scores
+     * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param boolean $withScores 是否返回成员的排序值 + * @return array */ - public function zRangeByScore() + public function zRevRange($key, $start, $end, $withScores) { } /** * - * + *获取有序集合中指定范围的成员(按排序值排列) * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) + * @return array */ - public function zRevRangeByScore() + public function zRangeByScore($key, $start, $end, Array $options) { } /** * - * + *获取有序集合中指定范围的成员(按排序值倒序排列) * @example - * @return + *
+     * $redis->zAdd('key', 0, 'val0');
+     * $redis->zAdd('key', 2, 'val2');
+     * $redis->zAdd('key', 10, 'val10');
+     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
+     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
+     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
+     * 
+ * @param string $key 集合键名 + * @param long $start 索引开始值 + * @param long $end 索引结束值 + * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) + * @return array */ - public function zRangeByLex() + public function zRevRangeByScore($key, $start, $end, Array $options) { } /** * - * + *按字母字典的顺序返回成员 * @example - * @return + *
+     * foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g') as $char) {
+     * $redis->zAdd('key', $char);
+     * }
+     * $redis->zRangeByLex('key', '-', '[c'); // array('a', 'b', 'c')
+     * $redis->zRangeByLex('key', '-', '(c'); // array('a', 'b')
+     * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c')
+     * 
+ * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @param long $offset 索引开始值 + * @param long $limit 成员数 + * @return array */ - public function zRevRangeByLex() + public function zRangeByLex($key, $min, $max, $offset, $limit) { } /** * - * + *按字母字典的顺序返回成员(倒序排序) * @example + * @param string $key 集合键名 + * @param long $min 最小的字母 + * @param long $max 最大的字母 + * @param long $offset 索引开始值 + * @param long $limit 成员数 * @return */ - public function zInter() + public function zRevRangeByLex($key, $min, $max, $offset, $limit) { } /** * - * + *将两个有序集合的交集存入到一个指定的键中 * @example - * @return + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->delete('ko4');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k1', 3, 'val3');
+     * $redis->zAdd('k2', 2, 'val1');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
+     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
+     * // Weighted zInter
+     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
+     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int */ - public function zinterstore() + public function zInter($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) { } /** * - * + *将两个有序集合的交集存入到一个指定的键中 * @example - * @return + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->delete('ko4');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k1', 3, 'val3');
+     * $redis->zAdd('k2', 2, 'val1');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
+     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
+     * // Weighted zInter
+     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
+     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int */ - public function zUnion() + public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) { } /** * - * + *将两个有序集合的并集存入到一个指定的键中 * @example - * @return + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k2', 2, 'val2');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
+     * // Weighted zUnion
+     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
+     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int */ - public function zunionstore() + public function zUnion($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) { } /** * - * + *将两个有序集合的并集存入到一个指定的键中 * @example - * @return + *
+     * $redis->delete('k1');
+     * $redis->delete('k2');
+     * $redis->delete('k3');
+     * $redis->delete('ko1');
+     * $redis->delete('ko2');
+     * $redis->delete('ko3');
+     * $redis->zAdd('k1', 0, 'val0');
+     * $redis->zAdd('k1', 1, 'val1');
+     * $redis->zAdd('k2', 2, 'val2');
+     * $redis->zAdd('k2', 3, 'val3');
+     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
+     * // Weighted zUnion
+     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
+     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
+     * 
+ * @param string $dstKey 目标集合键名 + * @param array $zsetKeys 集合键名 + * @param array $zsetKeysWeight 集合键对应的权重 + * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) + * @return int */ - public function incrBy() + public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) { } /** * - * + *按指定步长自增 * @example - * @return + *
+     * $redis->incr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value 1
+     * $redis->incr('key1');        // 2
+     * $redis->incr('key1');        // 3
+     * $redis->incr('key1');        // 4
+     * $redis->incrBy('key1', 10);  // 14
+     * 
+ * @param string $key 键名 + * @param int $step 自增步长 + * @return int */ - public function hIncrBy() + public function incrBy($key, $step) { } /** * - * + *为指定字段增加指定的值. * @example - * @return + *
+     * $redis->delete('h');
+     * $redis->hIncrBy('h', 'x', 2); // returns 2: h[x] = 2 now.
+     * $redis->hIncrBy('h', 'x', 1); // h[x] ← 2 + 1. Returns 3
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param int $step 自增步长 + * @return int */ - public function incr() + public function hIncrBy($key, $field, $step) { } /** * - * + *键值自增 * @example - * @return + *
+     * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
+     * $redis->incr('key1'); // 2
+     * $redis->incr('key1'); // 3
+     * $redis->incr('key1'); // 4
+     * 
+ * @param string $key 键名 + * @return int */ - public function decrBy() + public function incr($key) { } /** * - * + *按指定步长自减 * @example - * @return + *
+     * $redis->decr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value -1
+     * $redis->decr('key1');        // -2
+     * $redis->decr('key1');        // -3
+     * $redis->decrBy('key1', 10);  // -13
+     * 
+ * @param string $key 键名 + * @param float $step 自减步长 + * @return int */ - public function decr() + public function decrBy($key, $step) { } /** * - * + *键值自减 * @example - * @return + *
+     * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
+     * $redis->decr('key1'); // -2
+     * $redis->decr('key1'); // -3
+     * 
+ * @param string $key 键名 + * @return int */ - public function getBit() + public function decr($key) { } /** * - * + *获取某个键的某个位置的位值 * @example - * @return + *
+     * $redis->set('key', "\x7f");  // this is 0111 1111
+     * $redis->getBit('key', 0);    // 0
+     * $redis->getBit('key', 1);    // 1
+     * 
+ * @param string $key 键名 + * @param int $offset 所在位置 + * @return int */ - public function lInsert() + public function getBit($key, $offset) { } /** * - * + *在列表中,在某个元素的前面或后面插入一个新值 * @example - * @return + *
+     * $redis->delete('key1');
+     * $redis->lInsert('key1', Redis::AFTER, 'A', 'X');     // 0
+     * $redis->lPush('key1', 'A');
+     * $redis->lPush('key1', 'B');
+     * $redis->lPush('key1', 'C');
+     * $redis->lInsert('key1', Redis::BEFORE, 'C', 'X');    // 4
+     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C')
+     * $redis->lInsert('key1', Redis::AFTER, 'C', 'Y');     // 5
+     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C', 'Y')
+     * $redis->lInsert('key1', Redis::AFTER, 'W', 'value'); // -1
+     * 
+ * @param string $key 键名 + * @param string $position 位置(前面或后面,使用Redis::BEFORE | Redis::AFTER) + * @param string $element 元素 + * @param string $value 新值 + * @return int */ - public function lGet() + public function lInsert($key, $position, $element, $value) { } /** * - * + *获取列表中指定索引的值 * @example - * @return + * @param string $key 键名 + * @param int $index 索引值 + * @return string | boolean */ - public function lIndex() + public function lGet($key, $index) { } /** * - * + *获取列表中指定索引的值 * @example - * @return + * @param string $key 键名 + * @param int $index 索引值 + * @return string | boolean */ - public function setTimeout() + public function lIndex($key, $index) { } /** * - * + *设置键的有效期 * @example - * @return + * @param string $key 键名 + * @param int $ttl 有效期(秒数) + * @return boolean */ - public function expire() + public function setTimeout($key, $ttl) { } /** * - * + *设置键的有效期 * @example - * @return + * @param string $key 键名 + * @param int $ttl 有效期(秒数) + * @return boolean */ - public function pexpire() + public function expire($key, $ttl) { } /** * - * + *设置键的有效期(毫秒为单位) * @example - * @return + * @param string $key 键名 + * @param int $ttl 有效期(毫秒数) + * @return boolean */ - public function expireAt() + public function pexpire($key, $ttl) { } /** * - * + *为某个键设置有效期为某个时间点 * @example - * @return + *
+     * $redis->set('x', '42');
+     * $now = time(NULL);               // current timestamp
+     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
+     * sleep(5);                        // wait 5 seconds
+     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
+     * 
+ * @param string $key 键名 + * @param int $expireTime 到期时间 + * @return bool: */ - public function pexpireAt() + public function expireAt($key, $expireTime) { } /** * - * + *为某个键设置有效期为某个时间点(精确到毫秒) * @example - * @return + *
+     * $redis->set('x', '42');
+     * $now = time(NULL);               // current timestamp
+     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
+     * sleep(5);                        // wait 5 seconds
+     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
+     * 
+ * @param string $key 键名 + * @param int $expireTime 到期时间 + * @return bool: */ - public function move() + public function pexpireAt($key, $expireTime) { } /** * - * + *将某个键移动到其他数据库中 * @example - * @return + *
+     * $redis->select(0);       // switch to DB 0
+     * $redis->set('x', '42');  // write 42 to x
+     * $redis->move('x', 1);    // move to DB 1
+     * $redis->select(1);       // switch to DB 1
+     * $redis->get('x');        // will return 42
+     * 
+ * @param string $key 键名 + * @param int $dbIndex 数据库编号 + * @return bool */ - public function select() + public function move($key, $dbIndex) { } /** * - * + *切换数据库 * @example - * @return + *
+     * $redis->select(0);       // switch to DB 0
+     * $redis->set('x', '42');  // write 42 to x
+     * $redis->move('x', 1);    // move to DB 1
+     * $redis->select(1);       // switch to DB 1
+     * $redis->get('x');        // will return 42
+     * 
+ * @param int $dbIndex 数据库编号 + * @return bool */ - public function getRange() + public function select($dbIndex) { } /** * - * + *获取一个键值的子字符串 * @example - * @return + *
+     * $redis->set('key', 'string value');
+     * $redis->getRange('key', 0, 5);   // 'string'
+     * $redis->getRange('key', -5, -1); // 'value'
+     * 
+ * @param string $key 键名 + * @param int $start 开始位置 + * @param int $end 结束位置 + * @return string: */ - public function listTrim() + public function getRange($key, $start, $end) { } /** * - * + *删除指定范围外的其他元素 * @example - * @return + * @param string $key 键名 + * @param int $start 开始索引 + * @param int $end 结束索引 + * @return array | boolean */ - public function ltrim() + public function listTrim($key, $start, $end) { } /** * - * + *删除指定范围外的其他元素 * @example - * @return + * @param string $key 键名 + * @param int $start 开始索引 + * @param int $end 结束索引 + * @return array | boolean */ - public function lGetRange() + public function ltrim($key, $start, $end) { } /** * - * + *获取列表指定范围的值 * @example - * @return + * @param string $key 键名 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @return array */ - public function lRange() + public function lGetRange($key, $start, $end) { } /** * - * + *获取列表指定范围的值 * @example - * @return + * @param string $key 键名 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @return array */ - public function lRem() + public function lRange($key, $start, $end) { } /** * - * + *从列表中删除指定值的元素。 如果count为零,则删除所有匹配的元素。 如果计数是负数,则元素从尾部移到头部。 * @example - * @return + * @param string $key 键名 + * @param string $value 元素值 + * @param int $count 删除的个数 + * @return long | bool */ - public function lRemove() + public function lRem($key, $value, $count) { } /** * - * + *从列表中删除指定值的元素。 如果count为零,则删除所有匹配的元素。 如果计数是负数,则元素从尾部移到头部。 * @example - * @return + * @param string $key 键名 + * @param string $value 元素值 + * @param int $count 删除的个数 + * @return long | bool */ - public function zDeleteRangeByRank() + public function lRemove($key, $value, $count) { } /** * - * + *根据排序范围删除成员 * @example - * @return + *
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zAdd('key', 3, 'three');
+     * $redis->zRemRangeByRank('key', 0, 1); // 2
+     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int */ - public function zRemRangeByRank() + public function zDeleteRangeByRank($key, $start, $end) { } /** * - * + *根据排序范围删除成员 * @example - * @return + *
+     * $redis->zAdd('key', 1, 'one');
+     * $redis->zAdd('key', 2, 'two');
+     * $redis->zAdd('key', 3, 'three');
+     * $redis->zRemRangeByRank('key', 0, 1); // 2
+     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
+     * 
+ * @param string $key 集合键名 + * @param double $start 开始排序值 + * @param double $end 结束排序值 + * @return int */ - public function incrByFloat() + public function zRemRangeByRank($key, $start, $end) { } /** * - * + *按指定步长自增 * @example - * @return + *
+     * $redis = new Redis();
+     * $redis->connect('127.0.0.1');
+     * $redis->set('x', 3);
+     * var_dump( $redis->incrByFloat('x', 1.5) );   // float(4.5)
+     * // ! SIC
+     * var_dump( $redis->get('x') );                // string(3) "4.5"
+     * 
+ * @param string $key 键名 + * @param float $step 自增步长 + * @return float */ - public function hIncrByFloat() + public function incrByFloat($key, $step) { } /** * - * + *为指定字段增加指定的值 * @example + *
+     * $redis = new Redis();
+     * $redis->connect('127.0.0.1');
+     * $redis->hset('h', 'float', 3);
+     * $redis->hset('h', 'int',   3);
+     * var_dump( $redis->hIncrByFloat('h', 'float', 1.5) ); // float(4.5)
+     * var_dump( $redis->hGetAll('h') );
+     * // Output
+     * array(2) {
+     * ["float"]=>
+     * string(3) "4.5"
+     * ["int"]=>
+     * string(1) "3"
+     * }
+     * 
+ * @param string $key 键名 + * @param string $field 字段名 + * @param double $step 自增步长 * @return */ - public function bitCount() + public function hIncrByFloat($key, $field, $step) { } /** * - * + *统计字符串的位数 * @example - * @return + * @param string $key 键名 + * @return long */ - public function bitOp() + public function bitCount($key) { } /** * - * + *多个键的位操作,并将结果存入到指定的键中 * @example - * @return + * @param string $operation 操作(有 AND, OR, NOT, XOR 4种可选择) + * @param string $dstKey 目标键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名N + * @return long */ - public function sAdd() + public function bitOp($operation, $dstKey, $key1, $key2, $keyN) { } /** * - * + *给集合添加元素 * @example - * @return + *
+     * $redis->sAdd('k', 'v1');                // int(1)
+     * $redis->sAdd('k', 'v1', 'v2', 'v3');    // int(2)
+     * 
+ * @param string $key 键名 + * @param string $value 元素值 + * @return int */ - public function sMove() + public function sAdd($key, $value) { } /** * - * + *将某个集合中的元素移动到另外一个集合中 * @example - * @return + *
+     * $redis->sAdd('key1' , 'set11');
+     * $redis->sAdd('key1' , 'set12');
+     * $redis->sAdd('key1' , 'set13');          // 'key1' => {'set11', 'set12', 'set13'}
+     * $redis->sAdd('key2' , 'set21');
+     * $redis->sAdd('key2' , 'set22');          // 'key2' => {'set21', 'set22'}
+     * $redis->sMove('key1', 'key2', 'set13');  // 'key1' =>  {'set11', 'set12'}
+     * // 'key2' =>  {'set21', 'set22', 'set13'}
+     * 
+ * @param string $srcKey 原集合键名 + * @param string $dstKey 目标集合键名 + * @param string $member 成员 + * @return bool */ - public function sDiff() + public function sMove($srcKey, $dstKey, $member) { } /** * - * + *获取多个集合的差集 * @example - * @return + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s0', '3');
+     * $redis->sAdd('s0', '4');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * var_dump($redis->sDiff('s0', 's1', 's2'));
+     * //array(2) {
+     * //  [0]=>
+     * //  string(1) "4"
+     * //  [1]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string|... $key2 键名2 + * @return array */ - public function sDiffStore() + public function sDiff($key1, $key2) { } /** * - * + *获取多个集合的差集,并将结果存入到一个新的集合中 * @example - * @return + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s0', '3');
+     * $redis->sAdd('s0', '4');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * var_dump($redis->sDiffStore('dst', 's0', 's1', 's2'));
+     * var_dump($redis->sMembers('dst'));
+     * //int(2)
+     * //array(2) {
+     * //  [0]=>
+     * //  string(1) "4"
+     * //  [1]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int: */ - public function sUnion() + public function sDiffStore($dstKey, $key1, $key2, $keyN) { } /** * - * + *获取集合的并集 * @example - * @return + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s1', '3');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * $redis->sAdd('s2', '4');
+     * var_dump($redis->sUnion('s0', 's1', 's2'));
+     * array(4) {
+     * //  [0]=>
+     * //  string(1) "3"
+     * //  [1]=>
+     * //  string(1) "4"
+     * //  [2]=>
+     * //  string(1) "1"
+     * //  [3]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string|... $key2 键名2 + * @return array + */ + public function sUnion($key1, $key2) + { + } + + /** + * + *获取多个集合的并集,并将结果存入到另外一个集合中 + * @example + *
+     * $redis->delete('s0', 's1', 's2');
+     * $redis->sAdd('s0', '1');
+     * $redis->sAdd('s0', '2');
+     * $redis->sAdd('s1', '3');
+     * $redis->sAdd('s1', '1');
+     * $redis->sAdd('s2', '3');
+     * $redis->sAdd('s2', '4');
+     * var_dump($redis->sUnionStore('dst', 's0', 's1', 's2'));
+     * var_dump($redis->sMembers('dst'));
+     * //int(4)
+     * //array(4) {
+     * //  [0]=>
+     * //  string(1) "3"
+     * //  [1]=>
+     * //  string(1) "4"
+     * //  [2]=>
+     * //  string(1) "1"
+     * //  [3]=>
+     * //  string(1) "2"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int */ - public function sUnionStore() + public function sUnionStore($dstKey, $key1, $key2, $keyN) { } /** * - * + *获取两个集合的交集 * @example - * @return + *
+     * $redis->sAdd('key1', 'val1');
+     * $redis->sAdd('key1', 'val2');
+     * $redis->sAdd('key1', 'val3');
+     * $redis->sAdd('key1', 'val4');
+     * $redis->sAdd('key2', 'val3');
+     * $redis->sAdd('key2', 'val4');
+     * $redis->sAdd('key3', 'val3');
+     * $redis->sAdd('key3', 'val4');
+     * var_dump($redis->sInter('key1', 'key2', 'key3'));
+     * //array(2) {
+     * //  [0]=>
+     * //  string(4) "val4"
+     * //  [1]=>
+     * //  string(4) "val3"
+     * //}
+     * 
+ * @param string $key1 键名1 + * @param string $key2 键名2 + * @return array | boolean */ - public function sInter() + public function sInter($key1, $key2) { } /** * - * + *获取多个集合的交集,并将结果存入到另外一个集合中 * @example - * @return + *
+     * $redis->sAdd('key1', 'val1');
+     * $redis->sAdd('key1', 'val2');
+     * $redis->sAdd('key1', 'val3');
+     * $redis->sAdd('key1', 'val4');
+     * $redis->sAdd('key2', 'val3');
+     * $redis->sAdd('key2', 'val4');
+     * $redis->sAdd('key3', 'val3');
+     * $redis->sAdd('key3', 'val4');
+     * var_dump($redis->sInterStore('output', 'key1', 'key2', 'key3'));
+     * var_dump($redis->sMembers('output'));
+     * //int(2)
+     * //
+     * //array(2) {
+     * //  [0]=>
+     * //  string(4) "val4"
+     * //  [1]=>
+     * //  string(4) "val3"
+     * //}
+     * 
+ * @param string $dstKey 目标键,存放结果的键 + * @param string $key1 键名1 + * @param string $key2 键名2 + * @param string|... $keyN 键名n + * @return int */ - public function sInterStore() + public function sInterStore($dstKey, $key1, $key2, $keyN) { } /** * - * + *删除集合元素 * @example - * @return + * @param string $key 键名 + * @param string|... $member 成员 + * @return long */ - public function sRemove() + public function sRemove($key, $member) { } /** * - * + *删除集合元素 * @example - * @return + * @param string $key 键名 + * @param string|... $member 成员 + * @return long */ - public function srem() + public function srem($key, $member) { } /** * - * + *删除有序集合中的某个成员 * @example - * @return + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int */ - public function zDelete() + public function zDelete($key, $member) { } /** * - * + *删除有序集合中的某个成员 * @example - * @return + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int */ - public function zRemove() + public function zRemove($key, $member) { } /** * - * + *删除有序集合中的某个成员 * @example - * @return + * @param string $key 集合键名 + * @param string $member 成员值 + * @return int */ - public function zRem() + public function zRem($key, $member) { } /** * - * + *通过匹配模式来订阅这些匹配的消息频道 * @example + *
+     * function psubscribe($redis, $pattern, $chan, $msg) {
+     * echo "Pattern: $pattern\n";
+     * echo "Channel: $chan\n";
+     * echo "Payload: $msg\n";
+     * }
+     * 
+ * @param array $patterns 匹配模式 + * @param string|array $callback 回调函数名称 + * @param mixed $value 返回值 * @return */ - public function pSubscribe() + public function pSubscribe(Array $patterns, $callback, $value) { } /** * - * + *订阅消息 * @example - * @return + *
+     * function f($redis, $chan, $msg) {
+     * switch($chan) {
+     * case 'chan-1':
+     * ...
+     * break;
+     * case 'chan-2':
+     * ...
+     * break;
+     * case 'chan-2':
+     * ...
+     * break;
+     * }
+     * }
+     * $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
+     * 
+ * @param array $channels 订阅的消息频道 + * @param string|array $callback 回调函数名称 + * @param mixed $value 返回值 + * @return mixed */ - public function subscribe() + public function subscribe(Array $channels, $callback, $value) { } /** * - * + *开始一个事务. * @example + *
+     * $ret = $redis->multi()
+     * ->set('key1', 'val1')
+     * ->get('key1')
+     * ->set('key2', 'val2')
+     * ->get('key2')
+     * ->exec();
+     * //$ret == array (
+     * //    0 => TRUE,
+     * //    1 => 'val1',
+     * //    2 => TRUE,
+     * //    3 => 'val2');
+     * 
* @return */ public function multi() @@ -1525,7 +2642,7 @@ public function multi() /** * - * + *执行事务 * @example * @return */ @@ -1535,37 +2652,57 @@ public function exec() /** * - * + *执行lua脚本 * @example - * @return + * @param string $script 脚本 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 + * @return mixed */ - public function eval() + public function eval($script, Array $args, $num_keys) { } /** * - * - * @example + *从脚本的SHA1散列而不是脚本本身执行LUA脚本 + * @example $script = 'return 1'; + * $sha = $redis->script('load', $script); + * $redis->evalSha($sha); // Returns 1 + * @param string $script_sha 脚本的散列值 + * @param array $args 脚本参数 + * @param int $num_keys 应该进入KEYS数组的参数个数 * @return */ - public function evalSha() + public function evalSha($script_sha, Array $args, $num_keys) { } /** * - * + *在脚本子系统上执行redis命令 * @example + *
+     * $redis->script('load', $script);
+     * $redis->script('flush');
+     * $redis->script('kill');
+     * $redis->script('exists', $script1, [$script2, $script3, ...]);
+     * 
+ * SCRIPT LOAD will return the SHA1 hash of the passed script on success, and FALSE on failure. + * SCRIPT FLUSH should always return TRUE + * SCRIPT KILL will return true if a script was able to be killed and false if not + * SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script + * @param string $command redis命令 + * @param string|... $script 脚本 * @return */ - public function script() + public function script($command, $script) { } /** * - * + *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) * @example * @return */ @@ -1575,7 +2712,7 @@ public function __sleep() /** * - * + *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) * @example * @return */ diff --git a/src/Swoole/Event.php b/src/Swoole/Event.php index 39de7ba..5c49ad9 100644 --- a/src/Swoole/Event.php +++ b/src/Swoole/Event.php @@ -1,8 +1,8 @@ Date: Wed, 25 Apr 2018 19:34:21 +0800 Subject: [PATCH 12/34] =?UTF-8?q?swoole=20=E6=9B=B4=E6=96=B0=E5=88=B02.1.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Swoole/Async.php | 4 +- src/Swoole/Atomic.php | 4 +- src/Swoole/Atomic/Long.php | 4 +- src/Swoole/Buffer.php | 4 +- src/Swoole/Chan.php | 11 +- src/Swoole/Channel.php | 4 +- src/Swoole/Client.php | 6 +- src/Swoole/Co.php | 51 ++- src/Swoole/Co/Http/Client.php | 45 ++- src/Swoole/Co/Http/Server.php | 9 +- src/Swoole/Co/Http2/Client.php | 58 ++-- src/Swoole/Co/MySQL.php | 4 +- src/Swoole/Co/Redis.php | 11 +- src/Swoole/Co/Redis/Server.php | 9 +- src/Swoole/Co/Server.php | 7 +- src/Swoole/Co/WebSocket/Server.php | 9 +- src/Swoole/Connection/Iterator.php | 4 +- src/Swoole/Coroutine.php | 50 ++- src/Swoole/Coroutine/Channel.php | 11 +- src/Swoole/Coroutine/Client.php | 32 +- src/Swoole/Coroutine/Http/Client.php | 45 ++- src/Swoole/Coroutine/Http2/Client.php | 58 ++-- src/Swoole/Coroutine/Http2/Request.php | 4 +- src/Swoole/Coroutine/MySQL.php | 4 +- src/Swoole/Coroutine/MySQL/Exception.php | 4 +- src/Swoole/Coroutine/MySQL/Statement.php | 4 +- src/Swoole/Coroutine/PostgreSQL.php | 157 +++++++++ src/Swoole/Coroutine/Redis.php | 11 +- src/Swoole/Event.php | 4 +- src/Swoole/Exception.php | 4 +- src/Swoole/Http/Client.php | 4 +- src/Swoole/Http/Request.php | 4 +- src/Swoole/Http/Response.php | 4 +- src/Swoole/Http/Server.php | 6 +- src/Swoole/Http2/Client.php | 6 +- src/Swoole/Http2/Response.php | 4 +- src/Swoole/Lock.php | 4 +- src/Swoole/Mmap.php | 4 +- src/Swoole/MsgQueue.php | 90 +++++ src/Swoole/MySQL.php | 4 +- src/Swoole/MySQL/Exception.php | 4 +- src/Swoole/Process.php | 4 +- src/Swoole/Process/Pool.php | 96 +++++ src/Swoole/Redis.php | 4 +- src/Swoole/Redis/Server.php | 6 +- src/Swoole/RingQueue.php | 4 +- src/Swoole/Serialize.php | 4 +- src/Swoole/Server.php | 6 +- src/Swoole/Server/Port.php | 4 +- src/Swoole/Table.php | 4 +- src/Swoole/Table/Row.php | 4 +- src/Swoole/Timer.php | 4 +- src/Swoole/WebSocket/Frame.php | 4 +- src/Swoole/WebSocket/Server.php | 6 +- src/Swoole/swoole.namespace.php | 168 ++++++++- src/Swoole/swoole.php | 406 +++++++++++++++++++++- src/Swoole/swoole_async.php | 4 +- src/Swoole/swoole_atomic.php | 4 +- src/Swoole/swoole_atomic_long.php | 4 +- src/Swoole/swoole_buffer.php | 4 +- src/Swoole/swoole_channel.php | 4 +- src/Swoole/swoole_client.php | 21 +- src/Swoole/swoole_connection_iterator.php | 4 +- src/Swoole/swoole_coroutine.php | 138 +++++++- src/Swoole/swoole_event.php | 4 +- src/Swoole/swoole_exception.php | 4 +- src/Swoole/swoole_http2_client.php | 21 +- src/Swoole/swoole_http2_response.php | 11 +- src/Swoole/swoole_http_client.php | 4 +- src/Swoole/swoole_http_request.php | 4 +- src/Swoole/swoole_http_response.php | 4 +- src/Swoole/swoole_http_server.php | 6 +- src/Swoole/swoole_lock.php | 4 +- src/Swoole/swoole_mmap.php | 4 +- src/Swoole/swoole_msgqueue.php | 89 +++++ src/Swoole/swoole_mysql.php | 8 +- src/Swoole/swoole_mysql_exception.php | 4 +- src/Swoole/swoole_process.php | 46 ++- src/Swoole/swoole_process_pool.php | 95 +++++ src/Swoole/swoole_redis.php | 4 +- src/Swoole/swoole_redis_server.php | 6 +- src/Swoole/swoole_ringqueue.php | 66 ++++ src/Swoole/swoole_serialize.php | 4 +- src/Swoole/swoole_server.php | 6 +- src/Swoole/swoole_server_port.php | 15 +- src/Swoole/swoole_table.php | 4 +- src/Swoole/swoole_table_row.php | 4 +- src/Swoole/swoole_timer.php | 4 +- src/Swoole/swoole_websocket_frame.php | 4 +- src/Swoole/swoole_websocket_server.php | 6 +- 90 files changed, 1827 insertions(+), 277 deletions(-) create mode 100644 src/Swoole/Coroutine/PostgreSQL.php create mode 100644 src/Swoole/MsgQueue.php create mode 100644 src/Swoole/Process/Pool.php create mode 100644 src/Swoole/swoole_msgqueue.php create mode 100644 src/Swoole/swoole_process_pool.php create mode 100644 src/Swoole/swoole_ringqueue.php diff --git a/src/Swoole/Async.php b/src/Swoole/Async.php index 173122f..30e5d49 100644 --- a/src/Swoole/Async.php +++ b/src/Swoole/Async.php @@ -1,8 +1,8 @@ connect ("host=127.0.0.1 port=5432 dbname=test user=root password="); + * $result = $pg -> query($conn, 'SELECT * FROM test;'); + * $arr = $pg -> fetchAll($result); + * var_dump($arr); + * }); + * @return + */ + public function __construct() + { + } + + /** + * + *建立postgresql 非阻塞的协程连接 + * @example $a = new Swoole\Coroutine\PostgreSQL(); + * $conn = $a -> connect ("host=127.0.0.1 port=5432 dbname=test user=wuzhenyu password="); + * @param string $conninfo 连接信息 + * @return resource|bool + */ + public function connect($conninfo) + { + } + + /** + * + *postgresql发送异步非阻塞 协程命令 + * @example + * @param string $query 执行sql语句 + * @return resource + */ + public function query($query) + { + } + + /** + * + *提取结果中所有行作为一个数组 + * @example + * @param resource $result 通过query查询的结果 + * @param int $result_type 获取结果类型(如关联数组等) + * @return mixed + */ + public function fetchAll($result, $result_type) + { + } + + /** + * + *返回影响的行数 + * @example + * @param resource $result 结果 + * @return + */ + public function affectedRows($result) + { + } + + /** + * + *返回结果行数 + * @example + * @param resource $result 结果集 + * @return int + */ + public function numRows($result) + { + } + + /** + * + *查看表的元数据 异步非阻塞协程版 + * @example + * @param string $table_name 表名 + * @return + */ + public function metaData($table_name) + { + } + + /** + * + *提取一行作为对象 + * @example + * @param resource $result 结果集 + * @param int $row 行号 + * @return + */ + public function fetchObject($result, $row) + { + } + + /** + * + *提取一行作为关联数组 + * @example + * @param resource $result 结果集 + * @param int $row 要提取的行号 + * @return + */ + public function fetchAssoc($result, $row) + { + } + + /** + * + *返回一个与所提取的行(元组/记录)相一致的数组。如果没有更多行可供提取,则返回 FALSE + * @example + * @param resource $result 结果集 + * @param int $row 行号 + * @return + */ + public function fetchArray($result, $row) + { + } + + /** + * + *根据指定的 result 资源提取一行数据(记录)作为数组返回。每个得到的列依次存放在数组中,从偏移量 0 开始。 + * @example + * @param resource $result 结果集 + * @param int $row 行号 + * @return + */ + public function fetchRow($result, $row) + { + } + + /** + * + *析构函数 + * @example + * @return + */ + public function __destruct() + { + } + +} + diff --git a/src/Swoole/Coroutine/Redis.php b/src/Swoole/Coroutine/Redis.php index c103fe8..ddf88b8 100644 --- a/src/Swoole/Coroutine/Redis.php +++ b/src/Swoole/Coroutine/Redis.php @@ -1,8 +1,8 @@ on("Message", function ($pool, $message) {echo "Message: {$message} + * "; + * $pool->write("hello "); + * $pool->write("world "); + * $pool->write("\n"); + * }); + * $pool->listen('127.0.0.1', 8089); + * $pool->start(); + * + * @param string $data 写入的数据内容。可多次调用write,底层会在onMessage函数退出后将数据全部写入socket中,并close连接 + * @return + */ + public function write($data) + { + } + + /** + * + *启动工作进程 + * @example + * @return bool + */ + public function start() + { + } + +} + diff --git a/src/Swoole/Redis.php b/src/Swoole/Redis.php index 1d62d8f..46ef15e 100644 --- a/src/Swoole/Redis.php +++ b/src/Swoole/Redis.php @@ -1,8 +1,8 @@ wait操作,在Linux平台下相当手工调用一次epoll_wait。与swoole_event_wait不同的是,swoole_event_wait在底层内部维持了循环) +* @example +* +* @return +*/ +function swoole_event_dispatch() +{ +} + +/** +* +*检测传入的$fd是否已加入了事件监听 +* @example +* +* @param int $fd:任意的socket文件描述符,参考 swoole_event_add 文档 +* @param int $events:检测的事件类型(SWOOLE_EVENT_READ:是否监听了可读事件SWOOLE_EVENT_WRITE:是否监听了可写事件;;SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE:监听可读或可写事件) +* @return +*/ +function swoole_event_isset($fd, $events) +{ +} + /** * *添加一个在指定的时间后执行某个函数的定时器(执行成功返回定时器ID) @@ -814,6 +966,18 @@ function swoole_coroutine_create(Callable $func) { } +/** +* +*协程执行一个命令 +* @example +* +* @param string $command:执行的命令(如shell命令) +* @return +*/ +function swoole_coroutine_exec($command) +{ +} + /** * *开启一个协程 diff --git a/src/Swoole/swoole.php b/src/Swoole/swoole.php index cc14f9a..32beb89 100644 --- a/src/Swoole/swoole.php +++ b/src/Swoole/swoole.php @@ -1,8 +1,8 @@ wait操作,在Linux平台下相当手工调用一次epoll_wait。与swoole_event_wait不同的是,swoole_event_wait在底层内部维持了循环) +* @example +* +* @return +*/ +function swoole_event_dispatch() +{ +} + +/** +* +*检测传入的$fd是否已加入了事件监听 +* @example +* +* @param int $fd:任意的socket文件描述符,参考 swoole_event_add 文档 +* @param int $events:检测的事件类型(SWOOLE_EVENT_READ:是否监听了可读事件SWOOLE_EVENT_WRITE:是否监听了可写事件;;SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE:监听可读或可写事件) +* @return +*/ +function swoole_event_isset($fd, $events) +{ +} + /** * *添加一个在指定的时间后执行某个函数的定时器(执行成功返回定时器ID) @@ -603,6 +954,42 @@ function swoole_async_dns_lookup_coro($domain_name) { } +/** +* +*创建一个协程 +* @example +* +* @param callable $func:执行的函数 +* @return +*/ +function swoole_coroutine_create(Callable $func) +{ +} + +/** +* +*协程执行一个命令 +* @example +* +* @param string $command:执行的命令(如shell命令) +* @return +*/ +function swoole_coroutine_exec($command) +{ +} + +/** +* +*开启一个协程 +* @example +* +* @param callable | string | array $func:要执行的函数 +* @return +*/ +function go($func) +{ +} + /** * *swoole_client的并行处理中用了select来做IO事件循环 @@ -690,3 +1077,16 @@ function swoole_errno() { } +/** +* +*获取指定的数据的哈希码 +* @example +* +* @param string $data:指定的数据 +* @param int $type:类型 +* @return +*/ +function swoole_hashcode($data, $type) +{ +} + diff --git a/src/Swoole/swoole_async.php b/src/Swoole/swoole_async.php index 36aabd4..debfa44 100644 --- a/src/Swoole/swoole_async.php +++ b/src/Swoole/swoole_async.php @@ -1,8 +1,8 @@ on("Message", function ($pool, $message) {echo "Message: {$message} + * "; + * $pool->write("hello "); + * $pool->write("world "); + * $pool->write("\n"); + * }); + * $pool->listen('127.0.0.1', 8089); + * $pool->start(); + * + * @param string $data 写入的数据内容。可多次调用write,底层会在onMessage函数退出后将数据全部写入socket中,并close连接 + * @return + */ + public function write($data) + { + } + + /** + * + *启动工作进程 + * @example + * @return bool + */ + public function start() + { + } + +} + diff --git a/src/Swoole/swoole_redis.php b/src/Swoole/swoole_redis.php index d03098e..3f74b03 100644 --- a/src/Swoole/swoole_redis.php +++ b/src/Swoole/swoole_redis.php @@ -1,8 +1,8 @@ Date: Wed, 25 Apr 2018 19:35:38 +0800 Subject: [PATCH 13/34] =?UTF-8?q?swoole=20=E6=9B=B4=E6=96=B0=E5=88=B02.1.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ee67b9..c3cc02e 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 5、Redis(包括RedisCluster) -6、swoole扩展(支持swoole 2.1.0) +6、swoole扩展(支持swoole 2.1.3) 7、SeasLog(1.7.6) From 43b70a2e06371a24d3161772aec26d99d552bad1 Mon Sep 17 00:00:00 2001 From: shixinke Date: Sun, 20 May 2018 13:11:51 +0800 Subject: [PATCH 14/34] =?UTF-8?q?yaf=E6=96=87=E6=A1=A3=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E5=8F=8A=E6=9B=B4=E6=96=B0=E5=88=B03.0.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/Yaf/Action_Abstract.php | 227 ++---------- src/Yaf/Application.php | 190 +++++----- src/Yaf/Bootstrap_Abstract.php | 7 +- src/Yaf/Config/Ini.php | 168 +++++---- src/Yaf/Config/Simple.php | 180 +++++----- src/Yaf/Config_Abstract.php | 141 ++++++-- src/Yaf/Controller_Abstract.php | 155 ++++----- src/Yaf/Dispatcher.php | 320 ++++++++--------- src/Yaf/Exception.php | 101 +++--- src/Yaf/Exception/DispatchFailed.php | 101 +++--- src/Yaf/Exception/LoadFailed.php | 101 +++--- src/Yaf/Exception/LoadFailed/Action.php | 101 +++--- src/Yaf/Exception/LoadFailed/Controller.php | 101 +++--- src/Yaf/Exception/LoadFailed/Module.php | 101 +++--- src/Yaf/Exception/LoadFailed/View.php | 101 +++--- src/Yaf/Exception/RouterFailed.php | 101 +++--- src/Yaf/Exception/StartupError.php | 101 +++--- src/Yaf/Exception/TypeError.php | 101 +++--- src/Yaf/Loader.php | 104 +++--- src/Yaf/Plugin_Abstract.php | 81 ++--- src/Yaf/Registry.php | 59 ++-- src/Yaf/Request/Http.php | 321 ++++++++--------- src/Yaf/Request/Simple.php | 327 +++++++++--------- src/Yaf/Request_Abstract.php | 260 +++++++------- src/Yaf/Response/Cli.php | 138 +++++--- src/Yaf/Response/Http.php | 151 ++++---- src/Yaf/Response_Abstract.php | 135 +++++--- src/Yaf/Route/Map.php | 40 +-- src/Yaf/Route/Regex.php | 75 ++-- src/Yaf/Route/Rewrite.php | 65 ++-- src/Yaf/Route/Simple.php | 51 ++- src/Yaf/Route/Supervar.php | 39 +-- src/Yaf/Route_Interface.php | 24 +- src/Yaf/Route_Static.php | 35 +- src/Yaf/Router.php | 60 ++-- src/Yaf/Session.php | 193 +++++------ src/Yaf/View/Simple.php | 151 ++++---- src/Yaf/View_Interface.php | 42 +-- src/Yaf/Yaf.namespace.php | 58 ---- src/Yaf/Yaf.php | 58 ---- src/Yaf/Yaf_Action_Abstract.php | 227 ++---------- src/Yaf/Yaf_Application.php | 186 +++++----- src/Yaf/Yaf_Bootstrap_Abstract.php | 7 +- src/Yaf/Yaf_Config_Abstract.php | 141 ++++++-- src/Yaf/Yaf_Config_Ini.php | 166 +++++---- src/Yaf/Yaf_Config_Simple.php | 178 +++++----- src/Yaf/Yaf_Controller_Abstract.php | 155 ++++----- src/Yaf/Yaf_Dispatcher.php | 302 ++++++++-------- src/Yaf/Yaf_Exception.php | 101 +++--- src/Yaf/Yaf_Exception_DispatchFailed.php | 101 +++--- src/Yaf/Yaf_Exception_LoadFailed.php | 101 +++--- src/Yaf/Yaf_Exception_LoadFailed_Action.php | 101 +++--- .../Yaf_Exception_LoadFailed_Controller.php | 101 +++--- src/Yaf/Yaf_Exception_LoadFailed_Module.php | 101 +++--- src/Yaf/Yaf_Exception_LoadFailed_View.php | 101 +++--- src/Yaf/Yaf_Exception_RouterFailed.php | 101 +++--- src/Yaf/Yaf_Exception_StartupError.php | 101 +++--- src/Yaf/Yaf_Exception_TypeError.php | 101 +++--- src/Yaf/Yaf_Loader.php | 100 +++--- src/Yaf/Yaf_Plugin_Abstract.php | 81 ++--- src/Yaf/Yaf_Registry.php | 59 ++-- src/Yaf/Yaf_Request_Abstract.php | 260 +++++++------- src/Yaf/Yaf_Request_Http.php | 321 ++++++++--------- src/Yaf/Yaf_Request_Simple.php | 327 +++++++++--------- src/Yaf/Yaf_Response_Abstract.php | 135 +++++--- src/Yaf/Yaf_Response_Cli.php | 138 +++++--- src/Yaf/Yaf_Response_Http.php | 151 ++++---- src/Yaf/Yaf_Route_Interface.php | 24 +- src/Yaf/Yaf_Route_Map.php | 40 +-- src/Yaf/Yaf_Route_Regex.php | 75 ++-- src/Yaf/Yaf_Route_Rewrite.php | 65 ++-- src/Yaf/Yaf_Route_Simple.php | 51 ++- src/Yaf/Yaf_Route_Static.php | 35 +- src/Yaf/Yaf_Route_Supervar.php | 39 +-- src/Yaf/Yaf_Router.php | 60 ++-- src/Yaf/Yaf_Session.php | 193 +++++------ src/Yaf/Yaf_View_Interface.php | 42 +-- src/Yaf/Yaf_View_Simple.php | 151 ++++---- src/Yaf/yaf.namespace.php | 92 +++++ src/Yaf/yaf.php | 92 +++++ 81 files changed, 4966 insertions(+), 4804 deletions(-) delete mode 100644 src/Yaf/Yaf.namespace.php delete mode 100644 src/Yaf/Yaf.php create mode 100644 src/Yaf/yaf.namespace.php create mode 100644 src/Yaf/yaf.php diff --git a/README.md b/README.md index c3cc02e..07465a3 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 ## 目前支持的框架或扩展 -1、Yaf +1、Yaf(3.0.7) 2、Yac diff --git a/src/Yaf/Action_Abstract.php b/src/Yaf/Action_Abstract.php index ce59730..1b51c1c 100644 --- a/src/Yaf/Action_Abstract.php +++ b/src/Yaf/Action_Abstract.php @@ -1,247 +1,92 @@ = 3.0.2) -*Class YafX_Action_Abstract +*yaf中的操作定义(单独文件定义操作,通常是在控制器文件中定义操作,这里可以通过单独文件来定义操作) */ namespace Yaf; abstract class Action_Abstract extends \Yaf\Controller_Abstract { /** - * @var unknown $actions - * + * @var array $actions + * 操作列表 * @access public - public $actions; + */ + public $actions = array(); /** - * @var unknown $_module - * + * @var string $_module + * 当前模块对象 * @access protected + */ protected $_module; /** - * @var unknown $_name - * + * @var string $_name + * 当前操作名 * @access protected + */ protected $_name; /** - * @var unknown $_request - * + * @var Yaf_Request_Abstract $_request + * 当前请求对象 * @access protected + */ protected $_request; /** - * @var unknown $_response - * + * @var Yaf_Response_Abstract $_response + * 当前响应对象 * @access protected + */ protected $_response; /** - * @var unknown $_invoke_args - * + * @var array $_invoke_args + * 调用参数列表 * @access protected - protected $_invoke_args; + */ + protected $_invoke_args = array(); /** - * @var unknown $_view - * + * @var Yaf_View_Interface $_view + * 当前视图对象 * @access protected + */ protected $_view; /** - * @var unknown $_controller - * (Yaf >= 3.0.2) + * @var Yaf_Controller_Abstract $_controller * 当前请求的控制器实例 * @access protected - protected $_controller; - - /** - * - *(Yaf >= 3.0.2) - *动作入口方法,由Yaf框架自动调用 - * @example - * @return */ - public abstract function execute(); + protected $_controller; /** * - *(Yaf >= 3.0.2) *获取当前请求的控制器实例 * @example - * @return - */ - public function getController() - { - } - - /** - * - * - * @example - * @param mixed $tpl - * @param array $parameters - * @return - */ - protected function render($tpl, Array $parameters) - { - } - - /** - * - * - * @example - * @param mixed $tpl - * @param array $parameters - * @return - */ - protected function display($tpl, Array $parameters) - { - } - - /** - * - * - * @example - * @return - */ - public function getRequest() - { - } - - /** - * - * - * @example - * @return - */ - public function getResponse() - { - } - - /** - * - * - * @example - * @return - */ - public function getModuleName() - { - } - - /** - * - * - * @example - * @return - */ - public function getView() - { - } - - /** - * - * - * @example - * @param array $options - * @return - */ - public function initView(Array $options) - { - } - - /** - * - * - * @example - * @param mixed $view_directory - * @return + * @return Yaf_Action_Abstract */ - public function setViewpath($view_directory) + public function getController(): Yaf_Action_Abstract { + } /** * - * - * @example - * @return - */ - public function getViewpath() - { - } - - /** - * - * - * @example - * @param mixed $module - * @param mixed $controller - * @param mixed $action - * @param array $parameters - * @return - */ - public function forward($module, $controller, $action, Array $parameters) - { - } - - /** - * - * - * @example - * @param mixed $url - * @return - */ - public function redirect($url) - { - } - - /** - * - * - * @example - * @return - */ - public function getInvokeArgs() - { - } - - /** - * - * - * @example - * @param mixed $name - * @return - */ - public function getInvokeArg($name) - { - } - - /** - * - * - * @example - * @return - */ - public final function __construct() - { - } - - /** - * - * + *动作入口方法,由Yaf框架自动调用 * @example - * @return + * @param mixed $arg 参数 + * @param mixed $arg2 参数2 + * @return Yaf_Action_Abstract */ - private final function __clone() - { - } + public abstract function execute($arg, $arg2): Yaf_Action_Abstract; } diff --git a/src/Yaf/Application.php b/src/Yaf/Application.php index a5651d2..0c7b10e 100644 --- a/src/Yaf/Application.php +++ b/src/Yaf/Application.php @@ -1,279 +1,275 @@ = 3.0.2) -*Class YafX_Application +*为应用提供引导和依赖性检查的引导类 */ namespace Yaf; final class Application { /** - * @var unknown $config - * (Yaf >= 3.0.2) + * @var Yaf_Config_Abstract $config * 全局配置实例 * @access protected + */ protected $config; /** - * @var unknown $dispatcher - * (Yaf >= 3.0.2) - * YafX_Dispatcher实例,即分发器. + * @var Yaf_Dispatcher $dispatcher + * yaf_Dispatcher实例,即分发器. * @access protected + */ protected $dispatcher; /** - * @var unknown $_app - * (Yaf >= 3.0.2) + * @var Yaf_Application $_app * 过特殊的方式实现了单例模式, 此属性保存当前实例. * @access protected + */ protected static $_app; /** - * @var unknown $_modules - * (Yaf >= 3.0.2) + * @var array $_modules * 存在的模块名, 从配置文件中ap.modules读取. * @access protected - protected $_modules; + */ + protected $_modules = array(); /** - * @var unknown $_running - * (Yaf >= 3.0.2) - * 指明当前的YafX_Application是否已经运行. + * @var bool $_running + * 指明当前的yaf_Application是否已经运行. * @access protected - protected $_running = ''; + */ + protected $_running = false; /** - * @var unknown $_environ - * (Yaf >= 3.0.2) - * 前的环境名, 也就是YafX_Application在读取配置的时候, 获取的配置节名字. + * @var string $_environ + * 当前的环境名, 也就是yaf_Application在读取配置的时候, 获取的配置节名字. * 注:此值只能在Yaf扩展级的配置文件.ini里面进行修改,默认为product. * @access protected - protected $_environ = 'dev'; + */ + protected $_environ = 'product'; /** - * @var unknown $_err_no - * (Yaf >= 3.0.2) + * @var int $_err_no * 最近一次发生的错误代码. * @access protected + */ protected $_err_no = 0; /** - * @var unknown $_err_msg - * (Yaf >= 3.0.2) + * @var string $_err_msg * 最近一次产生的错误信息. * @access protected + */ protected $_err_msg = ''; /** * - *(Yaf >= 3.0.2) - *构造函数,根据配置初始化YafX_Application + *获取当前的yaf_Application实例. * @example - * @param mixed $config (Yaf >= 3.0.2) -构造函数,根据配置初始化YafX_Application - * @param mixed $environ - * @return + * @return Yaf_Application|null */ - public function __construct($config, $environ) + public static function app(): ?Yaf_Application { + } /** * - *(Yaf >= 3.0.2) - *运行YafX_Application + *调用bootstrap * @example - * @return + * @param Yaf_Bootstrap_Abstract $bootstrap 引导类 + * @return void */ - public function run() + public function bootstrap(Yaf_Bootstrap_Abstract $bootstrap) { + } /** * - *(Yaf >= 3.0.2) - *运行回调函数,一般在命令行模式下运行. + *运行yaf_Application * @example - * @param callable $entry (Yaf >= 3.0.2) -运行回调函数,一般在命令行模式下运行. - * @param mixed $... - * @return + * @return void */ - public function execute(Callable $entry, $...) + public function run() { + } /** * - *(Yaf >= 3.0.2) - *获取当前的YafX_Application实例. + *清除最近的错误信息,将设置$this->_err_no=0,$this->_err_msg=''. * @example - * @return + * @return Yaf_Application */ - public static function app() + public function clearLastError(): Yaf_Application { + } /** * - *(Yaf >= 3.0.2) - *获取当前YafX_Application的环境名,它被定义在yaf.environ,默认值为"product". + *构造函数,根据配置初始化yaf_Application * @example + * @param mixed $config 关联数组的配置, 或者一个指向ini格式的配置文件的路径的字符串. + * @param string $section 加载的配置节点,使用该节点的配置初始化应用. * @return */ - public function environ() + public function __construct($config, string $section = 'product') { + } /** * - *(Yaf >= 3.0.2) - *调用bootstrap + *运行回调函数,一般在命令行模式下运行. * @example - * @param mixed $bootstrap - * @return + * @param callable $entry 回调函数 + * @param mixed $parameter 零个或者多个回调函数参数 + * @return void */ - public function bootstrap($bootstrap) + public function execute(Callable $entry, $parameter) { + } /** * - *(Yaf >= 3.0.2) - *获取全局配置实例,即$this->config + *获取当前yaf_Application的环境名,它被定义在yaf.environ,默认值为"product". * @example - * @return + * @return string */ - public function getConfig() + public function environ(): string { + } /** * - *(Yaf >= 3.0.2) - *获取在配置文件中声明的模块,如果没有声明,它的默认值将是"Index". + *获取当前应用的主目录 * @example - * @return + * @return string */ - public function getModules() + public function getAppDirectory(): string { + } /** * - *(Yaf >= 3.0.2) - *获取当前请求的分发器YafX_Dispatcher的实例 + *获取全局配置实例,即$this->config * @example - * @return + * @return Yaf_Config_Abstract */ - public function getDispatcher() + public function getConfig(): Yaf_Config_Abstract { + } /** * - *(Yaf >= 3.0.2) - *设置应用的主目录 + *获取当前请求的分发器yaf_Dispatcher的实例 * @example - * @param String $directory (Yaf >= 3.0.2) -设置应用的主目录 - * @return + * @return Yaf_Dispatcher */ - public function setAppDirectory($directory) + public function getDispatcher(): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *获取当前应用的主目录 + *获取最近产生的错误信息. * @example - * @return + * @return string */ - public function getAppDirectory() + public function getLastErrorMsg(): string { + } /** * - *(Yaf >= 3.0.2) *获取最近产生的错误代码. * @example - * @return + * @return int */ - public function getLastErrorNo() + public function getLastErrorNo(): int { + } /** * - *(Yaf >= 3.0.2) - *获取最近产生的错误信息. + *获取在配置文件中声明的模块,如果没有声明,它的默认值将是"Index". * @example - * @return + * @return array */ - public function getLastErrorMsg() + public function getModules(): array { + } /** * - *(Yaf >= 3.0.2) - *清除最近的错误信息,将设置$this->_err_no=0,$this->_err_msg=''. + *设置应用的主目录 * @example - * @return + * @param String $directory 目录路径. + * @return Yaf_Application */ - public function clearLastError() + public function setAppDirectory(String $directory): Yaf_Application { + } /** * - *(Yaf >= 3.0.2) - *重置__destruct魔术方法. + *重置__clone魔术方法,防止克隆yaf_Application(因为是单例模式). * @example * @return */ - public function __destruct() + private function __clone() { + } /** * - *(Yaf >= 3.0.2) - *重置__clone魔术方法,防止克隆YafX_Application(因为是单例模式). + *重置__destruct魔术方法. * @example * @return */ - private function __clone() + public function __destruct() { + } /** * - *(Yaf >= 3.0.2) *重置__sleep魔术方法. * @example * @return */ private function __sleep() { + } /** * - *(Yaf >= 3.0.2) *重置__wakeup魔术方法. * @example * @return */ private function __wakeup() { + } } diff --git a/src/Yaf/Bootstrap_Abstract.php b/src/Yaf/Bootstrap_Abstract.php index 5773ab4..727ebda 100644 --- a/src/Yaf/Bootstrap_Abstract.php +++ b/src/Yaf/Bootstrap_Abstract.php @@ -1,13 +1,12 @@ = 3.0.2) -*Class YafX_Bootstrap_Abstract +*应用引导类(一般需要一个类来继承它,可定义_init开头的方法) */ namespace Yaf; abstract class Bootstrap_Abstract diff --git a/src/Yaf/Config/Ini.php b/src/Yaf/Config/Ini.php index 7580e1e..e1ce4f9 100644 --- a/src/Yaf/Config/Ini.php +++ b/src/Yaf/Config/Ini.php @@ -1,249 +1,243 @@ = 3.0.2) -*Class YafX_Config_Ini +*yaf中ini配置文件类 */ namespace Yaf\Config; -final class Ini extends \Yaf\Config_Abstract +final class Ini extends \Yaf\Config_Abstract implements \Iterator,\ArrayAccess,\Countable { /** - * @var unknown $_config - * (Yaf >= 3.0.2) + * @var array $_config * 存储已解析的配置 * @access protected - protected $_config; + */ + protected $_config = array(); /** - * @var unknown $_readonly - * (Yaf >= 3.0.2) + * @var int $_readonly * 配置是否只读,默认为1. * @access protected - protected $_readonly = '1'; - - /** - * - *(Yaf >= 3.0.2) - *构造方法,初始化YafX_Config_Ini对象 - * @example - * @param mixed $config_file - * @param string $section (Yaf >= 3.0.2) -构造方法,初始化YafX_Config_Ini对象 - * @return */ - public function __construct($config_file, $section) - { - } + protected $_readonly = 1; /** * - *(Yaf >= 3.0.2) - *魔术方法,当isset()检测某个配置节点是否存在时调用 + *构造方法,初始化yaf_Config_Ini对象 * @example - * @param string $name (Yaf >= 3.0.2) -魔术方法,当isset()检测某个配置节点是否存在时调用 + * @param string $filename ini文件全路径 + * @param string $section 初始化时的配置节点名称 * @return */ - public function __isset($name) + public function __construct(string $filename, string $section) { + } /** * - *(Yaf >= 3.0.2) - *获取配置节点的值 - *当不传递$name参数时,返回配置对象本身 + *魔术方法,当isset()检测某个配置节点是否存在时调用 * @example - * @param mixed $name + * @param string $name 节点名称 * @return */ - public function get($name) + public function __isset(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置配置节点值(无效) * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值(无效) - * @param mixed $value - * @return + * @param string $name 变量名 + * @param mixed $value 配置值 + * @return Yaf_Config_Abstract */ - public function set($name, $value) + public function set(string $name, $value): Yaf_Config_Abstract { + } /** * - *(Yaf >= 3.0.2) *返回配置节点的数量 * @example - * @return + * @return int */ - public function count() + public function count(): int { + } /** * - *(Yaf >= 3.0.2) - *重置遍历位置(php.net文档有误) + *重置遍历位置 * @example * @return */ public function rewind() { + } /** * - *(Yaf >= 3.0.2) *返回当前节点 * @example - * @return + * @return mixed */ public function current() { + } /** * - *(Yaf >= 3.0.2) *向前移动到下一个元素 * @example - * @return + * @return mixed */ public function next() { + } /** * - *(Yaf >= 3.0.2) *判断是否可以继续遍历 * @example * @return */ public function valid() { + } /** * - *(Yaf >= 3.0.2) *返回当前配置节点的key * @example - * @return + * @return mixed */ public function key() { + + } + + /** + * + *撤消某个配置节点(无效) + * @example + * @param string $name 变量名 + * @return mixed + */ + public function offsetUnset(string $name) + { + } /** * - *(Yaf >= 3.0.2) + *测某个配置节点是否存在 * @example + * @param mixed $name 节点名称 * @return */ - public function toArray() + public function offsetExists($name) { + } /** * - *(Yaf >= 3.0.2) + *设置配置节点值(无效) * @example + * @param string $name 配置项名称 + * @param mixed $value 配置值 * @return */ - public function readonly() + public function offsetSet(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) - *撤消某个配置节点(无效) + *获取配置节点的值 + *当不传递$name参数时,返回配置对象本身 * @example - * @param string $name (Yaf >= 3.0.2) -撤消某个配置节点(无效) + * @param string $name 索引值 * @return */ - public function offsetUnset($name) + public function offsetGet(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取配置节点的值 *当不传递$name参数时,返回配置对象本身 * @example - * @param mixed $name + * @param string $name 配置项名称 * @return */ - public function offsetGet($name) + public function get(string $name) { + } /** * - *(Yaf >= 3.0.2) - *测某个配置节点是否存在 + *获取配置节点的值 + *当不传递$name参数时,返回配置对象本身 * @example - * @param mixed $name (Yaf >= 3.0.2) -测某个配置节点是否存在 + * @param string $name 配置项名称 * @return */ - public function offsetExists($name) + public function __get(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置配置节点值(无效) * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值(无效) - * @param mixed $value + * @param string $name 配置项名 + * @param mixed $value 配置值 * @return */ - public function offsetSet($name, $value) + public function __set(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) - *获取配置节点的值 - *当不传递$name参数时,返回配置对象本身 + *将配置对象转化为数组 * @example - * @param mixed $name - * @return + * @return array */ - public function __get($name) + public function toArray(): array { + } /** * - *(Yaf >= 3.0.2) - *设置配置节点值(无效) + *配置是否只读 * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值(无效) - * @param mixed $value - * @return + * @return bool */ - public function __set($name, $value) + public function readonly(): bool { + } } diff --git a/src/Yaf/Config/Simple.php b/src/Yaf/Config/Simple.php index 2e426ba..de6555a 100644 --- a/src/Yaf/Config/Simple.php +++ b/src/Yaf/Config/Simple.php @@ -1,251 +1,243 @@ = 3.0.2) -*Class YafX_Config_Simple +*基础配置对象 */ namespace Yaf\Config; -final class Simple extends \Yaf\Config_Abstract +final class Simple extends \Yaf\Config_Abstract implements \Iterator,\ArrayAccess,\Countable { /** - * @var unknown $_config - * (Yaf >= 3.0.2) + * @var array $_config * 存储已解析的配置 * @access protected - protected $_config; + */ + protected $_config = array(); /** - * @var unknown $_readonly - * (Yaf >= 3.0.2) + * @var int $_readonly * 配置是否只读,默认为1. * @access protected - protected $_readonly = ''; + */ + protected $_readonly = 0; /** * - *(Yaf >= 3.0.2) - *构造方法,初始化YafX_Config_Simple对象 + *构造方法,初始化yaf_Config_Simple对象 * @example - * @param mixed $config_file - * @param mixed $section + * @param string $config 储存配置的数组 + * @param string $readonly 是否只读 * @return */ - public function __construct($config_file, $section) + public function __construct(string $config, string $readonly) { + } /** * - *(Yaf >= 3.0.2) *魔术方法,当isset()检测某个配置节点是否存在时调用 * @example - * @param string $name (Yaf >= 3.0.2) -魔术方法,当isset()检测某个配置节点是否存在时调用 + * @param string $name 节点名称 * @return */ - public function __isset($name) + public function __isset(string $name) { + } /** * - *(Yaf >= 3.0.2) - *获取配置节点的值 - *当不传递$name参数时,返回配置对象本身 + *设置配置节点值(无效) * @example - * @param mixed $name - * @return + * @param string $name 变量名 + * @param mixed $value 配置值 + * @return Yaf_Config_Abstract */ - public function get($name) + public function set(string $name, $value): Yaf_Config_Abstract { + } /** * - *(Yaf >= 3.0.2) - *设置配置节点值 + *返回配置节点的数量 * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值 - * @param mixed $value (Yaf >= 3.0.2) -设置配置节点值 - * @return + * @return int */ - public function set($name, $value) + public function count(): int { + } /** * - *(Yaf >= 3.0.2) - *返回配置节点的数量 + *重置遍历位置 * @example * @return */ - public function count() + public function rewind() { + } /** * - *(Yaf >= 3.0.2) - *撤消某个配置节点 + *返回当前节点 * @example - * @param string $name (Yaf >= 3.0.2) -撤消某个配置节点 - * @return + * @return mixed */ - public function offsetUnset($name) + public function current() { + } /** * - *(Yaf >= 3.0.2) - *重置遍历位置(php.net文档有误) + *向前移动到下一个元素 * @example - * @return + * @return mixed */ - public function rewind() + public function next() { + } /** * - *(Yaf >= 3.0.2) - *返回当前节点 + *判断是否可以继续遍历 * @example * @return */ - public function current() + public function valid() { + } /** * - *(Yaf >= 3.0.2) - *向前移动到下一个元素 + *返回当前配置节点的key * @example - * @return + * @return mixed */ - public function next() + public function key() { + } /** * - *(Yaf >= 3.0.2) - *判断是否可以继续遍历 + *撤消某个配置节点(无效) * @example - * @return + * @param string $name 变量名 + * @return mixed */ - public function valid() + public function offsetUnset(string $name) { + } /** * - *(Yaf >= 3.0.2) - *返回当前配置节点的key + *测某个配置节点是否存在 * @example + * @param mixed $name 节点名称 * @return */ - public function key() + public function offsetExists($name) { + } /** * - *(Yaf >= 3.0.2) + *设置配置节点值(无效) * @example + * @param string $name 配置项名称 + * @param mixed $value 配置值 * @return */ - public function readonly() + public function offsetSet(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) + *获取配置节点的值 + *当不传递$name参数时,返回配置对象本身 * @example + * @param string $name 索引值 * @return */ - public function toArray() + public function offsetGet(string $name) { + } /** * - *(Yaf >= 3.0.2) - *设置配置节点值 + *获取配置节点的值 + *当不传递$name参数时,返回配置对象本身 * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值 - * @param mixed $value (Yaf >= 3.0.2) -设置配置节点值 + * @param string $name 配置项名称 * @return */ - public function __set($name, $value) + public function get(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取配置节点的值 *当不传递$name参数时,返回配置对象本身 * @example - * @param mixed $name + * @param string $name 配置项名称 * @return */ - public function __get($name) + public function __get(string $name) { + } /** * - *(Yaf >= 3.0.2) - *获取配置节点的值 - *当不传递$name参数时,返回配置对象本身 + *设置配置节点值(无效) * @example - * @param mixed $name + * @param string $name 配置项名 + * @param mixed $value 配置值 * @return */ - public function offsetGet($name) + public function __set(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) - *测某个配置节点是否存在 + *将配置对象转化为数组 * @example - * @param mixed $name (Yaf >= 3.0.2) -测某个配置节点是否存在 - * @return + * @return array */ - public function offsetExists($name) + public function toArray(): array { + } /** * - *(Yaf >= 3.0.2) - *设置配置节点值 + *配置是否只读 * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值 - * @param mixed $value (Yaf >= 3.0.2) -设置配置节点值 - * @return + * @return bool */ - public function offsetSet($name, $value) + public function readonly(): bool { + } } diff --git a/src/Yaf/Config_Abstract.php b/src/Yaf/Config_Abstract.php index b57c54f..4bae46f 100644 --- a/src/Yaf/Config_Abstract.php +++ b/src/Yaf/Config_Abstract.php @@ -1,67 +1,162 @@ = 3.0.2) -*Class YafX_Config_Abstract +*yaf配置抽象类 */ namespace Yaf; abstract class Config_Abstract { /** - * @var unknown $_config - * (Yaf >= 3.0.2) + * @var array $_config * 存储已解析的配置 * @access protected - protected $_config; + */ + protected $_config = array(); /** - * @var unknown $_readonly - * (Yaf >= 3.0.2) + * @var int $_readonly * 配置是否只读,默认为1. * @access protected - protected $_readonly = '1'; + */ + protected $_readonly = 1; /** * - *(Yaf >= 3.0.2) *获取配置节点的值 *当不传递$name参数时,返回配置对象本身 * @example - * @return + * @param string $name 配置键 + * @param mixed $value 默认值 + * @return mixed */ - public abstract function get(); + public abstract function get(string $name, $value); /** * - *(Yaf >= 3.0.2) - *设置配置节点的值 + *设置配置节点的值(只读) * @example - * @return + * @return Yaf_Config_Abstract */ - public abstract function set(); + public abstract function set(): Yaf_Config_Abstract; /** * - *(Yaf >= 3.0.2) - *返回配置只读的状态 + *配置是否只读 * @example - * @return + * @return bool */ - public abstract function readonly(); + public abstract function readonly(): bool; /** * - *(Yaf >= 3.0.2) *将配置转换为数组 * @example + * @return array + */ + public abstract function toArray(): array; + + /** + * + *获取配置节点的值 + *当不传递$name参数时,返回配置对象本身 + * @example + * @param string $name 配置键 + * @return mixed + */ + public function __get(string $name) + { + + } + + /** + * + *返回当前值 + * @example + * @return void + */ + public abstract function current(); + + /** + * + *返回下一个值 + * @example + * @return void + */ + public abstract function next(); + + /** + * + *返回当前键 + * @example * @return */ - public abstract function toArray(); + public abstract function key(); + + /** + * + *验证当前对象是否合法 + * @example + * @return void + */ + public abstract function valid(); + + /** + * + *将迭代器重置到第一个位置 + * @example + * @return void + */ + public abstract function rewind(); + + /** + * + *返回当前迭代器的个数 + * @example + * @return + */ + public abstract function count(); + + /** + * + *当前索引对应的对象是否存在 + * @example + * @param string $offset 索引 + * @return void + */ + public abstract function offsetExists(string $offset); + + /** + * + *通过索引获取当前对象 + * @example + * @param string $offset 索引 + * @return void + */ + public abstract function offsetGet(string $offset); + + /** + * + *通过索引设置值 + * @example + * @param string $offset 索引 + * @param mixed $value 配置值 + * @return void + */ + public abstract function offsetSet(string $offset, $value); + + /** + * + *通过索引删除值 + * @example + * @param string $offset 索引 + * @return void + */ + public abstract function offsetUnset(string $offset); } diff --git a/src/Yaf/Controller_Abstract.php b/src/Yaf/Controller_Abstract.php index 6517598..9c206ed 100644 --- a/src/Yaf/Controller_Abstract.php +++ b/src/Yaf/Controller_Abstract.php @@ -1,194 +1,194 @@ = 3.0.2) -*Class YafX_Controller_Abstract +*控制器抽象类 */ namespace Yaf; abstract class Controller_Abstract { /** - * @var unknown $actions - * (Yaf >= 3.0.2) + * @var array $actions * 动作名与动作类文件路径映射数组 * @access public - public $actions; + */ + public $actions = array(); /** - * @var unknown $_module - * (Yaf >= 3.0.2) + * @var string $_module * 当前请求的模块名 * @access protected + */ protected $_module; /** - * @var unknown $_name - * (Yaf >= 3.0.2) + * @var string $_name * 当前请求的控制器名 * @access protected + */ protected $_name; /** - * @var unknown $_request - * (Yaf >= 3.0.2) - * 当前请求对象,包括请求的所有相关信息 + * @var Yaf_Request_Abstract $_request + * 当前请求对象 * @access protected + */ protected $_request; /** - * @var unknown $_response - * (Yaf >= 3.0.2) - * 当前响应对象,保存响应的所有相关信息 + * @var Yaf_Response_Abstract $_response + * 当前响应对象 * @access protected + */ protected $_response; /** - * @var unknown $_invoke_args - * (Yaf >= 3.0.2) - * 储存调用参数 + * @var array $_invoke_args + * 调用参数列表 * @access protected - protected $_invoke_args; + */ + protected $_invoke_args = array(); /** - * @var unknown $_view - * (Yaf >= 3.0.2) - * 视图对象 + * @var Yaf_View_Interface $_view + * 当前视图对象 * @access protected + */ protected $_view; /** * - *(Yaf >= 3.0.2) *渲染动作对应的模板,并返回结果 * @example - * @param mixed $tpl - * @param array $parameters - * @return + * @param string $action_name 模板名称 + * @param array $var_array 模板变量数组 + * @return Yaf_Controller_Abstract */ - protected function render($tpl, Array $parameters) + protected function render(string $action_name, Array $var_array = []): Yaf_Controller_Abstract { + } /** * - *(Yaf >= 3.0.2) *渲染动作对应的模板,并直接输出结果 * @example - * @param mixed $tpl - * @param array $parameters - * @return + * @param string $action_name 模板名称 + * @param array $var_array 模板变量数组 + * @return Yaf_Controller_Abstract */ - protected function display($tpl, Array $parameters) + protected function display(string $action_name, Array $var_array = []): Yaf_Controller_Abstract { + } /** * - *(Yaf >= 3.0.2) *获取请求对象 * @example - * @return + * @return Yaf_Request_Abstract */ - public function getRequest() + public function getRequest(): Yaf_Request_Abstract { + } /** * - *(Yaf >= 3.0.2) *获取响应对象 * @example - * @return + * @return Yaf_Response_Abstract */ - public function getResponse() + public function getResponse(): Yaf_Response_Abstract { + } /** * - *(Yaf >= 3.0.2) *获取当前模块名 * @example - * @return + * @return string */ - public function getModuleName() + public function getModuleName(): string { + } /** * - *(Yaf >= 3.0.2) - *返回视图对象 + *初始化视图对象 * @example - * @return + * @return void */ - public function getView() + public function initView() { + } /** * - *(Yaf >= 3.0.2) - *初始化视图对象 + *返回视图对象 * @example - * @param array $options - * @return + * @return Yaf_View_Interface */ - public function initView(Array $options) + public function getView(): Yaf_View_Interface { + } /** * - * + *设置模板文件目录 * @example - * @param mixed $view_directory - * @return + * @param string $path 模板目录 + * @return void */ - public function setViewpath($view_directory) + public function setViewPath(string $path) { + } /** * - * + *获取模板文件目录 * @example - * @return + * @return string */ - public function getViewpath() + public function getViewPath(): string { + } /** * - *(Yaf >= 3.0.2) *将当前的请求转交给另外的Action(对用户来说是透明的,相当于Web服务器的代理). * @example - * @param mixed $module - * @param mixed $controller - * @param mixed $action - * @param mixed $parameters - * @return + * @param string $module 模块名 + * @param string $controller 控制器名称 + * @param string $action 操作名称 + * @param array $parameters 参数列表数组 + * @return void */ - public function forward($module, $controller, $action, $parameters) + public function forward(string $module, string $controller, string $action, Array $parameters = []) { + } /** * - *(Yaf >= 3.0.2) *将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) * @example - * @param mixed $url + * @param string $url 跳转的地址 * @return */ - public function redirect($url) + public function redirect(string $url) { + } /** @@ -200,40 +200,41 @@ public function redirect($url) */ public function getInvokeArgs() { + } /** * - *(Yaf >= 3.0.2) *获取指定调用参数名的值 * @example - * @param mixed $name + * @param string $name 参数名称 * @return */ - public function getInvokeArg($name) + public function getInvokeArg(string $name) { + } /** * - *(Yaf >= 3.0.2) - *屏蔽构造方法 + *构造方法 * @example * @return */ public final function __construct() { + } /** * - *(Yaf >= 3.0.2) - *屏蔽克隆的魔术方法 + *克隆的魔术方法 * @example * @return */ - private final function __clone() + public final function __clone() { + } } diff --git a/src/Yaf/Dispatcher.php b/src/Yaf/Dispatcher.php index 1716d90..374db2b 100644 --- a/src/Yaf/Dispatcher.php +++ b/src/Yaf/Dispatcher.php @@ -1,398 +1,402 @@ = 3.0.2) -*Class YafX_Dispatcher +*路由及请求分发器 */ namespace Yaf; final class Dispatcher { /** - * @var unknown $_router - * (Yaf >= 3.0.2) + * @var Yaf_Router $_router * 路由器对象. * @access protected + */ protected $_router; /** - * @var unknown $_view - * (Yaf >= 3.0.2) + * @var Yaf_View_Interface $_view * 视图对象. * @access protected + */ protected $_view; /** - * @var unknown $_request - * (Yaf >= 3.0.2) + * @var Yaf_Request_Abstract $_request * 当前请求对象(包含请求的所有信息). * @access protected + */ protected $_request; /** - * @var unknown $_plugins - * (Yaf >= 3.0.2) + * @var array $_plugins * 已注册的插件对象 * @access protected - protected $_plugins; + */ + protected $_plugins = array(); /** - * @var unknown $_instance - * (Yaf >= 3.0.2) - * YafX_Dispatcher实现了单例模式,此属性保存当前实例. + * @var Yaf_Dispatcher $_instance + * yaf_Dispatcher实现了单例模式,此属性保存当前实例. * @access protected + */ protected static $_instance; /** - * @var unknown $_auto_render - * (Yaf >= 3.0.2) + * @var int $_auto_render * 自动渲染功能开关,默认1. * 自动渲染是指根据当前请求的控制器Controller和动作Action自动寻找模块文件,加载与渲染模块,之后返回结果或者输出. * 如果设置为0,$this->_instantly_flush,$this->_return_response的设置将无效,也即: - * YafX_Dispatcher::getInstance()->flushInstantly($flag); - * YafX_Dispatcher::getInstance()->returnResponse($flag); + * yaf_Dispatcher::getInstance()->flushInstantly($flag); + * yaf_Dispatcher::getInstance()->returnResponse($flag); * 设置无效,并且不会渲染模板. * @access protected - protected $_auto_render = '1'; + */ + protected $_auto_render = 1; /** - * @var unknown $_return_response - * (Yaf >= 3.0.2) + * @var int $_return_response * 返回包含请求正文的响应对象开关,默认为0. - * 默认情况下,Yaf的自动渲染查找并渲染模板(render,并非display),渲染结果写入YafX_Response_Abstract实例的_body属性, + * 默认情况下,Yaf的自动渲染查找并渲染模板(render,并非display),渲染结果写入yaf_Response_Abstract实例的_body属性, * 在分发器结束分发之后,输出_body(数组遍历输出)属性的值,并清空_body. - * 设置此属性为1,分发器结束分发之后,不会输出和清空_body,可以通过YafX_Application的run(),YafX_Dispatcher的方法dispatch(), - * 或者YafX_Controller_Abstract的getResponse()等方法的调用返回响应对象, - * 进而调用YafX_Response_Abstract实例的getBody()方法获取响应正文.此属性依赖$this->_auto_render的设置, + * 设置此属性为1,分发器结束分发之后,不会输出和清空_body,可以通过yaf_Application的run(),yaf_Dispatcher的方法dispatch(), + * 或者yaf_Controller_Abstract的getResponse()等方法的调用返回响应对象, + * 进而调用yaf_Response_Abstract实例的getBody()方法获取响应正文.此属性依赖$this->_auto_render的设置, * 当$this->_auto_render=1时,响应正文包括渲染模板的结果,反之则不包括. * @access protected - protected $_return_response = ''; + */ + protected $_return_response = 0; /** - * @var unknown $_instantly_flush - * (Yaf >= 3.0.2) + * @var int $_instantly_flush * 立即输出响应正文开头,默认为0. - * 默认情况下,Yaf自动渲染调用YafX_Controller_Abstract的render方法,渲染模板. - * 当此属性设置为1时,Yaf调用YafX_Controller_Abstract的display方法,直接渲染并输出,但不设置YafX_Response_Abstract实例的_body属性. + * 默认情况下,Yaf自动渲染调用yaf_Controller_Abstract的render方法,渲染模板. + * 当此属性设置为1时,Yaf调用yaf_Controller_Abstract的display方法,直接渲染并输出,但不设置yaf_Response_Abstract实例的_body属性. * @access protected - protected $_instantly_flush = ''; + */ + protected $_instantly_flush = 0; /** - * @var unknown $_default_module - * (Yaf >= 3.0.2) + * @var string $_default_module * 默认模块名 * @access protected + */ protected $_default_module; /** - * @var unknown $_default_controller - * (Yaf >= 3.0.2) + * @var string $_default_controller * 默认控制器 * @access protected + */ protected $_default_controller; /** - * @var unknown $_default_action - * (Yaf >= 3.0.2) + * @var string $_default_action * 默认动作名 * @access protected + */ protected $_default_action; /** * - *(Yaf >= 3.0.2) - *重置__construct魔术方法. + *关闭自动渲染模板 * @example - * @return + * @return bool */ - private function __construct() + public function disableView(): bool { + } /** * - *(Yaf >= 3.0.2) - *重置__clone魔术方法,防止克隆YafX_Dispatcher(因为是单例模式). + *开启自动渲染模板 * @example - * @return + * @return Yaf_Dispatcher */ - private function __clone() + public function enableView(): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *重置__sleep魔术方法. + *初始化视图对象 * @example - * @return + * @param string $tpl_dir 模板目录 + * @param mixed $options 全局的模板选项(配置相关) + * @return Yaf_View_Interface */ - private function __sleep() + public function initView(string $tpl_dir, $options): Yaf_View_Interface { + return Yaf_View_Simple(); } /** * - *(Yaf >= 3.0.2) - *重置__wakeup魔术方法. + *设置视图对象 * @example - * @return + * @param Yaf_View_Interface $view 视图对象实例 + * @return Yaf_Dispatcher */ - private function __wakeup() + public function setView(Yaf_View_Interface $view): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *开启自动渲染模板 + *设置请求对象(在命令行或者其他API模式下构造请求很有用) * @example - * @return + * @param Yaf_Request_Abstract $request 手动实例化的请求对象 + * @return Yaf_Dispatcher */ - public function enableView() + public function setRequest(Yaf_Request_Abstract $request): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *关闭自动渲染模板 + *返回应用实例 * @example - * @return + * @return Yaf_Application */ - public function disableView() + public function getApplication(): Yaf_Application { + } /** * - *(Yaf >= 3.0.2) - *初始化视图对象 + *返回路由器实例 * @example - * @param mixed $templates_dir - * @param mixed $options (Yaf >= 3.0.2) -初始化视图对象 - * @return + * @return Yaf_Router */ - public function initView($templates_dir, $options) + public function getRouter(): Yaf_Router { + } /** * - *(Yaf >= 3.0.2) - *设置视图对象 + *返回请求对象实例 * @example - * @param YafX_View_Interface $view (Yaf >= 3.0.2) -设置视图对象 - * @return + * @return Yaf_Request */ - public function setView($view) + public function getRequest(): Yaf_Request { + } /** * *(Yaf >= 3.0.2) - *设置请求对象(在命令行或者其他API模式下构造请求很有用) + *设置一个用户定义的错误处理函数(封装了PHP内置的set_error_handler函数) * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -设置请求对象(在命令行或者其他API模式下构造请求很有用) - * @return + * @param callable $callback PHP中可回调的结构 + * @param int $error_type 错误类型 + * @return Yaf_Dispatcher */ - public function setRequest($request) + public function setErrorHandler(Callable $callback, int $error_type = 32767): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *返回应用实例 + *设置默认模块 * @example - * @return + * @param string $module 模块名 + * @return Yaf_Dispatcher */ - public function getApplication() + public function setDefaultModule(string $module): Yaf_Dispatcher { + } /** * - *返回路由器实例 + *设置默认的控制器 * @example - * @return + * @param string $controller 控制器名 + * @return Yaf_Dispatcher */ - public function getRouter() + public function setDefaultController(string $controller): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *返回请求对象实例 + *设置默认的动作名 * @example - * @return + * @param string $action 操作名 + * @return Yaf_Dispatcher */ - public function getRequest() + public function setDefaultAction(string $action): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置一个用户定义的错误处理函数(封装了PHP内置的set_error_handler函数) + *设置或者返回$this->_return_response属性的值 + *当传递$flag参数时,设置$this->_return_response=$flag,并返回Dispatcher + *当不传递任何参数时,返回$this->_return_response当前值 * @example - * @param callable $callback (Yaf >= 3.0.2) -设置一个用户定义的错误处理函数(封装了PHP内置的set_error_handler函数) - * @param mixed $error_types - * @return + * @param bool $flag 是否返回响应 + * @return Yaf_Dispatcher */ - public function setErrorHandler(Callable $callback, $error_types) + public function returnResponse(bool $flag): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置默认模块 + *设置或者返回$this->_auto_render属性的值 + *当传递$flag参数时,设置$this->_auto_render=$flag,并返回Dispatcher + *当不传递任何参数时,返回$this->_auto_render属性的值 * @example - * @param string $module (Yaf >= 3.0.2) -设置默认模块 - * @return + * @param bool $flag 是否自动渲染 + * @return Yaf_Dispatcher */ - public function setDefaultModule($module) + public function autoRender(bool $flag): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置默认的控制器 + *设置或者返回$this->_instantly_flush属性的值 + *当传递$flag参数时,设置$this->_instantly_flush=$flag,并返回Dispatcher + *当不传递任何参数时,返回$this->_instantly_flush属性的值 * @example - * @param string $controller (Yaf >= 3.0.2) -设置默认的控制器 - * @return + * @param bool $flag 是否即时刷新缓存 + * @return Yaf_Dispatcher */ - public function setDefaultController($controller) + public function flushInstantly(bool $flag): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置默认的动作名 + *返回当前yaf_Dispatcher实例(单例模式) * @example - * @param mixed $action - * @return + * @return Yaf_Dispatcher */ - public function setDefaultAction($action) + public static function getInstance(): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置或者返回$this->_return_response属性的值 - *当传递$flag参数时,设置$this->_return_response=$flag,并返回Dispatcher - *当不传递任何参数时,返回$this->_return_response当前值 + *手动分发请求 * @example - * @param mixed $flag - * @return + * @param Yaf_Request_Abstract $request 分发的请求对象 + * @return Yaf_Response_Abstract */ - public function returnResponse($flag) + public function dispatch(Yaf_Request_Abstract $request): Yaf_Response_Abstract { + return new Yaf_Response_Http(); } /** * - *(Yaf >= 3.0.2) - *设置或者返回$this->_auto_render属性的值 - *当传递$flag参数时,设置$this->_auto_render=$flag,并返回Dispatcher - *当不传递任何参数时,返回$this->_auto_render属性的值 + *开启/关闭异常抛出或返回当前状态 * @example - * @param mixed $flag - * @return + * @param bool $flag 是否抛出异常 + * @return Yaf_Dispatcher */ - public function autoRender($flag) + public function throwException(bool $flag): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置或者返回$this->_instantly_flush属性的值 - *当传递$flag参数时,设置$this->_instantly_flush=$flag,并返回Dispatcher - *当不传递任何参数时,返回$this->_instantly_flush属性的值 + *开启/关闭自动异常捕获功能或返回当前状态 * @example - * @param mixed $flag - * @return + * @param bool $flag 是否捕获异常 + * @return Yaf_Dispatcher */ - public function flushInstantly($flag) + public function catchException(bool $flag): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *返回当前YafX_Dispatcher实例(单例模式) + *注册插件 + * @example + * @param Yaf_Plugin_Abstract $plugin 实例化的插件对象 + * @return Yaf_Dispatcher + */ + public function registerPlugin(Yaf_Plugin_Abstract $plugin): Yaf_Dispatcher + { + + } + + /** + * + *重置__construct魔术方法. * @example * @return */ - public static function getInstance() + private function __construct() { + } /** * - *(Yaf >= 3.0.2) - *手动分发请求 + *重置__clone魔术方法,防止克隆yaf_Dispatcher(因为是单例模式). * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -手动分发请求 * @return */ - public function dispatch($request) + private function __clone() { + } /** * - *(Yaf >= 3.0.2) - *开启/关闭异常抛出或返回当前状态 + *重置__destruct魔术方法. * @example - * @param mixed $flag * @return */ - public function throwException($flag) + public function __destruct() { + } /** * - *(Yaf >= 3.0.2) - *开启/关闭自动异常捕获功能或返回当前状态 + *重置__sleep魔术方法. * @example - * @param mixed $flag * @return */ - public function catchException($flag) + private function __sleep() { + } /** * - *(Yaf >= 3.0.2) - *注册插件 + *重置__wakeup魔术方法. * @example - * @param YafX_Plugin_Abstract $plugin (Yaf >= 3.0.2) -注册插件 * @return */ - public function registerPlugin($plugin) + private function __wakeup() { + } } diff --git a/src/Yaf/Exception.php b/src/Yaf/Exception.php index 6e0adab..61f69dc 100644 --- a/src/Yaf/Exception.php +++ b/src/Yaf/Exception.php @@ -1,70 +1,74 @@ = 3.0.2) -*Class YafX_Exception +*yaf异常蕨类 */ namespace Yaf; -class Exception extends \Exception +class Exception extends \Exception implements \Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -75,86 +79,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Exception/DispatchFailed.php b/src/Yaf/Exception/DispatchFailed.php index 5d2b03c..9945d4d 100644 --- a/src/Yaf/Exception/DispatchFailed.php +++ b/src/Yaf/Exception/DispatchFailed.php @@ -1,70 +1,74 @@ = 3.0.2) -*Class YafX_Exception_DispatchFailed +*yaf分发异常 */ namespace Yaf\Exception; -class DispatchFailed extends \Yaf\Exception +class DispatchFailed extends \Yaf\Exception implements \Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -75,86 +79,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Exception/LoadFailed.php b/src/Yaf/Exception/LoadFailed.php index f1f7417..2f7c33c 100644 --- a/src/Yaf/Exception/LoadFailed.php +++ b/src/Yaf/Exception/LoadFailed.php @@ -1,70 +1,74 @@ = 3.0.2) -*Class YafX_Exception_LoadFailed +*yaf加载异常 */ namespace Yaf\Exception; -class LoadFailed extends \Yaf\Exception +class LoadFailed extends \Yaf\Exception implements \Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -75,86 +79,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Exception/LoadFailed/Action.php b/src/Yaf/Exception/LoadFailed/Action.php index 70caf22..8e599d2 100644 --- a/src/Yaf/Exception/LoadFailed/Action.php +++ b/src/Yaf/Exception/LoadFailed/Action.php @@ -1,70 +1,74 @@ = 3.0.2) -*Class YafX_Exception_LoadFailed_Action +*操作文件加载异常 */ namespace Yaf\Exception\LoadFailed; -class Action extends \Yaf\Exception\LoadFailed +class Action extends \Yaf\Exception\LoadFailed implements \Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -75,86 +79,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Exception/LoadFailed/Controller.php b/src/Yaf/Exception/LoadFailed/Controller.php index c37a6f3..06122e9 100644 --- a/src/Yaf/Exception/LoadFailed/Controller.php +++ b/src/Yaf/Exception/LoadFailed/Controller.php @@ -1,70 +1,74 @@ = 3.0.2) -*Class YafX_Exception_LoadFailed_Controller +*控制器加载异常 */ namespace Yaf\Exception\LoadFailed; -class Controller extends \Yaf\Exception\LoadFailed +class Controller extends \Yaf\Exception\LoadFailed implements \Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -75,86 +79,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Exception/LoadFailed/Module.php b/src/Yaf/Exception/LoadFailed/Module.php index 5815694..a7054c9 100644 --- a/src/Yaf/Exception/LoadFailed/Module.php +++ b/src/Yaf/Exception/LoadFailed/Module.php @@ -1,70 +1,74 @@ = 3.0.2) -*Class YafX_Exception_LoadFailed_Module +*模块加载异常 */ namespace Yaf\Exception\LoadFailed; -class Module extends \Yaf\Exception\LoadFailed +class Module extends \Yaf\Exception\LoadFailed implements \Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -75,86 +79,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Exception/LoadFailed/View.php b/src/Yaf/Exception/LoadFailed/View.php index 9c577ac..76cd09a 100644 --- a/src/Yaf/Exception/LoadFailed/View.php +++ b/src/Yaf/Exception/LoadFailed/View.php @@ -1,70 +1,74 @@ = 3.0.2) -*Class YafX_Exception_LoadFailed_View +*视图加载异常 */ namespace Yaf\Exception\LoadFailed; -class View extends \Yaf\Exception\LoadFailed +class View extends \Yaf\Exception\LoadFailed implements \Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -75,86 +79,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Exception/RouterFailed.php b/src/Yaf/Exception/RouterFailed.php index ee167ce..faf2183 100644 --- a/src/Yaf/Exception/RouterFailed.php +++ b/src/Yaf/Exception/RouterFailed.php @@ -1,70 +1,74 @@ = 3.0.2) -*Class YafX_Exception_RouterFailed +*路由失败异常 */ namespace Yaf\Exception; -class RouterFailed extends \Yaf\Exception +class RouterFailed extends \Yaf\Exception implements \Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -75,86 +79,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Exception/StartupError.php b/src/Yaf/Exception/StartupError.php index f7e685c..ff3043c 100644 --- a/src/Yaf/Exception/StartupError.php +++ b/src/Yaf/Exception/StartupError.php @@ -1,70 +1,74 @@ = 3.0.2) -*Class YafX_Exception_StartupError +*启动失败异常 */ namespace Yaf\Exception; -class StartupError extends \Yaf\Exception +class StartupError extends \Yaf\Exception implements \Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -75,86 +79,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Exception/TypeError.php b/src/Yaf/Exception/TypeError.php index 6c0dc86..df82adc 100644 --- a/src/Yaf/Exception/TypeError.php +++ b/src/Yaf/Exception/TypeError.php @@ -1,70 +1,74 @@ = 3.0.2) -*Class YafX_Exception_TypeError +*类型错误异常 */ namespace Yaf\Exception; -class TypeError extends \Yaf\Exception +class TypeError extends \Yaf\Exception implements \Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -75,86 +79,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Loader.php b/src/Yaf/Loader.php index 8310156..cc5b500 100644 --- a/src/Yaf/Loader.php +++ b/src/Yaf/Loader.php @@ -1,188 +1,198 @@ = 3.0.2) -*Class YafX_Loader +*yaf类加载器 */ namespace Yaf; final class Loader { /** - * @var unknown $_library - * (Yaf >= 3.0.2) + * @var string $_library * 当前应用本地类库目录 * @access protected + */ protected $_library; /** - * @var unknown $_global_library - * (Yaf >= 3.0.2) + * @var string $_global_library * 全局类库目录 * @access protected + */ protected $_global_library; /** - * @var unknown $_instance - * (Yaf >= 3.0.2) + * @var Yaf_Loader $_instance * 当前Loader实例(单例模式) * @access protected + */ protected static $_instance; /** * - *(Yaf >= 3.0.2) - *重置__construct魔术方法. + *__construct魔术方法. * @example * @return */ private function __construct() { + } /** * - *(Yaf >= 3.0.2) - *重置__clone魔术方法,防止克隆YafX_Loader(因为是单例模式). + *重置__clone魔术方法,防止克隆yaf_Loader(因为是单例模式). * @example * @return */ private function __clone() { + + } + + /** + * + *__destruct魔术方法. + * @example + * @return + */ + public function __destruct() + { + } /** * - *(Yaf >= 3.0.2) *重置__sleep魔术方法. * @example * @return */ private function __sleep() { + } /** * - *(Yaf >= 3.0.2) *重置__wakeup魔术方法. * @example * @return */ private function __wakeup() { + } /** * - *(Yaf >= 3.0.2) *自动装载类 * @example - * @param mixed $class_name + * @param string $class 类名 * @return */ - public function autoload($class_name) + public function autoload(string $class) { + } /** * - *(Yaf >= 3.0.2) - *获取YafX_Loader实例 + *获取yaf_Loader实例 * @example - * @param mixed $local_library_path - * @param mixed $global_library_path - * @return + * @param string $library 本地类库目录 + * @param string $global 全局类库目录 + * @return Yaf_Loader */ - public static function getInstance($local_library_path, $global_library_path) + public static function getInstance(string $library, string $global): Yaf_Loader { + } /** * - *(Yaf >= 3.0.2) *注册本地类前缀 * @example - * @param mixed $name_prefix + * @param mixed $namespace 一个或者多个类前缀 * @return */ - public function registerLocalNamespace($name_prefix) + public function registerLocalNamespace($namespace) { + } /** * - *(Yaf >= 3.0.2) *获取当前已经注册的本地类前缀 * @example - * @return + * @return string */ - public function getLocalNamespace() + public function getLocalNamespace(): string { + } /** * - *(Yaf >= 3.0.2) *清空已注册的本地类前缀 * @example * @return */ public function clearLocalNamespace() { + } /** * - *(Yaf >= 3.0.2) *判断一个类, 是否是本地类. * @example - * @param mixed $class_name - * @return + * @param string $class_name 类名 + * @return bool */ - public function isLocalName($class_name) + public function isLocalName(string $class_name): bool { + } /** * - *(Yaf >= 3.0.2) *手动导入文件 * @example - * @param mixed $file + * @param string $file include的全路径文件名 * @return */ - public static function import($file) + public static function import(string $file) { + } /** * - *(Yaf >= 3.0.2) *设置本地或者全局类库目录 * @example - * @param mixed $library_path - * @param mixed $is_global + * @param string $library 目录路径 + * @param bool $global 是否为全局类库 * @return */ - public function setLibraryPath($library_path, $is_global) + public function setLibraryPath(string $library, bool $global = false) { + } /** * - *(Yaf >= 3.0.2) *获取本地或者全局类库目录 * @example - * @param mixed $is_global - * @return + * @param bool $global 是否全局类库 + * @return string|bool */ - public function getLibraryPath($is_global) + public function getLibraryPath(bool $global = false): ?string { + } } diff --git a/src/Yaf/Plugin_Abstract.php b/src/Yaf/Plugin_Abstract.php index 50e0d0d..d8de5b6 100644 --- a/src/Yaf/Plugin_Abstract.php +++ b/src/Yaf/Plugin_Abstract.php @@ -1,117 +1,92 @@ = 3.0.2) -*Class YafX_Plugin_Abstract +*插件抽象类 */ namespace Yaf; abstract class Plugin_Abstract { /** * - *(Yaf >= 3.0.2) *在路由之前触发 * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -在路由之前触发 - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -在路由之前触发 + * @param Yaf_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function routerStartup($request, $response) + public function routerStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { + } /** * - *(Yaf >= 3.0.2) *路由结束之后触发 * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -路由结束之后触发 - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -路由结束之后触发 + * @param Yaf_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function routerShutdown($request, $response) + public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { + } /** * - *(Yaf >= 3.0.2) *分发循环开始之前被触发 * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -分发循环开始之前被触发 - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -分发循环开始之前被触发 + * @param YafX_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function dispatchLoopStartup($request, $response) + public function dispatchLoopStartup(YafX_Request_Abstract $request, Yaf_Response_Abstract $response) { + } /** * - *(Yaf >= 3.0.2) - *dispatchLoopShutdown - * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -dispatchLoopShutdown - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -dispatchLoopShutdown - * @return - */ - public function dispatchLoopShutdown($request, $response) - { - } - - /** - * - *(Yaf >= 3.0.2) *分发之前触发 * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -分发之前触发 - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -分发之前触发 + * @param Yaf_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function preDispatch($request, $response) + public function preDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { + } /** * - *(Yaf >= 3.0.2) *分发结束之后触发 * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -分发结束之后触发 - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -分发结束之后触发 + * @param Yaf_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function postDispatch($request, $response) + public function postDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { + } /** * - * + *分发循环结束 * @example - * @param Yaf\Request_Abstract $request - * @param Yaf\Response_Abstract $response + * @param Yaf_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function preResponse($request, $response) + public function dispatchLoopShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { + } } diff --git a/src/Yaf/Registry.php b/src/Yaf/Registry.php index 3dd8db3..a270efa 100644 --- a/src/Yaf/Registry.php +++ b/src/Yaf/Registry.php @@ -1,104 +1,99 @@ = 3.0.2) -*Class YafX_Registry +*yaf变量注册器 */ namespace Yaf; final class Registry { /** - * @var unknown $_instance - * (Yaf >= 3.0.2) + * @var Yaf_Registry $_instance * Registry实例(单例模式) * @access protected + */ protected static $_instance; /** - * @var unknown $_entries - * (Yaf >= 3.0.2) + * @var array $_entries * 注册变量栈 * @access protected - protected $_entries; + */ + protected $_entries = array(); /** * - *(Yaf >= 3.0.2) *重置__construct魔术方法. * @example * @return */ private function __construct() { + } /** * - *(Yaf >= 3.0.2) *重置__clone魔术方法,防止克隆Dispatcher(因为是单例模式). * @example * @return */ private function __clone() { + } /** * - *(Yaf >= 3.0.2) *获取注册变量值 * @example - * @param string $name (Yaf >= 3.0.2) -获取注册变量值 - * @return + * @param string $name 变量名 + * @return mixed */ - public static function get($name) + public static function get(string $name) { + } /** * - *(Yaf >= 3.0.2) *检测变量是否存在 * @example - * @param string $name (Yaf >= 3.0.2) -检测变量是否存在 - * @return + * @param string $name 变量名 + * @return bool */ - public static function has($name) + public static function has(string $name): bool { + } /** * - *(Yaf >= 3.0.2) *注册变量 * @example - * @param string $name (Yaf >= 3.0.2) -注册变量 - * @param mixed $value (Yaf >= 3.0.2) -注册变量 - * @return + * @param string $name 变量名 + * @param mixed $value 变量值 + * @return bool */ - public static function set($name, $value) + public static function set(string $name, $value): bool { + } /** * - *(Yaf >= 3.0.2) - *删除变量 + *删除注册器中的变量 * @example - * @param mixed $name + * @param string $name 变量名 * @return */ - public static function del($name) + public static function del(string $name) { + } } diff --git a/src/Yaf/Request/Http.php b/src/Yaf/Request/Http.php index 9ee13af..2d8105c 100644 --- a/src/Yaf/Request/Http.php +++ b/src/Yaf/Request/Http.php @@ -1,387 +1,387 @@ = 3.0.2) -*Class YafX_Request_Http +*http请求对象 */ namespace Yaf\Request; class Http extends \Yaf\Request_Abstract { /** - * @var unknown $module - * (Yaf >= 3.0.2) + * @var string $module * 当前请求的模块名 * @access public + */ public $module; /** - * @var unknown $controller - * (Yaf >= 3.0.2) + * @var string $controller * 当前请求的控制器名 * @access public + */ public $controller; /** - * @var unknown $action - * (Yaf >= 3.0.2) + * @var stirng $action * 当前请求的动作名 * @access public + */ public $action; /** - * @var unknown $method - * (Yaf >= 3.0.2) + * @var string $method * 当前请求的方法 getMethod * @access public + */ public $method; /** - * @var unknown $params - * (Yaf >= 3.0.2) + * @var array $params * 请求传递的参数 * @access protected - protected $params; + */ + protected $params = array(); /** - * @var unknown $language - * (Yaf >= 3.0.2) + * @var string $language * http报头中HTTP_ACCEPT_LANGUAGE的值 * @access protected + */ protected $language; /** - * @var unknown $_exception - * (Yaf >= 3.0.2) + * @var Yaf_Exception $_exception * 异常对象 * @access protected + */ protected $_exception; /** - * @var unknown $_base_uri - * (Yaf >= 3.0.2) + * @var string $_base_uri * 请求的Base URI(http请求 or cli模式下) * @access protected + */ protected $_base_uri = ''; /** - * @var unknown $uri - * (Yaf >= 3.0.2) + * @var string $uri * 请求的URI(http请求) * @access protected + */ protected $uri = ''; /** - * @var unknown $dispatched - * (Yaf >= 3.0.2) + * @var bool $dispatched * 请求是否完成了分发,默认为0 * @access protected - protected $dispatched = ''; + */ + protected $dispatched = false; /** - * @var unknown $routed - * (Yaf >= 3.0.2) + * @var bool $routed * 请求是否完成了路由,默认为0 * @access protected - protected $routed = ''; + */ + protected $routed = false; /** * - *(Yaf >= 3.0.2) - *获取$_GET中名为$name的参数值 + *构造方法 * @example + * @param string $request_uri 请求uri + * @param string $base_uri Base URI * @return */ - public function getQuery() + public function __construct(string $request_uri, string $base_uri) { + } /** * - *(Yaf >= 3.0.2) - *获取$_REQUEST中名为$name的参数值 + *获取$_GET中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - public function getRequest() + public function getQuery(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) - *获取$_POST中名为$name的参数值 + *获取$_REQUEST中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return Yaf_Request_Abstract */ - public function getPost() + public function getRequest(string $name): Yaf_Request_Abstract { + } /** * - *(Yaf >= 3.0.2) - *获取$_COOKIE中名为$name的参数值 + *获取$_POST中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - public function getCookie() + public function getPost(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) - *获取$_FILES中名为$name的参数值 + *获取$_COOKIE中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return string */ - public function getFiles() + public function getCookie(string $name): string { + } /** * - *(Yaf >= 3.0.2) - *获取全局变量中的值(扫描顺序为$_POST,$_GET,$_COOKIE,$_SERVER) + *获取$_FILES中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return array */ - public function get() + public function getFiles(string $name): array { + } /** * - *(Yaf >= 3.0.2) *判断是否为AJAX请求 * @example - * @return + * @return bool */ - public function isXmlHttpRequest() + public function isXmlHttpRequest(): bool { + } /** * - *(Yaf >= 3.0.2) - *构造方法 + *获取全局变量中的值(扫描顺序为$_POST,$_GET,$_COOKIE,$_SERVER) * @example - * @return + * @param string $name 变量名 + * @param mixed $default 默认值 + * @return string */ - public function __construct() + public function get(string $name, $default): string { + } /** * - *(Yaf >= 3.0.2) *重置__clone魔术方法 * @example * @return */ private function __clone() { + } /** * - *(Yaf >= 3.0.2) *判断是否为GET请求 * @example - * @return + * @return bool */ - public function isGet() + public function isGet(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为POST请求 * @example - * @return + * @return bool */ - public function isPost() + public function isPost(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为PUT请求 * @example - * @return + * @return bool */ - public function isPut() + public function isPut(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为HEAD请求 * @example - * @return + * @return bool */ - public function isHead() + public function isHead(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为Options请求 * @example - * @return + * @return bool */ - public function isOptions() + public function isOptions(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为CLI请求 * @example - * @return + * @return bool */ - public function isCli() + public function isCli(): bool { + } /** * - *(Yaf >= 3.0.2) *获取服务器$_SERVER全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @param mixed $default (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @return + * @param string $name 变量名 + * @param mixed $default 默认值 + * @return mixed */ - public function getServer($name, $default) + public function getServer(string $name, $default) { + } /** * - *(Yaf >= 3.0.2) *获取环境变量$_ENV全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @param string $default (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return mixed */ - public function getEnv($name, $default) + public function getEnv(string $name, string $default) { + } /** * - *(Yaf >= 3.0.2) *设置请求的参数 *当只有一个参数且为Array类型,如果存在对应的键值将覆盖 * @example - * @param string $name (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 - * @param mixed $value (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function setParam($name, $value) + public function setParam(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) *获取请求的参数 * @example - * @param string $name (Yaf >= 3.0.2) -获取请求的参数 - * @param string $default (Yaf >= 3.0.2) -获取请求的参数 - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - public function getParam($name, $default) + public function getParam(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) *获取请求全部的参数 * @example - * @return + * @return array */ - public function getParams() + public function getParams(): array { + } /** * - *(Yaf >= 3.0.2) *获取异常对象 * @example - * @return + * @return Yaf_Exception */ - public function getException() + public function getException(): Yaf_Exception { + } /** * - *(Yaf >= 3.0.2) *获取当前模块名 * @example - * @return + * @return string */ - public function getModuleName() + public function getModuleName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前控制器名 * @example - * @return + * @return string */ - public function getControllerName() + public function getControllerName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前动作名 * @example - * @return + * @return string */ - public function getActionName() + public function getActionName(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的模块名 * @example - * @param mixed $module + * @param string $name 模块名 * @return */ - public function setModuleName($module) + public function setModuleName(string $name) { + } /** @@ -389,79 +389,80 @@ public function setModuleName($module) *(Yaf >= 3.0.2) *设置请求的控制器名 * @example - * @param mixed $controller + * @param string $name 控制器名称 * @return */ - public function setControllerName($controller) + public function setControllerName(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置请求的动作名 * @example - * @param mixed $action + * @param string $name 操作名称 * @return */ - public function setActionName($action) + public function setActionName(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取当前请求的方法 * @example - * @return + * @return string */ - public function getMethod() + public function getMethod(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前请求的请求 * @example - * @return + * @return string */ - public function getLanguage() + public function getLanguage(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的Base URI * @example - * @param mixed $uri + * @param string $baseuri 基本uri * @return */ - public function setBaseUri($uri) + public function setBaseUri(string $baseuri) { + } /** * - *(Yaf >= 3.0.2) *获取请求的Base URI * @example - * @return + * @return string */ - public function getBaseUri() + public function getBaseUri(): string { + } /** * - *(Yaf >= 3.0.2) *获取请求的uri * @example - * @return + * @return string */ - public function getRequestUri() + public function getRequestUri(): string { + } /** @@ -469,56 +470,56 @@ public function getRequestUri() *(Yaf >= 3.0.2) *设置请求的URI * @example - * @param mixed $uri + * @param string $uri 请求uri * @return */ - public function setRequestUri($uri) + public function setRequestUri(string $uri) { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了分发 * @example - * @return + * @return bool */ - public function isDispatched() + public function isDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成分发 * @example - * @return + * @return bool */ - public function setDispatched() + public function setDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了路由 * @example - * @return + * @return bool */ - public function isRouted() + public function isRouted(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成了路由 * @example - * @param mixed $flag - * @return + * @return bool */ - public function setRouted($flag) + public function setRouted(): bool { + } } diff --git a/src/Yaf/Request/Simple.php b/src/Yaf/Request/Simple.php index feb9794..574da24 100644 --- a/src/Yaf/Request/Simple.php +++ b/src/Yaf/Request/Simple.php @@ -1,397 +1,397 @@ = 3.0.2) -*Class YafX_Request_Simple +*yaf简单请求类 */ namespace Yaf\Request; final class Simple extends \Yaf\Request_Abstract { /** - * + *http请求 */ const SCHEME_HTTP = 'http'; /** - * + *https请求 */ const SCHEME_HTTPS = 'https'; /** - * @var unknown $module - * (Yaf >= 3.0.2) + * @var string $module * 当前请求的模块名 * @access public + */ public $module; /** - * @var unknown $controller - * (Yaf >= 3.0.2) + * @var string $controller * 当前请求的控制器名 * @access public + */ public $controller; /** - * @var unknown $action - * (Yaf >= 3.0.2) + * @var stirng $action * 当前请求的动作名 * @access public + */ public $action; /** - * @var unknown $method - * (Yaf >= 3.0.2) + * @var string $method * 当前请求的方法 getMethod * @access public + */ public $method; /** - * @var unknown $params - * (Yaf >= 3.0.2) + * @var array $params * 请求传递的参数 * @access protected - protected $params; + */ + protected $params = array(); /** - * @var unknown $language - * (Yaf >= 3.0.2) + * @var string $language * http报头中HTTP_ACCEPT_LANGUAGE的值 * @access protected + */ protected $language; /** - * @var unknown $_exception - * (Yaf >= 3.0.2) + * @var Yaf_Exception $_exception * 异常对象 * @access protected + */ protected $_exception; /** - * @var unknown $_base_uri - * (Yaf >= 3.0.2) + * @var string $_base_uri * 请求的Base URI(http请求 or cli模式下) * @access protected + */ protected $_base_uri = ''; /** - * @var unknown $uri - * (Yaf >= 3.0.2) + * @var string $uri * 请求的URI(http请求) * @access protected + */ protected $uri = ''; /** - * @var unknown $dispatched - * (Yaf >= 3.0.2) + * @var bool $dispatched * 请求是否完成了分发,默认为0 * @access protected - protected $dispatched = ''; + */ + protected $dispatched = false; /** - * @var unknown $routed - * (Yaf >= 3.0.2) + * @var bool $routed * 请求是否完成了路由,默认为0 * @access protected - protected $routed = ''; + */ + protected $routed = false; /** * - *(Yaf >= 3.0.2) *构造方法 * @example + * @param string $request_uri 请求uri + * @param string $base_uri Base URI * @return */ - public function __construct() + public function __construct(string $request_uri, string $base_uri) { + } /** * - *(Yaf >= 3.0.2) - *重置__clone魔术方法 + *获取$_GET中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - private function __clone() + public function getQuery(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) - *获取$_GET中名为$name的参数值 + *获取$_REQUEST中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return Yaf_Request_Abstract */ - public function getQuery() + public function getRequest(string $name): Yaf_Request_Abstract { + } /** * - *(Yaf >= 3.0.2) - *获取$_REQUEST中名为$name的参数值 + *获取$_POST中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - public function getRequest() + public function getPost(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) - *获取$_POST中名为$name的参数值 + *获取$_COOKIE中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return string */ - public function getPost() + public function getCookie(string $name): string { + } /** * - *(Yaf >= 3.0.2) - *获取$_COOKIE中名为$name的参数值 + *获取$_FILES中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return array */ - public function getCookie() + public function getFiles(string $name): array { + } /** * - *(Yaf >= 3.0.2) - *获取$_FILES中名为$name的参数值 + *判断是否为AJAX请求 * @example - * @return + * @return bool */ - public function getFiles() + public function isXmlHttpRequest(): bool { + } /** * - *(Yaf >= 3.0.2) *获取全局变量中的值(扫描顺序为$_POST,$_GET,$_COOKIE,$_SERVER) * @example - * @return + * @param string $name 变量名 + * @param mixed $default 默认值 + * @return string */ - public function get() + public function get(string $name, $default): string { + } /** * - *(Yaf >= 3.0.2) - *判断是否为AJAX请求 + *重置__clone魔术方法 * @example * @return */ - public function isXmlHttpRequest() + private function __clone() { + } /** * - *(Yaf >= 3.0.2) *判断是否为GET请求 * @example - * @return + * @return bool */ - public function isGet() + public function isGet(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为POST请求 * @example - * @return + * @return bool */ - public function isPost() + public function isPost(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为PUT请求 * @example - * @return + * @return bool */ - public function isPut() + public function isPut(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为HEAD请求 * @example - * @return + * @return bool */ - public function isHead() + public function isHead(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为Options请求 * @example - * @return + * @return bool */ - public function isOptions() + public function isOptions(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为CLI请求 * @example - * @return + * @return bool */ - public function isCli() + public function isCli(): bool { + } /** * - *(Yaf >= 3.0.2) *获取服务器$_SERVER全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @param mixed $default (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @return + * @param string $name 变量名 + * @param mixed $default 默认值 + * @return mixed */ - public function getServer($name, $default) + public function getServer(string $name, $default) { + } /** * - *(Yaf >= 3.0.2) *获取环境变量$_ENV全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @param string $default (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return mixed */ - public function getEnv($name, $default) + public function getEnv(string $name, string $default) { + } /** * - *(Yaf >= 3.0.2) *设置请求的参数 *当只有一个参数且为Array类型,如果存在对应的键值将覆盖 * @example - * @param string $name (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 - * @param mixed $value (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function setParam($name, $value) + public function setParam(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) *获取请求的参数 * @example - * @param string $name (Yaf >= 3.0.2) -获取请求的参数 - * @param string $default (Yaf >= 3.0.2) -获取请求的参数 - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - public function getParam($name, $default) + public function getParam(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) *获取请求全部的参数 * @example - * @return + * @return array */ - public function getParams() + public function getParams(): array { + } /** * - *(Yaf >= 3.0.2) *获取异常对象 * @example - * @return + * @return Yaf_Exception */ - public function getException() + public function getException(): Yaf_Exception { + } /** * - *(Yaf >= 3.0.2) *获取当前模块名 * @example - * @return + * @return string */ - public function getModuleName() + public function getModuleName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前控制器名 * @example - * @return + * @return string */ - public function getControllerName() + public function getControllerName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前动作名 * @example - * @return + * @return string */ - public function getActionName() + public function getActionName(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的模块名 * @example - * @param mixed $module + * @param string $name 模块名 * @return */ - public function setModuleName($module) + public function setModuleName(string $name) { + } /** @@ -399,79 +399,80 @@ public function setModuleName($module) *(Yaf >= 3.0.2) *设置请求的控制器名 * @example - * @param mixed $controller + * @param string $name 控制器名称 * @return */ - public function setControllerName($controller) + public function setControllerName(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置请求的动作名 * @example - * @param mixed $action + * @param string $name 操作名称 * @return */ - public function setActionName($action) + public function setActionName(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取当前请求的方法 * @example - * @return + * @return string */ - public function getMethod() + public function getMethod(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前请求的请求 * @example - * @return + * @return string */ - public function getLanguage() + public function getLanguage(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的Base URI * @example - * @param mixed $uri + * @param string $baseuri 基本uri * @return */ - public function setBaseUri($uri) + public function setBaseUri(string $baseuri) { + } /** * - *(Yaf >= 3.0.2) *获取请求的Base URI * @example - * @return + * @return string */ - public function getBaseUri() + public function getBaseUri(): string { + } /** * - *(Yaf >= 3.0.2) *获取请求的uri * @example - * @return + * @return string */ - public function getRequestUri() + public function getRequestUri(): string { + } /** @@ -479,56 +480,56 @@ public function getRequestUri() *(Yaf >= 3.0.2) *设置请求的URI * @example - * @param mixed $uri + * @param string $uri 请求uri * @return */ - public function setRequestUri($uri) + public function setRequestUri(string $uri) { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了分发 * @example - * @return + * @return bool */ - public function isDispatched() + public function isDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成分发 * @example - * @return + * @return bool */ - public function setDispatched() + public function setDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了路由 * @example - * @return + * @return bool */ - public function isRouted() + public function isRouted(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成了路由 * @example - * @param mixed $flag - * @return + * @return bool */ - public function setRouted($flag) + public function setRouted(): bool { + } } diff --git a/src/Yaf/Request_Abstract.php b/src/Yaf/Request_Abstract.php index 85d10f1..e6c986d 100644 --- a/src/Yaf/Request_Abstract.php +++ b/src/Yaf/Request_Abstract.php @@ -1,446 +1,434 @@ = 3.0.2) -*Class YafX_Request_Abstract +*请求抽象类 */ namespace Yaf; abstract class Request_Abstract { /** - * + *http请求 */ const SCHEME_HTTP = 'http'; /** - * + *https请求 */ const SCHEME_HTTPS = 'https'; /** - * @var unknown $module - * (Yaf >= 3.0.2) + * @var string $module * 当前请求的模块名 * @access public + */ public $module; /** - * @var unknown $controller - * (Yaf >= 3.0.2) + * @var string $controller * 当前请求的控制器名 * @access public + */ public $controller; /** - * @var unknown $action - * (Yaf >= 3.0.2) + * @var stirng $action * 当前请求的动作名 * @access public + */ public $action; /** - * @var unknown $method - * (Yaf >= 3.0.2) + * @var string $method * 当前请求的方法 getMethod * @access public + */ public $method; /** - * @var unknown $params - * (Yaf >= 3.0.2) + * @var array $params * 请求传递的参数 * @access protected - protected $params; + */ + protected $params = array(); /** - * @var unknown $language - * (Yaf >= 3.0.2) + * @var string $language * http报头中HTTP_ACCEPT_LANGUAGE的值 * @access protected + */ protected $language; /** - * @var unknown $_exception - * (Yaf >= 3.0.2) + * @var Yaf_Exception $_exception * 异常对象 * @access protected + */ protected $_exception; /** - * @var unknown $_base_uri - * (Yaf >= 3.0.2) + * @var string $_base_uri * 请求的Base URI(http请求 or cli模式下) * @access protected + */ protected $_base_uri = ''; /** - * @var unknown $uri - * (Yaf >= 3.0.2) + * @var string $uri * 请求的URI(http请求) * @access protected + */ protected $uri = ''; /** - * @var unknown $dispatched - * (Yaf >= 3.0.2) + * @var bool $dispatched * 请求是否完成了分发,默认为0 * @access protected - protected $dispatched = ''; + */ + protected $dispatched = false; /** - * @var unknown $routed - * (Yaf >= 3.0.2) + * @var bool $routed * 请求是否完成了路由,默认为0 * @access protected - protected $routed = ''; + */ + protected $routed = false; /** * - *(Yaf >= 3.0.2) *判断是否为GET请求 * @example - * @return + * @return bool */ - public function isGet() + public function isGet(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为POST请求 * @example - * @return + * @return bool */ - public function isPost() + public function isPost(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为PUT请求 * @example - * @return + * @return bool */ - public function isPut() + public function isPut(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为HEAD请求 * @example - * @return + * @return bool */ - public function isHead() + public function isHead(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为Options请求 * @example - * @return + * @return bool */ - public function isOptions() + public function isOptions(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为CLI请求 * @example - * @return + * @return bool */ - public function isCli() + public function isCli(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为AJAX请求 * @example - * @return + * @return bool */ - public function isXmlHttpRequest() + public function isXmlHttpRequest(): bool { + } /** * - *(Yaf >= 3.0.2) *获取服务器$_SERVER全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @param mixed $default (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @return + * @param string $name 变量名 + * @param mixed $default 默认值 + * @return mixed */ - public function getServer($name, $default) + public function getServer(string $name, $default) { + } /** * - *(Yaf >= 3.0.2) *获取环境变量$_ENV全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @param string $default (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return mixed */ - public function getEnv($name, $default) + public function getEnv(string $name, string $default) { + } /** * - *(Yaf >= 3.0.2) *设置请求的参数 *当只有一个参数且为Array类型,如果存在对应的键值将覆盖 * @example - * @param string $name (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 - * @param mixed $value (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function setParam($name, $value) + public function setParam(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) *获取请求的参数 * @example - * @param string $name (Yaf >= 3.0.2) -获取请求的参数 - * @param string $default (Yaf >= 3.0.2) -获取请求的参数 + * @param string $name 变量名 + * @param string $default 默认值 * @return */ - public function getParam($name, $default) + public function getParam(string $name, string $default) { + } /** * - *(Yaf >= 3.0.2) *获取请求全部的参数 * @example - * @return + * @return array|null */ - public function getParams() + public function getParams(): ?array { + } /** * - *(Yaf >= 3.0.2) *获取异常对象 * @example - * @return + * @return Yaf_Exception */ - public function getException() + public function getException(): Yaf_Exception { + } /** * - *(Yaf >= 3.0.2) *获取当前模块名 * @example - * @return + * @return string */ - public function getModuleName() + public function getModuleName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前控制器名 * @example - * @return + * @return string */ - public function getControllerName() + public function getControllerName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前动作名 * @example - * @return + * @return string */ - public function getActionName() + public function getActionName(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的模块名 * @example - * @param mixed $module + * @param string $name 模块名 * @return */ - public function setModuleName($module) + public function setModuleName(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置请求的控制器名 * @example - * @param mixed $controller + * @param string $name 控制器名称 * @return */ - public function setControllerName($controller) + public function setControllerName(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置请求的动作名 * @example - * @param mixed $action + * @param string $name 操作名称 * @return */ - public function setActionName($action) + public function setActionName(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取当前请求的方法 * @example - * @return + * @return string */ - public function getMethod() + public function getMethod(): string { + } /** * - *(Yaf >= 3.0.2) - *获取当前请求的请求 + *获取当前请求的请求的语言 * @example - * @return + * @return string */ - public function getLanguage() + public function getLanguage(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的Base URI * @example - * @param mixed $uri + * @param string $baseuri 基本请求地址 * @return */ - public function setBaseUri($uri) + public function setBaseUri(string $baseuri) { + } /** * - *(Yaf >= 3.0.2) *获取请求的Base URI * @example - * @return + * @return string */ - public function getBaseUri() + public function getBaseUri(): string { + } /** * - *(Yaf >= 3.0.2) *获取请求的uri * @example - * @return + * @return string */ - public function getRequestUri() + public function getRequestUri(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的URI * @example - * @param mixed $uri + * @param string $uri 请求uri * @return */ - public function setRequestUri($uri) + public function setRequestUri(string $uri) { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了分发 * @example - * @return + * @return bool */ - public function isDispatched() + public function isDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成分发 * @example - * @return + * @return bool */ - public function setDispatched() + public function setDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了路由 * @example - * @return + * @return bool */ - public function isRouted() + public function isRouted(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成了路由 * @example - * @param mixed $flag - * @return + * @return bool */ - public function setRouted($flag) + public function setRouted(): bool { + } } diff --git a/src/Yaf/Response/Cli.php b/src/Yaf/Response/Cli.php index df923f1..1d63317 100644 --- a/src/Yaf/Response/Cli.php +++ b/src/Yaf/Response/Cli.php @@ -1,166 +1,214 @@ = 3.0.2) -*Class YafX_Response_Cli +*命令行下响应对象 */ namespace Yaf\Response; class Cli extends \Yaf\Response_Abstract { /** - * + *默认内容 */ const DEFAULT_BODY = 'content'; /** - * @var unknown $_header - * (Yaf >= 3.0.2) + * @var array $_header * 响应报头 * @access protected - protected $_header; + */ + protected $_header = array(); /** - * @var unknown $_body - * (Yaf >= 3.0.2) - * 响应正文 + * @var string $_body + * 响应体 * @access protected + */ protected $_body; /** - * @var unknown $_sendheader - * (Yaf >= 3.0.2) + * @var bool $_sendheader * 是否开启已输出响应报头检测 * @access protected - protected $_sendheader = ''; + */ + protected $_sendheader = false; /** * - *(Yaf >= 3.0.2) *构造方法 * @example * @return */ public function __construct() { + } /** * - *(Yaf >= 3.0.2) *析构方法 * @example * @return */ public function __destruct() { + } /** * - *(Yaf >= 3.0.2) *重置__clone魔术方法 * @example * @return */ private function __clone() { + } /** * - *(Yaf >= 3.0.2) *返回响应正文的字符串 * @example * @return */ public function __toString() { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 + * @param string $body 响应正文内容(可覆盖原来的) + * @param string $name 响应正文类型,默认为content * @return */ - public function setBody($body, $name) + public function setBody(string $body, string $name = 'content') + { + + } + + /** + * + *获取类型为$name的响应正文内容 + * @example + * @param string $name 响应正文类型,默认为content + * @return string|null + */ + public function getBody(string $name = 'content'): ?string { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function appendBody($body, $name) + public function appendBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function prependBody($body, $name) + public function prependBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) *清空响应正文 * @example - * @param mixed $name * @return */ - public function clearBody($name) + public function clearBody() { + } /** * - *(Yaf >= 3.0.2) - *获取类型为$name的响应正文内容 + *获取响应报头 + * @example + * @return array + */ + public function getHeader(): array + { + + } + + /** + * + *批量设置响应报头 + * @example + * @param array $headers 响应头列表 + * @return + */ + public function setAllHeaders(Array $headers) + { + + } + + /** + * + *设置响应报头 + * @example + * @return + */ + public function setHeader() + { + + } + + /** + * + *清空响应报头 + * @example + * @return + */ + public function clearHeaders() + { + + } + + /** + * + *将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) * @example - * @param string $name (Yaf >= 3.0.2) -获取类型为$name的响应正文内容 + * @param string $url 重定向的绝对URL * @return */ - public function getBody($name) + public function setRedirect(string $url) { + } /** * - *(Yaf >= 3.0.2) *输出所有的响应正文 * @example * @return */ public function response() { + } } diff --git a/src/Yaf/Response/Http.php b/src/Yaf/Response/Http.php index 887f092..95ccfc0 100644 --- a/src/Yaf/Response/Http.php +++ b/src/Yaf/Response/Http.php @@ -1,236 +1,221 @@ = 3.0.2) -*Class YafX_Response_Http +*HTTP响应 */ namespace Yaf\Response; class Http extends \Yaf\Response_Abstract { /** - * + *默认内容 */ const DEFAULT_BODY = 'content'; /** - * @var unknown $_header - * (Yaf >= 3.0.2) + * @var array $_header * 响应报头 * @access protected - protected $_header; + */ + protected $_header = array(); /** - * @var unknown $_body - * (Yaf >= 3.0.2) + * @var string $_body * 响应正文 * @access protected + */ protected $_body; /** - * @var unknown $_sendheader - * (Yaf >= 3.0.2) + * @var bool $_sendheader * 是否开启已输出响应报头检测 * @access protected - protected $_sendheader = '1'; + */ + protected $_sendheader = true; /** - * @var unknown $_response_code - * (Yaf >= 3.0.2) + * @var int $_response_code * 响应状态码 * @access protected + */ protected $_response_code = 0; /** * - *(Yaf >= 3.0.2) - *设置响应报头 + *构造方法 * @example - * @param mixed $name - * @param mixed $value - * @param mixed $rep - * @param mixed $response_code * @return */ - public function setHeader($name, $value, $rep, $response_code) + public function __construct() { + } /** * - *(Yaf >= 3.0.2) - *获取所有响应报头 + *析构方法 * @example - * @param mixed $headers * @return */ - public function setAllHeaders($headers) + public function __destruct() { + } /** * - *(Yaf >= 3.0.2) - *获取响应报头 + *重置__clone魔术方法 * @example - * @param mixed $name * @return */ - public function getHeader($name) + private function __clone() { + } /** * - *(Yaf >= 3.0.2) - *清空响应报头 + *返回响应正文的字符串 * @example * @return */ - public function clearHeaders() + public function __toString() { + } /** * - *(Yaf >= 3.0.2) - *将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) + *设置类型为$name的响应正文内容 * @example - * @param string $url (Yaf >= 3.0.2) -将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) + * @param string $body 响应正文内容(可覆盖原来的) + * @param string $name 响应正文类型,默认为content * @return */ - public function setRedirect($url) + public function setBody(string $body, string $name = 'content') { + } /** * - *(Yaf >= 3.0.2) - *输出所有的响应正文 + *获取类型为$name的响应正文内容 * @example + * @param string $name 响应正文类型,默认为content * @return */ - public function response() + public function getBody(string $name = 'content') { + } /** * - *(Yaf >= 3.0.2) - *构造方法 + *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 * @example + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function __construct() + public function appendBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) - *析构方法 + *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 * @example + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function __destruct() + public function prependBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) - *重置__clone魔术方法 + *清空响应正文 * @example * @return */ - private function __clone() + public function clearBody() { + } /** * - *(Yaf >= 3.0.2) - *返回响应正文的字符串 + *获取响应报头 * @example * @return */ - public function __toString() + public function getHeader() { + } /** * - *(Yaf >= 3.0.2) - *设置类型为$name的响应正文内容 + *批量设置响应报头 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 + * @param array $headers 响应头列表 * @return */ - public function setBody($body, $name) + public function setAllHeaders(Array $headers) { + } /** * - *(Yaf >= 3.0.2) - *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 + *设置响应报头 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 * @return */ - public function appendBody($body, $name) + public function setHeader() { + } /** * - *(Yaf >= 3.0.2) - *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 + *清空响应报头 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 * @return */ - public function prependBody($body, $name) + public function clearHeaders() { + } /** * - *(Yaf >= 3.0.2) - *清空响应正文 + *将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) * @example - * @param mixed $name + * @param string $url 重定向的绝对URL * @return */ - public function clearBody($name) + public function setRedirect(string $url) { + } /** * - *(Yaf >= 3.0.2) - *获取类型为$name的响应正文内容 + *输出所有的响应正文 * @example - * @param string $name (Yaf >= 3.0.2) -获取类型为$name的响应正文内容 * @return */ - public function getBody($name) + public function response() { + } } diff --git a/src/Yaf/Response_Abstract.php b/src/Yaf/Response_Abstract.php index 9ef33ba..52e8bd5 100644 --- a/src/Yaf/Response_Abstract.php +++ b/src/Yaf/Response_Abstract.php @@ -1,166 +1,215 @@ = 3.0.2) -*Class YafX_Response_Abstract +*yaf响应抽象类 */ namespace Yaf; abstract class Response_Abstract { /** - * + *默认响应内容 */ const DEFAULT_BODY = 'content'; /** - * @var unknown $_header - * (Yaf >= 3.0.2) + * @var array $_header * 响应报头 * @access protected - protected $_header; + */ + protected $_header = array(); /** - * @var unknown $_body - * (Yaf >= 3.0.2) + * @var string $_body * 响应正文 * @access protected + */ protected $_body; /** - * @var unknown $_sendheader - * (Yaf >= 3.0.2) + * @var bool $_sendheader * 是否开启已输出响应报头检测 * @access protected - protected $_sendheader = ''; + */ + protected $_sendheader = false; /** * - *(Yaf >= 3.0.2) *构造方法 * @example * @return */ public function __construct() { + } /** * - *(Yaf >= 3.0.2) *析构方法 * @example * @return */ public function __destruct() { + } /** * - *(Yaf >= 3.0.2) *重置__clone魔术方法 * @example * @return */ private function __clone() { + } /** * - *(Yaf >= 3.0.2) *返回响应正文的字符串 * @example * @return */ public function __toString() { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 + * @param string $body 响应正文内容(可覆盖原来的) + * @param string $name 响应正文类型,默认为content * @return */ - public function setBody($body, $name) + public function setBody(string $body, string $name = 'content') { + + } + + /** + * + *获取类型为$name的响应正文内容 + * @example + * @param string $name 响应正文类型,默认为content + * @return string + */ + public function getBody(string $name = 'content'): string + { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function appendBody($body, $name) + public function appendBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function prependBody($body, $name) + public function prependBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) *清空响应正文 * @example - * @param mixed $name * @return */ - public function clearBody($name) + public function clearBody() { + } /** * - *(Yaf >= 3.0.2) - *获取类型为$name的响应正文内容 + *获取响应报头 + * @example + * @return array + */ + public function getHeader(): array + { + + } + + /** + * + *批量设置响应报头 * @example - * @param string $name (Yaf >= 3.0.2) -获取类型为$name的响应正文内容 + * @param array $headers 响应头列表 * @return */ - public function getBody($name) + public function setAllHeaders(Array $headers) { + } /** * *(Yaf >= 3.0.2) + *设置响应报头 + * @example + * @return + */ + public function setHeader() + { + + } + + /** + * + *清空响应报头 + * @example + * @return + */ + public function clearHeaders() + { + + } + + /** + * + *将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) + * @example + * @param string $url 重定向的绝对URL + * @return + */ + public function setRedirect(string $url) + { + + } + + /** + * *输出所有的响应正文 * @example * @return */ public function response() { + } } diff --git a/src/Yaf/Route/Map.php b/src/Yaf/Route/Map.php index c52f0c8..95424fd 100644 --- a/src/Yaf/Route/Map.php +++ b/src/Yaf/Route/Map.php @@ -1,66 +1,66 @@ = 3.0.2) -*Class YafX_Route_Map +*map路由 */ namespace Yaf\Route; -final class Map +final class Map implements \Yaf\Route_Interface { /** * @var unknown $_ctl_router - * (Yaf >= 3.0.2) * 表示路由结果是作为动作的路由结果,还是控制器的路由结果,默认的是动作路由结果. * @access protected + */ protected $_ctl_router = ''; /** * @var unknown $_delimiter * * @access protected + */ protected $_delimiter; /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param mixed $controller_prefer - * @param mixed $delimiter + * @param bool $controller_prefer 表示路由结果是作为动作的路由结果,还是控制器的路由结果,默认的是动作路由结果 + * @param string $delimiter 表示一个分隔符,如果设置了这个分隔符,那么在REQUEST_URI中,分隔符之前的作为路由信息载体,而之后的作为请求参数. * @return */ - public function __construct($controller_prefer, $delimiter) + public function __construct(bool $controller_prefer = false, string $delimiter = '') { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Route/Regex.php b/src/Yaf/Route/Regex.php index de401ec..5dd2f6b 100644 --- a/src/Yaf/Route/Regex.php +++ b/src/Yaf/Route/Regex.php @@ -1,93 +1,90 @@ = 3.0.2) -*Class YafX_Route_Regex +*yaf正则路由 */ namespace Yaf\Route; -final class Regex +final class Regex implements \Yaf\Route_Interface { /** - * @var unknown $_route - * (Yaf >= 3.0.2) + * @var array $_route * 匹配模式(正则表达式) * @access protected - protected $_route; + */ + protected $_route = array(); /** - * @var unknown $_default - * (Yaf >= 3.0.2) + * @var array $_default * 路由信息 * @access protected - protected $_default; + */ + protected $_default = array(); /** - * @var unknown $_maps - * (Yaf >= 3.0.2) + * @var array $_maps * 模式分组的映射关系 * @access protected - protected $_maps; + */ + protected $_maps = array(); /** - * @var unknown $_verify - * (Yaf >= 3.0.2) - * 哥也不清楚(实在没有查到作用,源码也没看出所以然,问鸟哥!) + * @var array $_verify + * * @access protected - protected $_verify; + */ + protected $_verify = array(); /** - * @var unknown $_reverse + * @var string $_reverse * * @access protected + */ protected $_reverse; /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param string $match (Yaf >= 3.0.2) -构造方法 - * @param array $route (Yaf >= 3.0.2) -构造方法 - * @param array $map (Yaf >= 3.0.2) -构造方法 - * @param mixed $verify - * @param mixed $reverse + * @param string $match 匹配模式(正则表达式) + * @param array $route 路由信息 + * @param array $map 模式分组的映射关系 + * @param array $verify + * @param string $reverse * @return */ - public function __construct($match, Array $route, Array $map, $verify, $reverse) + public function __construct(string $match, Array $route, Array $map, Array $verify, string $reverse ) { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Route/Rewrite.php b/src/Yaf/Route/Rewrite.php index 10993bc..704a235 100644 --- a/src/Yaf/Route/Rewrite.php +++ b/src/Yaf/Route/Rewrite.php @@ -1,77 +1,74 @@ = 3.0.2) -*Class YafX_Route_Rewrite +*重写路由 */ namespace Yaf\Route; -final class Rewrite +final class Rewrite implements \Yaf\Route_Interface { /** - * @var unknown $_route - * (Yaf >= 3.0.2) - * 匹配模式(正则表达式) + * @var array $_route + * 路由信息 * @access protected - protected $_route; + */ + protected $_route = array(); /** - * @var unknown $_default - * (Yaf >= 3.0.2) - * 路由信息 + * @var array $_default + * 默认路由信息 * @access protected - protected $_default; + */ + protected $_default = array(); /** - * @var unknown $_verify - * (Yaf >= 3.0.2) - * 哥也不清楚(实在没有查到作用,源码也没看出所以然,问鸟哥!) + * @var array $_verify + * * @access protected - protected $_verify; + */ + protected $_verify = array(); /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param string $match (Yaf >= 3.0.2) -构造方法 - * @param array $route (Yaf >= 3.0.2) -构造方法 - * @param mixed $verify + * @param string $match 匹配模式(正则表达式) + * @param array $route 路由信息 + * @param array $verify * @return */ - public function __construct($match, Array $route, $verify) + public function __construct(string $match, Array $route, Array $verify) { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Route/Simple.php b/src/Yaf/Route/Simple.php index a563987..f22a50a 100644 --- a/src/Yaf/Route/Simple.php +++ b/src/Yaf/Route/Simple.php @@ -1,75 +1,74 @@ = 3.0.2) -*Class YafX_Route_Simple +*简单路由 */ namespace Yaf\Route; -final class Simple +final class Simple implements \Yaf\Route_Interface { /** - * @var unknown $controller - * (Yaf >= 3.0.2) + * @var string $controller * 控制器名 * @access protected + */ protected $controller; /** - * @var unknown $module - * (Yaf >= 3.0.2) + * @var string $module * 模块名 * @access protected + */ protected $module; /** - * @var unknown $action - * (Yaf >= 3.0.2) + * @var string $action * 动作名 * @access protected + */ protected $action; /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param mixed $module_name - * @param mixed $controller_name - * @param mixed $action_name + * @param string $module 模块名 + * @param string $controller 控制器名 + * @param string $action 动作名 * @return */ - public function __construct($module_name, $controller_name, $action_name) + public function __construct(string $module, string $controller, string $action) { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Route/Supervar.php b/src/Yaf/Route/Supervar.php index 4d1a292..0981387 100644 --- a/src/Yaf/Route/Supervar.php +++ b/src/Yaf/Route/Supervar.php @@ -1,59 +1,58 @@ = 3.0.2) -*Class YafX_Route_Supervar +*变量路由 */ namespace Yaf\Route; -final class Supervar +final class Supervar implements \Yaf\Route_Interface { /** - * @var unknown $_var_name - * (Yaf >= 3.0.2) + * @var string $_var_name * 全局路由变量名 * @access protected + */ protected $_var_name; /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param mixed $supervar_name + * @param string $var 全局路由变量名 * @return */ - public function __construct($supervar_name) + public function __construct(string $var) { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Route_Interface.php b/src/Yaf/Route_Interface.php index 4e8d924..a793bfe 100644 --- a/src/Yaf/Route_Interface.php +++ b/src/Yaf/Route_Interface.php @@ -1,34 +1,34 @@ = 3.0.2) -*Class YafX_Route_Static +*静态路由 */ namespace Yaf; -class Route_Static +class Route_Static implements \Yaf\Route_Interface { /** * - *(Yaf >= 3.0.2) *匹配请求 * @example - * @param mixed $uri + * @param string $uri 匹配的uri * @return */ - public function match($uri) + public function match(string $uri) { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Router.php b/src/Yaf/Router.php index c2922ca..b8ecad4 100644 --- a/src/Yaf/Router.php +++ b/src/Yaf/Router.php @@ -1,106 +1,110 @@ = 3.0.2) -*Class YafX_Router +*yaf路由器 */ namespace Yaf; final class Router { /** - * @var unknown $_routes - * (Yaf >= 3.0.2) + * @var array $_routes * 路由器已有的路由协议栈, 默认的栈底总是名为"default"的Route_Static路由协议的实例 * @access protected - protected $_routes; + */ + protected $_routes = array(); /** - * @var unknown $_current - * (Yaf >= 3.0.2) + * @var int $_current * 在路由成功后, 路由生效的路由协议实例的索引 * @access protected + */ protected $_current; /** * - *(Yaf >= 3.0.2) *构造方法 * @example * @return */ public function __construct() { + } /** * - *(Yaf >= 3.0.2) *往Router中添加新的路由 * @example - * @return + * @param string $name 别名 + * @param Yaf_Route_Interface $route 路由对象 + * @return bool */ - public function addRoute() + public function addRoute(string $name, Yaf_Route_Interface $route): bool { + } /** * - *(Yaf >= 3.0.2) *向Router中添加配置文件或者配置数组定义的路由 * @example - * @return + * @param Yaf_Config_Abstract $config 配置对象 + * @return bool */ - public function addConfig() + public function addConfig(Yaf_Config_Abstract $config): bool { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route() + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 3.0.2) *获取路由名对应的路由协议实例 * @example - * @return + * @param string $name 路由名 + * @return string */ - public function getRoute() + public function getRoute(string $name): string { + } /** * - *(Yaf >= 3.0.2) *获取已注册的所有路由协议 * @example - * @return + * @return array */ - public function getRoutes() + public function getRoutes(): array { + } /** * - *(Yaf >= 3.0.2) *获取当前路由成功的路由协议实例 * @example - * @return + * @return string */ - public function getCurrentRoute() + public function getCurrentRoute(): string { + } } diff --git a/src/Yaf/Session.php b/src/Yaf/Session.php index 1c2f960..6b7e475 100644 --- a/src/Yaf/Session.php +++ b/src/Yaf/Session.php @@ -1,333 +1,302 @@ = 3.0.2) -*Class YafX_Session +*yaf的会话对象 */ namespace Yaf; -final class Session +final class Session implements \Iterator,\Traversable,\ArrayAccess,\Countable { /** - * @var unknown $_instance - * + * @var Yaf_Session $_instance + * session对象 * @access protected + */ protected static $_instance; /** - * @var unknown $_session - * + * @var array $_session + * session存储对象 * @access protected - protected $_session; + */ + protected $_session = array(); /** - * @var unknown $_started - * + * @var bool $_started + * 是否开启session * @access protected - protected $_started = ''; + */ + protected $_started = false; /** * - *(Yaf >= 3.0.2) *重置__construct魔术方法. * @example * @return */ private function __construct() { + } /** * - *(Yaf >= 3.0.2) *重置__clone魔术方法(因为是单例模式). * @example * @return */ private function __clone() { + } /** * - *(Yaf >= 3.0.2) *重置__sleep魔术方法. * @example * @return */ private function __sleep() { + } /** * - *(Yaf >= 3.0.2) *重置__wakeup魔术方法. * @example * @return */ private function __wakeup() { + } /** * - *(Yaf >= 3.0.2) *获取Session实例(单例模式) * @example - * @return + * @return Yaf_Session */ - public static function getInstance() + public static function getInstance(): Yaf_Session { + } /** * - *(Yaf >= 3.0.2) *开启会话 * @example * @return */ public function start() { + } /** * - *(Yaf >= 3.0.2) - *获取session变量 + *重置__destruct魔术方法. * @example - * @param string $name (Yaf >= 3.0.2) -获取session变量 * @return */ - public function get($name) + public function __destruct() { + } /** * - * + *魔术方法,当isset()检测session变量是否存在时调用 * @example - * @param mixed $name + * @param string $name 节点名称 * @return */ - public function has($name) + public function __isset(string $name) { + } /** * - *(Yaf >= 3.0.2) - *设置session变量 + *获取session变量 * @example - * @param string $name (Yaf >= 3.0.2) -设置session变量 - * @param mixed $value (Yaf >= 3.0.2) -设置session变量 + * @param string $name 变量名 * @return */ - public function set($name, $value) + public function get(string $name) { + } /** * - *(Yaf >= 3.0.2) - *撤消session变量 + *设置session变量 * @example - * @param string $name (Yaf >= 3.0.2) -撤消session变量 + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function del($name) + public function set(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) - *返回session变量的数量 + *撤消session变量 * @example + * @param string $name 变量名 * @return */ - public function count() + public function del(string $name) { + } /** * - *(Yaf >= 3.0.2) - *重置遍历位置 + *返回session变量的数量 * @example * @return */ - public function rewind() + public function count() { + } /** * - *(Yaf >= 3.0.2) - *向前移动到下一个元素 + *重置遍历位置 * @example * @return */ - public function next() + public function rewind() { + } /** * - *(Yaf >= 3.0.2) *返回当前变量 * @example * @return */ public function current() { + } /** * - *(Yaf >= 3.0.2) - *返回当前配置节点的key + *向前移动到下一个元素 * @example * @return */ - public function key() + public function next() { + } /** * - *(Yaf >= 3.0.2) *判断是否可以继续遍历 * @example * @return */ public function valid() { + } /** * - * - * @example - * @return - */ - public function clear() - { - } - - /** - * - *(Yaf >= 3.0.2) - *获取session变量 + *返回当前配置节点的key * @example - * @param string $name (Yaf >= 3.0.2) -获取session变量 * @return */ - public function offsetGet($name) + public function key() { + } /** * - *(Yaf >= 3.0.2) - *设置session变量 + *撤消某个session变量 * @example - * @param string $name (Yaf >= 3.0.2) -设置session变量 - * @param mixed $value (Yaf >= 3.0.2) -设置session变量 + * @param string $name 变量名 * @return */ - public function offsetSet($name, $value) + public function offsetUnset(string $name) { + } /** * - *(Yaf >= 3.0.2) *测试某个session变量是否存在 * @example - * @param mixed $name (Yaf >= 3.0.2) -测试某个session变量是否存在 + * @param mixed $name 变量名 * @return */ public function offsetExists($name) { + } /** * - *(Yaf >= 3.0.2) - *撤消某个session变量 + *获取session变量 * @example - * @param string $name (Yaf >= 3.0.2) -撤消某个session变量 + * @param string $name 变量名 * @return */ - public function offsetUnset($name) + public function offsetGet(string $name) { + } /** * - *(Yaf >= 3.0.2) - *获取session变量值 - *当不传递$name参数时,返回全部变量 + *设置session变量 * @example - * @param mixed $name + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function __get($name) + public function offsetSet(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) - *魔术方法,当isset()检测session变量是否存在时调用 + *获取session变量值 + *当不传递$name参数时,返回全部变量 * @example - * @param string $name (Yaf >= 3.0.2) -魔术方法,当isset()检测session变量是否存在时调用 + * @param string $name session键名 * @return */ - public function __isset($name) + public function __get(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置session变量 * @example - * @param string $name (Yaf >= 3.0.2) -设置session变量 - * @param mixed $value (Yaf >= 3.0.2) -设置session变量 - * @return - */ - public function __set($name, $value) - { - } - - /** - * - * - * @example - * @param mixed $name + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function __unset($name) + public function __set(string $name, $value) { + } } diff --git a/src/Yaf/View/Simple.php b/src/Yaf/View/Simple.php index ab49b88..57130d4 100644 --- a/src/Yaf/View/Simple.php +++ b/src/Yaf/View/Simple.php @@ -1,209 +1,184 @@ = 3.0.2) -*Class YafX_View_Simple +*简单视图对象 */ namespace Yaf\View; -class Simple +class Simple implements \Yaf\View_Interface { /** - * @var unknown $_tpl_vars - * (Yaf >= 3.0.2) + * @var array $_tpl_vars * 储存所有模板变量 * @access protected - protected $_tpl_vars; + */ + protected $_tpl_vars = array(); /** - * @var unknown $_tpl_dir - * (Yaf >= 3.0.2) + * @var string $_tpl_dir * 模板文件目录 * @access protected + */ protected $_tpl_dir; /** - * @var unknown $_options - * (Yaf >= 3.0.2) + * @var array $_options + * 配置选项 * @access protected - protected $_options; + */ + protected $_options = array(); /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param mixed $template_dir - * @param array $options (Yaf >= 3.0.2) -构造方法 + * @param string $tpl_dir 模板文件目录 + * @param array $options 此属性在php-5.4以下版本中适用,用以设置模板渲染的方式 * @return */ - public final function __construct($template_dir, Array $options) + public function __construct(string $tpl_dir, Array $options) { + } /** * - *(Yaf >= 3.0.2) *当isset检测某个属性是否存在时自动调用(判断是否传递某个模板变量) * @example - * @param string $name (Yaf >= 3.0.2) -当isset检测某个属性是否存在时自动调用(判断是否传递某个模板变量) + * @param string $name 模板变量名 * @return */ - public function __isset($name) + public function __isset(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取某个模板变量的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取某个模板变量的值 + * @param string $name 模板变量名 * @return */ - public function get($name) + public function __get(string $name) { + } /** * - *(Yaf >= 3.0.2) - *传递变量到模板 + *获取某个模板变量的值 * @example - * @param string $name (Yaf >= 3.0.2) -传递变量到模板 - * @param string $value (Yaf >= 3.0.2) -传递变量到模板 + * @param string $name 模板变量名 * @return */ - public function assign($name, $value) + public function get(string $name) { + } /** * - *(Yaf >= 3.0.2) - *渲染模板并返回结果 + *传递变量到模板 * @example - * @param string $tpl (Yaf >= 3.0.2) -渲染模板并返回结果 - * @param mixed $tpl_vars + * @param string $name 变量名 + * @param string $value 变量值 * @return */ - public function render($tpl, $tpl_vars) + public function __set(string $name, string $value) { + } /** * - * + *清空某个模板变量的值 * @example - * @param mixed $tpl_str - * @param mixed $vars + * @param string $name 模板变量名 * @return */ - public function eval($tpl_str, $vars) + public function clear(string $name) { + } /** * - *(Yaf >= 3.0.2) - *渲染模板并直接输出 + *传递变量到模板 * @example - * @param string $tpl (Yaf >= 3.0.2) -渲染模板并直接输出 - * @param mixed $tpl_vars + * @param string $name 变量名 + * @param string $value 变量值 * @return */ - public function display($tpl, $tpl_vars) + public function assign(string $name, string $value) { + } /** * - *(Yaf >= 3.0.2) *以引用的方式传递变量到模板 * @example - * @param string $name (Yaf >= 3.0.2) -以引用的方式传递变量到模板 - * @param string $value (Yaf >= 3.0.2) -以引用的方式传递变量到模板 - * @return - */ - public function assignRef($name, $value) - { - } - - /** - * - *(Yaf >= 3.0.2) - *清空某个模板变量的值 - * @example - * @param string $name (Yaf >= 3.0.2) -清空某个模板变量的值 + * @param string $name 变量名 + * @param string $value 变量值 * @return */ - public function clear($name) + public function assignRef(string $name, string $value) { + } /** * - *(Yaf >= 3.0.2) - *设置模板文件目录 + *渲染模板并直接输出 * @example - * @param mixed $template_dir + * @param string $tpl 模板文件名 + * @param array $var_array 模板变量数组 * @return */ - public function setScriptPath($template_dir) + public function display(string $tpl, Array $var_array = []) { + } /** * - *(Yaf >= 3.0.2) - *获取模板目录文件 + *渲染模板并返回结果 * @example + * @param string $tpl 模板文件名 + * @param array $var_array 模板变量数组 * @return */ - public function getScriptPath() + public function render(string $tpl, Array $var_array = []) { + } /** * - *(Yaf >= 3.0.2) - *获取某个模板变量的值 + *设置模板文件目录 * @example - * @param string $name (Yaf >= 3.0.2) -获取某个模板变量的值 + * @param string $tpl_dir 模板文件目录 * @return */ - public function __get($name) + public function setScriptPath(string $tpl_dir) { + } /** * - *(Yaf >= 3.0.2) - *传递变量到模板 + *获取模板目录文件 * @example - * @param string $name (Yaf >= 3.0.2) -传递变量到模板 - * @param string $value (Yaf >= 3.0.2) -传递变量到模板 - * @return + * @return string */ - public function __set($name, $value) + public function getScriptPath(): string { + } } diff --git a/src/Yaf/View_Interface.php b/src/Yaf/View_Interface.php index 57fdf1b..10af3bd 100644 --- a/src/Yaf/View_Interface.php +++ b/src/Yaf/View_Interface.php @@ -1,62 +1,62 @@ = 3.0.2) -*Class yaf_Action_Abstract +*yaf中的操作定义(单独文件定义操作,通常是在控制器文件中定义操作,这里可以通过单独文件来定义操作) */ abstract class Yaf_Action_Abstract extends Yaf_Controller_Abstract { /** - * @var unknown $actions - * + * @var array $actions + * 操作列表 * @access public - public $actions; + */ + public $actions = array(); /** - * @var unknown $_module - * + * @var string $_module + * 当前模块对象 * @access protected + */ protected $_module; /** - * @var unknown $_name - * + * @var string $_name + * 当前操作名 * @access protected + */ protected $_name; /** - * @var unknown $_request - * + * @var Yaf_Request_Abstract $_request + * 当前请求对象 * @access protected + */ protected $_request; /** - * @var unknown $_response - * + * @var Yaf_Response_Abstract $_response + * 当前响应对象 * @access protected + */ protected $_response; /** - * @var unknown $_invoke_args - * + * @var array $_invoke_args + * 调用参数列表 * @access protected - protected $_invoke_args; + */ + protected $_invoke_args = array(); /** - * @var unknown $_view - * + * @var Yaf_View_Interface $_view + * 当前视图对象 * @access protected + */ protected $_view; /** - * @var unknown $_controller - * (Yaf >= 3.0.2) + * @var Yaf_Controller_Abstract $_controller * 当前请求的控制器实例 * @access protected - protected $_controller; - - /** - * - *(Yaf >= 3.0.2) - *动作入口方法,由Yaf框架自动调用 - * @example - * @return */ - public abstract function execute(); + protected $_controller; /** * - *(Yaf >= 3.0.2) *获取当前请求的控制器实例 * @example - * @return - */ - public function getController() - { - } - - /** - * - * - * @example - * @param mixed $tpl - * @param array $parameters - * @return - */ - protected function render($tpl, Array $parameters) - { - } - - /** - * - * - * @example - * @param mixed $tpl - * @param array $parameters - * @return - */ - protected function display($tpl, Array $parameters) - { - } - - /** - * - * - * @example - * @return - */ - public function getRequest() - { - } - - /** - * - * - * @example - * @return - */ - public function getResponse() - { - } - - /** - * - * - * @example - * @return - */ - public function getModuleName() - { - } - - /** - * - * - * @example - * @return - */ - public function getView() - { - } - - /** - * - * - * @example - * @param array $options - * @return - */ - public function initView(Array $options) - { - } - - /** - * - * - * @example - * @param mixed $view_directory - * @return + * @return Yaf_Action_Abstract */ - public function setViewpath($view_directory) + public function getController(): Yaf_Action_Abstract { + } /** * - * - * @example - * @return - */ - public function getViewpath() - { - } - - /** - * - * - * @example - * @param mixed $module - * @param mixed $controller - * @param mixed $action - * @param array $parameters - * @return - */ - public function forward($module, $controller, $action, Array $parameters) - { - } - - /** - * - * - * @example - * @param mixed $url - * @return - */ - public function redirect($url) - { - } - - /** - * - * - * @example - * @return - */ - public function getInvokeArgs() - { - } - - /** - * - * - * @example - * @param mixed $name - * @return - */ - public function getInvokeArg($name) - { - } - - /** - * - * - * @example - * @return - */ - public final function __construct() - { - } - - /** - * - * + *动作入口方法,由Yaf框架自动调用 * @example - * @return + * @param mixed $arg 参数 + * @param mixed $arg2 参数2 + * @return Yaf_Action_Abstract */ - private final function __clone() - { - } + public abstract function execute($arg, $arg2): Yaf_Action_Abstract; } diff --git a/src/Yaf/Yaf_Application.php b/src/Yaf/Yaf_Application.php index 7a548ef..1ff3793 100644 --- a/src/Yaf/Yaf_Application.php +++ b/src/Yaf/Yaf_Application.php @@ -1,278 +1,274 @@ = 3.0.2) -*Class yaf_Application +*为应用提供引导和依赖性检查的引导类 */ final class Yaf_Application { /** - * @var unknown $config - * (Yaf >= 3.0.2) + * @var Yaf_Config_Abstract $config * 全局配置实例 * @access protected + */ protected $config; /** - * @var unknown $dispatcher - * (Yaf >= 3.0.2) + * @var Yaf_Dispatcher $dispatcher * yaf_Dispatcher实例,即分发器. * @access protected + */ protected $dispatcher; /** - * @var unknown $_app - * (Yaf >= 3.0.2) + * @var Yaf_Application $_app * 过特殊的方式实现了单例模式, 此属性保存当前实例. * @access protected + */ protected static $_app; /** - * @var unknown $_modules - * (Yaf >= 3.0.2) + * @var array $_modules * 存在的模块名, 从配置文件中ap.modules读取. * @access protected - protected $_modules; + */ + protected $_modules = array(); /** - * @var unknown $_running - * (Yaf >= 3.0.2) + * @var bool $_running * 指明当前的yaf_Application是否已经运行. * @access protected - protected $_running = ''; + */ + protected $_running = false; /** - * @var unknown $_environ - * (Yaf >= 3.0.2) - * 前的环境名, 也就是yaf_Application在读取配置的时候, 获取的配置节名字. + * @var string $_environ + * 当前的环境名, 也就是yaf_Application在读取配置的时候, 获取的配置节名字. * 注:此值只能在Yaf扩展级的配置文件.ini里面进行修改,默认为product. * @access protected - protected $_environ = 'dev'; + */ + protected $_environ = 'product'; /** - * @var unknown $_err_no - * (Yaf >= 3.0.2) + * @var int $_err_no * 最近一次发生的错误代码. * @access protected + */ protected $_err_no = 0; /** - * @var unknown $_err_msg - * (Yaf >= 3.0.2) + * @var string $_err_msg * 最近一次产生的错误信息. * @access protected + */ protected $_err_msg = ''; /** * - *(Yaf >= 3.0.2) - *构造函数,根据配置初始化yaf_Application + *获取当前的yaf_Application实例. * @example - * @param mixed $config (Yaf >= 3.0.2) -构造函数,根据配置初始化yaf_Application - * @param mixed $environ - * @return + * @return Yaf_Application|null */ - public function __construct($config, $environ) + public static function app(): ?Yaf_Application { + } /** * - *(Yaf >= 3.0.2) - *运行yaf_Application + *调用bootstrap * @example - * @return + * @param Yaf_Bootstrap_Abstract $bootstrap 引导类 + * @return void */ - public function run() + public function bootstrap(Yaf_Bootstrap_Abstract $bootstrap) { + } /** * - *(Yaf >= 3.0.2) - *运行回调函数,一般在命令行模式下运行. + *运行yaf_Application * @example - * @param callable $entry (Yaf >= 3.0.2) -运行回调函数,一般在命令行模式下运行. - * @param mixed $... - * @return + * @return void */ - public function execute(Callable $entry, $...) + public function run() { + } /** * - *(Yaf >= 3.0.2) - *获取当前的yaf_Application实例. + *清除最近的错误信息,将设置$this->_err_no=0,$this->_err_msg=''. * @example - * @return + * @return Yaf_Application */ - public static function app() + public function clearLastError(): Yaf_Application { + } /** * - *(Yaf >= 3.0.2) - *获取当前yaf_Application的环境名,它被定义在yaf.environ,默认值为"product". + *构造函数,根据配置初始化yaf_Application * @example + * @param mixed $config 关联数组的配置, 或者一个指向ini格式的配置文件的路径的字符串. + * @param string $section 加载的配置节点,使用该节点的配置初始化应用. * @return */ - public function environ() + public function __construct($config, string $section = 'product') { + } /** * - *(Yaf >= 3.0.2) - *调用bootstrap + *运行回调函数,一般在命令行模式下运行. * @example - * @param mixed $bootstrap - * @return + * @param callable $entry 回调函数 + * @param mixed $parameter 零个或者多个回调函数参数 + * @return void */ - public function bootstrap($bootstrap) + public function execute(Callable $entry, $parameter) { + } /** * - *(Yaf >= 3.0.2) - *获取全局配置实例,即$this->config + *获取当前yaf_Application的环境名,它被定义在yaf.environ,默认值为"product". * @example - * @return + * @return string */ - public function getConfig() + public function environ(): string { + } /** * - *(Yaf >= 3.0.2) - *获取在配置文件中声明的模块,如果没有声明,它的默认值将是"Index". + *获取当前应用的主目录 * @example - * @return + * @return string */ - public function getModules() + public function getAppDirectory(): string { + } /** * - *(Yaf >= 3.0.2) - *获取当前请求的分发器yaf_Dispatcher的实例 + *获取全局配置实例,即$this->config * @example - * @return + * @return Yaf_Config_Abstract */ - public function getDispatcher() + public function getConfig(): Yaf_Config_Abstract { + } /** * - *(Yaf >= 3.0.2) - *设置应用的主目录 + *获取当前请求的分发器yaf_Dispatcher的实例 * @example - * @param String $directory (Yaf >= 3.0.2) -设置应用的主目录 - * @return + * @return Yaf_Dispatcher */ - public function setAppDirectory($directory) + public function getDispatcher(): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *获取当前应用的主目录 + *获取最近产生的错误信息. * @example - * @return + * @return string */ - public function getAppDirectory() + public function getLastErrorMsg(): string { + } /** * - *(Yaf >= 3.0.2) *获取最近产生的错误代码. * @example - * @return + * @return int */ - public function getLastErrorNo() + public function getLastErrorNo(): int { + } /** * - *(Yaf >= 3.0.2) - *获取最近产生的错误信息. + *获取在配置文件中声明的模块,如果没有声明,它的默认值将是"Index". * @example - * @return + * @return array */ - public function getLastErrorMsg() + public function getModules(): array { + } /** * - *(Yaf >= 3.0.2) - *清除最近的错误信息,将设置$this->_err_no=0,$this->_err_msg=''. + *设置应用的主目录 * @example - * @return + * @param String $directory 目录路径. + * @return Yaf_Application */ - public function clearLastError() + public function setAppDirectory(String $directory): Yaf_Application { + } /** * - *(Yaf >= 3.0.2) - *重置__destruct魔术方法. + *重置__clone魔术方法,防止克隆yaf_Application(因为是单例模式). * @example * @return */ - public function __destruct() + private function __clone() { + } /** * - *(Yaf >= 3.0.2) - *重置__clone魔术方法,防止克隆yaf_Application(因为是单例模式). + *重置__destruct魔术方法. * @example * @return */ - private function __clone() + public function __destruct() { + } /** * - *(Yaf >= 3.0.2) *重置__sleep魔术方法. * @example * @return */ private function __sleep() { + } /** * - *(Yaf >= 3.0.2) *重置__wakeup魔术方法. * @example * @return */ private function __wakeup() { + } } diff --git a/src/Yaf/Yaf_Bootstrap_Abstract.php b/src/Yaf/Yaf_Bootstrap_Abstract.php index 060772f..4062e0f 100644 --- a/src/Yaf/Yaf_Bootstrap_Abstract.php +++ b/src/Yaf/Yaf_Bootstrap_Abstract.php @@ -1,13 +1,12 @@ = 3.0.2) -*Class yaf_Bootstrap_Abstract +*应用引导类(一般需要一个类来继承它,可定义_init开头的方法) */ abstract class Yaf_Bootstrap_Abstract { diff --git a/src/Yaf/Yaf_Config_Abstract.php b/src/Yaf/Yaf_Config_Abstract.php index e2c5548..96b831d 100644 --- a/src/Yaf/Yaf_Config_Abstract.php +++ b/src/Yaf/Yaf_Config_Abstract.php @@ -1,66 +1,161 @@ = 3.0.2) -*Class yaf_Config_Abstract +*yaf配置抽象类 */ abstract class Yaf_Config_Abstract { /** - * @var unknown $_config - * (Yaf >= 3.0.2) + * @var array $_config * 存储已解析的配置 * @access protected - protected $_config; + */ + protected $_config = array(); /** - * @var unknown $_readonly - * (Yaf >= 3.0.2) + * @var int $_readonly * 配置是否只读,默认为1. * @access protected - protected $_readonly = '1'; + */ + protected $_readonly = 1; /** * - *(Yaf >= 3.0.2) *获取配置节点的值 *当不传递$name参数时,返回配置对象本身 * @example - * @return + * @param string $name 配置键 + * @param mixed $value 默认值 + * @return mixed */ - public abstract function get(); + public abstract function get(string $name, $value); /** * - *(Yaf >= 3.0.2) - *设置配置节点的值 + *设置配置节点的值(只读) * @example - * @return + * @return Yaf_Config_Abstract */ - public abstract function set(); + public abstract function set(): Yaf_Config_Abstract; /** * - *(Yaf >= 3.0.2) - *返回配置只读的状态 + *配置是否只读 * @example - * @return + * @return bool */ - public abstract function readonly(); + public abstract function readonly(): bool; /** * - *(Yaf >= 3.0.2) *将配置转换为数组 * @example + * @return array + */ + public abstract function toArray(): array; + + /** + * + *获取配置节点的值 + *当不传递$name参数时,返回配置对象本身 + * @example + * @param string $name 配置键 + * @return mixed + */ + public function __get(string $name) + { + + } + + /** + * + *返回当前值 + * @example + * @return void + */ + public abstract function current(); + + /** + * + *返回下一个值 + * @example + * @return void + */ + public abstract function next(); + + /** + * + *返回当前键 + * @example * @return */ - public abstract function toArray(); + public abstract function key(); + + /** + * + *验证当前对象是否合法 + * @example + * @return void + */ + public abstract function valid(); + + /** + * + *将迭代器重置到第一个位置 + * @example + * @return void + */ + public abstract function rewind(); + + /** + * + *返回当前迭代器的个数 + * @example + * @return + */ + public abstract function count(); + + /** + * + *当前索引对应的对象是否存在 + * @example + * @param string $offset 索引 + * @return void + */ + public abstract function offsetExists(string $offset); + + /** + * + *通过索引获取当前对象 + * @example + * @param string $offset 索引 + * @return void + */ + public abstract function offsetGet(string $offset); + + /** + * + *通过索引设置值 + * @example + * @param string $offset 索引 + * @param mixed $value 配置值 + * @return void + */ + public abstract function offsetSet(string $offset, $value); + + /** + * + *通过索引删除值 + * @example + * @param string $offset 索引 + * @return void + */ + public abstract function offsetUnset(string $offset); } diff --git a/src/Yaf/Yaf_Config_Ini.php b/src/Yaf/Yaf_Config_Ini.php index 52244b7..7be6ab3 100644 --- a/src/Yaf/Yaf_Config_Ini.php +++ b/src/Yaf/Yaf_Config_Ini.php @@ -1,248 +1,242 @@ = 3.0.2) -*Class yaf_Config_Ini +*yaf中ini配置文件类 */ -final class Yaf_Config_Ini extends Yaf_Config_Abstract +final class Yaf_Config_Ini extends Yaf_Config_Abstract implements Iterator, ArrayAccess, Countable { /** - * @var unknown $_config - * (Yaf >= 3.0.2) + * @var array $_config * 存储已解析的配置 * @access protected - protected $_config; + */ + protected $_config = array(); /** - * @var unknown $_readonly - * (Yaf >= 3.0.2) + * @var int $_readonly * 配置是否只读,默认为1. * @access protected - protected $_readonly = '1'; + */ + protected $_readonly = 1; /** * - *(Yaf >= 3.0.2) *构造方法,初始化yaf_Config_Ini对象 * @example - * @param mixed $config_file - * @param string $section (Yaf >= 3.0.2) -构造方法,初始化yaf_Config_Ini对象 + * @param string $filename ini文件全路径 + * @param string $section 初始化时的配置节点名称 * @return */ - public function __construct($config_file, $section) + public function __construct(string $filename, string $section) { + } /** * - *(Yaf >= 3.0.2) *魔术方法,当isset()检测某个配置节点是否存在时调用 * @example - * @param string $name (Yaf >= 3.0.2) -魔术方法,当isset()检测某个配置节点是否存在时调用 - * @return - */ - public function __isset($name) - { - } - - /** - * - *(Yaf >= 3.0.2) - *获取配置节点的值 - *当不传递$name参数时,返回配置对象本身 - * @example - * @param mixed $name + * @param string $name 节点名称 * @return */ - public function get($name) + public function __isset(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置配置节点值(无效) * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值(无效) - * @param mixed $value - * @return + * @param string $name 变量名 + * @param mixed $value 配置值 + * @return Yaf_Config_Abstract */ - public function set($name, $value) + public function set(string $name, $value): Yaf_Config_Abstract { + } /** * - *(Yaf >= 3.0.2) *返回配置节点的数量 * @example - * @return + * @return int */ - public function count() + public function count(): int { + } /** * - *(Yaf >= 3.0.2) - *重置遍历位置(php.net文档有误) + *重置遍历位置 * @example * @return */ public function rewind() { + } /** * - *(Yaf >= 3.0.2) *返回当前节点 * @example - * @return + * @return mixed */ public function current() { + } /** * - *(Yaf >= 3.0.2) *向前移动到下一个元素 * @example - * @return + * @return mixed */ public function next() { + } /** * - *(Yaf >= 3.0.2) *判断是否可以继续遍历 * @example * @return */ public function valid() { + } /** * - *(Yaf >= 3.0.2) *返回当前配置节点的key * @example - * @return + * @return mixed */ public function key() { + + } + + /** + * + *撤消某个配置节点(无效) + * @example + * @param string $name 变量名 + * @return mixed + */ + public function offsetUnset(string $name) + { + } /** * - *(Yaf >= 3.0.2) + *测某个配置节点是否存在 * @example + * @param mixed $name 节点名称 * @return */ - public function toArray() + public function offsetExists($name) { + } /** * - *(Yaf >= 3.0.2) + *设置配置节点值(无效) * @example + * @param string $name 配置项名称 + * @param mixed $value 配置值 * @return */ - public function readonly() + public function offsetSet(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) - *撤消某个配置节点(无效) + *获取配置节点的值 + *当不传递$name参数时,返回配置对象本身 * @example - * @param string $name (Yaf >= 3.0.2) -撤消某个配置节点(无效) + * @param string $name 索引值 * @return */ - public function offsetUnset($name) + public function offsetGet(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取配置节点的值 *当不传递$name参数时,返回配置对象本身 * @example - * @param mixed $name + * @param string $name 配置项名称 * @return */ - public function offsetGet($name) + public function get(string $name) { + } /** * - *(Yaf >= 3.0.2) - *测某个配置节点是否存在 + *获取配置节点的值 + *当不传递$name参数时,返回配置对象本身 * @example - * @param mixed $name (Yaf >= 3.0.2) -测某个配置节点是否存在 + * @param string $name 配置项名称 * @return */ - public function offsetExists($name) + public function __get(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置配置节点值(无效) * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值(无效) - * @param mixed $value + * @param string $name 配置项名 + * @param mixed $value 配置值 * @return */ - public function offsetSet($name, $value) + public function __set(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) - *获取配置节点的值 - *当不传递$name参数时,返回配置对象本身 + *将配置对象转化为数组 * @example - * @param mixed $name - * @return + * @return array */ - public function __get($name) + public function toArray(): array { + } /** * - *(Yaf >= 3.0.2) - *设置配置节点值(无效) + *配置是否只读 * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值(无效) - * @param mixed $value - * @return + * @return bool */ - public function __set($name, $value) + public function readonly(): bool { + } } diff --git a/src/Yaf/Yaf_Config_Simple.php b/src/Yaf/Yaf_Config_Simple.php index e377b84..756f379 100644 --- a/src/Yaf/Yaf_Config_Simple.php +++ b/src/Yaf/Yaf_Config_Simple.php @@ -1,250 +1,242 @@ = 3.0.2) -*Class yaf_Config_Simple +*基础配置对象 */ -final class Yaf_Config_Simple extends Yaf_Config_Abstract +final class Yaf_Config_Simple extends Yaf_Config_Abstract implements Iterator, ArrayAccess, Countable { /** - * @var unknown $_config - * (Yaf >= 3.0.2) + * @var array $_config * 存储已解析的配置 * @access protected - protected $_config; + */ + protected $_config = array(); /** - * @var unknown $_readonly - * (Yaf >= 3.0.2) + * @var int $_readonly * 配置是否只读,默认为1. * @access protected - protected $_readonly = ''; + */ + protected $_readonly = 0; /** * - *(Yaf >= 3.0.2) *构造方法,初始化yaf_Config_Simple对象 * @example - * @param mixed $config_file - * @param mixed $section + * @param string $config 储存配置的数组 + * @param string $readonly 是否只读 * @return */ - public function __construct($config_file, $section) + public function __construct(string $config, string $readonly) { + } /** * - *(Yaf >= 3.0.2) *魔术方法,当isset()检测某个配置节点是否存在时调用 * @example - * @param string $name (Yaf >= 3.0.2) -魔术方法,当isset()检测某个配置节点是否存在时调用 + * @param string $name 节点名称 * @return */ - public function __isset($name) + public function __isset(string $name) { + } /** * - *(Yaf >= 3.0.2) - *获取配置节点的值 - *当不传递$name参数时,返回配置对象本身 + *设置配置节点值(无效) * @example - * @param mixed $name - * @return + * @param string $name 变量名 + * @param mixed $value 配置值 + * @return Yaf_Config_Abstract */ - public function get($name) + public function set(string $name, $value): Yaf_Config_Abstract { + } /** * - *(Yaf >= 3.0.2) - *设置配置节点值 + *返回配置节点的数量 * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值 - * @param mixed $value (Yaf >= 3.0.2) -设置配置节点值 - * @return + * @return int */ - public function set($name, $value) + public function count(): int { + } /** * - *(Yaf >= 3.0.2) - *返回配置节点的数量 + *重置遍历位置 * @example * @return */ - public function count() + public function rewind() { + } /** * - *(Yaf >= 3.0.2) - *撤消某个配置节点 + *返回当前节点 * @example - * @param string $name (Yaf >= 3.0.2) -撤消某个配置节点 - * @return + * @return mixed */ - public function offsetUnset($name) + public function current() { + } /** * - *(Yaf >= 3.0.2) - *重置遍历位置(php.net文档有误) + *向前移动到下一个元素 * @example - * @return + * @return mixed */ - public function rewind() + public function next() { + } /** * - *(Yaf >= 3.0.2) - *返回当前节点 + *判断是否可以继续遍历 * @example * @return */ - public function current() + public function valid() { + } /** * - *(Yaf >= 3.0.2) - *向前移动到下一个元素 + *返回当前配置节点的key * @example - * @return + * @return mixed */ - public function next() + public function key() { + } /** * - *(Yaf >= 3.0.2) - *判断是否可以继续遍历 + *撤消某个配置节点(无效) * @example - * @return + * @param string $name 变量名 + * @return mixed */ - public function valid() + public function offsetUnset(string $name) { + } /** * - *(Yaf >= 3.0.2) - *返回当前配置节点的key + *测某个配置节点是否存在 * @example + * @param mixed $name 节点名称 * @return */ - public function key() + public function offsetExists($name) { + } /** * - *(Yaf >= 3.0.2) + *设置配置节点值(无效) * @example + * @param string $name 配置项名称 + * @param mixed $value 配置值 * @return */ - public function readonly() + public function offsetSet(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) + *获取配置节点的值 + *当不传递$name参数时,返回配置对象本身 * @example + * @param string $name 索引值 * @return */ - public function toArray() + public function offsetGet(string $name) { + } /** * - *(Yaf >= 3.0.2) - *设置配置节点值 + *获取配置节点的值 + *当不传递$name参数时,返回配置对象本身 * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值 - * @param mixed $value (Yaf >= 3.0.2) -设置配置节点值 + * @param string $name 配置项名称 * @return */ - public function __set($name, $value) + public function get(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取配置节点的值 *当不传递$name参数时,返回配置对象本身 * @example - * @param mixed $name + * @param string $name 配置项名称 * @return */ - public function __get($name) + public function __get(string $name) { + } /** * - *(Yaf >= 3.0.2) - *获取配置节点的值 - *当不传递$name参数时,返回配置对象本身 + *设置配置节点值(无效) * @example - * @param mixed $name + * @param string $name 配置项名 + * @param mixed $value 配置值 * @return */ - public function offsetGet($name) + public function __set(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) - *测某个配置节点是否存在 + *将配置对象转化为数组 * @example - * @param mixed $name (Yaf >= 3.0.2) -测某个配置节点是否存在 - * @return + * @return array */ - public function offsetExists($name) + public function toArray(): array { + } /** * - *(Yaf >= 3.0.2) - *设置配置节点值 + *配置是否只读 * @example - * @param string $name (Yaf >= 3.0.2) -设置配置节点值 - * @param mixed $value (Yaf >= 3.0.2) -设置配置节点值 - * @return + * @return bool */ - public function offsetSet($name, $value) + public function readonly(): bool { + } } diff --git a/src/Yaf/Yaf_Controller_Abstract.php b/src/Yaf/Yaf_Controller_Abstract.php index a948eb5..fa80872 100644 --- a/src/Yaf/Yaf_Controller_Abstract.php +++ b/src/Yaf/Yaf_Controller_Abstract.php @@ -1,193 +1,193 @@ = 3.0.2) -*Class yaf_Controller_Abstract +*控制器抽象类 */ abstract class Yaf_Controller_Abstract { /** - * @var unknown $actions - * (Yaf >= 3.0.2) + * @var array $actions * 动作名与动作类文件路径映射数组 * @access public - public $actions; + */ + public $actions = array(); /** - * @var unknown $_module - * (Yaf >= 3.0.2) + * @var string $_module * 当前请求的模块名 * @access protected + */ protected $_module; /** - * @var unknown $_name - * (Yaf >= 3.0.2) + * @var string $_name * 当前请求的控制器名 * @access protected + */ protected $_name; /** - * @var unknown $_request - * (Yaf >= 3.0.2) - * 当前请求对象,包括请求的所有相关信息 + * @var Yaf_Request_Abstract $_request + * 当前请求对象 * @access protected + */ protected $_request; /** - * @var unknown $_response - * (Yaf >= 3.0.2) - * 当前响应对象,保存响应的所有相关信息 + * @var Yaf_Response_Abstract $_response + * 当前响应对象 * @access protected + */ protected $_response; /** - * @var unknown $_invoke_args - * (Yaf >= 3.0.2) - * 储存调用参数 + * @var array $_invoke_args + * 调用参数列表 * @access protected - protected $_invoke_args; + */ + protected $_invoke_args = array(); /** - * @var unknown $_view - * (Yaf >= 3.0.2) - * 视图对象 + * @var Yaf_View_Interface $_view + * 当前视图对象 * @access protected + */ protected $_view; /** * - *(Yaf >= 3.0.2) *渲染动作对应的模板,并返回结果 * @example - * @param mixed $tpl - * @param array $parameters - * @return + * @param string $action_name 模板名称 + * @param array $var_array 模板变量数组 + * @return Yaf_Controller_Abstract */ - protected function render($tpl, Array $parameters) + protected function render(string $action_name, Array $var_array = []): Yaf_Controller_Abstract { + } /** * - *(Yaf >= 3.0.2) *渲染动作对应的模板,并直接输出结果 * @example - * @param mixed $tpl - * @param array $parameters - * @return + * @param string $action_name 模板名称 + * @param array $var_array 模板变量数组 + * @return Yaf_Controller_Abstract */ - protected function display($tpl, Array $parameters) + protected function display(string $action_name, Array $var_array = []): Yaf_Controller_Abstract { + } /** * - *(Yaf >= 3.0.2) *获取请求对象 * @example - * @return + * @return Yaf_Request_Abstract */ - public function getRequest() + public function getRequest(): Yaf_Request_Abstract { + } /** * - *(Yaf >= 3.0.2) *获取响应对象 * @example - * @return + * @return Yaf_Response_Abstract */ - public function getResponse() + public function getResponse(): Yaf_Response_Abstract { + } /** * - *(Yaf >= 3.0.2) *获取当前模块名 * @example - * @return + * @return string */ - public function getModuleName() + public function getModuleName(): string { + } /** * - *(Yaf >= 3.0.2) - *返回视图对象 + *初始化视图对象 * @example - * @return + * @return void */ - public function getView() + public function initView() { + } /** * - *(Yaf >= 3.0.2) - *初始化视图对象 + *返回视图对象 * @example - * @param array $options - * @return + * @return Yaf_View_Interface */ - public function initView(Array $options) + public function getView(): Yaf_View_Interface { + } /** * - * + *设置模板文件目录 * @example - * @param mixed $view_directory - * @return + * @param string $path 模板目录 + * @return void */ - public function setViewpath($view_directory) + public function setViewPath(string $path) { + } /** * - * + *获取模板文件目录 * @example - * @return + * @return string */ - public function getViewpath() + public function getViewPath(): string { + } /** * - *(Yaf >= 3.0.2) *将当前的请求转交给另外的Action(对用户来说是透明的,相当于Web服务器的代理). * @example - * @param mixed $module - * @param mixed $controller - * @param mixed $action - * @param mixed $parameters - * @return + * @param string $module 模块名 + * @param string $controller 控制器名称 + * @param string $action 操作名称 + * @param array $parameters 参数列表数组 + * @return void */ - public function forward($module, $controller, $action, $parameters) + public function forward(string $module, string $controller, string $action, Array $parameters = []) { + } /** * - *(Yaf >= 3.0.2) *将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) * @example - * @param mixed $url + * @param string $url 跳转的地址 * @return */ - public function redirect($url) + public function redirect(string $url) { + } /** @@ -199,40 +199,41 @@ public function redirect($url) */ public function getInvokeArgs() { + } /** * - *(Yaf >= 3.0.2) *获取指定调用参数名的值 * @example - * @param mixed $name + * @param string $name 参数名称 * @return */ - public function getInvokeArg($name) + public function getInvokeArg(string $name) { + } /** * - *(Yaf >= 3.0.2) - *屏蔽构造方法 + *构造方法 * @example * @return */ public final function __construct() { + } /** * - *(Yaf >= 3.0.2) - *屏蔽克隆的魔术方法 + *克隆的魔术方法 * @example * @return */ - private final function __clone() + public final function __clone() { + } } diff --git a/src/Yaf/Yaf_Dispatcher.php b/src/Yaf/Yaf_Dispatcher.php index 6452f06..cad8c23 100644 --- a/src/Yaf/Yaf_Dispatcher.php +++ b/src/Yaf/Yaf_Dispatcher.php @@ -1,54 +1,52 @@ = 3.0.2) -*Class yaf_Dispatcher +*路由及请求分发器 */ final class Yaf_Dispatcher { /** - * @var unknown $_router - * (Yaf >= 3.0.2) + * @var Yaf_Router $_router * 路由器对象. * @access protected + */ protected $_router; /** - * @var unknown $_view - * (Yaf >= 3.0.2) + * @var Yaf_View_Interface $_view * 视图对象. * @access protected + */ protected $_view; /** - * @var unknown $_request - * (Yaf >= 3.0.2) + * @var Yaf_Request_Abstract $_request * 当前请求对象(包含请求的所有信息). * @access protected + */ protected $_request; /** - * @var unknown $_plugins - * (Yaf >= 3.0.2) + * @var array $_plugins * 已注册的插件对象 * @access protected - protected $_plugins; + */ + protected $_plugins = array(); /** - * @var unknown $_instance - * (Yaf >= 3.0.2) + * @var Yaf_Dispatcher $_instance * yaf_Dispatcher实现了单例模式,此属性保存当前实例. * @access protected + */ protected static $_instance; /** - * @var unknown $_auto_render - * (Yaf >= 3.0.2) + * @var int $_auto_render * 自动渲染功能开关,默认1. * 自动渲染是指根据当前请求的控制器Controller和动作Action自动寻找模块文件,加载与渲染模块,之后返回结果或者输出. * 如果设置为0,$this->_instantly_flush,$this->_return_response的设置将无效,也即: @@ -56,11 +54,11 @@ final class Yaf_Dispatcher * yaf_Dispatcher::getInstance()->returnResponse($flag); * 设置无效,并且不会渲染模板. * @access protected - protected $_auto_render = '1'; + */ + protected $_auto_render = 1; /** - * @var unknown $_return_response - * (Yaf >= 3.0.2) + * @var int $_return_response * 返回包含请求正文的响应对象开关,默认为0. * 默认情况下,Yaf的自动渲染查找并渲染模板(render,并非display),渲染结果写入yaf_Response_Abstract实例的_body属性, * 在分发器结束分发之后,输出_body(数组遍历输出)属性的值,并清空_body. @@ -69,329 +67,335 @@ final class Yaf_Dispatcher * 进而调用yaf_Response_Abstract实例的getBody()方法获取响应正文.此属性依赖$this->_auto_render的设置, * 当$this->_auto_render=1时,响应正文包括渲染模板的结果,反之则不包括. * @access protected - protected $_return_response = ''; + */ + protected $_return_response = 0; /** - * @var unknown $_instantly_flush - * (Yaf >= 3.0.2) + * @var int $_instantly_flush * 立即输出响应正文开头,默认为0. * 默认情况下,Yaf自动渲染调用yaf_Controller_Abstract的render方法,渲染模板. * 当此属性设置为1时,Yaf调用yaf_Controller_Abstract的display方法,直接渲染并输出,但不设置yaf_Response_Abstract实例的_body属性. * @access protected - protected $_instantly_flush = ''; + */ + protected $_instantly_flush = 0; /** - * @var unknown $_default_module - * (Yaf >= 3.0.2) + * @var string $_default_module * 默认模块名 * @access protected + */ protected $_default_module; /** - * @var unknown $_default_controller - * (Yaf >= 3.0.2) + * @var string $_default_controller * 默认控制器 * @access protected + */ protected $_default_controller; /** - * @var unknown $_default_action - * (Yaf >= 3.0.2) + * @var string $_default_action * 默认动作名 * @access protected + */ protected $_default_action; /** * - *(Yaf >= 3.0.2) - *重置__construct魔术方法. + *关闭自动渲染模板 * @example - * @return + * @return bool */ - private function __construct() + public function disableView(): bool { + } /** * - *(Yaf >= 3.0.2) - *重置__clone魔术方法,防止克隆yaf_Dispatcher(因为是单例模式). + *开启自动渲染模板 * @example - * @return + * @return Yaf_Dispatcher */ - private function __clone() + public function enableView(): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *重置__sleep魔术方法. + *初始化视图对象 * @example - * @return + * @param string $tpl_dir 模板目录 + * @param mixed $options 全局的模板选项(配置相关) + * @return Yaf_View_Interface */ - private function __sleep() + public function initView(string $tpl_dir, $options): Yaf_View_Interface { + return Yaf_View_Simple(); } /** * - *(Yaf >= 3.0.2) - *重置__wakeup魔术方法. + *设置视图对象 * @example - * @return + * @param Yaf_View_Interface $view 视图对象实例 + * @return Yaf_Dispatcher */ - private function __wakeup() + public function setView(Yaf_View_Interface $view): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *开启自动渲染模板 + *设置请求对象(在命令行或者其他API模式下构造请求很有用) * @example - * @return + * @param Yaf_Request_Abstract $request 手动实例化的请求对象 + * @return Yaf_Dispatcher */ - public function enableView() + public function setRequest(Yaf_Request_Abstract $request): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *关闭自动渲染模板 + *返回应用实例 * @example - * @return + * @return Yaf_Application */ - public function disableView() + public function getApplication(): Yaf_Application { + } /** * - *(Yaf >= 3.0.2) - *初始化视图对象 + *返回路由器实例 * @example - * @param mixed $templates_dir - * @param mixed $options (Yaf >= 3.0.2) -初始化视图对象 - * @return + * @return Yaf_Router */ - public function initView($templates_dir, $options) + public function getRouter(): Yaf_Router { + } /** * - *(Yaf >= 3.0.2) - *设置视图对象 + *返回请求对象实例 * @example - * @param YafX_View_Interface $view (Yaf >= 3.0.2) -设置视图对象 - * @return + * @return Yaf_Request */ - public function setView($view) + public function getRequest(): Yaf_Request { + } /** * *(Yaf >= 3.0.2) - *设置请求对象(在命令行或者其他API模式下构造请求很有用) + *设置一个用户定义的错误处理函数(封装了PHP内置的set_error_handler函数) * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -设置请求对象(在命令行或者其他API模式下构造请求很有用) - * @return + * @param callable $callback PHP中可回调的结构 + * @param int $error_type 错误类型 + * @return Yaf_Dispatcher */ - public function setRequest($request) + public function setErrorHandler(Callable $callback, int $error_type = 32767): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *返回应用实例 + *设置默认模块 * @example - * @return + * @param string $module 模块名 + * @return Yaf_Dispatcher */ - public function getApplication() + public function setDefaultModule(string $module): Yaf_Dispatcher { + } /** * - *返回路由器实例 + *设置默认的控制器 * @example - * @return + * @param string $controller 控制器名 + * @return Yaf_Dispatcher */ - public function getRouter() + public function setDefaultController(string $controller): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *返回请求对象实例 + *设置默认的动作名 * @example - * @return + * @param string $action 操作名 + * @return Yaf_Dispatcher */ - public function getRequest() + public function setDefaultAction(string $action): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置一个用户定义的错误处理函数(封装了PHP内置的set_error_handler函数) + *设置或者返回$this->_return_response属性的值 + *当传递$flag参数时,设置$this->_return_response=$flag,并返回Dispatcher + *当不传递任何参数时,返回$this->_return_response当前值 * @example - * @param callable $callback (Yaf >= 3.0.2) -设置一个用户定义的错误处理函数(封装了PHP内置的set_error_handler函数) - * @param mixed $error_types - * @return + * @param bool $flag 是否返回响应 + * @return Yaf_Dispatcher */ - public function setErrorHandler(Callable $callback, $error_types) + public function returnResponse(bool $flag): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置默认模块 + *设置或者返回$this->_auto_render属性的值 + *当传递$flag参数时,设置$this->_auto_render=$flag,并返回Dispatcher + *当不传递任何参数时,返回$this->_auto_render属性的值 * @example - * @param string $module (Yaf >= 3.0.2) -设置默认模块 - * @return + * @param bool $flag 是否自动渲染 + * @return Yaf_Dispatcher */ - public function setDefaultModule($module) + public function autoRender(bool $flag): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置默认的控制器 + *设置或者返回$this->_instantly_flush属性的值 + *当传递$flag参数时,设置$this->_instantly_flush=$flag,并返回Dispatcher + *当不传递任何参数时,返回$this->_instantly_flush属性的值 * @example - * @param string $controller (Yaf >= 3.0.2) -设置默认的控制器 - * @return + * @param bool $flag 是否即时刷新缓存 + * @return Yaf_Dispatcher */ - public function setDefaultController($controller) + public function flushInstantly(bool $flag): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置默认的动作名 + *返回当前yaf_Dispatcher实例(单例模式) * @example - * @param mixed $action - * @return + * @return Yaf_Dispatcher */ - public function setDefaultAction($action) + public static function getInstance(): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置或者返回$this->_return_response属性的值 - *当传递$flag参数时,设置$this->_return_response=$flag,并返回Dispatcher - *当不传递任何参数时,返回$this->_return_response当前值 + *手动分发请求 * @example - * @param mixed $flag - * @return + * @param Yaf_Request_Abstract $request 分发的请求对象 + * @return Yaf_Response_Abstract */ - public function returnResponse($flag) + public function dispatch(Yaf_Request_Abstract $request): Yaf_Response_Abstract { + return new Yaf_Response_Http(); } /** * - *(Yaf >= 3.0.2) - *设置或者返回$this->_auto_render属性的值 - *当传递$flag参数时,设置$this->_auto_render=$flag,并返回Dispatcher - *当不传递任何参数时,返回$this->_auto_render属性的值 + *开启/关闭异常抛出或返回当前状态 * @example - * @param mixed $flag - * @return + * @param bool $flag 是否抛出异常 + * @return Yaf_Dispatcher */ - public function autoRender($flag) + public function throwException(bool $flag): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *设置或者返回$this->_instantly_flush属性的值 - *当传递$flag参数时,设置$this->_instantly_flush=$flag,并返回Dispatcher - *当不传递任何参数时,返回$this->_instantly_flush属性的值 + *开启/关闭自动异常捕获功能或返回当前状态 * @example - * @param mixed $flag - * @return + * @param bool $flag 是否捕获异常 + * @return Yaf_Dispatcher */ - public function flushInstantly($flag) + public function catchException(bool $flag): Yaf_Dispatcher { + } /** * - *(Yaf >= 3.0.2) - *返回当前yaf_Dispatcher实例(单例模式) + *注册插件 + * @example + * @param Yaf_Plugin_Abstract $plugin 实例化的插件对象 + * @return Yaf_Dispatcher + */ + public function registerPlugin(Yaf_Plugin_Abstract $plugin): Yaf_Dispatcher + { + + } + + /** + * + *重置__construct魔术方法. * @example * @return */ - public static function getInstance() + private function __construct() { + } /** * - *(Yaf >= 3.0.2) - *手动分发请求 + *重置__clone魔术方法,防止克隆yaf_Dispatcher(因为是单例模式). * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -手动分发请求 * @return */ - public function dispatch($request) + private function __clone() { + } /** * - *(Yaf >= 3.0.2) - *开启/关闭异常抛出或返回当前状态 + *重置__destruct魔术方法. * @example - * @param mixed $flag * @return */ - public function throwException($flag) + public function __destruct() { + } /** * - *(Yaf >= 3.0.2) - *开启/关闭自动异常捕获功能或返回当前状态 + *重置__sleep魔术方法. * @example - * @param mixed $flag * @return */ - public function catchException($flag) + private function __sleep() { + } /** * - *(Yaf >= 3.0.2) - *注册插件 + *重置__wakeup魔术方法. * @example - * @param YafX_Plugin_Abstract $plugin (Yaf >= 3.0.2) -注册插件 * @return */ - public function registerPlugin($plugin) + private function __wakeup() { + } } diff --git a/src/Yaf/Yaf_Exception.php b/src/Yaf/Yaf_Exception.php index bac49ac..c53137e 100644 --- a/src/Yaf/Yaf_Exception.php +++ b/src/Yaf/Yaf_Exception.php @@ -1,69 +1,73 @@ = 3.0.2) -*Class yaf_Exception +*yaf异常蕨类 */ -class Yaf_Exception extends Exception +class Yaf_Exception extends Exception implements Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -74,86 +78,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Yaf_Exception_DispatchFailed.php b/src/Yaf/Yaf_Exception_DispatchFailed.php index 316e58b..c1ff52d 100644 --- a/src/Yaf/Yaf_Exception_DispatchFailed.php +++ b/src/Yaf/Yaf_Exception_DispatchFailed.php @@ -1,69 +1,73 @@ = 3.0.2) -*Class yaf_Exception_DispatchFailed +*yaf分发异常 */ -class Yaf_Exception_DispatchFailed extends Yaf_Exception +class Yaf_Exception_DispatchFailed extends Yaf_Exception implements Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -74,86 +78,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Yaf_Exception_LoadFailed.php b/src/Yaf/Yaf_Exception_LoadFailed.php index 4dc8264..e1118ba 100644 --- a/src/Yaf/Yaf_Exception_LoadFailed.php +++ b/src/Yaf/Yaf_Exception_LoadFailed.php @@ -1,69 +1,73 @@ = 3.0.2) -*Class yaf_Exception_LoadFailed +*yaf加载异常 */ -class Yaf_Exception_LoadFailed extends Yaf_Exception +class Yaf_Exception_LoadFailed extends Yaf_Exception implements Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -74,86 +78,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Yaf_Exception_LoadFailed_Action.php b/src/Yaf/Yaf_Exception_LoadFailed_Action.php index d00bc93..928829c 100644 --- a/src/Yaf/Yaf_Exception_LoadFailed_Action.php +++ b/src/Yaf/Yaf_Exception_LoadFailed_Action.php @@ -1,69 +1,73 @@ = 3.0.2) -*Class yaf_Exception_LoadFailed_Action +*操作文件加载异常 */ -class Yaf_Exception_LoadFailed_Action extends Yaf_Exception_LoadFailed +class Yaf_Exception_LoadFailed_Action extends Yaf_Exception_LoadFailed implements Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -74,86 +78,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Yaf_Exception_LoadFailed_Controller.php b/src/Yaf/Yaf_Exception_LoadFailed_Controller.php index cdaf8a2..549f26a 100644 --- a/src/Yaf/Yaf_Exception_LoadFailed_Controller.php +++ b/src/Yaf/Yaf_Exception_LoadFailed_Controller.php @@ -1,69 +1,73 @@ = 3.0.2) -*Class yaf_Exception_LoadFailed_Controller +*控制器加载异常 */ -class Yaf_Exception_LoadFailed_Controller extends Yaf_Exception_LoadFailed +class Yaf_Exception_LoadFailed_Controller extends Yaf_Exception_LoadFailed implements Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -74,86 +78,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Yaf_Exception_LoadFailed_Module.php b/src/Yaf/Yaf_Exception_LoadFailed_Module.php index 6b29042..dcbade9 100644 --- a/src/Yaf/Yaf_Exception_LoadFailed_Module.php +++ b/src/Yaf/Yaf_Exception_LoadFailed_Module.php @@ -1,69 +1,73 @@ = 3.0.2) -*Class yaf_Exception_LoadFailed_Module +*模块加载异常 */ -class Yaf_Exception_LoadFailed_Module extends Yaf_Exception_LoadFailed +class Yaf_Exception_LoadFailed_Module extends Yaf_Exception_LoadFailed implements Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -74,86 +78,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Yaf_Exception_LoadFailed_View.php b/src/Yaf/Yaf_Exception_LoadFailed_View.php index dedd477..6a21d76 100644 --- a/src/Yaf/Yaf_Exception_LoadFailed_View.php +++ b/src/Yaf/Yaf_Exception_LoadFailed_View.php @@ -1,69 +1,73 @@ = 3.0.2) -*Class yaf_Exception_LoadFailed_View +*视图加载异常 */ -class Yaf_Exception_LoadFailed_View extends Yaf_Exception_LoadFailed +class Yaf_Exception_LoadFailed_View extends Yaf_Exception_LoadFailed implements Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -74,86 +78,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Yaf_Exception_RouterFailed.php b/src/Yaf/Yaf_Exception_RouterFailed.php index a191652..b738d25 100644 --- a/src/Yaf/Yaf_Exception_RouterFailed.php +++ b/src/Yaf/Yaf_Exception_RouterFailed.php @@ -1,69 +1,73 @@ = 3.0.2) -*Class yaf_Exception_RouterFailed +*路由失败异常 */ -class Yaf_Exception_RouterFailed extends Yaf_Exception +class Yaf_Exception_RouterFailed extends Yaf_Exception implements Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -74,86 +78,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Yaf_Exception_StartupError.php b/src/Yaf/Yaf_Exception_StartupError.php index 38018cb..e82c257 100644 --- a/src/Yaf/Yaf_Exception_StartupError.php +++ b/src/Yaf/Yaf_Exception_StartupError.php @@ -1,69 +1,73 @@ = 3.0.2) -*Class yaf_Exception_StartupError +*启动失败异常 */ -class Yaf_Exception_StartupError extends Yaf_Exception +class Yaf_Exception_StartupError extends Yaf_Exception implements Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -74,86 +78,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Yaf_Exception_TypeError.php b/src/Yaf/Yaf_Exception_TypeError.php index 059b7eb..40c3ebe 100644 --- a/src/Yaf/Yaf_Exception_TypeError.php +++ b/src/Yaf/Yaf_Exception_TypeError.php @@ -1,69 +1,73 @@ = 3.0.2) -*Class yaf_Exception_TypeError +*类型错误异常 */ -class Yaf_Exception_TypeError extends Yaf_Exception +class Yaf_Exception_TypeError extends Yaf_Exception implements Throwable { /** - * @var unknown $file - * + * @var string $file + * 异常文件名称 * @access protected + */ protected $file; /** - * @var unknown $line - * + * @var int $line + * 异常文件行数 * @access protected + */ protected $line; /** - * @var unknown $message - * (Yaf >= 3.0.2) + * @var string $message * 异常信息 * @access protected + */ protected $message; /** - * @var unknown $code - * + * @var int $code + * 异常码 * @access protected + */ protected $code = 0; /** - * @var unknown $previous - * (Yaf >= 3.0.2) + * @var Throwable $previous * 上一个异常对象 * @access protected + */ protected $previous; /** * - * + *克隆方法 * @example * @return */ private final function __clone() { + } /** * - * + *初始化异常 * @example - * @param mixed $message - * @param mixed $code - * @param mixed $previous + * @param string $message 异常提示 + * @param int $code 异常码 + * @param Throwable $previous 上一个异常对象 * @return */ - public function __construct($message, $code, $previous) + public function __construct(string $message = '', int $code = 0, Throwable $previous) { + } /** @@ -74,86 +78,95 @@ public function __construct($message, $code, $previous) */ public function __wakeup() { + } /** * - * + *获取异常信息 * @example - * @return + * @return string */ - public final function getMessage() + public final function getMessage(): string { + } /** * - * + *获取异常码 * @example - * @return + * @return int */ - public final function getCode() + public final function getCode(): int { + } /** * - * + *获取异常文件名称 * @example - * @return + * @return string */ - public final function getFile() + public final function getFile(): string { + } /** * - * + *获取异常行数 * @example - * @return + * @return int */ - public final function getLine() + public final function getLine(): int { + } /** * - * + *获取trace调试数组 * @example - * @return + * @return array */ - public final function getTrace() + public final function getTrace(): array { + } /** * - * + *获取前一个异常对象 * @example - * @return + * @return Throwable */ public final function getPrevious() { + return new Exception(); } /** * - * + *获取调试信息的字符串 * @example - * @return + * @return string */ - public final function getTraceAsString() + public final function getTraceAsString(): string { + } /** * - * + *转化为字符串 * @example - * @return + * @return string */ - public function __toString() + public function __toString(): string { + } } diff --git a/src/Yaf/Yaf_Loader.php b/src/Yaf/Yaf_Loader.php index 39dcc49..4df8f85 100644 --- a/src/Yaf/Yaf_Loader.php +++ b/src/Yaf/Yaf_Loader.php @@ -1,187 +1,197 @@ = 3.0.2) -*Class yaf_Loader +*yaf类加载器 */ final class Yaf_Loader { /** - * @var unknown $_library - * (Yaf >= 3.0.2) + * @var string $_library * 当前应用本地类库目录 * @access protected + */ protected $_library; /** - * @var unknown $_global_library - * (Yaf >= 3.0.2) + * @var string $_global_library * 全局类库目录 * @access protected + */ protected $_global_library; /** - * @var unknown $_instance - * (Yaf >= 3.0.2) + * @var Yaf_Loader $_instance * 当前Loader实例(单例模式) * @access protected + */ protected static $_instance; /** * - *(Yaf >= 3.0.2) - *重置__construct魔术方法. + *__construct魔术方法. * @example * @return */ private function __construct() { + } /** * - *(Yaf >= 3.0.2) *重置__clone魔术方法,防止克隆yaf_Loader(因为是单例模式). * @example * @return */ private function __clone() { + + } + + /** + * + *__destruct魔术方法. + * @example + * @return + */ + public function __destruct() + { + } /** * - *(Yaf >= 3.0.2) *重置__sleep魔术方法. * @example * @return */ private function __sleep() { + } /** * - *(Yaf >= 3.0.2) *重置__wakeup魔术方法. * @example * @return */ private function __wakeup() { + } /** * - *(Yaf >= 3.0.2) *自动装载类 * @example - * @param mixed $class_name + * @param string $class 类名 * @return */ - public function autoload($class_name) + public function autoload(string $class) { + } /** * - *(Yaf >= 3.0.2) *获取yaf_Loader实例 * @example - * @param mixed $local_library_path - * @param mixed $global_library_path - * @return + * @param string $library 本地类库目录 + * @param string $global 全局类库目录 + * @return Yaf_Loader */ - public static function getInstance($local_library_path, $global_library_path) + public static function getInstance(string $library, string $global): Yaf_Loader { + } /** * - *(Yaf >= 3.0.2) *注册本地类前缀 * @example - * @param mixed $name_prefix + * @param mixed $namespace 一个或者多个类前缀 * @return */ - public function registerLocalNamespace($name_prefix) + public function registerLocalNamespace($namespace) { + } /** * - *(Yaf >= 3.0.2) *获取当前已经注册的本地类前缀 * @example - * @return + * @return string */ - public function getLocalNamespace() + public function getLocalNamespace(): string { + } /** * - *(Yaf >= 3.0.2) *清空已注册的本地类前缀 * @example * @return */ public function clearLocalNamespace() { + } /** * - *(Yaf >= 3.0.2) *判断一个类, 是否是本地类. * @example - * @param mixed $class_name - * @return + * @param string $class_name 类名 + * @return bool */ - public function isLocalName($class_name) + public function isLocalName(string $class_name): bool { + } /** * - *(Yaf >= 3.0.2) *手动导入文件 * @example - * @param mixed $file + * @param string $file include的全路径文件名 * @return */ - public static function import($file) + public static function import(string $file) { + } /** * - *(Yaf >= 3.0.2) *设置本地或者全局类库目录 * @example - * @param mixed $library_path - * @param mixed $is_global + * @param string $library 目录路径 + * @param bool $global 是否为全局类库 * @return */ - public function setLibraryPath($library_path, $is_global) + public function setLibraryPath(string $library, bool $global = false) { + } /** * - *(Yaf >= 3.0.2) *获取本地或者全局类库目录 * @example - * @param mixed $is_global - * @return + * @param bool $global 是否全局类库 + * @return string|bool */ - public function getLibraryPath($is_global) + public function getLibraryPath(bool $global = false): ?string { + } } diff --git a/src/Yaf/Yaf_Plugin_Abstract.php b/src/Yaf/Yaf_Plugin_Abstract.php index adb10be..247cc41 100644 --- a/src/Yaf/Yaf_Plugin_Abstract.php +++ b/src/Yaf/Yaf_Plugin_Abstract.php @@ -1,116 +1,91 @@ = 3.0.2) -*Class yaf_Plugin_Abstract +*插件抽象类 */ abstract class Yaf_Plugin_Abstract { /** * - *(Yaf >= 3.0.2) *在路由之前触发 * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -在路由之前触发 - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -在路由之前触发 + * @param Yaf_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function routerStartup($request, $response) + public function routerStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { + } /** * - *(Yaf >= 3.0.2) *路由结束之后触发 * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -路由结束之后触发 - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -路由结束之后触发 + * @param Yaf_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function routerShutdown($request, $response) + public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { + } /** * - *(Yaf >= 3.0.2) *分发循环开始之前被触发 * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -分发循环开始之前被触发 - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -分发循环开始之前被触发 + * @param YafX_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function dispatchLoopStartup($request, $response) + public function dispatchLoopStartup(YafX_Request_Abstract $request, Yaf_Response_Abstract $response) { + } /** * - *(Yaf >= 3.0.2) - *dispatchLoopShutdown - * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -dispatchLoopShutdown - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -dispatchLoopShutdown - * @return - */ - public function dispatchLoopShutdown($request, $response) - { - } - - /** - * - *(Yaf >= 3.0.2) *分发之前触发 * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -分发之前触发 - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -分发之前触发 + * @param Yaf_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function preDispatch($request, $response) + public function preDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { + } /** * - *(Yaf >= 3.0.2) *分发结束之后触发 * @example - * @param YafX_Request_Abstract $request (Yaf >= 3.0.2) -分发结束之后触发 - * @param YafX_Response_Abstract $response (Yaf >= 3.0.2) -分发结束之后触发 + * @param Yaf_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function postDispatch($request, $response) + public function postDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { + } /** * - * + *分发循环结束 * @example - * @param Yaf_Request_Abstract $request - * @param Yaf_Response_Abstract $response + * @param Yaf_Request_Abstract $request 当前请求对象 + * @param Yaf_Response_Abstract $response 当前响应对象 * @return */ - public function preResponse($request, $response) + public function dispatchLoopShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { + } } diff --git a/src/Yaf/Yaf_Registry.php b/src/Yaf/Yaf_Registry.php index 1a3aee5..0ed6f35 100644 --- a/src/Yaf/Yaf_Registry.php +++ b/src/Yaf/Yaf_Registry.php @@ -1,103 +1,98 @@ = 3.0.2) -*Class yaf_Registry +*yaf变量注册器 */ final class Yaf_Registry { /** - * @var unknown $_instance - * (Yaf >= 3.0.2) + * @var Yaf_Registry $_instance * Registry实例(单例模式) * @access protected + */ protected static $_instance; /** - * @var unknown $_entries - * (Yaf >= 3.0.2) + * @var array $_entries * 注册变量栈 * @access protected - protected $_entries; + */ + protected $_entries = array(); /** * - *(Yaf >= 3.0.2) *重置__construct魔术方法. * @example * @return */ private function __construct() { + } /** * - *(Yaf >= 3.0.2) *重置__clone魔术方法,防止克隆Dispatcher(因为是单例模式). * @example * @return */ private function __clone() { + } /** * - *(Yaf >= 3.0.2) *获取注册变量值 * @example - * @param string $name (Yaf >= 3.0.2) -获取注册变量值 - * @return + * @param string $name 变量名 + * @return mixed */ - public static function get($name) + public static function get(string $name) { + } /** * - *(Yaf >= 3.0.2) *检测变量是否存在 * @example - * @param string $name (Yaf >= 3.0.2) -检测变量是否存在 - * @return + * @param string $name 变量名 + * @return bool */ - public static function has($name) + public static function has(string $name): bool { + } /** * - *(Yaf >= 3.0.2) *注册变量 * @example - * @param string $name (Yaf >= 3.0.2) -注册变量 - * @param mixed $value (Yaf >= 3.0.2) -注册变量 - * @return + * @param string $name 变量名 + * @param mixed $value 变量值 + * @return bool */ - public static function set($name, $value) + public static function set(string $name, $value): bool { + } /** * - *(Yaf >= 3.0.2) - *删除变量 + *删除注册器中的变量 * @example - * @param mixed $name + * @param string $name 变量名 * @return */ - public static function del($name) + public static function del(string $name) { + } } diff --git a/src/Yaf/Yaf_Request_Abstract.php b/src/Yaf/Yaf_Request_Abstract.php index cd12ad9..25531ef 100644 --- a/src/Yaf/Yaf_Request_Abstract.php +++ b/src/Yaf/Yaf_Request_Abstract.php @@ -1,445 +1,433 @@ = 3.0.2) -*Class yaf_Request_Abstract +*请求抽象类 */ abstract class Yaf_Request_Abstract { /** - * + *http请求 */ const SCHEME_HTTP = 'http'; /** - * + *https请求 */ const SCHEME_HTTPS = 'https'; /** - * @var unknown $module - * (Yaf >= 3.0.2) + * @var string $module * 当前请求的模块名 * @access public + */ public $module; /** - * @var unknown $controller - * (Yaf >= 3.0.2) + * @var string $controller * 当前请求的控制器名 * @access public + */ public $controller; /** - * @var unknown $action - * (Yaf >= 3.0.2) + * @var stirng $action * 当前请求的动作名 * @access public + */ public $action; /** - * @var unknown $method - * (Yaf >= 3.0.2) + * @var string $method * 当前请求的方法 getMethod * @access public + */ public $method; /** - * @var unknown $params - * (Yaf >= 3.0.2) + * @var array $params * 请求传递的参数 * @access protected - protected $params; + */ + protected $params = array(); /** - * @var unknown $language - * (Yaf >= 3.0.2) + * @var string $language * http报头中HTTP_ACCEPT_LANGUAGE的值 * @access protected + */ protected $language; /** - * @var unknown $_exception - * (Yaf >= 3.0.2) + * @var Yaf_Exception $_exception * 异常对象 * @access protected + */ protected $_exception; /** - * @var unknown $_base_uri - * (Yaf >= 3.0.2) + * @var string $_base_uri * 请求的Base URI(http请求 or cli模式下) * @access protected + */ protected $_base_uri = ''; /** - * @var unknown $uri - * (Yaf >= 3.0.2) + * @var string $uri * 请求的URI(http请求) * @access protected + */ protected $uri = ''; /** - * @var unknown $dispatched - * (Yaf >= 3.0.2) + * @var bool $dispatched * 请求是否完成了分发,默认为0 * @access protected - protected $dispatched = ''; + */ + protected $dispatched = false; /** - * @var unknown $routed - * (Yaf >= 3.0.2) + * @var bool $routed * 请求是否完成了路由,默认为0 * @access protected - protected $routed = ''; + */ + protected $routed = false; /** * - *(Yaf >= 3.0.2) *判断是否为GET请求 * @example - * @return + * @return bool */ - public function isGet() + public function isGet(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为POST请求 * @example - * @return + * @return bool */ - public function isPost() + public function isPost(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为PUT请求 * @example - * @return + * @return bool */ - public function isPut() + public function isPut(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为HEAD请求 * @example - * @return + * @return bool */ - public function isHead() + public function isHead(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为Options请求 * @example - * @return + * @return bool */ - public function isOptions() + public function isOptions(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为CLI请求 * @example - * @return + * @return bool */ - public function isCli() + public function isCli(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为AJAX请求 * @example - * @return + * @return bool */ - public function isXmlHttpRequest() + public function isXmlHttpRequest(): bool { + } /** * - *(Yaf >= 3.0.2) *获取服务器$_SERVER全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @param mixed $default (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @return + * @param string $name 变量名 + * @param mixed $default 默认值 + * @return mixed */ - public function getServer($name, $default) + public function getServer(string $name, $default) { + } /** * - *(Yaf >= 3.0.2) *获取环境变量$_ENV全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @param string $default (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return mixed */ - public function getEnv($name, $default) + public function getEnv(string $name, string $default) { + } /** * - *(Yaf >= 3.0.2) *设置请求的参数 *当只有一个参数且为Array类型,如果存在对应的键值将覆盖 * @example - * @param string $name (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 - * @param mixed $value (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function setParam($name, $value) + public function setParam(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) *获取请求的参数 * @example - * @param string $name (Yaf >= 3.0.2) -获取请求的参数 - * @param string $default (Yaf >= 3.0.2) -获取请求的参数 + * @param string $name 变量名 + * @param string $default 默认值 * @return */ - public function getParam($name, $default) + public function getParam(string $name, string $default) { + } /** * - *(Yaf >= 3.0.2) *获取请求全部的参数 * @example - * @return + * @return array|null */ - public function getParams() + public function getParams(): ?array { + } /** * - *(Yaf >= 3.0.2) *获取异常对象 * @example - * @return + * @return Yaf_Exception */ - public function getException() + public function getException(): Yaf_Exception { + } /** * - *(Yaf >= 3.0.2) *获取当前模块名 * @example - * @return + * @return string */ - public function getModuleName() + public function getModuleName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前控制器名 * @example - * @return + * @return string */ - public function getControllerName() + public function getControllerName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前动作名 * @example - * @return + * @return string */ - public function getActionName() + public function getActionName(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的模块名 * @example - * @param mixed $module + * @param string $name 模块名 * @return */ - public function setModuleName($module) + public function setModuleName(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置请求的控制器名 * @example - * @param mixed $controller + * @param string $name 控制器名称 * @return */ - public function setControllerName($controller) + public function setControllerName(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置请求的动作名 * @example - * @param mixed $action + * @param string $name 操作名称 * @return */ - public function setActionName($action) + public function setActionName(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取当前请求的方法 * @example - * @return + * @return string */ - public function getMethod() + public function getMethod(): string { + } /** * - *(Yaf >= 3.0.2) - *获取当前请求的请求 + *获取当前请求的请求的语言 * @example - * @return + * @return string */ - public function getLanguage() + public function getLanguage(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的Base URI * @example - * @param mixed $uri + * @param string $baseuri 基本请求地址 * @return */ - public function setBaseUri($uri) + public function setBaseUri(string $baseuri) { + } /** * - *(Yaf >= 3.0.2) *获取请求的Base URI * @example - * @return + * @return string */ - public function getBaseUri() + public function getBaseUri(): string { + } /** * - *(Yaf >= 3.0.2) *获取请求的uri * @example - * @return + * @return string */ - public function getRequestUri() + public function getRequestUri(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的URI * @example - * @param mixed $uri + * @param string $uri 请求uri * @return */ - public function setRequestUri($uri) + public function setRequestUri(string $uri) { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了分发 * @example - * @return + * @return bool */ - public function isDispatched() + public function isDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成分发 * @example - * @return + * @return bool */ - public function setDispatched() + public function setDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了路由 * @example - * @return + * @return bool */ - public function isRouted() + public function isRouted(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成了路由 * @example - * @param mixed $flag - * @return + * @return bool */ - public function setRouted($flag) + public function setRouted(): bool { + } } diff --git a/src/Yaf/Yaf_Request_Http.php b/src/Yaf/Yaf_Request_Http.php index 26c5b24..bff2e55 100644 --- a/src/Yaf/Yaf_Request_Http.php +++ b/src/Yaf/Yaf_Request_Http.php @@ -1,386 +1,386 @@ = 3.0.2) -*Class yaf_Request_Http +*http请求对象 */ class Yaf_Request_Http extends Yaf_Request_Abstract { /** - * @var unknown $module - * (Yaf >= 3.0.2) + * @var string $module * 当前请求的模块名 * @access public + */ public $module; /** - * @var unknown $controller - * (Yaf >= 3.0.2) + * @var string $controller * 当前请求的控制器名 * @access public + */ public $controller; /** - * @var unknown $action - * (Yaf >= 3.0.2) + * @var stirng $action * 当前请求的动作名 * @access public + */ public $action; /** - * @var unknown $method - * (Yaf >= 3.0.2) + * @var string $method * 当前请求的方法 getMethod * @access public + */ public $method; /** - * @var unknown $params - * (Yaf >= 3.0.2) + * @var array $params * 请求传递的参数 * @access protected - protected $params; + */ + protected $params = array(); /** - * @var unknown $language - * (Yaf >= 3.0.2) + * @var string $language * http报头中HTTP_ACCEPT_LANGUAGE的值 * @access protected + */ protected $language; /** - * @var unknown $_exception - * (Yaf >= 3.0.2) + * @var Yaf_Exception $_exception * 异常对象 * @access protected + */ protected $_exception; /** - * @var unknown $_base_uri - * (Yaf >= 3.0.2) + * @var string $_base_uri * 请求的Base URI(http请求 or cli模式下) * @access protected + */ protected $_base_uri = ''; /** - * @var unknown $uri - * (Yaf >= 3.0.2) + * @var string $uri * 请求的URI(http请求) * @access protected + */ protected $uri = ''; /** - * @var unknown $dispatched - * (Yaf >= 3.0.2) + * @var bool $dispatched * 请求是否完成了分发,默认为0 * @access protected - protected $dispatched = ''; + */ + protected $dispatched = false; /** - * @var unknown $routed - * (Yaf >= 3.0.2) + * @var bool $routed * 请求是否完成了路由,默认为0 * @access protected - protected $routed = ''; + */ + protected $routed = false; /** * - *(Yaf >= 3.0.2) - *获取$_GET中名为$name的参数值 + *构造方法 * @example + * @param string $request_uri 请求uri + * @param string $base_uri Base URI * @return */ - public function getQuery() + public function __construct(string $request_uri, string $base_uri) { + } /** * - *(Yaf >= 3.0.2) - *获取$_REQUEST中名为$name的参数值 + *获取$_GET中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - public function getRequest() + public function getQuery(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) - *获取$_POST中名为$name的参数值 + *获取$_REQUEST中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return Yaf_Request_Abstract */ - public function getPost() + public function getRequest(string $name): Yaf_Request_Abstract { + } /** * - *(Yaf >= 3.0.2) - *获取$_COOKIE中名为$name的参数值 + *获取$_POST中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - public function getCookie() + public function getPost(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) - *获取$_FILES中名为$name的参数值 + *获取$_COOKIE中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return string */ - public function getFiles() + public function getCookie(string $name): string { + } /** * - *(Yaf >= 3.0.2) - *获取全局变量中的值(扫描顺序为$_POST,$_GET,$_COOKIE,$_SERVER) + *获取$_FILES中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return array */ - public function get() + public function getFiles(string $name): array { + } /** * - *(Yaf >= 3.0.2) *判断是否为AJAX请求 * @example - * @return + * @return bool */ - public function isXmlHttpRequest() + public function isXmlHttpRequest(): bool { + } /** * - *(Yaf >= 3.0.2) - *构造方法 + *获取全局变量中的值(扫描顺序为$_POST,$_GET,$_COOKIE,$_SERVER) * @example - * @return + * @param string $name 变量名 + * @param mixed $default 默认值 + * @return string */ - public function __construct() + public function get(string $name, $default): string { + } /** * - *(Yaf >= 3.0.2) *重置__clone魔术方法 * @example * @return */ private function __clone() { + } /** * - *(Yaf >= 3.0.2) *判断是否为GET请求 * @example - * @return + * @return bool */ - public function isGet() + public function isGet(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为POST请求 * @example - * @return + * @return bool */ - public function isPost() + public function isPost(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为PUT请求 * @example - * @return + * @return bool */ - public function isPut() + public function isPut(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为HEAD请求 * @example - * @return + * @return bool */ - public function isHead() + public function isHead(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为Options请求 * @example - * @return + * @return bool */ - public function isOptions() + public function isOptions(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为CLI请求 * @example - * @return + * @return bool */ - public function isCli() + public function isCli(): bool { + } /** * - *(Yaf >= 3.0.2) *获取服务器$_SERVER全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @param mixed $default (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @return + * @param string $name 变量名 + * @param mixed $default 默认值 + * @return mixed */ - public function getServer($name, $default) + public function getServer(string $name, $default) { + } /** * - *(Yaf >= 3.0.2) *获取环境变量$_ENV全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @param string $default (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return mixed */ - public function getEnv($name, $default) + public function getEnv(string $name, string $default) { + } /** * - *(Yaf >= 3.0.2) *设置请求的参数 *当只有一个参数且为Array类型,如果存在对应的键值将覆盖 * @example - * @param string $name (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 - * @param mixed $value (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function setParam($name, $value) + public function setParam(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) *获取请求的参数 * @example - * @param string $name (Yaf >= 3.0.2) -获取请求的参数 - * @param string $default (Yaf >= 3.0.2) -获取请求的参数 - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - public function getParam($name, $default) + public function getParam(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) *获取请求全部的参数 * @example - * @return + * @return array */ - public function getParams() + public function getParams(): array { + } /** * - *(Yaf >= 3.0.2) *获取异常对象 * @example - * @return + * @return Yaf_Exception */ - public function getException() + public function getException(): Yaf_Exception { + } /** * - *(Yaf >= 3.0.2) *获取当前模块名 * @example - * @return + * @return string */ - public function getModuleName() + public function getModuleName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前控制器名 * @example - * @return + * @return string */ - public function getControllerName() + public function getControllerName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前动作名 * @example - * @return + * @return string */ - public function getActionName() + public function getActionName(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的模块名 * @example - * @param mixed $module + * @param string $name 模块名 * @return */ - public function setModuleName($module) + public function setModuleName(string $name) { + } /** @@ -388,79 +388,80 @@ public function setModuleName($module) *(Yaf >= 3.0.2) *设置请求的控制器名 * @example - * @param mixed $controller + * @param string $name 控制器名称 * @return */ - public function setControllerName($controller) + public function setControllerName(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置请求的动作名 * @example - * @param mixed $action + * @param string $name 操作名称 * @return */ - public function setActionName($action) + public function setActionName(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取当前请求的方法 * @example - * @return + * @return string */ - public function getMethod() + public function getMethod(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前请求的请求 * @example - * @return + * @return string */ - public function getLanguage() + public function getLanguage(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的Base URI * @example - * @param mixed $uri + * @param string $baseuri 基本uri * @return */ - public function setBaseUri($uri) + public function setBaseUri(string $baseuri) { + } /** * - *(Yaf >= 3.0.2) *获取请求的Base URI * @example - * @return + * @return string */ - public function getBaseUri() + public function getBaseUri(): string { + } /** * - *(Yaf >= 3.0.2) *获取请求的uri * @example - * @return + * @return string */ - public function getRequestUri() + public function getRequestUri(): string { + } /** @@ -468,56 +469,56 @@ public function getRequestUri() *(Yaf >= 3.0.2) *设置请求的URI * @example - * @param mixed $uri + * @param string $uri 请求uri * @return */ - public function setRequestUri($uri) + public function setRequestUri(string $uri) { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了分发 * @example - * @return + * @return bool */ - public function isDispatched() + public function isDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成分发 * @example - * @return + * @return bool */ - public function setDispatched() + public function setDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了路由 * @example - * @return + * @return bool */ - public function isRouted() + public function isRouted(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成了路由 * @example - * @param mixed $flag - * @return + * @return bool */ - public function setRouted($flag) + public function setRouted(): bool { + } } diff --git a/src/Yaf/Yaf_Request_Simple.php b/src/Yaf/Yaf_Request_Simple.php index a0b34bd..5bafe61 100644 --- a/src/Yaf/Yaf_Request_Simple.php +++ b/src/Yaf/Yaf_Request_Simple.php @@ -1,396 +1,396 @@ = 3.0.2) -*Class yaf_Request_Simple +*yaf简单请求类 */ final class Yaf_Request_Simple extends Yaf_Request_Abstract { /** - * + *http请求 */ const SCHEME_HTTP = 'http'; /** - * + *https请求 */ const SCHEME_HTTPS = 'https'; /** - * @var unknown $module - * (Yaf >= 3.0.2) + * @var string $module * 当前请求的模块名 * @access public + */ public $module; /** - * @var unknown $controller - * (Yaf >= 3.0.2) + * @var string $controller * 当前请求的控制器名 * @access public + */ public $controller; /** - * @var unknown $action - * (Yaf >= 3.0.2) + * @var stirng $action * 当前请求的动作名 * @access public + */ public $action; /** - * @var unknown $method - * (Yaf >= 3.0.2) + * @var string $method * 当前请求的方法 getMethod * @access public + */ public $method; /** - * @var unknown $params - * (Yaf >= 3.0.2) + * @var array $params * 请求传递的参数 * @access protected - protected $params; + */ + protected $params = array(); /** - * @var unknown $language - * (Yaf >= 3.0.2) + * @var string $language * http报头中HTTP_ACCEPT_LANGUAGE的值 * @access protected + */ protected $language; /** - * @var unknown $_exception - * (Yaf >= 3.0.2) + * @var Yaf_Exception $_exception * 异常对象 * @access protected + */ protected $_exception; /** - * @var unknown $_base_uri - * (Yaf >= 3.0.2) + * @var string $_base_uri * 请求的Base URI(http请求 or cli模式下) * @access protected + */ protected $_base_uri = ''; /** - * @var unknown $uri - * (Yaf >= 3.0.2) + * @var string $uri * 请求的URI(http请求) * @access protected + */ protected $uri = ''; /** - * @var unknown $dispatched - * (Yaf >= 3.0.2) + * @var bool $dispatched * 请求是否完成了分发,默认为0 * @access protected - protected $dispatched = ''; + */ + protected $dispatched = false; /** - * @var unknown $routed - * (Yaf >= 3.0.2) + * @var bool $routed * 请求是否完成了路由,默认为0 * @access protected - protected $routed = ''; + */ + protected $routed = false; /** * - *(Yaf >= 3.0.2) *构造方法 * @example + * @param string $request_uri 请求uri + * @param string $base_uri Base URI * @return */ - public function __construct() + public function __construct(string $request_uri, string $base_uri) { + } /** * - *(Yaf >= 3.0.2) - *重置__clone魔术方法 + *获取$_GET中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - private function __clone() + public function getQuery(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) - *获取$_GET中名为$name的参数值 + *获取$_REQUEST中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return Yaf_Request_Abstract */ - public function getQuery() + public function getRequest(string $name): Yaf_Request_Abstract { + } /** * - *(Yaf >= 3.0.2) - *获取$_REQUEST中名为$name的参数值 + *获取$_POST中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - public function getRequest() + public function getPost(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) - *获取$_POST中名为$name的参数值 + *获取$_COOKIE中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return string */ - public function getPost() + public function getCookie(string $name): string { + } /** * - *(Yaf >= 3.0.2) - *获取$_COOKIE中名为$name的参数值 + *获取$_FILES中名为$name的参数值 * @example - * @return + * @param string $name 变量名 + * @return array */ - public function getCookie() + public function getFiles(string $name): array { + } /** * - *(Yaf >= 3.0.2) - *获取$_FILES中名为$name的参数值 + *判断是否为AJAX请求 * @example - * @return + * @return bool */ - public function getFiles() + public function isXmlHttpRequest(): bool { + } /** * - *(Yaf >= 3.0.2) *获取全局变量中的值(扫描顺序为$_POST,$_GET,$_COOKIE,$_SERVER) * @example - * @return + * @param string $name 变量名 + * @param mixed $default 默认值 + * @return string */ - public function get() + public function get(string $name, $default): string { + } /** * - *(Yaf >= 3.0.2) - *判断是否为AJAX请求 + *重置__clone魔术方法 * @example * @return */ - public function isXmlHttpRequest() + private function __clone() { + } /** * - *(Yaf >= 3.0.2) *判断是否为GET请求 * @example - * @return + * @return bool */ - public function isGet() + public function isGet(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为POST请求 * @example - * @return + * @return bool */ - public function isPost() + public function isPost(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为PUT请求 * @example - * @return + * @return bool */ - public function isPut() + public function isPut(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为HEAD请求 * @example - * @return + * @return bool */ - public function isHead() + public function isHead(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为Options请求 * @example - * @return + * @return bool */ - public function isOptions() + public function isOptions(): bool { + } /** * - *(Yaf >= 3.0.2) *判断是否为CLI请求 * @example - * @return + * @return bool */ - public function isCli() + public function isCli(): bool { + } /** * - *(Yaf >= 3.0.2) *获取服务器$_SERVER全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @param mixed $default (Yaf >= 3.0.2) -获取服务器$_SERVER全局变量中的值 - * @return + * @param string $name 变量名 + * @param mixed $default 默认值 + * @return mixed */ - public function getServer($name, $default) + public function getServer(string $name, $default) { + } /** * - *(Yaf >= 3.0.2) *获取环境变量$_ENV全局变量中的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @param string $default (Yaf >= 3.0.2) -获取环境变量$_ENV全局变量中的值 - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return mixed */ - public function getEnv($name, $default) + public function getEnv(string $name, string $default) { + } /** * - *(Yaf >= 3.0.2) *设置请求的参数 *当只有一个参数且为Array类型,如果存在对应的键值将覆盖 * @example - * @param string $name (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 - * @param mixed $value (Yaf >= 3.0.2) -设置请求的参数 -当只有一个参数且为Array类型,如果存在对应的键值将覆盖 + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function setParam($name, $value) + public function setParam(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) *获取请求的参数 * @example - * @param string $name (Yaf >= 3.0.2) -获取请求的参数 - * @param string $default (Yaf >= 3.0.2) -获取请求的参数 - * @return + * @param string $name 变量名 + * @param string $default 默认值 + * @return string */ - public function getParam($name, $default) + public function getParam(string $name, string $default): string { + } /** * - *(Yaf >= 3.0.2) *获取请求全部的参数 * @example - * @return + * @return array */ - public function getParams() + public function getParams(): array { + } /** * - *(Yaf >= 3.0.2) *获取异常对象 * @example - * @return + * @return Yaf_Exception */ - public function getException() + public function getException(): Yaf_Exception { + } /** * - *(Yaf >= 3.0.2) *获取当前模块名 * @example - * @return + * @return string */ - public function getModuleName() + public function getModuleName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前控制器名 * @example - * @return + * @return string */ - public function getControllerName() + public function getControllerName(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前动作名 * @example - * @return + * @return string */ - public function getActionName() + public function getActionName(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的模块名 * @example - * @param mixed $module + * @param string $name 模块名 * @return */ - public function setModuleName($module) + public function setModuleName(string $name) { + } /** @@ -398,79 +398,80 @@ public function setModuleName($module) *(Yaf >= 3.0.2) *设置请求的控制器名 * @example - * @param mixed $controller + * @param string $name 控制器名称 * @return */ - public function setControllerName($controller) + public function setControllerName(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置请求的动作名 * @example - * @param mixed $action + * @param string $name 操作名称 * @return */ - public function setActionName($action) + public function setActionName(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取当前请求的方法 * @example - * @return + * @return string */ - public function getMethod() + public function getMethod(): string { + } /** * - *(Yaf >= 3.0.2) *获取当前请求的请求 * @example - * @return + * @return string */ - public function getLanguage() + public function getLanguage(): string { + } /** * - *(Yaf >= 3.0.2) *设置请求的Base URI * @example - * @param mixed $uri + * @param string $baseuri 基本uri * @return */ - public function setBaseUri($uri) + public function setBaseUri(string $baseuri) { + } /** * - *(Yaf >= 3.0.2) *获取请求的Base URI * @example - * @return + * @return string */ - public function getBaseUri() + public function getBaseUri(): string { + } /** * - *(Yaf >= 3.0.2) *获取请求的uri * @example - * @return + * @return string */ - public function getRequestUri() + public function getRequestUri(): string { + } /** @@ -478,56 +479,56 @@ public function getRequestUri() *(Yaf >= 3.0.2) *设置请求的URI * @example - * @param mixed $uri + * @param string $uri 请求uri * @return */ - public function setRequestUri($uri) + public function setRequestUri(string $uri) { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了分发 * @example - * @return + * @return bool */ - public function isDispatched() + public function isDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成分发 * @example - * @return + * @return bool */ - public function setDispatched() + public function setDispatched(): bool { + } /** * - *(Yaf >= 3.0.2) *判断请求是否完成了路由 * @example - * @return + * @return bool */ - public function isRouted() + public function isRouted(): bool { + } /** * - *(Yaf >= 3.0.2) *设置请求已经完成了路由 * @example - * @param mixed $flag - * @return + * @return bool */ - public function setRouted($flag) + public function setRouted(): bool { + } } diff --git a/src/Yaf/Yaf_Response_Abstract.php b/src/Yaf/Yaf_Response_Abstract.php index 2df25e4..b2e5b14 100644 --- a/src/Yaf/Yaf_Response_Abstract.php +++ b/src/Yaf/Yaf_Response_Abstract.php @@ -1,165 +1,214 @@ = 3.0.2) -*Class yaf_Response_Abstract +*yaf响应抽象类 */ abstract class Yaf_Response_Abstract { /** - * + *默认响应内容 */ const DEFAULT_BODY = 'content'; /** - * @var unknown $_header - * (Yaf >= 3.0.2) + * @var array $_header * 响应报头 * @access protected - protected $_header; + */ + protected $_header = array(); /** - * @var unknown $_body - * (Yaf >= 3.0.2) + * @var string $_body * 响应正文 * @access protected + */ protected $_body; /** - * @var unknown $_sendheader - * (Yaf >= 3.0.2) + * @var bool $_sendheader * 是否开启已输出响应报头检测 * @access protected - protected $_sendheader = ''; + */ + protected $_sendheader = false; /** * - *(Yaf >= 3.0.2) *构造方法 * @example * @return */ public function __construct() { + } /** * - *(Yaf >= 3.0.2) *析构方法 * @example * @return */ public function __destruct() { + } /** * - *(Yaf >= 3.0.2) *重置__clone魔术方法 * @example * @return */ private function __clone() { + } /** * - *(Yaf >= 3.0.2) *返回响应正文的字符串 * @example * @return */ public function __toString() { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 + * @param string $body 响应正文内容(可覆盖原来的) + * @param string $name 响应正文类型,默认为content * @return */ - public function setBody($body, $name) + public function setBody(string $body, string $name = 'content') { + + } + + /** + * + *获取类型为$name的响应正文内容 + * @example + * @param string $name 响应正文类型,默认为content + * @return string + */ + public function getBody(string $name = 'content'): string + { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function appendBody($body, $name) + public function appendBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function prependBody($body, $name) + public function prependBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) *清空响应正文 * @example - * @param mixed $name * @return */ - public function clearBody($name) + public function clearBody() { + } /** * - *(Yaf >= 3.0.2) - *获取类型为$name的响应正文内容 + *获取响应报头 + * @example + * @return array + */ + public function getHeader(): array + { + + } + + /** + * + *批量设置响应报头 * @example - * @param string $name (Yaf >= 3.0.2) -获取类型为$name的响应正文内容 + * @param array $headers 响应头列表 * @return */ - public function getBody($name) + public function setAllHeaders(Array $headers) { + } /** * *(Yaf >= 3.0.2) + *设置响应报头 + * @example + * @return + */ + public function setHeader() + { + + } + + /** + * + *清空响应报头 + * @example + * @return + */ + public function clearHeaders() + { + + } + + /** + * + *将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) + * @example + * @param string $url 重定向的绝对URL + * @return + */ + public function setRedirect(string $url) + { + + } + + /** + * *输出所有的响应正文 * @example * @return */ public function response() { + } } diff --git a/src/Yaf/Yaf_Response_Cli.php b/src/Yaf/Yaf_Response_Cli.php index 554b1ed..5307c0a 100644 --- a/src/Yaf/Yaf_Response_Cli.php +++ b/src/Yaf/Yaf_Response_Cli.php @@ -1,165 +1,213 @@ = 3.0.2) -*Class yaf_Response_Cli +*命令行下响应对象 */ class Yaf_Response_Cli extends Yaf_Response_Abstract { /** - * + *默认内容 */ const DEFAULT_BODY = 'content'; /** - * @var unknown $_header - * (Yaf >= 3.0.2) + * @var array $_header * 响应报头 * @access protected - protected $_header; + */ + protected $_header = array(); /** - * @var unknown $_body - * (Yaf >= 3.0.2) - * 响应正文 + * @var string $_body + * 响应体 * @access protected + */ protected $_body; /** - * @var unknown $_sendheader - * (Yaf >= 3.0.2) + * @var bool $_sendheader * 是否开启已输出响应报头检测 * @access protected - protected $_sendheader = ''; + */ + protected $_sendheader = false; /** * - *(Yaf >= 3.0.2) *构造方法 * @example * @return */ public function __construct() { + } /** * - *(Yaf >= 3.0.2) *析构方法 * @example * @return */ public function __destruct() { + } /** * - *(Yaf >= 3.0.2) *重置__clone魔术方法 * @example * @return */ private function __clone() { + } /** * - *(Yaf >= 3.0.2) *返回响应正文的字符串 * @example * @return */ public function __toString() { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 + * @param string $body 响应正文内容(可覆盖原来的) + * @param string $name 响应正文类型,默认为content * @return */ - public function setBody($body, $name) + public function setBody(string $body, string $name = 'content') + { + + } + + /** + * + *获取类型为$name的响应正文内容 + * @example + * @param string $name 响应正文类型,默认为content + * @return string|null + */ + public function getBody(string $name = 'content'): ?string { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function appendBody($body, $name) + public function appendBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function prependBody($body, $name) + public function prependBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) *清空响应正文 * @example - * @param mixed $name * @return */ - public function clearBody($name) + public function clearBody() { + } /** * - *(Yaf >= 3.0.2) - *获取类型为$name的响应正文内容 + *获取响应报头 + * @example + * @return array + */ + public function getHeader(): array + { + + } + + /** + * + *批量设置响应报头 + * @example + * @param array $headers 响应头列表 + * @return + */ + public function setAllHeaders(Array $headers) + { + + } + + /** + * + *设置响应报头 + * @example + * @return + */ + public function setHeader() + { + + } + + /** + * + *清空响应报头 + * @example + * @return + */ + public function clearHeaders() + { + + } + + /** + * + *将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) * @example - * @param string $name (Yaf >= 3.0.2) -获取类型为$name的响应正文内容 + * @param string $url 重定向的绝对URL * @return */ - public function getBody($name) + public function setRedirect(string $url) { + } /** * - *(Yaf >= 3.0.2) *输出所有的响应正文 * @example * @return */ public function response() { + } } diff --git a/src/Yaf/Yaf_Response_Http.php b/src/Yaf/Yaf_Response_Http.php index 146960a..47b6eba 100644 --- a/src/Yaf/Yaf_Response_Http.php +++ b/src/Yaf/Yaf_Response_Http.php @@ -1,235 +1,220 @@ = 3.0.2) -*Class yaf_Response_Http +*HTTP响应 */ class Yaf_Response_Http extends Yaf_Response_Abstract { /** - * + *默认内容 */ const DEFAULT_BODY = 'content'; /** - * @var unknown $_header - * (Yaf >= 3.0.2) + * @var array $_header * 响应报头 * @access protected - protected $_header; + */ + protected $_header = array(); /** - * @var unknown $_body - * (Yaf >= 3.0.2) + * @var string $_body * 响应正文 * @access protected + */ protected $_body; /** - * @var unknown $_sendheader - * (Yaf >= 3.0.2) + * @var bool $_sendheader * 是否开启已输出响应报头检测 * @access protected - protected $_sendheader = '1'; + */ + protected $_sendheader = true; /** - * @var unknown $_response_code - * (Yaf >= 3.0.2) + * @var int $_response_code * 响应状态码 * @access protected + */ protected $_response_code = 0; /** * - *(Yaf >= 3.0.2) - *设置响应报头 + *构造方法 * @example - * @param mixed $name - * @param mixed $value - * @param mixed $rep - * @param mixed $response_code * @return */ - public function setHeader($name, $value, $rep, $response_code) + public function __construct() { + } /** * - *(Yaf >= 3.0.2) - *获取所有响应报头 + *析构方法 * @example - * @param mixed $headers * @return */ - public function setAllHeaders($headers) + public function __destruct() { + } /** * - *(Yaf >= 3.0.2) - *获取响应报头 + *重置__clone魔术方法 * @example - * @param mixed $name * @return */ - public function getHeader($name) + private function __clone() { + } /** * - *(Yaf >= 3.0.2) - *清空响应报头 + *返回响应正文的字符串 * @example * @return */ - public function clearHeaders() + public function __toString() { + } /** * - *(Yaf >= 3.0.2) - *将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) + *设置类型为$name的响应正文内容 * @example - * @param string $url (Yaf >= 3.0.2) -将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) + * @param string $body 响应正文内容(可覆盖原来的) + * @param string $name 响应正文类型,默认为content * @return */ - public function setRedirect($url) + public function setBody(string $body, string $name = 'content') { + } /** * - *(Yaf >= 3.0.2) - *输出所有的响应正文 + *获取类型为$name的响应正文内容 * @example + * @param string $name 响应正文类型,默认为content * @return */ - public function response() + public function getBody(string $name = 'content') { + } /** * - *(Yaf >= 3.0.2) - *构造方法 + *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 * @example + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function __construct() + public function appendBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) - *析构方法 + *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 * @example + * @param string $body 响应正文内容(可追加) + * @param string $name 响应正文类型,默认为content * @return */ - public function __destruct() + public function prependBody(string $body, string $name) { + } /** * - *(Yaf >= 3.0.2) - *重置__clone魔术方法 + *清空响应正文 * @example * @return */ - private function __clone() + public function clearBody() { + } /** * - *(Yaf >= 3.0.2) - *返回响应正文的字符串 + *获取响应报头 * @example * @return */ - public function __toString() + public function getHeader() { + } /** * - *(Yaf >= 3.0.2) - *设置类型为$name的响应正文内容 + *批量设置响应报头 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容 + * @param array $headers 响应头列表 * @return */ - public function setBody($body, $name) + public function setAllHeaders(Array $headers) { + } /** * - *(Yaf >= 3.0.2) - *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 + *设置响应报头 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的后面 * @return */ - public function appendBody($body, $name) + public function setHeader() { + } /** * - *(Yaf >= 3.0.2) - *设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 + *清空响应报头 * @example - * @param string $body (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 - * @param string $name (Yaf >= 3.0.2) -设置类型为$name的响应正文内容, 如已存在,则追加到原来正文的前面 * @return */ - public function prependBody($body, $name) + public function clearHeaders() { + } /** * - *(Yaf >= 3.0.2) - *清空响应正文 + *将当前请求重定向到指定的URL(内部实现是通过发送Location报头实现,如:header("Location:http//www.phpboy.net/")) * @example - * @param mixed $name + * @param string $url 重定向的绝对URL * @return */ - public function clearBody($name) + public function setRedirect(string $url) { + } /** * - *(Yaf >= 3.0.2) - *获取类型为$name的响应正文内容 + *输出所有的响应正文 * @example - * @param string $name (Yaf >= 3.0.2) -获取类型为$name的响应正文内容 * @return */ - public function getBody($name) + public function response() { + } } diff --git a/src/Yaf/Yaf_Route_Interface.php b/src/Yaf/Yaf_Route_Interface.php index 98dc915..f7ca921 100644 --- a/src/Yaf/Yaf_Route_Interface.php +++ b/src/Yaf/Yaf_Route_Interface.php @@ -1,33 +1,33 @@ = 3.0.2) -*Class yaf_Route_Map +*map路由 */ -final class Yaf_Route_Map +final class Yaf_Route_Map implements Yaf_Route_Interface { /** * @var unknown $_ctl_router - * (Yaf >= 3.0.2) * 表示路由结果是作为动作的路由结果,还是控制器的路由结果,默认的是动作路由结果. * @access protected + */ protected $_ctl_router = ''; /** * @var unknown $_delimiter * * @access protected + */ protected $_delimiter; /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param mixed $controller_prefer - * @param mixed $delimiter + * @param bool $controller_prefer 表示路由结果是作为动作的路由结果,还是控制器的路由结果,默认的是动作路由结果 + * @param string $delimiter 表示一个分隔符,如果设置了这个分隔符,那么在REQUEST_URI中,分隔符之前的作为路由信息载体,而之后的作为请求参数. * @return */ - public function __construct($controller_prefer, $delimiter) + public function __construct(bool $controller_prefer = false, string $delimiter = '') { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Yaf_Route_Regex.php b/src/Yaf/Yaf_Route_Regex.php index 8be1866..42260ce 100644 --- a/src/Yaf/Yaf_Route_Regex.php +++ b/src/Yaf/Yaf_Route_Regex.php @@ -1,92 +1,89 @@ = 3.0.2) -*Class yaf_Route_Regex +*yaf正则路由 */ -final class Yaf_Route_Regex +final class Yaf_Route_Regex implements Yaf_Route_Interface { /** - * @var unknown $_route - * (Yaf >= 3.0.2) + * @var array $_route * 匹配模式(正则表达式) * @access protected - protected $_route; + */ + protected $_route = array(); /** - * @var unknown $_default - * (Yaf >= 3.0.2) + * @var array $_default * 路由信息 * @access protected - protected $_default; + */ + protected $_default = array(); /** - * @var unknown $_maps - * (Yaf >= 3.0.2) + * @var array $_maps * 模式分组的映射关系 * @access protected - protected $_maps; + */ + protected $_maps = array(); /** - * @var unknown $_verify - * (Yaf >= 3.0.2) - * 哥也不清楚(实在没有查到作用,源码也没看出所以然,问鸟哥!) + * @var array $_verify + * * @access protected - protected $_verify; + */ + protected $_verify = array(); /** - * @var unknown $_reverse + * @var string $_reverse * * @access protected + */ protected $_reverse; /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param string $match (Yaf >= 3.0.2) -构造方法 - * @param array $route (Yaf >= 3.0.2) -构造方法 - * @param array $map (Yaf >= 3.0.2) -构造方法 - * @param mixed $verify - * @param mixed $reverse + * @param string $match 匹配模式(正则表达式) + * @param array $route 路由信息 + * @param array $map 模式分组的映射关系 + * @param array $verify + * @param string $reverse * @return */ - public function __construct($match, Array $route, Array $map, $verify, $reverse) + public function __construct(string $match, Array $route, Array $map, Array $verify, string $reverse ) { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Yaf_Route_Rewrite.php b/src/Yaf/Yaf_Route_Rewrite.php index f784eff..1ca3142 100644 --- a/src/Yaf/Yaf_Route_Rewrite.php +++ b/src/Yaf/Yaf_Route_Rewrite.php @@ -1,76 +1,73 @@ = 3.0.2) -*Class yaf_Route_Rewrite +*重写路由 */ -final class Yaf_Route_Rewrite +final class Yaf_Route_Rewrite implements Yaf_Route_Interface { /** - * @var unknown $_route - * (Yaf >= 3.0.2) - * 匹配模式(正则表达式) + * @var array $_route + * 路由信息 * @access protected - protected $_route; + */ + protected $_route = array(); /** - * @var unknown $_default - * (Yaf >= 3.0.2) - * 路由信息 + * @var array $_default + * 默认路由信息 * @access protected - protected $_default; + */ + protected $_default = array(); /** - * @var unknown $_verify - * (Yaf >= 3.0.2) - * 哥也不清楚(实在没有查到作用,源码也没看出所以然,问鸟哥!) + * @var array $_verify + * * @access protected - protected $_verify; + */ + protected $_verify = array(); /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param string $match (Yaf >= 3.0.2) -构造方法 - * @param array $route (Yaf >= 3.0.2) -构造方法 - * @param mixed $verify + * @param string $match 匹配模式(正则表达式) + * @param array $route 路由信息 + * @param array $verify * @return */ - public function __construct($match, Array $route, $verify) + public function __construct(string $match, Array $route, Array $verify) { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Yaf_Route_Simple.php b/src/Yaf/Yaf_Route_Simple.php index 8857c26..4552a28 100644 --- a/src/Yaf/Yaf_Route_Simple.php +++ b/src/Yaf/Yaf_Route_Simple.php @@ -1,74 +1,73 @@ = 3.0.2) -*Class yaf_Route_Simple +*简单路由 */ -final class Yaf_Route_Simple +final class Yaf_Route_Simple implements Yaf_Route_Interface { /** - * @var unknown $controller - * (Yaf >= 3.0.2) + * @var string $controller * 控制器名 * @access protected + */ protected $controller; /** - * @var unknown $module - * (Yaf >= 3.0.2) + * @var string $module * 模块名 * @access protected + */ protected $module; /** - * @var unknown $action - * (Yaf >= 3.0.2) + * @var string $action * 动作名 * @access protected + */ protected $action; /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param mixed $module_name - * @param mixed $controller_name - * @param mixed $action_name + * @param string $module 模块名 + * @param string $controller 控制器名 + * @param string $action 动作名 * @return */ - public function __construct($module_name, $controller_name, $action_name) + public function __construct(string $module, string $controller, string $action) { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Yaf_Route_Static.php b/src/Yaf/Yaf_Route_Static.php index 6dc7744..4d3d95c 100644 --- a/src/Yaf/Yaf_Route_Static.php +++ b/src/Yaf/Yaf_Route_Static.php @@ -1,51 +1,50 @@ = 3.0.2) -*Class yaf_Route_Static +*静态路由 */ -class Yaf_Route_Static +class Yaf_Route_Static implements Yaf_Route_Interface { /** * - *(Yaf >= 3.0.2) *匹配请求 * @example - * @param mixed $uri + * @param string $uri 匹配的uri * @return */ - public function match($uri) + public function match(string $uri) { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Yaf_Route_Supervar.php b/src/Yaf/Yaf_Route_Supervar.php index a55282e..43c1cb3 100644 --- a/src/Yaf/Yaf_Route_Supervar.php +++ b/src/Yaf/Yaf_Route_Supervar.php @@ -1,58 +1,57 @@ = 3.0.2) -*Class yaf_Route_Supervar +*变量路由 */ -final class Yaf_Route_Supervar +final class Yaf_Route_Supervar implements Yaf_Route_Interface { /** - * @var unknown $_var_name - * (Yaf >= 3.0.2) + * @var string $_var_name * 全局路由变量名 * @access protected + */ protected $_var_name; /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param mixed $supervar_name + * @param string $var 全局路由变量名 * @return */ - public function __construct($supervar_name) + public function __construct(string $var) { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @param mixed $request - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route($request) + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 2.3.2) - *组合uri,路由解析的逆操作 + *组装请求 * @example - * @param mixed $info - * @param mixed $query - * @return + * @param array $info 路径信息 + * @param array $query 查询字符串 + * @return string */ - public function assemble($info, $query) + public function assemble(Array $info, Array $query): string { + } } diff --git a/src/Yaf/Yaf_Router.php b/src/Yaf/Yaf_Router.php index b7b50e6..5b3c95e 100644 --- a/src/Yaf/Yaf_Router.php +++ b/src/Yaf/Yaf_Router.php @@ -1,105 +1,109 @@ = 3.0.2) -*Class yaf_Router +*yaf路由器 */ final class Yaf_Router { /** - * @var unknown $_routes - * (Yaf >= 3.0.2) + * @var array $_routes * 路由器已有的路由协议栈, 默认的栈底总是名为"default"的Route_Static路由协议的实例 * @access protected - protected $_routes; + */ + protected $_routes = array(); /** - * @var unknown $_current - * (Yaf >= 3.0.2) + * @var int $_current * 在路由成功后, 路由生效的路由协议实例的索引 * @access protected + */ protected $_current; /** * - *(Yaf >= 3.0.2) *构造方法 * @example * @return */ public function __construct() { + } /** * - *(Yaf >= 3.0.2) *往Router中添加新的路由 * @example - * @return + * @param string $name 别名 + * @param Yaf_Route_Interface $route 路由对象 + * @return bool */ - public function addRoute() + public function addRoute(string $name, Yaf_Route_Interface $route): bool { + } /** * - *(Yaf >= 3.0.2) *向Router中添加配置文件或者配置数组定义的路由 * @example - * @return + * @param Yaf_Config_Abstract $config 配置对象 + * @return bool */ - public function addConfig() + public function addConfig(Yaf_Config_Abstract $config): bool { + } /** * - *(Yaf >= 3.0.2) *路由请求 * @example - * @return + * @param Yaf_Request_Abstract $request 请求对象 + * @return bool */ - public function route() + public function route(Yaf_Request_Abstract $request): bool { + } /** * - *(Yaf >= 3.0.2) *获取路由名对应的路由协议实例 * @example - * @return + * @param string $name 路由名 + * @return string */ - public function getRoute() + public function getRoute(string $name): string { + } /** * - *(Yaf >= 3.0.2) *获取已注册的所有路由协议 * @example - * @return + * @return array */ - public function getRoutes() + public function getRoutes(): array { + } /** * - *(Yaf >= 3.0.2) *获取当前路由成功的路由协议实例 * @example - * @return + * @return string */ - public function getCurrentRoute() + public function getCurrentRoute(): string { + } } diff --git a/src/Yaf/Yaf_Session.php b/src/Yaf/Yaf_Session.php index 92c7fac..e9bca75 100644 --- a/src/Yaf/Yaf_Session.php +++ b/src/Yaf/Yaf_Session.php @@ -1,332 +1,301 @@ = 3.0.2) -*Class yaf_Session +*yaf的会话对象 */ -final class Yaf_Session +final class Yaf_Session implements Iterator,ArrayAccess, Countable { /** - * @var unknown $_instance - * + * @var Yaf_Session $_instance + * session对象 * @access protected + */ protected static $_instance; /** - * @var unknown $_session - * + * @var array $_session + * session存储对象 * @access protected - protected $_session; + */ + protected $_session = array(); /** - * @var unknown $_started - * + * @var bool $_started + * 是否开启session * @access protected - protected $_started = ''; + */ + protected $_started = false; /** * - *(Yaf >= 3.0.2) *重置__construct魔术方法. * @example * @return */ private function __construct() { + } /** * - *(Yaf >= 3.0.2) *重置__clone魔术方法(因为是单例模式). * @example * @return */ private function __clone() { + } /** * - *(Yaf >= 3.0.2) *重置__sleep魔术方法. * @example * @return */ private function __sleep() { + } /** * - *(Yaf >= 3.0.2) *重置__wakeup魔术方法. * @example * @return */ private function __wakeup() { + } /** * - *(Yaf >= 3.0.2) *获取Session实例(单例模式) * @example - * @return + * @return Yaf_Session */ - public static function getInstance() + public static function getInstance(): Yaf_Session { + } /** * - *(Yaf >= 3.0.2) *开启会话 * @example * @return */ public function start() { + } /** * - *(Yaf >= 3.0.2) - *获取session变量 + *重置__destruct魔术方法. * @example - * @param string $name (Yaf >= 3.0.2) -获取session变量 * @return */ - public function get($name) + public function __destruct() { + } /** * - * + *魔术方法,当isset()检测session变量是否存在时调用 * @example - * @param mixed $name + * @param string $name 节点名称 * @return */ - public function has($name) + public function __isset(string $name) { + } /** * - *(Yaf >= 3.0.2) - *设置session变量 + *获取session变量 * @example - * @param string $name (Yaf >= 3.0.2) -设置session变量 - * @param mixed $value (Yaf >= 3.0.2) -设置session变量 + * @param string $name 变量名 * @return */ - public function set($name, $value) + public function get(string $name) { + } /** * - *(Yaf >= 3.0.2) - *撤消session变量 + *设置session变量 * @example - * @param string $name (Yaf >= 3.0.2) -撤消session变量 + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function del($name) + public function set(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) - *返回session变量的数量 + *撤消session变量 * @example + * @param string $name 变量名 * @return */ - public function count() + public function del(string $name) { + } /** * - *(Yaf >= 3.0.2) - *重置遍历位置 + *返回session变量的数量 * @example * @return */ - public function rewind() + public function count() { + } /** * - *(Yaf >= 3.0.2) - *向前移动到下一个元素 + *重置遍历位置 * @example * @return */ - public function next() + public function rewind() { + } /** * - *(Yaf >= 3.0.2) *返回当前变量 * @example * @return */ public function current() { + } /** * - *(Yaf >= 3.0.2) - *返回当前配置节点的key + *向前移动到下一个元素 * @example * @return */ - public function key() + public function next() { + } /** * - *(Yaf >= 3.0.2) *判断是否可以继续遍历 * @example * @return */ public function valid() { + } /** * - * - * @example - * @return - */ - public function clear() - { - } - - /** - * - *(Yaf >= 3.0.2) - *获取session变量 + *返回当前配置节点的key * @example - * @param string $name (Yaf >= 3.0.2) -获取session变量 * @return */ - public function offsetGet($name) + public function key() { + } /** * - *(Yaf >= 3.0.2) - *设置session变量 + *撤消某个session变量 * @example - * @param string $name (Yaf >= 3.0.2) -设置session变量 - * @param mixed $value (Yaf >= 3.0.2) -设置session变量 + * @param string $name 变量名 * @return */ - public function offsetSet($name, $value) + public function offsetUnset(string $name) { + } /** * - *(Yaf >= 3.0.2) *测试某个session变量是否存在 * @example - * @param mixed $name (Yaf >= 3.0.2) -测试某个session变量是否存在 + * @param mixed $name 变量名 * @return */ public function offsetExists($name) { + } /** * - *(Yaf >= 3.0.2) - *撤消某个session变量 + *获取session变量 * @example - * @param string $name (Yaf >= 3.0.2) -撤消某个session变量 + * @param string $name 变量名 * @return */ - public function offsetUnset($name) + public function offsetGet(string $name) { + } /** * - *(Yaf >= 3.0.2) - *获取session变量值 - *当不传递$name参数时,返回全部变量 + *设置session变量 * @example - * @param mixed $name + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function __get($name) + public function offsetSet(string $name, $value) { + } /** * - *(Yaf >= 3.0.2) - *魔术方法,当isset()检测session变量是否存在时调用 + *获取session变量值 + *当不传递$name参数时,返回全部变量 * @example - * @param string $name (Yaf >= 3.0.2) -魔术方法,当isset()检测session变量是否存在时调用 + * @param string $name session键名 * @return */ - public function __isset($name) + public function __get(string $name) { + } /** * - *(Yaf >= 3.0.2) *设置session变量 * @example - * @param string $name (Yaf >= 3.0.2) -设置session变量 - * @param mixed $value (Yaf >= 3.0.2) -设置session变量 - * @return - */ - public function __set($name, $value) - { - } - - /** - * - * - * @example - * @param mixed $name + * @param string $name 变量名 + * @param mixed $value 变量值 * @return */ - public function __unset($name) + public function __set(string $name, $value) { + } } diff --git a/src/Yaf/Yaf_View_Interface.php b/src/Yaf/Yaf_View_Interface.php index b0bcdef..2faa72e 100644 --- a/src/Yaf/Yaf_View_Interface.php +++ b/src/Yaf/Yaf_View_Interface.php @@ -1,61 +1,61 @@ = 3.0.2) -*Class yaf_View_Simple +*简单视图对象 */ -class Yaf_View_Simple +class Yaf_View_Simple implements Yaf_View_Interface { /** - * @var unknown $_tpl_vars - * (Yaf >= 3.0.2) + * @var array $_tpl_vars * 储存所有模板变量 * @access protected - protected $_tpl_vars; + */ + protected $_tpl_vars = array(); /** - * @var unknown $_tpl_dir - * (Yaf >= 3.0.2) + * @var string $_tpl_dir * 模板文件目录 * @access protected + */ protected $_tpl_dir; /** - * @var unknown $_options - * (Yaf >= 3.0.2) + * @var array $_options + * 配置选项 * @access protected - protected $_options; + */ + protected $_options = array(); /** * - *(Yaf >= 3.0.2) *构造方法 * @example - * @param mixed $template_dir - * @param array $options (Yaf >= 3.0.2) -构造方法 + * @param string $tpl_dir 模板文件目录 + * @param array $options 此属性在php-5.4以下版本中适用,用以设置模板渲染的方式 * @return */ - public final function __construct($template_dir, Array $options) + public function __construct(string $tpl_dir, Array $options) { + } /** * - *(Yaf >= 3.0.2) *当isset检测某个属性是否存在时自动调用(判断是否传递某个模板变量) * @example - * @param string $name (Yaf >= 3.0.2) -当isset检测某个属性是否存在时自动调用(判断是否传递某个模板变量) + * @param string $name 模板变量名 * @return */ - public function __isset($name) + public function __isset(string $name) { + } /** * - *(Yaf >= 3.0.2) *获取某个模板变量的值 * @example - * @param string $name (Yaf >= 3.0.2) -获取某个模板变量的值 + * @param string $name 模板变量名 * @return */ - public function get($name) + public function __get(string $name) { + } /** * - *(Yaf >= 3.0.2) - *传递变量到模板 + *获取某个模板变量的值 * @example - * @param string $name (Yaf >= 3.0.2) -传递变量到模板 - * @param string $value (Yaf >= 3.0.2) -传递变量到模板 + * @param string $name 模板变量名 * @return */ - public function assign($name, $value) + public function get(string $name) { + } /** * - *(Yaf >= 3.0.2) - *渲染模板并返回结果 + *传递变量到模板 * @example - * @param string $tpl (Yaf >= 3.0.2) -渲染模板并返回结果 - * @param mixed $tpl_vars + * @param string $name 变量名 + * @param string $value 变量值 * @return */ - public function render($tpl, $tpl_vars) + public function __set(string $name, string $value) { + } /** * - * + *清空某个模板变量的值 * @example - * @param mixed $tpl_str - * @param mixed $vars + * @param string $name 模板变量名 * @return */ - public function eval($tpl_str, $vars) + public function clear(string $name) { + } /** * - *(Yaf >= 3.0.2) - *渲染模板并直接输出 + *传递变量到模板 * @example - * @param string $tpl (Yaf >= 3.0.2) -渲染模板并直接输出 - * @param mixed $tpl_vars + * @param string $name 变量名 + * @param string $value 变量值 * @return */ - public function display($tpl, $tpl_vars) + public function assign(string $name, string $value) { + } /** * - *(Yaf >= 3.0.2) *以引用的方式传递变量到模板 * @example - * @param string $name (Yaf >= 3.0.2) -以引用的方式传递变量到模板 - * @param string $value (Yaf >= 3.0.2) -以引用的方式传递变量到模板 - * @return - */ - public function assignRef($name, $value) - { - } - - /** - * - *(Yaf >= 3.0.2) - *清空某个模板变量的值 - * @example - * @param string $name (Yaf >= 3.0.2) -清空某个模板变量的值 + * @param string $name 变量名 + * @param string $value 变量值 * @return */ - public function clear($name) + public function assignRef(string $name, string $value) { + } /** * - *(Yaf >= 3.0.2) - *设置模板文件目录 + *渲染模板并直接输出 * @example - * @param mixed $template_dir + * @param string $tpl 模板文件名 + * @param array $var_array 模板变量数组 * @return */ - public function setScriptPath($template_dir) + public function display(string $tpl, Array $var_array = []) { + } /** * - *(Yaf >= 3.0.2) - *获取模板目录文件 + *渲染模板并返回结果 * @example + * @param string $tpl 模板文件名 + * @param array $var_array 模板变量数组 * @return */ - public function getScriptPath() + public function render(string $tpl, Array $var_array = []) { + } /** * - *(Yaf >= 3.0.2) - *获取某个模板变量的值 + *设置模板文件目录 * @example - * @param string $name (Yaf >= 3.0.2) -获取某个模板变量的值 + * @param string $tpl_dir 模板文件目录 * @return */ - public function __get($name) + public function setScriptPath(string $tpl_dir) { + } /** * - *(Yaf >= 3.0.2) - *传递变量到模板 + *获取模板目录文件 * @example - * @param string $name (Yaf >= 3.0.2) -传递变量到模板 - * @param string $value (Yaf >= 3.0.2) -传递变量到模板 - * @return + * @return string */ - public function __set($name, $value) + public function getScriptPath(): string { + } } diff --git a/src/Yaf/yaf.namespace.php b/src/Yaf/yaf.namespace.php new file mode 100644 index 0000000..851fe2e --- /dev/null +++ b/src/Yaf/yaf.namespace.php @@ -0,0 +1,92 @@ + Date: Sun, 20 May 2018 13:42:20 +0800 Subject: [PATCH 15/34] =?UTF-8?q?=E6=9B=B4=E6=96=B0yac=E5=92=8Cyaconf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- src/Yac/Yac.php | 140 ++++++++++++++++++++++++++++-------------- src/Yaconf/Yaconf.php | 43 +++++++++---- 3 files changed, 128 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 07465a3..198a411 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 1、Yaf(3.0.7) -2、Yac +2、Yac(2.0.3-dev) -3、Yaconf +3、Yaconf(1.0.8-dev) 4、Yar diff --git a/src/Yac/Yac.php b/src/Yac/Yac.php index 84538f0..f5e9e60 100644 --- a/src/Yac/Yac.php +++ b/src/Yac/Yac.php @@ -1,38 +1,61 @@ goods = 'apple';//相当于$yac->set('goods', 'apple'); + * @param string $key 键 + * @param mixed $value 值 * @return */ - public function __set($key, $value) + public function __set(string $key, $value) { + } /** * - * - * @example - * @param mixed $keys + *获取某个键的值或某些键的值 + * @example $yac->get('goods'); + * $yac->get(array('goods', 'test')); + * @param mixed $keys 键名 * @return */ public function get($keys) { + } /** * - * - * @example - * @param mixed $key + *获取某个键值的魔术方法 + * @example return $yac->goods;//相当于$yac->get('goods') + * @param string $key 键名 * @return */ - public function __get($key) + public function __get(string $key) { + } /** * - * - * @example - * @param mixed $keys - * @param mixed $ttl + *删除某个键或某几个键 + * @example $yac->delete('goods'); + * $yac->delete(array('goods', 'test')); + * @param mixed $keys 要删除的键 + * @param int $ttl 延迟删除时间 * @return */ - public function delete($keys, $ttl) + public function delete($keys, int $ttl) { + } /** * - * + *刷新缓存,即清空缓存 * @example * @return */ public function flush() { + } /** * - * - * @example - * @return + *获取缓存使用情况等信息 + * @example var_dump($yac->info()); + * array(11) { ["memory_size"]=> int(541065216) + * ["slots_memory_size"]=> int(4194304) + * ["values_memory_size"]=> int(536870912) + * ["segment_size"]=> int(4194304) + * ["segment_num"]=> int(128) + * ["miss"]=> int(0) + * ["hits"]=> int(955) + * ["fails"]=> int(0) + * ["kicks"]=> int(0) + * ["slots_size"]=> int(32768) + * ["slots_used"]=> int(955) + * } + * @return array */ - public function info() + public function info(): array { + } /** * - * + *导出缓存 * @example * @return */ public function dump() { + } } diff --git a/src/Yaconf/Yaconf.php b/src/Yaconf/Yaconf.php index 6fdb58a..90577dd 100644 --- a/src/Yaconf/Yaconf.php +++ b/src/Yaconf/Yaconf.php @@ -1,35 +1,56 @@ Date: Sun, 20 May 2018 14:28:37 +0800 Subject: [PATCH 16/34] update yar --- README.md | 2 +- src/Yar/Yar_Client.php | 73 +++++++------- src/Yar/Yar_Client_Exception.php | 100 ++++++++++--------- src/Yar/Yar_Client_Packager_Exception.php | 100 ++++++++++--------- src/Yar/Yar_Client_Protocol_Exception.php | 100 ++++++++++--------- src/Yar/Yar_Client_Transport_Exception.php | 100 ++++++++++--------- src/Yar/Yar_Concurrent_Client.php | 63 ++++++------ src/Yar/Yar_Server.php | 21 ++-- src/Yar/Yar_Server_Exception.php | 100 ++++++++++--------- src/Yar/Yar_Server_Output_Exception.php | 100 ++++++++++--------- src/Yar/Yar_Server_Packager_Exception.php | 100 ++++++++++--------- src/Yar/Yar_Server_Protocol_Exception.php | 100 ++++++++++--------- src/Yar/Yar_Server_Request_Exception.php | 100 ++++++++++--------- src/Yar/yar.php | 110 +++++++++++++++++++++ 14 files changed, 699 insertions(+), 470 deletions(-) create mode 100644 src/Yar/yar.php diff --git a/README.md b/README.md index 198a411..5c5d2ca 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 3、Yaconf(1.0.8-dev) -4、Yar +4、Yar(2.0.4) 5、Redis(包括RedisCluster) diff --git a/src/Yar/Yar_Client.php b/src/Yar/Yar_Client.php index f153821..4ce7925 100644 --- a/src/Yar/Yar_Client.php +++ b/src/Yar/Yar_Client.php @@ -1,100 +1,105 @@ Date: Thu, 24 May 2018 20:12:12 +0800 Subject: [PATCH 17/34] =?UTF-8?q?=E6=9B=B4=E6=96=B0swoole=20=E5=88=B02.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/Swoole/Async.php | 26 +- src/Swoole/Atomic.php | 28 +- src/Swoole/Atomic/Long.php | 22 +- src/Swoole/Buffer.php | 28 +- src/Swoole/Chan.php | 32 +- src/Swoole/Channel.php | 18 +- src/Swoole/Client.php | 47 ++- src/Swoole/Co.php | 49 ++- src/Swoole/Co/Http/Client.php | 64 ++-- src/Swoole/Co/Http/Server.php | 109 ++++-- src/Swoole/Co/Http2/Client.php | 28 +- src/Swoole/Co/MySQL.php | 23 +- src/Swoole/Co/Redis.php | 445 +++++++++++++++------- src/Swoole/Co/Redis/Server.php | 119 ++++-- src/Swoole/Co/Server.php | 113 ++++-- src/Swoole/Co/WebSocket/Server.php | 122 ++++-- src/Swoole/Connection/Iterator.php | 26 +- src/Swoole/Coroutine.php | 49 ++- src/Swoole/Coroutine/Channel.php | 32 +- src/Swoole/Coroutine/Client.php | 60 +-- src/Swoole/Coroutine/Http/Client.php | 64 ++-- src/Swoole/Coroutine/Http2/Client.php | 28 +- src/Swoole/Coroutine/Http2/Request.php | 16 +- src/Swoole/Coroutine/MySQL.php | 23 +- src/Swoole/Coroutine/MySQL/Exception.php | 31 +- src/Swoole/Coroutine/MySQL/Statement.php | 8 +- src/Swoole/Coroutine/PostgreSQL.php | 36 +- src/Swoole/Coroutine/Redis.php | 445 +++++++++++++++------- src/Swoole/Coroutine/Socket.php | 183 +++++++++ src/Swoole/Coroutine/Socket/Exception.php | 167 ++++++++ src/Swoole/Event.php | 20 +- src/Swoole/Exception.php | 31 +- src/Swoole/Http/Client.php | 55 ++- src/Swoole/Http/Request.php | 30 +- src/Swoole/Http/Response.php | 55 ++- src/Swoole/Http/Server.php | 109 ++++-- src/Swoole/Http2/Client.php | 70 +++- src/Swoole/Http2/Response.php | 4 +- src/Swoole/Lock.php | 23 +- src/Swoole/Mmap.php | 7 +- src/Swoole/MsgQueue.php | 21 +- src/Swoole/MySQL.php | 22 +- src/Swoole/MySQL/Exception.php | 31 +- src/Swoole/Process.php | 63 ++- src/Swoole/Process/Pool.php | 20 +- src/Swoole/Redis.php | 21 +- src/Swoole/Redis/Server.php | 119 ++++-- src/Swoole/RingQueue.php | 11 +- src/Swoole/Serialize.php | 10 +- src/Swoole/Server.php | 113 ++++-- src/Swoole/Server/Port.php | 16 +- src/Swoole/Table.php | 57 ++- src/Swoole/Table/Row.php | 19 +- src/Swoole/Timer.php | 16 +- src/Swoole/WebSocket/Frame.php | 4 +- src/Swoole/WebSocket/Server.php | 122 ++++-- src/Swoole/swoole.namespace.php | 185 +++++---- src/Swoole/swoole.php | 183 +++++---- src/Swoole/swoole_async.php | 26 +- src/Swoole/swoole_atomic.php | 28 +- src/Swoole/swoole_atomic_long.php | 22 +- src/Swoole/swoole_buffer.php | 28 +- src/Swoole/swoole_channel.php | 18 +- src/Swoole/swoole_client.php | 47 ++- src/Swoole/swoole_connection_iterator.php | 26 +- src/Swoole/swoole_coroutine.php | 49 ++- src/Swoole/swoole_event.php | 20 +- src/Swoole/swoole_exception.php | 31 +- src/Swoole/swoole_http2_client.php | 70 +++- src/Swoole/swoole_http2_response.php | 4 +- src/Swoole/swoole_http_client.php | 55 ++- src/Swoole/swoole_http_request.php | 30 +- src/Swoole/swoole_http_response.php | 55 ++- src/Swoole/swoole_http_server.php | 109 ++++-- src/Swoole/swoole_lock.php | 23 +- src/Swoole/swoole_mmap.php | 7 +- src/Swoole/swoole_msgqueue.php | 21 +- src/Swoole/swoole_mysql.php | 22 +- src/Swoole/swoole_mysql_exception.php | 31 +- src/Swoole/swoole_process.php | 63 ++- src/Swoole/swoole_process_pool.php | 20 +- src/Swoole/swoole_redis.php | 21 +- src/Swoole/swoole_redis_server.php | 119 ++++-- src/Swoole/swoole_ringqueue.php | 11 +- src/Swoole/swoole_serialize.php | 10 +- src/Swoole/swoole_server.php | 113 ++++-- src/Swoole/swoole_server_port.php | 16 +- src/Swoole/swoole_table.php | 57 ++- src/Swoole/swoole_table_row.php | 19 +- src/Swoole/swoole_timer.php | 16 +- src/Swoole/swoole_websocket_frame.php | 4 +- src/Swoole/swoole_websocket_server.php | 122 ++++-- 93 files changed, 3593 insertions(+), 1600 deletions(-) create mode 100644 src/Swoole/Coroutine/Socket.php create mode 100644 src/Swoole/Coroutine/Socket/Exception.php diff --git a/README.md b/README.md index 5c5d2ca..f0668eb 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 5、Redis(包括RedisCluster) -6、swoole扩展(支持swoole 2.1.3) +6、swoole扩展(支持swoole 2.2) 7、SeasLog(1.7.6) diff --git a/src/Swoole/Async.php b/src/Swoole/Async.php index 30e5d49..32cb998 100644 --- a/src/Swoole/Async.php +++ b/src/Swoole/Async.php @@ -1,8 +1,8 @@ 0, + 'queue_bytes'=>0 + ]; } } diff --git a/src/Swoole/Client.php b/src/Swoole/Client.php index 92be4fa..14a1108 100644 --- a/src/Swoole/Client.php +++ b/src/Swoole/Client.php @@ -1,8 +1,8 @@ get('key'); * @return string|bool */ - public function get() + public function get(): ?string { + } /** @@ -258,6 +271,7 @@ public function get() */ public function mGet(Array $keys) { + } /** @@ -268,8 +282,9 @@ public function mGet(Array $keys) * @param array|string $keys 键名 * @return int */ - public function del($keys) + public function del(array $keys): int { + } /** @@ -297,8 +312,9 @@ public function del($keys) * @param string|array $fields 字段名 * @return int */ - public function hDel($key, $fields) + public function hDel(string $key, string $fields): int { + } /** @@ -317,8 +333,9 @@ public function hDel($key, $fields) * @param string $value 字段值 * @return long */ - public function hSet($key, $field, $value) + public function hSet(string $key, string $field, string $value): long { + } /** @@ -334,8 +351,9 @@ public function hSet($key, $field, $value) * @param array $fields 字段键值对 * @return boolean */ - public function hMSet($key, Array $fields) + public function hMSet(string $key, Array $fields): boolean { + } /** @@ -353,8 +371,9 @@ public function hMSet($key, Array $fields) * @param string $value 字段值 * @return bool */ - public function hSetNx($key, $field, $value) + public function hSetNx(string $key, string $field, string $value): bool { + } /** @@ -365,8 +384,9 @@ public function hSetNx($key, $field, $value) * @param array|string $keys 键名 * @return int */ - public function delete($keys) + public function delete(array $keys): int { + } /** @@ -384,8 +404,9 @@ public function delete($keys) * @param array $values 要设置的键值对 * @return bool */ - public function mSet(Array $values) + public function mSet(Array $values): bool { + } /** @@ -403,8 +424,9 @@ public function mSet(Array $values) * @param array $values 要设置的键值对 * @return bool */ - public function mSetNx(Array $values) + public function mSetNx(Array $values): bool { + } /** @@ -416,8 +438,9 @@ public function mSetNx(Array $values) * @param string $pattern 匹配模式 * @return array */ - public function getKeys($pattern) + public function getKeys(string $pattern): array { + } /** @@ -429,8 +452,9 @@ public function getKeys($pattern) * @param string $pattern 匹配模式 * @return array */ - public function keys($pattern) + public function keys(string $pattern): array { + } /** @@ -445,8 +469,9 @@ public function keys($pattern) * @param string $key 键名 * @return bool */ - public function exists($key) + public function exists(string $key): bool { + } /** @@ -456,8 +481,9 @@ public function exists($key) * @param string $key 键名 * @return int */ - public function type($key) + public function type(string $key): int { + } /** @@ -471,8 +497,9 @@ public function type($key) * @param string $key 键名 * @return int */ - public function strLen($key) + public function strLen(string $key): int { + } /** @@ -488,8 +515,9 @@ public function strLen($key) * @param string $key 键名 * @return string */ - public function lPop($key) + public function lPop(string $key): string { + } /** @@ -520,8 +548,9 @@ public function lPop($key) * @param int $timeout 超时时间 * @return array */ - public function blPop($key, $timeout) + public function blPop(string $key, int $timeout): array { + } /** @@ -537,8 +566,9 @@ public function blPop($key, $timeout) * @param string $key 键名 * @return string */ - public function rPop($key) + public function rPop(string $key): string { + } /** @@ -569,8 +599,9 @@ public function rPop($key) * @param int $timeout 超时时间 * @return array */ - public function brPop($key, $timeout) + public function brPop(string $key, int $timeout): array { + } /** @@ -581,8 +612,9 @@ public function brPop($key, $timeout) * @param string $dstKey 要插入元素的队列的键名 * @return string */ - public function bRPopLPush($srcKey, $dstKey) + public function bRPopLPush(string $srcKey, string $dstKey): string { + } /** @@ -592,8 +624,9 @@ public function bRPopLPush($srcKey, $dstKey) * @param string|...|array $key 键名 * @return long | bool */ - public function lSize($key) + public function lSize(string $key): ?long { + } /** @@ -603,8 +636,9 @@ public function lSize($key) * @param string|...|array $key 键名 * @return long | bool */ - public function lLen($key) + public function lLen(string $key): ?long { + } /** @@ -614,8 +648,9 @@ public function lLen($key) * @param string $key 键名 * @return long */ - public function sSize($key) + public function sSize(string $key): long { + } /** @@ -625,8 +660,9 @@ public function sSize($key) * @param string $key 键名 * @return long */ - public function scard($key) + public function scard(string $key): long { + } /** @@ -644,8 +680,9 @@ public function scard($key) * @param int $count 删除个数 * @return string | bool */ - public function sPop($key, $count) + public function sPop(string $key, int $count): ?string { + } /** @@ -672,8 +709,9 @@ public function sPop($key, $count) * @param string $key 键名 * @return array */ - public function sMembers($key) + public function sMembers(string $key): array { + } /** @@ -700,8 +738,9 @@ public function sMembers($key) * @param string $key 键名 * @return array */ - public function sGetMembers($key) + public function sGetMembers(string $key): array { + } /** @@ -723,8 +762,9 @@ public function sGetMembers($key) * @param string $key 键名 * @return string | bool */ - public function sRandMember($key) + public function sRandMember(string $key): ?string { + } /** @@ -734,8 +774,9 @@ public function sRandMember($key) * @param string $key 键名 * @return bool: */ - public function persist($key) + public function persist(string $key): bool: { + } /** @@ -745,8 +786,9 @@ public function persist($key) * @param string $key 键名 * @return long */ - public function ttl($key) + public function ttl(string $key): long { + } /** @@ -756,8 +798,9 @@ public function ttl($key) * @param string $key 键名 * @return long */ - public function pttl($key) + public function pttl(string $key): long { + } /** @@ -773,8 +816,9 @@ public function pttl($key) * @param string $key 集合键名 * @return int */ - public function zCard($key) + public function zCard(string $key): int { + } /** @@ -790,8 +834,9 @@ public function zCard($key) * @param string $key 集合键名 * @return int */ - public function zSize($key) + public function zSize(string $key): int { + } /** @@ -807,8 +852,9 @@ public function zSize($key) * @param string $key 键名 * @return int */ - public function hLen($key) + public function hLen(string $key): int { + } /** @@ -838,8 +884,9 @@ public function hLen($key) * @param string $key 键名 * @return array */ - public function hKeys($key) + public function hKeys(string $key): array { + } /** @@ -869,8 +916,9 @@ public function hKeys($key) * @param string $key 键名 * @return array */ - public function hVals($key) + public function hVals(string $key): array { + } /** @@ -900,8 +948,9 @@ public function hVals($key) * @param string $key 键名 * @return array */ - public function hGetAll($key) + public function hGetAll(string $key): array { + } /** @@ -912,6 +961,7 @@ public function hGetAll($key) */ public function debug() { + } /** @@ -928,8 +978,9 @@ public function debug() * @param string $value dump导出的二进制数据 * @return */ - public function restore($key, $ttl, $value) + public function restore(string $key, int $ttl, string $value) { + } /** @@ -943,8 +994,9 @@ public function restore($key, $ttl, $value) * @param string $key 键名 * @return string */ - public function dump($key) + public function dump(string $key): string { + } /** @@ -955,8 +1007,9 @@ public function dump($key) * @param string $dstKey 新键名 * @return boolean */ - public function renameKey($srcKey, $dstKey) + public function renameKey(string $srcKey, string $dstKey): boolean { + } /** @@ -967,8 +1020,9 @@ public function renameKey($srcKey, $dstKey) * @param string $dstKey 新键名 * @return boolean */ - public function rename($srcKey, $dstKey) + public function rename(string $srcKey, string $dstKey): boolean { + } /** @@ -979,8 +1033,9 @@ public function rename($srcKey, $dstKey) * @param string $dstKey 新键名 * @return boolean */ - public function renameNx($srcKey, $dstKey) + public function renameNx(string $srcKey, string $dstKey): boolean { + } /** @@ -1017,8 +1072,9 @@ public function renameNx($srcKey, $dstKey) * @param string $dstKey 要插入元素的队列的键名 * @return string */ - public function rpoplpush($srcKey, $dstKey) + public function rpoplpush(string $srcKey, string $dstKey): string { + } /** @@ -1031,8 +1087,9 @@ public function rpoplpush($srcKey, $dstKey) *
* @return string */ - public function randomKey() + public function randomKey(): string { + } /** @@ -1041,8 +1098,9 @@ public function randomKey() * @example * @return string */ - public function ping() + public function ping(): string { + } /** @@ -1052,8 +1110,9 @@ public function ping() * @param string $password 认证密码 * @return bool: */ - public function auth($password) + public function auth(string $password): bool: { + } /** @@ -1063,8 +1122,9 @@ public function auth($password) * @param string|array $keys 键名 * @return */ - public function unwatch($keys) + public function unwatch(string $keys) { + } /** @@ -1082,8 +1142,9 @@ public function unwatch($keys) * @param string|array $keys 键名 * @return */ - public function watch($keys) + public function watch(string $keys) { + } /** @@ -1092,8 +1153,9 @@ public function watch($keys) * @example $redis->save(); * @return boolean */ - public function save() + public function save(): boolean { + } /** @@ -1104,6 +1166,7 @@ public function save() */ public function bgSave() { + } /** @@ -1112,8 +1175,9 @@ public function bgSave() * @example $redis->lastSave(); * @return int */ - public function lastSave() + public function lastSave(): int { + } /** @@ -1122,8 +1186,9 @@ public function lastSave() * @example $redis->flushDB(); * @return bool */ - public function flushDB() + public function flushDB(): bool { + } /** @@ -1132,8 +1197,9 @@ public function flushDB() * @example $redis->flushAll(); * @return bool */ - public function flushAll() + public function flushAll(): bool { + } /** @@ -1146,8 +1212,9 @@ public function flushAll() *
* @return int */ - public function dbSize() + public function dbSize(): int { + } /** @@ -1156,8 +1223,9 @@ public function dbSize() * @example $redis->bgrewriteaof(); * @return bool */ - public function bgrewriteaof() + public function bgrewriteaof(): bool { + } /** @@ -1173,8 +1241,9 @@ public function bgrewriteaof() *
* @return int */ - public function time() + public function time(): int { + } /** @@ -1183,8 +1252,9 @@ public function time() * @example * @return string */ - public function role() + public function role(): string { + } /** @@ -1201,8 +1271,9 @@ public function role() * @param string $value 被替换的子串的值 * @return string */ - public function setRange($key, $offset, $value) + public function setRange(string $key, int $offset, string $value): string { + } /** @@ -1215,8 +1286,9 @@ public function setRange($key, $offset, $value) * @param string $value 设置的缓存值 * @return bool: */ - public function setNx($key, $value) + public function setNx(string $key, string $value): bool: { + } /** @@ -1232,8 +1304,9 @@ public function setNx($key, $value) * @param string $value 设置的缓存值 * @return string */ - public function getSet($key, $value) + public function getSet(string $key, string $value): string { + } /** @@ -1249,8 +1322,9 @@ public function getSet($key, $value) * @param string $value 追加的值 * @return int */ - public function append($key, $value) + public function append(string $key, string $value): int { + } /** @@ -1269,8 +1343,9 @@ public function append($key, $value) * @param string $value 元素值 * @return int */ - public function lPushx($key, $value) + public function lPushx(string $key, string $value): int { + } /** @@ -1292,8 +1367,9 @@ public function lPushx($key, $value) * @param string $value 元素值 * @return int */ - public function lPush($key, $value) + public function lPush(string $key, string $value): int { + } /** @@ -1315,8 +1391,9 @@ public function lPush($key, $value) * @param string $value 元素值 * @return int */ - public function rPush($key, $value) + public function rPush(string $key, string $value): int { + } /** @@ -1335,8 +1412,9 @@ public function rPush($key, $value) * @param string $value 元素值 * @return int */ - public function rPushx($key, $value) + public function rPushx(string $key, string $value): int { + } /** @@ -1347,8 +1425,9 @@ public function rPushx($key, $value) * @param string $member 成员值 * @return boolean */ - public function sContains($key, $member) + public function sContains(string $key, string $member): boolean { + } /** @@ -1359,8 +1438,9 @@ public function sContains($key, $member) * @param string $member 成员值 * @return boolean */ - public function sismember($key, $member) + public function sismember(string $key, string $member): boolean { + } /** @@ -1375,8 +1455,9 @@ public function sismember($key, $member) * @param string $member 成员值 * @return double */ - public function zScore($key, $member) + public function zScore(string $key, string $member): double { + } /** @@ -1396,8 +1477,9 @@ public function zScore($key, $member) * @param string $member 成员值 * @return int */ - public function zRank($key, $member) + public function zRank(string $key, string $member): int { + } /** @@ -1408,8 +1490,9 @@ public function zRank($key, $member) * @param string $member 成员值 * @return int */ - public function zRevRank($key, $member) + public function zRevRank(string $key, string $member): int { + } /** @@ -1420,8 +1503,9 @@ public function zRevRank($key, $member) * @param string $field 字段名 * @return string */ - public function hGet($key, $field) + public function hGet(string $key, string $field): string { + } /** @@ -1432,8 +1516,9 @@ public function hGet($key, $field) * @param array $fields 字段名列表 * @return array */ - public function hMGet($key, Array $fields) + public function hMGet(string $key, Array $fields): array { + } /** @@ -1449,8 +1534,9 @@ public function hMGet($key, Array $fields) * @param string $field 字段名 * @return bool */ - public function hExists($key, $field) + public function hExists(string $key, string $field): bool { + } /** @@ -1461,8 +1547,9 @@ public function hExists($key, $field) * @param string $message 消息 * @return int */ - public function publish($channel, $message) + public function publish(string $channel, string $message): int { + } /** @@ -1480,8 +1567,9 @@ public function publish($channel, $message) * @param string $member 成员 * @return float */ - public function zIncrBy($key, $step, $member) + public function zIncrBy(string $key, double $step, string $member): float { + } /** @@ -1505,8 +1593,9 @@ public function zIncrBy($key, $step, $member) * @param string $value 元素值 * @return int */ - public function zAdd($key, $score, $value) + public function zAdd(string $key, double $score, string $value): int { + } /** @@ -1518,8 +1607,9 @@ public function zAdd($key, $score, $value) * @param double $end 结束排序值 * @return long */ - public function zDeleteRangeByScore($key, $start, $end) + public function zDeleteRangeByScore(string $key, double $start, double $end): long { + } /** @@ -1531,8 +1621,9 @@ public function zDeleteRangeByScore($key, $start, $end) * @param double $end 结束排序值 * @return long */ - public function zRemRangeByScore($key, $start, $end) + public function zRemRangeByScore(string $key, double $start, double $end): long { + } /** @@ -1550,8 +1641,9 @@ public function zRemRangeByScore($key, $start, $end) * @param double $end 结束排序值 * @return int */ - public function zCount($key, $start, $end) + public function zCount(string $key, double $start, double $end): int { + } /** @@ -1572,8 +1664,9 @@ public function zCount($key, $start, $end) * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRange($key, $start, $end, $withScores) + public function zRange(string $key, long $start, long $end, boolean $withScores): array { + } /** @@ -1594,8 +1687,9 @@ public function zRange($key, $start, $end, $withScores) * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRevRange($key, $start, $end, $withScores) + public function zRevRange(string $key, long $start, long $end, boolean $withScores): array { + } /** @@ -1618,8 +1712,9 @@ public function zRevRange($key, $start, $end, $withScores) * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRangeByScore($key, $start, $end, Array $options) + public function zRangeByScore(string $key, long $start, long $end, Array $options): array { + } /** @@ -1642,8 +1737,9 @@ public function zRangeByScore($key, $start, $end, Array $options) * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRevRangeByScore($key, $start, $end, Array $options) + public function zRevRangeByScore(string $key, long $start, long $end, Array $options): array { + } /** @@ -1665,8 +1761,9 @@ public function zRevRangeByScore($key, $start, $end, Array $options) * @param long $limit 成员数 * @return array */ - public function zRangeByLex($key, $min, $max, $offset, $limit) + public function zRangeByLex(string $key, long $min, long $max, long $offset, long $limit): array { + } /** @@ -1680,8 +1777,9 @@ public function zRangeByLex($key, $min, $max, $offset, $limit) * @param long $limit 成员数 * @return */ - public function zRevRangeByLex($key, $min, $max, $offset, $limit) + public function zRevRangeByLex(string $key, long $min, long $max, long $offset, long $limit) { + } /** @@ -1713,8 +1811,9 @@ public function zRevRangeByLex($key, $min, $max, $offset, $limit) * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zInter($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zInter(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -1746,8 +1845,9 @@ public function zInter($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggrega * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zinterstore(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -1776,8 +1876,9 @@ public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $ag * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zUnion($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zUnion(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -1806,8 +1907,9 @@ public function zUnion($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggrega * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zunionstore(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -1825,8 +1927,9 @@ public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $ag * @param int $step 自增步长 * @return int */ - public function incrBy($key, $step) + public function incrBy(string $key, int $step): int { + } /** @@ -1843,8 +1946,9 @@ public function incrBy($key, $step) * @param int $step 自增步长 * @return int */ - public function hIncrBy($key, $field, $step) + public function hIncrBy(string $key, string $field, int $step): int { + } /** @@ -1860,8 +1964,9 @@ public function hIncrBy($key, $field, $step) * @param string $key 键名 * @return int */ - public function incr($key) + public function incr(string $key): int { + } /** @@ -1878,8 +1983,9 @@ public function incr($key) * @param float $step 自减步长 * @return int */ - public function decrBy($key, $step) + public function decrBy(string $key, float $step): int { + } /** @@ -1894,8 +2000,9 @@ public function decrBy($key, $step) * @param string $key 键名 * @return int */ - public function decr($key) + public function decr(string $key): int { + } /** @@ -1911,8 +2018,9 @@ public function decr($key) * @param int $offset 所在位置 * @return int */ - public function getBit($key, $offset) + public function getBit(string $key, int $offset): int { + } /** @@ -1937,8 +2045,9 @@ public function getBit($key, $offset) * @param string $value 新值 * @return int */ - public function lInsert($key, $position, $element, $value) + public function lInsert(string $key, string $position, string $element, string $value): int { + } /** @@ -1949,8 +2058,9 @@ public function lInsert($key, $position, $element, $value) * @param int $index 索引值 * @return string | boolean */ - public function lGet($key, $index) + public function lGet(string $key, int $index): ?string { + } /** @@ -1961,8 +2071,9 @@ public function lGet($key, $index) * @param int $index 索引值 * @return string | boolean */ - public function lIndex($key, $index) + public function lIndex(string $key, int $index): ?string { + } /** @@ -1973,8 +2084,9 @@ public function lIndex($key, $index) * @param int $ttl 有效期(秒数) * @return boolean */ - public function setTimeout($key, $ttl) + public function setTimeout(string $key, int $ttl): boolean { + } /** @@ -1985,8 +2097,9 @@ public function setTimeout($key, $ttl) * @param int $ttl 有效期(秒数) * @return boolean */ - public function expire($key, $ttl) + public function expire(string $key, int $ttl): boolean { + } /** @@ -1997,8 +2110,9 @@ public function expire($key, $ttl) * @param int $ttl 有效期(毫秒数) * @return boolean */ - public function pexpire($key, $ttl) + public function pexpire(string $key, int $ttl): boolean { + } /** @@ -2016,8 +2130,9 @@ public function pexpire($key, $ttl) * @param int $expireTime 到期时间 * @return bool: */ - public function expireAt($key, $expireTime) + public function expireAt(string $key, int $expireTime): bool: { + } /** @@ -2035,8 +2150,9 @@ public function expireAt($key, $expireTime) * @param int $expireTime 到期时间 * @return bool: */ - public function pexpireAt($key, $expireTime) + public function pexpireAt(string $key, int $expireTime): bool: { + } /** @@ -2054,8 +2170,9 @@ public function pexpireAt($key, $expireTime) * @param int $dbIndex 数据库编号 * @return bool */ - public function move($key, $dbIndex) + public function move(string $key, int $dbIndex): bool { + } /** @@ -2072,8 +2189,9 @@ public function move($key, $dbIndex) * @param int $dbIndex 数据库编号 * @return bool */ - public function select($dbIndex) + public function select(int $dbIndex): bool { + } /** @@ -2090,8 +2208,9 @@ public function select($dbIndex) * @param int $end 结束位置 * @return string: */ - public function getRange($key, $start, $end) + public function getRange(string $key, int $start, int $end): string: { + } /** @@ -2103,8 +2222,9 @@ public function getRange($key, $start, $end) * @param int $end 结束索引 * @return array | boolean */ - public function listTrim($key, $start, $end) + public function listTrim(string $key, int $start, int $end): ?array { + } /** @@ -2116,8 +2236,9 @@ public function listTrim($key, $start, $end) * @param int $end 结束索引 * @return array | boolean */ - public function ltrim($key, $start, $end) + public function ltrim(string $key, int $start, int $end): ?array { + } /** @@ -2129,8 +2250,9 @@ public function ltrim($key, $start, $end) * @param int $end 索引结束值 * @return array */ - public function lGetRange($key, $start, $end) + public function lGetRange(string $key, int $start, int $end): array { + } /** @@ -2142,8 +2264,9 @@ public function lGetRange($key, $start, $end) * @param int $end 索引结束值 * @return array */ - public function lRange($key, $start, $end) + public function lRange(string $key, int $start, int $end): array { + } /** @@ -2155,8 +2278,9 @@ public function lRange($key, $start, $end) * @param int $count 删除的个数 * @return long | bool */ - public function lRem($key, $value, $count) + public function lRem(string $key, string $value, int $count): ?long { + } /** @@ -2168,8 +2292,9 @@ public function lRem($key, $value, $count) * @param int $count 删除的个数 * @return long | bool */ - public function lRemove($key, $value, $count) + public function lRemove(string $key, string $value, int $count): ?long { + } /** @@ -2188,8 +2313,9 @@ public function lRemove($key, $value, $count) * @param double $end 结束排序值 * @return int */ - public function zDeleteRangeByRank($key, $start, $end) + public function zDeleteRangeByRank(string $key, double $start, double $end): int { + } /** @@ -2208,8 +2334,9 @@ public function zDeleteRangeByRank($key, $start, $end) * @param double $end 结束排序值 * @return int */ - public function zRemRangeByRank($key, $start, $end) + public function zRemRangeByRank(string $key, double $start, double $end): int { + } /** @@ -2228,8 +2355,9 @@ public function zRemRangeByRank($key, $start, $end) * @param float $step 自增步长 * @return float */ - public function incrByFloat($key, $step) + public function incrByFloat(string $key, float $step): float { + } /** @@ -2256,8 +2384,9 @@ public function incrByFloat($key, $step) * @param double $step 自增步长 * @return */ - public function hIncrByFloat($key, $field, $step) + public function hIncrByFloat(string $key, string $field, double $step) { + } /** @@ -2267,8 +2396,9 @@ public function hIncrByFloat($key, $field, $step) * @param string $key 键名 * @return long */ - public function bitCount($key) + public function bitCount(string $key): long { + } /** @@ -2282,8 +2412,9 @@ public function bitCount($key) * @param string|... $keyN 键名N * @return long */ - public function bitOp($operation, $dstKey, $key1, $key2, $keyN) + public function bitOp(string $operation, string $dstKey, string $key1, string $key2, string $keyN): long { + } /** @@ -2298,8 +2429,9 @@ public function bitOp($operation, $dstKey, $key1, $key2, $keyN) * @param string $value 元素值 * @return int */ - public function sAdd($key, $value) + public function sAdd(string $key, string $value): int { + } /** @@ -2320,8 +2452,9 @@ public function sAdd($key, $value) * @param string $member 成员 * @return bool */ - public function sMove($srcKey, $dstKey, $member) + public function sMove(string $srcKey, string $dstKey, string $member): bool { + } /** @@ -2348,8 +2481,9 @@ public function sMove($srcKey, $dstKey, $member) * @param string|... $key2 键名2 * @return array */ - public function sDiff($key1, $key2) + public function sDiff(string $key1, string $key2): array { + } /** @@ -2380,8 +2514,9 @@ public function sDiff($key1, $key2) * @param string|... $keyN 键名n * @return int: */ - public function sDiffStore($dstKey, $key1, $key2, $keyN) + public function sDiffStore(string $dstKey, string $key1, string $key2, string $keyN): int: { + } /** @@ -2412,8 +2547,9 @@ public function sDiffStore($dstKey, $key1, $key2, $keyN) * @param string|... $key2 键名2 * @return array */ - public function sUnion($key1, $key2) + public function sUnion(string $key1, string $key2): array { + } /** @@ -2448,8 +2584,9 @@ public function sUnion($key1, $key2) * @param string|... $keyN 键名n * @return int */ - public function sUnionStore($dstKey, $key1, $key2, $keyN) + public function sUnionStore(string $dstKey, string $key1, string $key2, string $keyN): int { + } /** @@ -2477,8 +2614,9 @@ public function sUnionStore($dstKey, $key1, $key2, $keyN) * @param string $key2 键名2 * @return array | boolean */ - public function sInter($key1, $key2) + public function sInter(string $key1, string $key2): ?array { + } /** @@ -2511,8 +2649,9 @@ public function sInter($key1, $key2) * @param string|... $keyN 键名n * @return int */ - public function sInterStore($dstKey, $key1, $key2, $keyN) + public function sInterStore(string $dstKey, string $key1, string $key2, string $keyN): int { + } /** @@ -2523,8 +2662,9 @@ public function sInterStore($dstKey, $key1, $key2, $keyN) * @param string|... $member 成员 * @return long */ - public function sRemove($key, $member) + public function sRemove(string $key, string $member): long { + } /** @@ -2535,8 +2675,9 @@ public function sRemove($key, $member) * @param string|... $member 成员 * @return long */ - public function srem($key, $member) + public function srem(string $key, string $member): long { + } /** @@ -2547,8 +2688,9 @@ public function srem($key, $member) * @param string $member 成员值 * @return int */ - public function zDelete($key, $member) + public function zDelete(string $key, string $member): int { + } /** @@ -2559,8 +2701,9 @@ public function zDelete($key, $member) * @param string $member 成员值 * @return int */ - public function zRemove($key, $member) + public function zRemove(string $key, string $member): int { + } /** @@ -2571,8 +2714,9 @@ public function zRemove($key, $member) * @param string $member 成员值 * @return int */ - public function zRem($key, $member) + public function zRem(string $key, string $member): int { + } /** @@ -2591,8 +2735,9 @@ public function zRem($key, $member) * @param mixed $value 返回值 * @return */ - public function pSubscribe(Array $patterns, $callback, $value) + public function pSubscribe(Array $patterns, string $callback, $value) { + } /** @@ -2620,8 +2765,9 @@ public function pSubscribe(Array $patterns, $callback, $value) * @param mixed $value 返回值 * @return mixed */ - public function subscribe(Array $channels, $callback, $value) + public function subscribe(Array $channels, string $callback, $value) { + } /** @@ -2645,6 +2791,7 @@ public function subscribe(Array $channels, $callback, $value) */ public function multi() { + } /** @@ -2655,6 +2802,7 @@ public function multi() */ public function exec() { + } /** @@ -2666,8 +2814,9 @@ public function exec() * @param int $num_keys 应该进入KEYS数组的参数个数 * @return mixed */ - public function eval($script, Array $args, $num_keys) + public function eval(string $script, Array $args, int $num_keys) { + } /** @@ -2681,8 +2830,9 @@ public function eval($script, Array $args, $num_keys) * @param int $num_keys 应该进入KEYS数组的参数个数 * @return */ - public function evalSha($script_sha, Array $args, $num_keys) + public function evalSha(string $script_sha, Array $args, int $num_keys) { + } /** @@ -2703,8 +2853,9 @@ public function evalSha($script_sha, Array $args, $num_keys) * @param string|... $script 脚本 * @return */ - public function script($command, $script) + public function script(string $command, string $script) { + } /** @@ -2715,6 +2866,7 @@ public function script($command, $script) */ public function __sleep() { + } /** @@ -2725,6 +2877,7 @@ public function __sleep() */ public function __wakeup() { + } } diff --git a/src/Swoole/Co/Redis/Server.php b/src/Swoole/Co/Redis/Server.php index 5e746a9..1aa0e7e 100644 --- a/src/Swoole/Co/Redis/Server.php +++ b/src/Swoole/Co/Redis/Server.php @@ -1,8 +1,8 @@ get('key'); * @return string|bool */ - public function get() + public function get(): ?string { + } /** @@ -258,6 +271,7 @@ public function get() */ public function mGet(Array $keys) { + } /** @@ -268,8 +282,9 @@ public function mGet(Array $keys) * @param array|string $keys 键名 * @return int */ - public function del($keys) + public function del(array $keys): int { + } /** @@ -297,8 +312,9 @@ public function del($keys) * @param string|array $fields 字段名 * @return int */ - public function hDel($key, $fields) + public function hDel(string $key, string $fields): int { + } /** @@ -317,8 +333,9 @@ public function hDel($key, $fields) * @param string $value 字段值 * @return long */ - public function hSet($key, $field, $value) + public function hSet(string $key, string $field, string $value): long { + } /** @@ -334,8 +351,9 @@ public function hSet($key, $field, $value) * @param array $fields 字段键值对 * @return boolean */ - public function hMSet($key, Array $fields) + public function hMSet(string $key, Array $fields): boolean { + } /** @@ -353,8 +371,9 @@ public function hMSet($key, Array $fields) * @param string $value 字段值 * @return bool */ - public function hSetNx($key, $field, $value) + public function hSetNx(string $key, string $field, string $value): bool { + } /** @@ -365,8 +384,9 @@ public function hSetNx($key, $field, $value) * @param array|string $keys 键名 * @return int */ - public function delete($keys) + public function delete(array $keys): int { + } /** @@ -384,8 +404,9 @@ public function delete($keys) * @param array $values 要设置的键值对 * @return bool */ - public function mSet(Array $values) + public function mSet(Array $values): bool { + } /** @@ -403,8 +424,9 @@ public function mSet(Array $values) * @param array $values 要设置的键值对 * @return bool */ - public function mSetNx(Array $values) + public function mSetNx(Array $values): bool { + } /** @@ -416,8 +438,9 @@ public function mSetNx(Array $values) * @param string $pattern 匹配模式 * @return array */ - public function getKeys($pattern) + public function getKeys(string $pattern): array { + } /** @@ -429,8 +452,9 @@ public function getKeys($pattern) * @param string $pattern 匹配模式 * @return array */ - public function keys($pattern) + public function keys(string $pattern): array { + } /** @@ -445,8 +469,9 @@ public function keys($pattern) * @param string $key 键名 * @return bool */ - public function exists($key) + public function exists(string $key): bool { + } /** @@ -456,8 +481,9 @@ public function exists($key) * @param string $key 键名 * @return int */ - public function type($key) + public function type(string $key): int { + } /** @@ -471,8 +497,9 @@ public function type($key) * @param string $key 键名 * @return int */ - public function strLen($key) + public function strLen(string $key): int { + } /** @@ -488,8 +515,9 @@ public function strLen($key) * @param string $key 键名 * @return string */ - public function lPop($key) + public function lPop(string $key): string { + } /** @@ -520,8 +548,9 @@ public function lPop($key) * @param int $timeout 超时时间 * @return array */ - public function blPop($key, $timeout) + public function blPop(string $key, int $timeout): array { + } /** @@ -537,8 +566,9 @@ public function blPop($key, $timeout) * @param string $key 键名 * @return string */ - public function rPop($key) + public function rPop(string $key): string { + } /** @@ -569,8 +599,9 @@ public function rPop($key) * @param int $timeout 超时时间 * @return array */ - public function brPop($key, $timeout) + public function brPop(string $key, int $timeout): array { + } /** @@ -581,8 +612,9 @@ public function brPop($key, $timeout) * @param string $dstKey 要插入元素的队列的键名 * @return string */ - public function bRPopLPush($srcKey, $dstKey) + public function bRPopLPush(string $srcKey, string $dstKey): string { + } /** @@ -592,8 +624,9 @@ public function bRPopLPush($srcKey, $dstKey) * @param string|...|array $key 键名 * @return long | bool */ - public function lSize($key) + public function lSize(string $key): ?long { + } /** @@ -603,8 +636,9 @@ public function lSize($key) * @param string|...|array $key 键名 * @return long | bool */ - public function lLen($key) + public function lLen(string $key): ?long { + } /** @@ -614,8 +648,9 @@ public function lLen($key) * @param string $key 键名 * @return long */ - public function sSize($key) + public function sSize(string $key): long { + } /** @@ -625,8 +660,9 @@ public function sSize($key) * @param string $key 键名 * @return long */ - public function scard($key) + public function scard(string $key): long { + } /** @@ -644,8 +680,9 @@ public function scard($key) * @param int $count 删除个数 * @return string | bool */ - public function sPop($key, $count) + public function sPop(string $key, int $count): ?string { + } /** @@ -672,8 +709,9 @@ public function sPop($key, $count) * @param string $key 键名 * @return array */ - public function sMembers($key) + public function sMembers(string $key): array { + } /** @@ -700,8 +738,9 @@ public function sMembers($key) * @param string $key 键名 * @return array */ - public function sGetMembers($key) + public function sGetMembers(string $key): array { + } /** @@ -723,8 +762,9 @@ public function sGetMembers($key) * @param string $key 键名 * @return string | bool */ - public function sRandMember($key) + public function sRandMember(string $key): ?string { + } /** @@ -734,8 +774,9 @@ public function sRandMember($key) * @param string $key 键名 * @return bool: */ - public function persist($key) + public function persist(string $key): bool: { + } /** @@ -745,8 +786,9 @@ public function persist($key) * @param string $key 键名 * @return long */ - public function ttl($key) + public function ttl(string $key): long { + } /** @@ -756,8 +798,9 @@ public function ttl($key) * @param string $key 键名 * @return long */ - public function pttl($key) + public function pttl(string $key): long { + } /** @@ -773,8 +816,9 @@ public function pttl($key) * @param string $key 集合键名 * @return int */ - public function zCard($key) + public function zCard(string $key): int { + } /** @@ -790,8 +834,9 @@ public function zCard($key) * @param string $key 集合键名 * @return int */ - public function zSize($key) + public function zSize(string $key): int { + } /** @@ -807,8 +852,9 @@ public function zSize($key) * @param string $key 键名 * @return int */ - public function hLen($key) + public function hLen(string $key): int { + } /** @@ -838,8 +884,9 @@ public function hLen($key) * @param string $key 键名 * @return array */ - public function hKeys($key) + public function hKeys(string $key): array { + } /** @@ -869,8 +916,9 @@ public function hKeys($key) * @param string $key 键名 * @return array */ - public function hVals($key) + public function hVals(string $key): array { + } /** @@ -900,8 +948,9 @@ public function hVals($key) * @param string $key 键名 * @return array */ - public function hGetAll($key) + public function hGetAll(string $key): array { + } /** @@ -912,6 +961,7 @@ public function hGetAll($key) */ public function debug() { + } /** @@ -928,8 +978,9 @@ public function debug() * @param string $value dump导出的二进制数据 * @return */ - public function restore($key, $ttl, $value) + public function restore(string $key, int $ttl, string $value) { + } /** @@ -943,8 +994,9 @@ public function restore($key, $ttl, $value) * @param string $key 键名 * @return string */ - public function dump($key) + public function dump(string $key): string { + } /** @@ -955,8 +1007,9 @@ public function dump($key) * @param string $dstKey 新键名 * @return boolean */ - public function renameKey($srcKey, $dstKey) + public function renameKey(string $srcKey, string $dstKey): boolean { + } /** @@ -967,8 +1020,9 @@ public function renameKey($srcKey, $dstKey) * @param string $dstKey 新键名 * @return boolean */ - public function rename($srcKey, $dstKey) + public function rename(string $srcKey, string $dstKey): boolean { + } /** @@ -979,8 +1033,9 @@ public function rename($srcKey, $dstKey) * @param string $dstKey 新键名 * @return boolean */ - public function renameNx($srcKey, $dstKey) + public function renameNx(string $srcKey, string $dstKey): boolean { + } /** @@ -1017,8 +1072,9 @@ public function renameNx($srcKey, $dstKey) * @param string $dstKey 要插入元素的队列的键名 * @return string */ - public function rpoplpush($srcKey, $dstKey) + public function rpoplpush(string $srcKey, string $dstKey): string { + } /** @@ -1031,8 +1087,9 @@ public function rpoplpush($srcKey, $dstKey) *
* @return string */ - public function randomKey() + public function randomKey(): string { + } /** @@ -1041,8 +1098,9 @@ public function randomKey() * @example * @return string */ - public function ping() + public function ping(): string { + } /** @@ -1052,8 +1110,9 @@ public function ping() * @param string $password 认证密码 * @return bool: */ - public function auth($password) + public function auth(string $password): bool: { + } /** @@ -1063,8 +1122,9 @@ public function auth($password) * @param string|array $keys 键名 * @return */ - public function unwatch($keys) + public function unwatch(string $keys) { + } /** @@ -1082,8 +1142,9 @@ public function unwatch($keys) * @param string|array $keys 键名 * @return */ - public function watch($keys) + public function watch(string $keys) { + } /** @@ -1092,8 +1153,9 @@ public function watch($keys) * @example $redis->save(); * @return boolean */ - public function save() + public function save(): boolean { + } /** @@ -1104,6 +1166,7 @@ public function save() */ public function bgSave() { + } /** @@ -1112,8 +1175,9 @@ public function bgSave() * @example $redis->lastSave(); * @return int */ - public function lastSave() + public function lastSave(): int { + } /** @@ -1122,8 +1186,9 @@ public function lastSave() * @example $redis->flushDB(); * @return bool */ - public function flushDB() + public function flushDB(): bool { + } /** @@ -1132,8 +1197,9 @@ public function flushDB() * @example $redis->flushAll(); * @return bool */ - public function flushAll() + public function flushAll(): bool { + } /** @@ -1146,8 +1212,9 @@ public function flushAll() * * @return int */ - public function dbSize() + public function dbSize(): int { + } /** @@ -1156,8 +1223,9 @@ public function dbSize() * @example $redis->bgrewriteaof(); * @return bool */ - public function bgrewriteaof() + public function bgrewriteaof(): bool { + } /** @@ -1173,8 +1241,9 @@ public function bgrewriteaof() * * @return int */ - public function time() + public function time(): int { + } /** @@ -1183,8 +1252,9 @@ public function time() * @example * @return string */ - public function role() + public function role(): string { + } /** @@ -1201,8 +1271,9 @@ public function role() * @param string $value 被替换的子串的值 * @return string */ - public function setRange($key, $offset, $value) + public function setRange(string $key, int $offset, string $value): string { + } /** @@ -1215,8 +1286,9 @@ public function setRange($key, $offset, $value) * @param string $value 设置的缓存值 * @return bool: */ - public function setNx($key, $value) + public function setNx(string $key, string $value): bool: { + } /** @@ -1232,8 +1304,9 @@ public function setNx($key, $value) * @param string $value 设置的缓存值 * @return string */ - public function getSet($key, $value) + public function getSet(string $key, string $value): string { + } /** @@ -1249,8 +1322,9 @@ public function getSet($key, $value) * @param string $value 追加的值 * @return int */ - public function append($key, $value) + public function append(string $key, string $value): int { + } /** @@ -1269,8 +1343,9 @@ public function append($key, $value) * @param string $value 元素值 * @return int */ - public function lPushx($key, $value) + public function lPushx(string $key, string $value): int { + } /** @@ -1292,8 +1367,9 @@ public function lPushx($key, $value) * @param string $value 元素值 * @return int */ - public function lPush($key, $value) + public function lPush(string $key, string $value): int { + } /** @@ -1315,8 +1391,9 @@ public function lPush($key, $value) * @param string $value 元素值 * @return int */ - public function rPush($key, $value) + public function rPush(string $key, string $value): int { + } /** @@ -1335,8 +1412,9 @@ public function rPush($key, $value) * @param string $value 元素值 * @return int */ - public function rPushx($key, $value) + public function rPushx(string $key, string $value): int { + } /** @@ -1347,8 +1425,9 @@ public function rPushx($key, $value) * @param string $member 成员值 * @return boolean */ - public function sContains($key, $member) + public function sContains(string $key, string $member): boolean { + } /** @@ -1359,8 +1438,9 @@ public function sContains($key, $member) * @param string $member 成员值 * @return boolean */ - public function sismember($key, $member) + public function sismember(string $key, string $member): boolean { + } /** @@ -1375,8 +1455,9 @@ public function sismember($key, $member) * @param string $member 成员值 * @return double */ - public function zScore($key, $member) + public function zScore(string $key, string $member): double { + } /** @@ -1396,8 +1477,9 @@ public function zScore($key, $member) * @param string $member 成员值 * @return int */ - public function zRank($key, $member) + public function zRank(string $key, string $member): int { + } /** @@ -1408,8 +1490,9 @@ public function zRank($key, $member) * @param string $member 成员值 * @return int */ - public function zRevRank($key, $member) + public function zRevRank(string $key, string $member): int { + } /** @@ -1420,8 +1503,9 @@ public function zRevRank($key, $member) * @param string $field 字段名 * @return string */ - public function hGet($key, $field) + public function hGet(string $key, string $field): string { + } /** @@ -1432,8 +1516,9 @@ public function hGet($key, $field) * @param array $fields 字段名列表 * @return array */ - public function hMGet($key, Array $fields) + public function hMGet(string $key, Array $fields): array { + } /** @@ -1449,8 +1534,9 @@ public function hMGet($key, Array $fields) * @param string $field 字段名 * @return bool */ - public function hExists($key, $field) + public function hExists(string $key, string $field): bool { + } /** @@ -1461,8 +1547,9 @@ public function hExists($key, $field) * @param string $message 消息 * @return int */ - public function publish($channel, $message) + public function publish(string $channel, string $message): int { + } /** @@ -1480,8 +1567,9 @@ public function publish($channel, $message) * @param string $member 成员 * @return float */ - public function zIncrBy($key, $step, $member) + public function zIncrBy(string $key, double $step, string $member): float { + } /** @@ -1505,8 +1593,9 @@ public function zIncrBy($key, $step, $member) * @param string $value 元素值 * @return int */ - public function zAdd($key, $score, $value) + public function zAdd(string $key, double $score, string $value): int { + } /** @@ -1518,8 +1607,9 @@ public function zAdd($key, $score, $value) * @param double $end 结束排序值 * @return long */ - public function zDeleteRangeByScore($key, $start, $end) + public function zDeleteRangeByScore(string $key, double $start, double $end): long { + } /** @@ -1531,8 +1621,9 @@ public function zDeleteRangeByScore($key, $start, $end) * @param double $end 结束排序值 * @return long */ - public function zRemRangeByScore($key, $start, $end) + public function zRemRangeByScore(string $key, double $start, double $end): long { + } /** @@ -1550,8 +1641,9 @@ public function zRemRangeByScore($key, $start, $end) * @param double $end 结束排序值 * @return int */ - public function zCount($key, $start, $end) + public function zCount(string $key, double $start, double $end): int { + } /** @@ -1572,8 +1664,9 @@ public function zCount($key, $start, $end) * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRange($key, $start, $end, $withScores) + public function zRange(string $key, long $start, long $end, boolean $withScores): array { + } /** @@ -1594,8 +1687,9 @@ public function zRange($key, $start, $end, $withScores) * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRevRange($key, $start, $end, $withScores) + public function zRevRange(string $key, long $start, long $end, boolean $withScores): array { + } /** @@ -1618,8 +1712,9 @@ public function zRevRange($key, $start, $end, $withScores) * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRangeByScore($key, $start, $end, Array $options) + public function zRangeByScore(string $key, long $start, long $end, Array $options): array { + } /** @@ -1642,8 +1737,9 @@ public function zRangeByScore($key, $start, $end, Array $options) * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRevRangeByScore($key, $start, $end, Array $options) + public function zRevRangeByScore(string $key, long $start, long $end, Array $options): array { + } /** @@ -1665,8 +1761,9 @@ public function zRevRangeByScore($key, $start, $end, Array $options) * @param long $limit 成员数 * @return array */ - public function zRangeByLex($key, $min, $max, $offset, $limit) + public function zRangeByLex(string $key, long $min, long $max, long $offset, long $limit): array { + } /** @@ -1680,8 +1777,9 @@ public function zRangeByLex($key, $min, $max, $offset, $limit) * @param long $limit 成员数 * @return */ - public function zRevRangeByLex($key, $min, $max, $offset, $limit) + public function zRevRangeByLex(string $key, long $min, long $max, long $offset, long $limit) { + } /** @@ -1713,8 +1811,9 @@ public function zRevRangeByLex($key, $min, $max, $offset, $limit) * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zInter($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zInter(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -1746,8 +1845,9 @@ public function zInter($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggrega * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zinterstore(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -1776,8 +1876,9 @@ public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $ag * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zUnion($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zUnion(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -1806,8 +1907,9 @@ public function zUnion($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggrega * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zunionstore(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -1825,8 +1927,9 @@ public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $ag * @param int $step 自增步长 * @return int */ - public function incrBy($key, $step) + public function incrBy(string $key, int $step): int { + } /** @@ -1843,8 +1946,9 @@ public function incrBy($key, $step) * @param int $step 自增步长 * @return int */ - public function hIncrBy($key, $field, $step) + public function hIncrBy(string $key, string $field, int $step): int { + } /** @@ -1860,8 +1964,9 @@ public function hIncrBy($key, $field, $step) * @param string $key 键名 * @return int */ - public function incr($key) + public function incr(string $key): int { + } /** @@ -1878,8 +1983,9 @@ public function incr($key) * @param float $step 自减步长 * @return int */ - public function decrBy($key, $step) + public function decrBy(string $key, float $step): int { + } /** @@ -1894,8 +2000,9 @@ public function decrBy($key, $step) * @param string $key 键名 * @return int */ - public function decr($key) + public function decr(string $key): int { + } /** @@ -1911,8 +2018,9 @@ public function decr($key) * @param int $offset 所在位置 * @return int */ - public function getBit($key, $offset) + public function getBit(string $key, int $offset): int { + } /** @@ -1937,8 +2045,9 @@ public function getBit($key, $offset) * @param string $value 新值 * @return int */ - public function lInsert($key, $position, $element, $value) + public function lInsert(string $key, string $position, string $element, string $value): int { + } /** @@ -1949,8 +2058,9 @@ public function lInsert($key, $position, $element, $value) * @param int $index 索引值 * @return string | boolean */ - public function lGet($key, $index) + public function lGet(string $key, int $index): ?string { + } /** @@ -1961,8 +2071,9 @@ public function lGet($key, $index) * @param int $index 索引值 * @return string | boolean */ - public function lIndex($key, $index) + public function lIndex(string $key, int $index): ?string { + } /** @@ -1973,8 +2084,9 @@ public function lIndex($key, $index) * @param int $ttl 有效期(秒数) * @return boolean */ - public function setTimeout($key, $ttl) + public function setTimeout(string $key, int $ttl): boolean { + } /** @@ -1985,8 +2097,9 @@ public function setTimeout($key, $ttl) * @param int $ttl 有效期(秒数) * @return boolean */ - public function expire($key, $ttl) + public function expire(string $key, int $ttl): boolean { + } /** @@ -1997,8 +2110,9 @@ public function expire($key, $ttl) * @param int $ttl 有效期(毫秒数) * @return boolean */ - public function pexpire($key, $ttl) + public function pexpire(string $key, int $ttl): boolean { + } /** @@ -2016,8 +2130,9 @@ public function pexpire($key, $ttl) * @param int $expireTime 到期时间 * @return bool: */ - public function expireAt($key, $expireTime) + public function expireAt(string $key, int $expireTime): bool: { + } /** @@ -2035,8 +2150,9 @@ public function expireAt($key, $expireTime) * @param int $expireTime 到期时间 * @return bool: */ - public function pexpireAt($key, $expireTime) + public function pexpireAt(string $key, int $expireTime): bool: { + } /** @@ -2054,8 +2170,9 @@ public function pexpireAt($key, $expireTime) * @param int $dbIndex 数据库编号 * @return bool */ - public function move($key, $dbIndex) + public function move(string $key, int $dbIndex): bool { + } /** @@ -2072,8 +2189,9 @@ public function move($key, $dbIndex) * @param int $dbIndex 数据库编号 * @return bool */ - public function select($dbIndex) + public function select(int $dbIndex): bool { + } /** @@ -2090,8 +2208,9 @@ public function select($dbIndex) * @param int $end 结束位置 * @return string: */ - public function getRange($key, $start, $end) + public function getRange(string $key, int $start, int $end): string: { + } /** @@ -2103,8 +2222,9 @@ public function getRange($key, $start, $end) * @param int $end 结束索引 * @return array | boolean */ - public function listTrim($key, $start, $end) + public function listTrim(string $key, int $start, int $end): ?array { + } /** @@ -2116,8 +2236,9 @@ public function listTrim($key, $start, $end) * @param int $end 结束索引 * @return array | boolean */ - public function ltrim($key, $start, $end) + public function ltrim(string $key, int $start, int $end): ?array { + } /** @@ -2129,8 +2250,9 @@ public function ltrim($key, $start, $end) * @param int $end 索引结束值 * @return array */ - public function lGetRange($key, $start, $end) + public function lGetRange(string $key, int $start, int $end): array { + } /** @@ -2142,8 +2264,9 @@ public function lGetRange($key, $start, $end) * @param int $end 索引结束值 * @return array */ - public function lRange($key, $start, $end) + public function lRange(string $key, int $start, int $end): array { + } /** @@ -2155,8 +2278,9 @@ public function lRange($key, $start, $end) * @param int $count 删除的个数 * @return long | bool */ - public function lRem($key, $value, $count) + public function lRem(string $key, string $value, int $count): ?long { + } /** @@ -2168,8 +2292,9 @@ public function lRem($key, $value, $count) * @param int $count 删除的个数 * @return long | bool */ - public function lRemove($key, $value, $count) + public function lRemove(string $key, string $value, int $count): ?long { + } /** @@ -2188,8 +2313,9 @@ public function lRemove($key, $value, $count) * @param double $end 结束排序值 * @return int */ - public function zDeleteRangeByRank($key, $start, $end) + public function zDeleteRangeByRank(string $key, double $start, double $end): int { + } /** @@ -2208,8 +2334,9 @@ public function zDeleteRangeByRank($key, $start, $end) * @param double $end 结束排序值 * @return int */ - public function zRemRangeByRank($key, $start, $end) + public function zRemRangeByRank(string $key, double $start, double $end): int { + } /** @@ -2228,8 +2355,9 @@ public function zRemRangeByRank($key, $start, $end) * @param float $step 自增步长 * @return float */ - public function incrByFloat($key, $step) + public function incrByFloat(string $key, float $step): float { + } /** @@ -2256,8 +2384,9 @@ public function incrByFloat($key, $step) * @param double $step 自增步长 * @return */ - public function hIncrByFloat($key, $field, $step) + public function hIncrByFloat(string $key, string $field, double $step) { + } /** @@ -2267,8 +2396,9 @@ public function hIncrByFloat($key, $field, $step) * @param string $key 键名 * @return long */ - public function bitCount($key) + public function bitCount(string $key): long { + } /** @@ -2282,8 +2412,9 @@ public function bitCount($key) * @param string|... $keyN 键名N * @return long */ - public function bitOp($operation, $dstKey, $key1, $key2, $keyN) + public function bitOp(string $operation, string $dstKey, string $key1, string $key2, string $keyN): long { + } /** @@ -2298,8 +2429,9 @@ public function bitOp($operation, $dstKey, $key1, $key2, $keyN) * @param string $value 元素值 * @return int */ - public function sAdd($key, $value) + public function sAdd(string $key, string $value): int { + } /** @@ -2320,8 +2452,9 @@ public function sAdd($key, $value) * @param string $member 成员 * @return bool */ - public function sMove($srcKey, $dstKey, $member) + public function sMove(string $srcKey, string $dstKey, string $member): bool { + } /** @@ -2348,8 +2481,9 @@ public function sMove($srcKey, $dstKey, $member) * @param string|... $key2 键名2 * @return array */ - public function sDiff($key1, $key2) + public function sDiff(string $key1, string $key2): array { + } /** @@ -2380,8 +2514,9 @@ public function sDiff($key1, $key2) * @param string|... $keyN 键名n * @return int: */ - public function sDiffStore($dstKey, $key1, $key2, $keyN) + public function sDiffStore(string $dstKey, string $key1, string $key2, string $keyN): int: { + } /** @@ -2412,8 +2547,9 @@ public function sDiffStore($dstKey, $key1, $key2, $keyN) * @param string|... $key2 键名2 * @return array */ - public function sUnion($key1, $key2) + public function sUnion(string $key1, string $key2): array { + } /** @@ -2448,8 +2584,9 @@ public function sUnion($key1, $key2) * @param string|... $keyN 键名n * @return int */ - public function sUnionStore($dstKey, $key1, $key2, $keyN) + public function sUnionStore(string $dstKey, string $key1, string $key2, string $keyN): int { + } /** @@ -2477,8 +2614,9 @@ public function sUnionStore($dstKey, $key1, $key2, $keyN) * @param string $key2 键名2 * @return array | boolean */ - public function sInter($key1, $key2) + public function sInter(string $key1, string $key2): ?array { + } /** @@ -2511,8 +2649,9 @@ public function sInter($key1, $key2) * @param string|... $keyN 键名n * @return int */ - public function sInterStore($dstKey, $key1, $key2, $keyN) + public function sInterStore(string $dstKey, string $key1, string $key2, string $keyN): int { + } /** @@ -2523,8 +2662,9 @@ public function sInterStore($dstKey, $key1, $key2, $keyN) * @param string|... $member 成员 * @return long */ - public function sRemove($key, $member) + public function sRemove(string $key, string $member): long { + } /** @@ -2535,8 +2675,9 @@ public function sRemove($key, $member) * @param string|... $member 成员 * @return long */ - public function srem($key, $member) + public function srem(string $key, string $member): long { + } /** @@ -2547,8 +2688,9 @@ public function srem($key, $member) * @param string $member 成员值 * @return int */ - public function zDelete($key, $member) + public function zDelete(string $key, string $member): int { + } /** @@ -2559,8 +2701,9 @@ public function zDelete($key, $member) * @param string $member 成员值 * @return int */ - public function zRemove($key, $member) + public function zRemove(string $key, string $member): int { + } /** @@ -2571,8 +2714,9 @@ public function zRemove($key, $member) * @param string $member 成员值 * @return int */ - public function zRem($key, $member) + public function zRem(string $key, string $member): int { + } /** @@ -2591,8 +2735,9 @@ public function zRem($key, $member) * @param mixed $value 返回值 * @return */ - public function pSubscribe(Array $patterns, $callback, $value) + public function pSubscribe(Array $patterns, string $callback, $value) { + } /** @@ -2620,8 +2765,9 @@ public function pSubscribe(Array $patterns, $callback, $value) * @param mixed $value 返回值 * @return mixed */ - public function subscribe(Array $channels, $callback, $value) + public function subscribe(Array $channels, string $callback, $value) { + } /** @@ -2645,6 +2791,7 @@ public function subscribe(Array $channels, $callback, $value) */ public function multi() { + } /** @@ -2655,6 +2802,7 @@ public function multi() */ public function exec() { + } /** @@ -2666,8 +2814,9 @@ public function exec() * @param int $num_keys 应该进入KEYS数组的参数个数 * @return mixed */ - public function eval($script, Array $args, $num_keys) + public function eval(string $script, Array $args, int $num_keys) { + } /** @@ -2681,8 +2830,9 @@ public function eval($script, Array $args, $num_keys) * @param int $num_keys 应该进入KEYS数组的参数个数 * @return */ - public function evalSha($script_sha, Array $args, $num_keys) + public function evalSha(string $script_sha, Array $args, int $num_keys) { + } /** @@ -2703,8 +2853,9 @@ public function evalSha($script_sha, Array $args, $num_keys) * @param string|... $script 脚本 * @return */ - public function script($command, $script) + public function script(string $command, string $script) { + } /** @@ -2715,6 +2866,7 @@ public function script($command, $script) */ public function __sleep() { + } /** @@ -2725,6 +2877,7 @@ public function __sleep() */ public function __wakeup() { + } } diff --git a/src/Swoole/Coroutine/Socket.php b/src/Swoole/Coroutine/Socket.php new file mode 100644 index 0000000..73b9485 --- /dev/null +++ b/src/Swoole/Coroutine/Socket.php @@ -0,0 +1,183 @@ +'192.168.0.25')) +* @return array */ -function swoole_get_local_ip() +function swoole_get_local_ip(): array { -} + + } /** * @@ -1050,9 +1081,10 @@ function swoole_get_local_ip() * $macs = swoole_get_local_mac(); * @return array */ -function swoole_get_local_mac() +function swoole_get_local_mac(): array { -} + + } /** * @@ -1062,9 +1094,10 @@ function swoole_get_local_mac() * @param int $errno:标准错误码 * @return string */ -function swoole_strerror($errno) +function swoole_strerror(int $errno): string { -} + + } /** * @@ -1073,9 +1106,10 @@ function swoole_strerror($errno) * echo swoole_strerror(swoole_errno()); * @return int */ -function swoole_errno() +function swoole_errno(): int { -} + + } /** * @@ -1086,7 +1120,8 @@ function swoole_errno() * @param int $type:类型 * @return */ -function swoole_hashcode($data, $type) +function swoole_hashcode(string $data, int $type) { -} + + } diff --git a/src/Swoole/swoole.php b/src/Swoole/swoole.php index 32beb89..a96e93b 100644 --- a/src/Swoole/swoole.php +++ b/src/Swoole/swoole.php @@ -1,8 +1,8 @@ '192.168.0.25')) +* @return array */ -function swoole_get_local_ip() +function swoole_get_local_ip(): array { -} + + } /** * @@ -1050,9 +1081,10 @@ function swoole_get_local_ip() * $macs = swoole_get_local_mac(); * @return array */ -function swoole_get_local_mac() +function swoole_get_local_mac(): array { -} + + } /** * @@ -1062,9 +1094,10 @@ function swoole_get_local_mac() * @param int $errno:标准错误码 * @return string */ -function swoole_strerror($errno) +function swoole_strerror(int $errno): string { -} + + } /** * @@ -1073,9 +1106,10 @@ function swoole_strerror($errno) * echo swoole_strerror(swoole_errno()); * @return int */ -function swoole_errno() +function swoole_errno(): int { -} + + } /** * @@ -1086,7 +1120,8 @@ function swoole_errno() * @param int $type:类型 * @return */ -function swoole_hashcode($data, $type) +function swoole_hashcode(string $data, int $type) { -} + + } diff --git a/src/Swoole/swoole_async.php b/src/Swoole/swoole_async.php index debfa44..d09c436 100644 --- a/src/Swoole/swoole_async.php +++ b/src/Swoole/swoole_async.php @@ -1,8 +1,8 @@ 0, + 'queue_bytes'=>0 + ]; } } diff --git a/src/Swoole/swoole_client.php b/src/Swoole/swoole_client.php index 3e7c0ca..30182dd 100644 --- a/src/Swoole/swoole_client.php +++ b/src/Swoole/swoole_client.php @@ -1,8 +1,8 @@ Date: Tue, 29 May 2018 09:58:01 +0800 Subject: [PATCH 18/34] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0668eb..dd8f3a6 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ php framework and php extension Auto Compelete for phpstorm Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自动补全(屏蔽IDE undefined,全命名空间,中文详细文档,比手册更详细) -这个想法fork自phpboy(https://github.com/xudianyang/yaf.auto.complete) +这个想法fork自phpboy(https://github.com/xudianyang/yaf.auto.complete) ## 原理 From e814da68b3eddf0685424651fe6cbcb6eccaad82 Mon Sep 17 00:00:00 2001 From: shixinke Date: Fri, 8 Jun 2018 14:36:57 +0800 Subject: [PATCH 19/34] =?UTF-8?q?seaslog=E6=9B=B4=E6=96=B0=E5=88=B01.8.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/Seaslog/SeasLog.php | 106 ++++++++++++++++++++++++++++------------ 2 files changed, 77 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index dd8f3a6..5fba23c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 6、swoole扩展(支持swoole 2.2) -7、SeasLog(1.7.6) +7、SeasLog(1.8.5) 8、MsgPack(beta) diff --git a/src/Seaslog/SeasLog.php b/src/Seaslog/SeasLog.php index 94c931a..2129fab 100644 --- a/src/Seaslog/SeasLog.php +++ b/src/Seaslog/SeasLog.php @@ -1,8 +1,8 @@ Date: Thu, 14 Jun 2018 21:04:07 +0800 Subject: [PATCH 20/34] =?UTF-8?q?swoole=E6=9B=B4=E6=96=B0=E5=88=B04.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/Swoole/Async.php | 4 +- src/Swoole/Atomic.php | 4 +- src/Swoole/Atomic/Long.php | 4 +- src/Swoole/Buffer.php | 4 +- src/Swoole/Chan.php | 4 +- src/Swoole/Channel.php | 15 ++- src/Swoole/Client.php | 4 +- src/Swoole/Co.php | 4 +- src/Swoole/Co/Http/Client.php | 4 +- src/Swoole/Co/Http/Server.php | 4 +- src/Swoole/Co/Http2/Client.php | 8 +- src/Swoole/Co/MySQL.php | 4 +- src/Swoole/Co/Redis.php | 140 +++++++++++----------- src/Swoole/Co/Redis/Server.php | 4 +- src/Swoole/Co/Server.php | 4 +- src/Swoole/Co/WebSocket/Server.php | 4 +- src/Swoole/Connection/Iterator.php | 6 +- src/Swoole/Coroutine.php | 4 +- src/Swoole/Coroutine/Channel.php | 4 +- src/Swoole/Coroutine/Client.php | 4 +- src/Swoole/Coroutine/Http/Client.php | 4 +- src/Swoole/Coroutine/Http2/Client.php | 8 +- src/Swoole/Coroutine/Http2/Request.php | 4 +- src/Swoole/Coroutine/MySQL.php | 4 +- src/Swoole/Coroutine/MySQL/Exception.php | 4 +- src/Swoole/Coroutine/MySQL/Statement.php | 4 +- src/Swoole/Coroutine/PostgreSQL.php | 4 +- src/Swoole/Coroutine/Redis.php | 140 +++++++++++----------- src/Swoole/Coroutine/Socket.php | 4 +- src/Swoole/Coroutine/Socket/Exception.php | 4 +- src/Swoole/Event.php | 4 +- src/Swoole/Exception.php | 4 +- src/Swoole/Http/Client.php | 4 +- src/Swoole/Http/Request.php | 4 +- src/Swoole/Http/Response.php | 4 +- src/Swoole/Http/Server.php | 4 +- src/Swoole/Http2/Client.php | 4 +- src/Swoole/Http2/Response.php | 4 +- src/Swoole/Lock.php | 4 +- src/Swoole/Memory/Pool.php | 78 ++++++++++++ src/Swoole/Memory/Pool/Slice.php | 52 ++++++++ src/Swoole/Mmap.php | 4 +- src/Swoole/MsgQueue.php | 4 +- src/Swoole/MySQL.php | 4 +- src/Swoole/MySQL/Exception.php | 4 +- src/Swoole/Process.php | 4 +- src/Swoole/Process/Pool.php | 4 +- src/Swoole/Redis.php | 4 +- src/Swoole/Redis/Server.php | 4 +- src/Swoole/RingQueue.php | 4 +- src/Swoole/Serialize.php | 4 +- src/Swoole/Server.php | 4 +- src/Swoole/Server/Port.php | 4 +- src/Swoole/Table.php | 6 +- src/Swoole/Table/Row.php | 4 +- src/Swoole/Timer.php | 4 +- src/Swoole/WebSocket/Frame.php | 4 +- src/Swoole/WebSocket/Server.php | 4 +- src/Swoole/swoole.namespace.php | 88 ++++++++------ src/Swoole/swoole.php | 88 ++++++++------ src/Swoole/swoole_async.php | 4 +- src/Swoole/swoole_atomic.php | 4 +- src/Swoole/swoole_atomic_long.php | 4 +- src/Swoole/swoole_buffer.php | 4 +- src/Swoole/swoole_channel.php | 15 ++- src/Swoole/swoole_client.php | 4 +- src/Swoole/swoole_connection_iterator.php | 6 +- src/Swoole/swoole_coroutine.php | 4 +- src/Swoole/swoole_event.php | 4 +- src/Swoole/swoole_exception.php | 4 +- src/Swoole/swoole_http2_client.php | 4 +- src/Swoole/swoole_http2_response.php | 4 +- src/Swoole/swoole_http_client.php | 4 +- src/Swoole/swoole_http_request.php | 4 +- src/Swoole/swoole_http_response.php | 4 +- src/Swoole/swoole_http_server.php | 4 +- src/Swoole/swoole_lock.php | 4 +- src/Swoole/swoole_mmap.php | 4 +- src/Swoole/swoole_msgqueue.php | 4 +- src/Swoole/swoole_mysql.php | 4 +- src/Swoole/swoole_mysql_exception.php | 4 +- src/Swoole/swoole_process.php | 4 +- src/Swoole/swoole_process_pool.php | 4 +- src/Swoole/swoole_redis.php | 4 +- src/Swoole/swoole_redis_server.php | 4 +- src/Swoole/swoole_ringqueue.php | 4 +- src/Swoole/swoole_serialize.php | 4 +- src/Swoole/swoole_server.php | 4 +- src/Swoole/swoole_server_port.php | 4 +- src/Swoole/swoole_table.php | 6 +- src/Swoole/swoole_table_row.php | 4 +- src/Swoole/swoole_timer.php | 4 +- src/Swoole/swoole_websocket_frame.php | 4 +- src/Swoole/swoole_websocket_server.php | 4 +- 95 files changed, 577 insertions(+), 401 deletions(-) create mode 100644 src/Swoole/Memory/Pool.php create mode 100644 src/Swoole/Memory/Pool/Slice.php diff --git a/README.md b/README.md index 5fba23c..0adc3e5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 5、Redis(包括RedisCluster) -6、swoole扩展(支持swoole 2.2) +6、swoole扩展(支持swoole 4.0) 7、SeasLog(1.8.5) diff --git a/src/Swoole/Async.php b/src/Swoole/Async.php index 32cb998..5a6045f 100644 --- a/src/Swoole/Async.php +++ b/src/Swoole/Async.php @@ -1,8 +1,8 @@ persist('key'); * @param string $key 键名 - * @return bool: + * @return bool */ - public function persist(string $key): bool: + public function persist(string $key): bool { } @@ -784,9 +784,9 @@ public function persist(string $key): bool: *返回指定键的有效时间(秒) * @example $redis->ttl('key'); * @param string $key 键名 - * @return long + * @return int */ - public function ttl(string $key): long + public function ttl(string $key): int { } @@ -796,9 +796,9 @@ public function ttl(string $key): long *返回指定键的有效时间(毫秒) * @example $redis->pttl('key'); * @param string $key 键名 - * @return long + * @return int */ - public function pttl(string $key): long + public function pttl(string $key): int { } @@ -1108,9 +1108,9 @@ public function ping(): string *设置连接的认证密码 * @example $redis->auth('foobared'); * @param string $password 认证密码 - * @return bool: + * @return bool */ - public function auth(string $password): bool: + public function auth(string $password): bool { } @@ -1284,9 +1284,9 @@ public function setRange(string $key, int $offset, string $value): string * * @param string $key 设置的缓存键 * @param string $value 设置的缓存值 - * @return bool: + * @return bool */ - public function setNx(string $key, string $value): bool: + public function setNx(string $key, string $value): bool { } @@ -1605,9 +1605,9 @@ public function zAdd(string $key, double $score, string $value): int * @param string $key 集合键名 * @param double $start 开始排序值 * @param double $end 结束排序值 - * @return long + * @return int */ - public function zDeleteRangeByScore(string $key, double $start, double $end): long + public function zDeleteRangeByScore(string $key, double $start, double $end): int { } @@ -1619,9 +1619,9 @@ public function zDeleteRangeByScore(string $key, double $start, double $end): lo * @param string $key 集合键名 * @param double $start 开始排序值 * @param double $end 结束排序值 - * @return long + * @return int */ - public function zRemRangeByScore(string $key, double $start, double $end): long + public function zRemRangeByScore(string $key, double $start, double $end): int { } @@ -1659,12 +1659,12 @@ public function zCount(string $key, double $start, double $end): int * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRange(string $key, long $start, long $end, boolean $withScores): array + public function zRange(string $key, int $start, int $end, boolean $withScores): array { } @@ -1682,12 +1682,12 @@ public function zRange(string $key, long $start, long $end, boolean $withScores) * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRevRange(string $key, long $start, long $end, boolean $withScores): array + public function zRevRange(string $key, int $start, int $end, boolean $withScores): array { } @@ -1707,12 +1707,12 @@ public function zRevRange(string $key, long $start, long $end, boolean $withScor * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1)); // array('val2' => 2) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRangeByScore(string $key, long $start, long $end, Array $options): array + public function zRangeByScore(string $key, int $start, int $end, Array $options): array { } @@ -1732,12 +1732,12 @@ public function zRangeByScore(string $key, long $start, long $end, Array $option * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1)); // array('val2' => 2) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRevRangeByScore(string $key, long $start, long $end, Array $options): array + public function zRevRangeByScore(string $key, int $start, int $end, Array $options): array { } @@ -1755,13 +1755,13 @@ public function zRevRangeByScore(string $key, long $start, long $end, Array $opt * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c') * * @param string $key 集合键名 - * @param long $min 最小的字母 - * @param long $max 最大的字母 - * @param long $offset 索引开始值 - * @param long $limit 成员数 + * @param int $min 最小的字母 + * @param int $max 最大的字母 + * @param int $offset 索引开始值 + * @param int $limit 成员数 * @return array */ - public function zRangeByLex(string $key, long $min, long $max, long $offset, long $limit): array + public function zRangeByLex(string $key, int $min, int $max, int $offset, int $limit): array { } @@ -1771,13 +1771,13 @@ public function zRangeByLex(string $key, long $min, long $max, long $offset, lon *按字母字典的顺序返回成员(倒序排序) * @example * @param string $key 集合键名 - * @param long $min 最小的字母 - * @param long $max 最大的字母 - * @param long $offset 索引开始值 - * @param long $limit 成员数 + * @param int $min 最小的字母 + * @param int $max 最大的字母 + * @param int $offset 索引开始值 + * @param int $limit 成员数 * @return */ - public function zRevRangeByLex(string $key, long $min, long $max, long $offset, long $limit) + public function zRevRangeByLex(string $key, int $min, int $max, int $offset, int $limit) { } @@ -2128,9 +2128,9 @@ public function pexpire(string $key, int $ttl): boolean * * @param string $key 键名 * @param int $expireTime 到期时间 - * @return bool: + * @return bool */ - public function expireAt(string $key, int $expireTime): bool: + public function expireAt(string $key, int $expireTime): bool { } @@ -2148,9 +2148,9 @@ public function expireAt(string $key, int $expireTime): bool: * * @param string $key 键名 * @param int $expireTime 到期时间 - * @return bool: + * @return bool */ - public function pexpireAt(string $key, int $expireTime): bool: + public function pexpireAt(string $key, int $expireTime): bool { } @@ -2206,9 +2206,9 @@ public function select(int $dbIndex): bool * @param string $key 键名 * @param int $start 开始位置 * @param int $end 结束位置 - * @return string: + * @return string */ - public function getRange(string $key, int $start, int $end): string: + public function getRange(string $key, int $start, int $end): string { } @@ -2276,9 +2276,9 @@ public function lRange(string $key, int $start, int $end): array * @param string $key 键名 * @param string $value 元素值 * @param int $count 删除的个数 - * @return long | bool + * @return int | bool */ - public function lRem(string $key, string $value, int $count): ?long + public function lRem(string $key, string $value, int $count): ?int { } @@ -2290,9 +2290,9 @@ public function lRem(string $key, string $value, int $count): ?long * @param string $key 键名 * @param string $value 元素值 * @param int $count 删除的个数 - * @return long | bool + * @return int | bool */ - public function lRemove(string $key, string $value, int $count): ?long + public function lRemove(string $key, string $value, int $count): ?int { } @@ -2394,9 +2394,9 @@ public function hIncrByFloat(string $key, string $field, double $step) *统计字符串的位数 * @example * @param string $key 键名 - * @return long + * @return int */ - public function bitCount(string $key): long + public function bitCount(string $key): int { } @@ -2410,9 +2410,9 @@ public function bitCount(string $key): long * @param string $key1 键名1 * @param string $key2 键名2 * @param string|... $keyN 键名N - * @return long + * @return int */ - public function bitOp(string $operation, string $dstKey, string $key1, string $key2, string $keyN): long + public function bitOp(string $operation, string $dstKey, string $key1, string $key2, string $keyN): int { } @@ -2512,9 +2512,9 @@ public function sDiff(string $key1, string $key2): array * @param string $key1 键名1 * @param string $key2 键名2 * @param string|... $keyN 键名n - * @return int: + * @return int */ - public function sDiffStore(string $dstKey, string $key1, string $key2, string $keyN): int: + public function sDiffStore(string $dstKey, string $key1, string $key2, string $keyN): int { } @@ -2660,9 +2660,9 @@ public function sInterStore(string $dstKey, string $key1, string $key2, string $ * @example * @param string $key 键名 * @param string|... $member 成员 - * @return long + * @return int */ - public function sRemove(string $key, string $member): long + public function sRemove(string $key, string $member): int { } @@ -2673,9 +2673,9 @@ public function sRemove(string $key, string $member): long * @example * @param string $key 键名 * @param string|... $member 成员 - * @return long + * @return int */ - public function srem(string $key, string $member): long + public function srem(string $key, string $member): int { } diff --git a/src/Swoole/Co/Redis/Server.php b/src/Swoole/Co/Redis/Server.php index 1aa0e7e..ebc989d 100644 --- a/src/Swoole/Co/Redis/Server.php +++ b/src/Swoole/Co/Redis/Server.php @@ -1,8 +1,8 @@ persist('key'); * @param string $key 键名 - * @return bool: + * @return bool */ - public function persist(string $key): bool: + public function persist(string $key): bool { } @@ -784,9 +784,9 @@ public function persist(string $key): bool: *返回指定键的有效时间(秒) * @example $redis->ttl('key'); * @param string $key 键名 - * @return long + * @return int */ - public function ttl(string $key): long + public function ttl(string $key): int { } @@ -796,9 +796,9 @@ public function ttl(string $key): long *返回指定键的有效时间(毫秒) * @example $redis->pttl('key'); * @param string $key 键名 - * @return long + * @return int */ - public function pttl(string $key): long + public function pttl(string $key): int { } @@ -1108,9 +1108,9 @@ public function ping(): string *设置连接的认证密码 * @example $redis->auth('foobared'); * @param string $password 认证密码 - * @return bool: + * @return bool */ - public function auth(string $password): bool: + public function auth(string $password): bool { } @@ -1284,9 +1284,9 @@ public function setRange(string $key, int $offset, string $value): string * * @param string $key 设置的缓存键 * @param string $value 设置的缓存值 - * @return bool: + * @return bool */ - public function setNx(string $key, string $value): bool: + public function setNx(string $key, string $value): bool { } @@ -1605,9 +1605,9 @@ public function zAdd(string $key, double $score, string $value): int * @param string $key 集合键名 * @param double $start 开始排序值 * @param double $end 结束排序值 - * @return long + * @return int */ - public function zDeleteRangeByScore(string $key, double $start, double $end): long + public function zDeleteRangeByScore(string $key, double $start, double $end): int { } @@ -1619,9 +1619,9 @@ public function zDeleteRangeByScore(string $key, double $start, double $end): lo * @param string $key 集合键名 * @param double $start 开始排序值 * @param double $end 结束排序值 - * @return long + * @return int */ - public function zRemRangeByScore(string $key, double $start, double $end): long + public function zRemRangeByScore(string $key, double $start, double $end): int { } @@ -1659,12 +1659,12 @@ public function zCount(string $key, double $start, double $end): int * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRange(string $key, long $start, long $end, boolean $withScores): array + public function zRange(string $key, int $start, int $end, boolean $withScores): array { } @@ -1682,12 +1682,12 @@ public function zRange(string $key, long $start, long $end, boolean $withScores) * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRevRange(string $key, long $start, long $end, boolean $withScores): array + public function zRevRange(string $key, int $start, int $end, boolean $withScores): array { } @@ -1707,12 +1707,12 @@ public function zRevRange(string $key, long $start, long $end, boolean $withScor * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1)); // array('val2' => 2) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRangeByScore(string $key, long $start, long $end, Array $options): array + public function zRangeByScore(string $key, int $start, int $end, Array $options): array { } @@ -1732,12 +1732,12 @@ public function zRangeByScore(string $key, long $start, long $end, Array $option * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1)); // array('val2' => 2) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRevRangeByScore(string $key, long $start, long $end, Array $options): array + public function zRevRangeByScore(string $key, int $start, int $end, Array $options): array { } @@ -1755,13 +1755,13 @@ public function zRevRangeByScore(string $key, long $start, long $end, Array $opt * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c') * * @param string $key 集合键名 - * @param long $min 最小的字母 - * @param long $max 最大的字母 - * @param long $offset 索引开始值 - * @param long $limit 成员数 + * @param int $min 最小的字母 + * @param int $max 最大的字母 + * @param int $offset 索引开始值 + * @param int $limit 成员数 * @return array */ - public function zRangeByLex(string $key, long $min, long $max, long $offset, long $limit): array + public function zRangeByLex(string $key, int $min, int $max, int $offset, int $limit): array { } @@ -1771,13 +1771,13 @@ public function zRangeByLex(string $key, long $min, long $max, long $offset, lon *按字母字典的顺序返回成员(倒序排序) * @example * @param string $key 集合键名 - * @param long $min 最小的字母 - * @param long $max 最大的字母 - * @param long $offset 索引开始值 - * @param long $limit 成员数 + * @param int $min 最小的字母 + * @param int $max 最大的字母 + * @param int $offset 索引开始值 + * @param int $limit 成员数 * @return */ - public function zRevRangeByLex(string $key, long $min, long $max, long $offset, long $limit) + public function zRevRangeByLex(string $key, int $min, int $max, int $offset, int $limit) { } @@ -2128,9 +2128,9 @@ public function pexpire(string $key, int $ttl): boolean * * @param string $key 键名 * @param int $expireTime 到期时间 - * @return bool: + * @return bool */ - public function expireAt(string $key, int $expireTime): bool: + public function expireAt(string $key, int $expireTime): bool { } @@ -2148,9 +2148,9 @@ public function expireAt(string $key, int $expireTime): bool: * * @param string $key 键名 * @param int $expireTime 到期时间 - * @return bool: + * @return bool */ - public function pexpireAt(string $key, int $expireTime): bool: + public function pexpireAt(string $key, int $expireTime): bool { } @@ -2206,9 +2206,9 @@ public function select(int $dbIndex): bool * @param string $key 键名 * @param int $start 开始位置 * @param int $end 结束位置 - * @return string: + * @return string */ - public function getRange(string $key, int $start, int $end): string: + public function getRange(string $key, int $start, int $end): string { } @@ -2276,9 +2276,9 @@ public function lRange(string $key, int $start, int $end): array * @param string $key 键名 * @param string $value 元素值 * @param int $count 删除的个数 - * @return long | bool + * @return int | bool */ - public function lRem(string $key, string $value, int $count): ?long + public function lRem(string $key, string $value, int $count): ?int { } @@ -2290,9 +2290,9 @@ public function lRem(string $key, string $value, int $count): ?long * @param string $key 键名 * @param string $value 元素值 * @param int $count 删除的个数 - * @return long | bool + * @return int | bool */ - public function lRemove(string $key, string $value, int $count): ?long + public function lRemove(string $key, string $value, int $count): ?int { } @@ -2394,9 +2394,9 @@ public function hIncrByFloat(string $key, string $field, double $step) *统计字符串的位数 * @example * @param string $key 键名 - * @return long + * @return int */ - public function bitCount(string $key): long + public function bitCount(string $key): int { } @@ -2410,9 +2410,9 @@ public function bitCount(string $key): long * @param string $key1 键名1 * @param string $key2 键名2 * @param string|... $keyN 键名N - * @return long + * @return int */ - public function bitOp(string $operation, string $dstKey, string $key1, string $key2, string $keyN): long + public function bitOp(string $operation, string $dstKey, string $key1, string $key2, string $keyN): int { } @@ -2512,9 +2512,9 @@ public function sDiff(string $key1, string $key2): array * @param string $key1 键名1 * @param string $key2 键名2 * @param string|... $keyN 键名n - * @return int: + * @return int */ - public function sDiffStore(string $dstKey, string $key1, string $key2, string $keyN): int: + public function sDiffStore(string $dstKey, string $key1, string $key2, string $keyN): int { } @@ -2660,9 +2660,9 @@ public function sInterStore(string $dstKey, string $key1, string $key2, string $ * @example * @param string $key 键名 * @param string|... $member 成员 - * @return long + * @return int */ - public function sRemove(string $key, string $member): long + public function sRemove(string $key, string $member): int { } @@ -2673,9 +2673,9 @@ public function sRemove(string $key, string $member): long * @example * @param string $key 键名 * @param string|... $member 成员 - * @return long + * @return int */ - public function srem(string $key, string $member): long + public function srem(string $key, string $member): int { } diff --git a/src/Swoole/Coroutine/Socket.php b/src/Swoole/Coroutine/Socket.php index 73b9485..2554e07 100644 --- a/src/Swoole/Coroutine/Socket.php +++ b/src/Swoole/Coroutine/Socket.php @@ -1,8 +1,8 @@ Date: Wed, 20 Jun 2018 19:16:11 +0800 Subject: [PATCH 21/34] =?UTF-8?q?=E6=9B=B4=E6=96=B0phpredis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/Redis/Redis.php | 820 ++++++++++++++++++---------- src/Redis/RedisArray.php | 79 ++- src/Redis/RedisCluster.php | 500 +++++++++++------ src/Redis/RedisClusterException.php | 31 +- src/Redis/RedisException.php | 31 +- 6 files changed, 972 insertions(+), 491 deletions(-) diff --git a/README.md b/README.md index 0adc3e5..5ebed2c 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 4、Yar(2.0.4) -5、Redis(包括RedisCluster) +5、phpRedis(包括RedisCluster,支持phpredis 4.1.0RC1) 6、swoole扩展(支持swoole 4.0) diff --git a/src/Redis/Redis.php b/src/Redis/Redis.php index 14b3680..f090e30 100644 --- a/src/Redis/Redis.php +++ b/src/Redis/Redis.php @@ -1,8 +1,8 @@ get('key'); * @return string|bool */ - public function get() + public function get(): ?string { + } /** @@ -258,8 +314,9 @@ public function get() * @param int|array $options 附加项,可以是超时时间或者一个选项数组 * @return bool */ - public function set($key, $value, $options) + public function set(string $key, string $value, int $options): bool { + } /** @@ -271,8 +328,9 @@ public function set($key, $value, $options) * @param int $ttl 有效期 * @return bool */ - public function setex($key, $value, $ttl) + public function setex(string $key, string $value, int $ttl): bool { + } /** @@ -284,8 +342,9 @@ public function setex($key, $value, $ttl) * @param int $ttl 有效期(毫秒为单位) * @return */ - public function psetex($key, $value, $ttl) + public function psetex(string $key, string $value, int $ttl) { + } /** @@ -296,10 +355,11 @@ public function psetex($key, $value, $ttl) * * @param string $key 设置的缓存键 * @param string $value 设置的缓存值 - * @return bool: + * @return bool */ - public function setnx($key, $value) + public function setnx(string $key, string $value): bool { + } /** @@ -315,8 +375,9 @@ public function setnx($key, $value) * @param string $value 设置的缓存值 * @return string */ - public function getSet($key, $value) + public function getSet(string $key, string $value): string { + } /** @@ -329,8 +390,9 @@ public function getSet($key, $value) * * @return string */ - public function randomKey() + public function randomKey(): string { + } /** @@ -339,10 +401,11 @@ public function randomKey() * @example * @param string $srcKey 旧键名 * @param string $dstKey 新键名 - * @return boolean + * @return bool */ - public function renameKey($srcKey, $dstKey) + public function renameKey(string $srcKey, string $dstKey): bool { + } /** @@ -351,10 +414,11 @@ public function renameKey($srcKey, $dstKey) * @example * @param string $srcKey 旧键名 * @param string $dstKey 新键名 - * @return boolean + * @return bool */ - public function renameNx($srcKey, $dstKey) + public function renameNx(string $srcKey, string $dstKey): bool { + } /** @@ -371,8 +435,9 @@ public function renameNx($srcKey, $dstKey) * @param array $keys 键名数组 * @return array */ - public function getMultiple(Array $keys) + public function getMultiple(Array $keys): array { + } /** @@ -387,8 +452,9 @@ public function getMultiple(Array $keys) * @param string $key 键名 * @return bool */ - public function exists($key) + public function exists(string $key): bool { + } /** @@ -399,8 +465,9 @@ public function exists($key) * @param array|string $keys 键名 * @return int */ - public function delete($keys) + public function delete(array $keys): int { + } /** @@ -416,8 +483,9 @@ public function delete($keys) * @param string $key 键名 * @return int */ - public function incr($key) + public function incr(string $key): int { + } /** @@ -435,8 +503,9 @@ public function incr($key) * @param int $step 自增步长 * @return int */ - public function incrBy($key, $step) + public function incrBy(string $key, int $step): int { + } /** @@ -455,8 +524,9 @@ public function incrBy($key, $step) * @param float $step 自增步长 * @return float */ - public function incrByFloat($key, $step) + public function incrByFloat(string $key, float $step): float { + } /** @@ -471,8 +541,9 @@ public function incrByFloat($key, $step) * @param string $key 键名 * @return int */ - public function decr($key) + public function decr(string $key): int { + } /** @@ -489,8 +560,9 @@ public function decr($key) * @param float $step 自减步长 * @return int */ - public function decrBy($key, $step) + public function decrBy(string $key, float $step): int { + } /** @@ -500,8 +572,9 @@ public function decrBy($key, $step) * @param string $key 键名 * @return int */ - public function type($key) + public function type(string $key): int { + } /** @@ -517,8 +590,9 @@ public function type($key) * @param string $value 追加的值 * @return int */ - public function append($key, $value) + public function append(string $key, string $value): int { + } /** @@ -533,10 +607,11 @@ public function append($key, $value) * @param string $key 键名 * @param int $start 开始位置 * @param int $end 结束位置 - * @return string: + * @return string */ - public function getRange($key, $start, $end) + public function getRange(string $key, int $start, int $end): string { + } /** @@ -553,8 +628,9 @@ public function getRange($key, $start, $end) * @param string $value 被替换的子串的值 * @return string */ - public function setRange($key, $offset, $value) + public function setRange(string $key, int $offset, string $value): string { + } /** @@ -570,8 +646,9 @@ public function setRange($key, $offset, $value) * @param int $offset 所在位置 * @return int */ - public function getBit($key, $offset) + public function getBit(string $key, int $offset): int { + } /** @@ -586,11 +663,12 @@ public function getBit($key, $offset) * * @param string $key 键名 * @param int $offset 开始位置 - * @param boolean|int $value 新值 - * @return int: + * @param bool|int $value 新值 + * @return int */ - public function setBit($key, $offset, $value) + public function setBit(string $key, int $offset, int $value): int { + } /** @@ -604,8 +682,9 @@ public function setBit($key, $offset, $value) * @param string $key 键名 * @return int */ - public function strlen($key) + public function strlen(string $key): int { + } /** @@ -617,8 +696,9 @@ public function strlen($key) * @param string $pattern 匹配模式 * @return array */ - public function getKeys($pattern) + public function getKeys(string $pattern): array { + } /** @@ -640,8 +720,9 @@ public function getKeys($pattern) * @param array $options 排序参数,如:array('sort' => 'desc') * @return An */ - public function sort($key, Array $options) + public function sort(string $key, Array $options): An { + } /** @@ -651,8 +732,9 @@ public function sort($key, Array $options) * @param string $key 键名 * @return */ - public function sortAsc($key) + public function sortAsc(string $key) { + } /** @@ -662,8 +744,9 @@ public function sortAsc($key) * @param string $key 键名 * @return */ - public function sortAscAlpha($key) + public function sortAscAlpha(string $key) { + } /** @@ -673,8 +756,9 @@ public function sortAscAlpha($key) * @param string $key 键名 * @return */ - public function sortDesc($key) + public function sortDesc(string $key) { + } /** @@ -684,8 +768,9 @@ public function sortDesc($key) * @param string $key 键名 * @return */ - public function sortDescAlpha($key) + public function sortDescAlpha(string $key) { + } /** @@ -707,8 +792,9 @@ public function sortDescAlpha($key) * @param string $value 元素值 * @return int */ - public function lPush($key, $value) + public function lPush(string $key, string $value): int { + } /** @@ -730,8 +816,9 @@ public function lPush($key, $value) * @param string $value 元素值 * @return int */ - public function rPush($key, $value) + public function rPush(string $key, string $value): int { + } /** @@ -750,8 +837,9 @@ public function rPush($key, $value) * @param string $value 元素值 * @return int */ - public function lPushx($key, $value) + public function lPushx(string $key, string $value): int { + } /** @@ -770,8 +858,9 @@ public function lPushx($key, $value) * @param string $value 元素值 * @return int */ - public function rPushx($key, $value) + public function rPushx(string $key, string $value): int { + } /** @@ -787,8 +876,9 @@ public function rPushx($key, $value) * @param string $key 键名 * @return string */ - public function lPop($key) + public function lPop(string $key): string { + } /** @@ -804,8 +894,9 @@ public function lPop($key) * @param string $key 键名 * @return string */ - public function rPop($key) + public function rPop(string $key): string { + } /** @@ -836,8 +927,9 @@ public function rPop($key) * @param int $timeout 超时时间 * @return array */ - public function blPop($key, $timeout) + public function blPop(string $key, int $timeout): array { + } /** @@ -868,8 +960,9 @@ public function blPop($key, $timeout) * @param int $timeout 超时时间 * @return array */ - public function brPop($key, $timeout) + public function brPop(string $key, int $timeout): array { + } /** @@ -877,10 +970,11 @@ public function brPop($key, $timeout) *返回列表的长度 * @example * @param string|...|array $key 键名 - * @return long | bool + * @return int | bool */ - public function lSize($key) + public function lSize(string $key): ?int { + } /** @@ -890,10 +984,11 @@ public function lSize($key) * @param string $key 键名 * @param string $value 元素值 * @param int $count 删除的个数 - * @return long | bool + * @return int | bool */ - public function lRemove($key, $value, $count) + public function lRemove(string $key, string $value, int $count): ?int { + } /** @@ -903,10 +998,11 @@ public function lRemove($key, $value, $count) * @param string $key 键名 * @param int $start 开始索引 * @param int $end 结束索引 - * @return array | boolean + * @return array | bool */ - public function listTrim($key, $start, $end) + public function listTrim(string $key, int $start, int $end): ?array { + } /** @@ -915,10 +1011,11 @@ public function listTrim($key, $start, $end) * @example * @param string $key 键名 * @param int $index 索引值 - * @return string | boolean + * @return string | bool */ - public function lGet($key, $index) + public function lGet(string $key, int $index): ?string { + } /** @@ -930,8 +1027,9 @@ public function lGet($key, $index) * @param int $end 索引结束值 * @return array */ - public function lGetRange($key, $start, $end) + public function lGetRange(string $key, int $start, int $end): array { + } /** @@ -949,10 +1047,11 @@ public function lGetRange($key, $start, $end) * @param string $key 键名 * @param int $index 索引值 * @param string $value 新值 - * @return boolean + * @return bool */ - public function lSet($key, $index, $value) + public function lSet(string $key, int $index, string $value): bool { + } /** @@ -977,8 +1076,9 @@ public function lSet($key, $index, $value) * @param string $value 新值 * @return int */ - public function lInsert($key, $position, $element, $value) + public function lInsert(string $key, string $position, string $element, string $value): int { + } /** @@ -993,8 +1093,9 @@ public function lInsert($key, $position, $element, $value) * @param string $value 元素值 * @return int */ - public function sAdd($key, $value) + public function sAdd(string $key, string $value): int { + } /** @@ -1005,8 +1106,9 @@ public function sAdd($key, $value) * @param array $value 元素值 * @return */ - public function sAddArray($key, Array $value) + public function sAddArray(string $key, Array $value) { + } /** @@ -1014,10 +1116,11 @@ public function sAddArray($key, Array $value) *返回集合的元素个数 * @example * @param string $key 键名 - * @return long + * @return int */ - public function sSize($key) + public function sSize(string $key): int { + } /** @@ -1026,10 +1129,11 @@ public function sSize($key) * @example * @param string $key 键名 * @param string|... $member 成员 - * @return long + * @return int */ - public function sRemove($key, $member) + public function sRemove(string $key, string $member): int { + } /** @@ -1050,8 +1154,9 @@ public function sRemove($key, $member) * @param string $member 成员 * @return bool */ - public function sMove($srcKey, $dstKey, $member) + public function sMove(string $srcKey, string $dstKey, string $member): bool { + } /** @@ -1069,8 +1174,9 @@ public function sMove($srcKey, $dstKey, $member) * @param int $count 删除个数 * @return string | bool */ - public function sPop($key, $count) + public function sPop(string $key, int $count): ?string { + } /** @@ -1092,8 +1198,9 @@ public function sPop($key, $count) * @param string $key 键名 * @return string | bool */ - public function sRandMember($key) + public function sRandMember(string $key): ?string { + } /** @@ -1102,10 +1209,11 @@ public function sRandMember($key) * @example * @param string $key 键名 * @param string $member 成员值 - * @return boolean + * @return bool */ - public function sContains($key, $member) + public function sContains(string $key, string $member): bool { + } /** @@ -1132,8 +1240,9 @@ public function sContains($key, $member) * @param string $key 键名 * @return array */ - public function sMembers($key) + public function sMembers(string $key): array { + } /** @@ -1159,10 +1268,11 @@ public function sMembers($key) * * @param string $key1 键名1 * @param string $key2 键名2 - * @return array | boolean + * @return array | bool */ - public function sInter($key1, $key2) + public function sInter(string $key1, string $key2): ?array { + } /** @@ -1195,8 +1305,9 @@ public function sInter($key1, $key2) * @param string|... $keyN 键名n * @return int */ - public function sInterStore($dstKey, $key1, $key2, $keyN) + public function sInterStore(string $dstKey, string $key1, string $key2, string $keyN): int { + } /** @@ -1227,8 +1338,9 @@ public function sInterStore($dstKey, $key1, $key2, $keyN) * @param string|... $key2 键名2 * @return array */ - public function sUnion($key1, $key2) + public function sUnion(string $key1, string $key2): array { + } /** @@ -1263,8 +1375,9 @@ public function sUnion($key1, $key2) * @param string|... $keyN 键名n * @return int */ - public function sUnionStore($dstKey, $key1, $key2, $keyN) + public function sUnionStore(string $dstKey, string $key1, string $key2, string $keyN): int { + } /** @@ -1291,8 +1404,9 @@ public function sUnionStore($dstKey, $key1, $key2, $keyN) * @param string|... $key2 键名2 * @return array */ - public function sDiff($key1, $key2) + public function sDiff(string $key1, string $key2): array { + } /** @@ -1321,10 +1435,11 @@ public function sDiff($key1, $key2) * @param string $key1 键名1 * @param string $key2 键名2 * @param string|... $keyN 键名n - * @return int: + * @return int */ - public function sDiffStore($dstKey, $key1, $key2, $keyN) + public function sDiffStore(string $dstKey, string $key1, string $key2, string $keyN): int { + } /** @@ -1333,20 +1448,22 @@ public function sDiffStore($dstKey, $key1, $key2, $keyN) * @example * @param string $key 键名 * @param int $ttl 有效期(秒数) - * @return boolean + * @return bool */ - public function setTimeout($key, $ttl) + public function setTimeout(string $key, int $ttl): bool { + } /** * *将数据同步到硬盘上 * @example $redis->save(); - * @return boolean + * @return bool */ - public function save() + public function save(): bool { + } /** @@ -1357,6 +1474,7 @@ public function save() */ public function bgSave() { + } /** @@ -1365,8 +1483,9 @@ public function bgSave() * @example $redis->lastSave(); * @return int */ - public function lastSave() + public function lastSave(): int { + } /** @@ -1375,8 +1494,9 @@ public function lastSave() * @example $redis->flushDB(); * @return bool */ - public function flushDB() + public function flushDB(): bool { + } /** @@ -1385,8 +1505,9 @@ public function flushDB() * @example $redis->flushAll(); * @return bool */ - public function flushAll() + public function flushAll(): bool { + } /** @@ -1399,8 +1520,9 @@ public function flushAll() * * @return int */ - public function dbSize() + public function dbSize(): int { + } /** @@ -1408,10 +1530,11 @@ public function dbSize() *设置连接的认证密码 * @example $redis->auth('foobared'); * @param string $password 认证密码 - * @return bool: + * @return bool */ - public function auth($password) + public function auth(string $password): bool { + } /** @@ -1419,10 +1542,11 @@ public function auth($password) *返回指定键的有效时间(秒) * @example $redis->ttl('key'); * @param string $key 键名 - * @return long + * @return int */ - public function ttl($key) + public function ttl(string $key): int { + } /** @@ -1430,10 +1554,11 @@ public function ttl($key) *返回指定键的有效时间(毫秒) * @example $redis->pttl('key'); * @param string $key 键名 - * @return long + * @return int */ - public function pttl($key) + public function pttl(string $key): int { + } /** @@ -1441,10 +1566,11 @@ public function pttl($key) *移除指定键的有效期,让它永久有效 * @example $redis->persist('key'); * @param string $key 键名 - * @return bool: + * @return bool */ - public function persist($key) + public function persist(string $key): bool { + } /** @@ -1459,8 +1585,9 @@ public function persist($key) * * @return array */ - public function info() + public function info(): array { + } /** @@ -1477,8 +1604,9 @@ public function info() * @param int $dbIndex 数据库编号 * @return bool */ - public function select($dbIndex) + public function select(int $dbIndex): bool { + } /** @@ -1496,8 +1624,9 @@ public function select($dbIndex) * @param int $dbIndex 数据库编号 * @return bool */ - public function move($key, $dbIndex) + public function move(string $key, int $dbIndex): bool { + } /** @@ -1506,8 +1635,9 @@ public function move($key, $dbIndex) * @example $redis->bgrewriteaof(); * @return bool */ - public function bgrewriteaof() + public function bgrewriteaof(): bool { + } /** @@ -1521,10 +1651,11 @@ public function bgrewriteaof() * * @param string $host 服务器 * @param int $port 端口号 - * @return bool: + * @return bool */ - public function slaveof($host, $port) + public function slaveof(string $host, int $port): bool { + } /** @@ -1540,8 +1671,9 @@ public function slaveof($host, $port) * @param string $key 键名 * @return string */ - public function object($info, $key) + public function object(string $info, string $key): string { + } /** @@ -1553,10 +1685,11 @@ public function object($info, $key) * @param string $key1 键名1 * @param string $key2 键名2 * @param string|... $keyN 键名N - * @return long + * @return int */ - public function bitop($operation, $dstKey, $key1, $key2, $keyN) + public function bitop(string $operation, string $dstKey, string $key1, string $key2, string $keyN): int { + } /** @@ -1564,10 +1697,11 @@ public function bitop($operation, $dstKey, $key1, $key2, $keyN) *统计字符串的位数 * @example * @param string $key 键名 - * @return long + * @return int */ - public function bitcount($key) + public function bitcount(string $key): int { + } /** @@ -1587,10 +1721,11 @@ public function bitcount($key) * @param int $bit 位值 * @param int $start 开始位置 * @param int $end 结束位置 - * @return function + * @return callable */ - public function bitpos($key, $bit, $start, $end) + public function bitpos(string $key, int $bit, int $start, int $end): callable { + } /** @@ -1608,8 +1743,9 @@ public function bitpos($key, $bit, $start, $end) * @param array $values 要设置的键值对 * @return bool */ - public function mset(Array $values) + public function mset(Array $values): bool { + } /** @@ -1627,8 +1763,9 @@ public function mset(Array $values) * @param array $values 要设置的键值对 * @return bool */ - public function msetnx(Array $values) + public function msetnx(Array $values): bool { + } /** @@ -1665,8 +1802,9 @@ public function msetnx(Array $values) * @param string $dstKey 要插入元素的队列的键名 * @return string */ - public function rpoplpush($srcKey, $dstKey) + public function rpoplpush(string $srcKey, string $dstKey): string { + } /** @@ -1677,8 +1815,9 @@ public function rpoplpush($srcKey, $dstKey) * @param string $dstKey 要插入元素的队列的键名 * @return string */ - public function brpoplpush($srcKey, $dstKey) + public function brpoplpush(string $srcKey, string $dstKey): string { + } /** @@ -1702,8 +1841,9 @@ public function brpoplpush($srcKey, $dstKey) * @param string $value 元素值 * @return int */ - public function zAdd($key, $score, $value) + public function zAdd(string $key, double $score, string $value): int { + } /** @@ -1714,8 +1854,9 @@ public function zAdd($key, $score, $value) * @param string $member 成员值 * @return int */ - public function zDelete($key, $member) + public function zDelete(string $key, string $member): int { + } /** @@ -1731,13 +1872,14 @@ public function zDelete($key, $member) * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 - * @param boolean $withScores 是否返回成员的排序值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @param bool $withScores 是否返回成员的排序值 * @return array */ - public function zRange($key, $start, $end, $withScores) + public function zRange(string $key, int $start, int $end, bool $withScores): array { + } /** @@ -1753,13 +1895,14 @@ public function zRange($key, $start, $end, $withScores) * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 - * @param boolean $withScores 是否返回成员的排序值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @param bool $withScores 是否返回成员的排序值 * @return array */ - public function zRevRange($key, $start, $end, $withScores) + public function zRevRange(string $key, int $start, int $end, bool $withScores): array { + } /** @@ -1777,13 +1920,14 @@ public function zRevRange($key, $start, $end, $withScores) * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1)); // array('val2' => 2) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRangeByScore($key, $start, $end, Array $options) + public function zRangeByScore(string $key, int $start, int $end, Array $options): array { + } /** @@ -1801,13 +1945,14 @@ public function zRangeByScore($key, $start, $end, Array $options) * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1)); // array('val2' => 2) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRevRangeByScore($key, $start, $end, Array $options) + public function zRevRangeByScore(string $key, int $start, int $end, Array $options): array { + } /** @@ -1823,14 +1968,15 @@ public function zRevRangeByScore($key, $start, $end, Array $options) * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c') * * @param string $key 集合键名 - * @param long $min 最小的字母 - * @param long $max 最大的字母 - * @param long $offset 索引开始值 - * @param long $limit 成员数 + * @param int $min 最小的字母 + * @param int $max 最大的字母 + * @param int $offset 索引开始值 + * @param int $limit 成员数 * @return array */ - public function zRangeByLex($key, $min, $max, $offset, $limit) + public function zRangeByLex(string $key, int $min, int $max, int $offset, int $limit): array { + } /** @@ -1838,14 +1984,15 @@ public function zRangeByLex($key, $min, $max, $offset, $limit) *按字母字典的顺序返回成员(倒序排序) * @example * @param string $key 集合键名 - * @param long $min 最小的字母 - * @param long $max 最大的字母 - * @param long $offset 索引开始值 - * @param long $limit 成员数 + * @param int $min 最小的字母 + * @param int $max 最大的字母 + * @param int $offset 索引开始值 + * @param int $limit 成员数 * @return */ - public function zRevRangeByLex($key, $min, $max, $offset, $limit) + public function zRevRangeByLex(string $key, int $min, int $max, int $offset, int $limit) { + } /** @@ -1853,12 +2000,13 @@ public function zRevRangeByLex($key, $min, $max, $offset, $limit) *获取指定字母范围的成员数 * @example * @param string $key 集合键名 - * @param long $min 最小的字母 - * @param long $max 最大的字母 + * @param int $min 最小的字母 + * @param int $max 最大的字母 * @return int */ - public function zLexCount($key, $min, $max) + public function zLexCount(string $key, int $min, int $max): int { + } /** @@ -1866,12 +2014,13 @@ public function zLexCount($key, $min, $max) *删除指定字母范围的成员 * @example * @param string $key 集合键名 - * @param long $min 最小的字母 - * @param long $max 最大的字母 - * @return long + * @param int $min 最小的字母 + * @param int $max 最大的字母 + * @return int */ - public function zRemRangeByLex($key, $min, $max) + public function zRemRangeByLex(string $key, int $min, int $max): int { + } /** @@ -1889,8 +2038,9 @@ public function zRemRangeByLex($key, $min, $max) * @param double $end 结束排序值 * @return int */ - public function zCount($key, $start, $end) + public function zCount(string $key, double $start, double $end): int { + } /** @@ -1900,10 +2050,11 @@ public function zCount($key, $start, $end) * @param string $key 集合键名 * @param double $start 开始排序值 * @param double $end 结束排序值 - * @return long + * @return int */ - public function zDeleteRangeByScore($key, $start, $end) + public function zDeleteRangeByScore(string $key, double $start, double $end): int { + } /** @@ -1922,8 +2073,9 @@ public function zDeleteRangeByScore($key, $start, $end) * @param double $end 结束排序值 * @return int */ - public function zDeleteRangeByRank($key, $start, $end) + public function zDeleteRangeByRank(string $key, double $start, double $end): int { + } /** @@ -1939,8 +2091,9 @@ public function zDeleteRangeByRank($key, $start, $end) * @param string $key 集合键名 * @return int */ - public function zCard($key) + public function zCard(string $key): int { + } /** @@ -1955,8 +2108,9 @@ public function zCard($key) * @param string $member 成员值 * @return double */ - public function zScore($key, $member) + public function zScore(string $key, string $member): double { + } /** @@ -1976,8 +2130,9 @@ public function zScore($key, $member) * @param string $member 成员值 * @return int */ - public function zRank($key, $member) + public function zRank(string $key, string $member): int { + } /** @@ -1988,8 +2143,9 @@ public function zRank($key, $member) * @param string $member 成员值 * @return int */ - public function zRevRank($key, $member) + public function zRevRank(string $key, string $member): int { + } /** @@ -2021,8 +2177,9 @@ public function zRevRank($key, $member) * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zInter($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zInter(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -2051,8 +2208,9 @@ public function zInter($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggrega * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zUnion($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zUnion(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -2070,8 +2228,9 @@ public function zUnion($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggrega * @param string $member 成员 * @return float */ - public function zIncrBy($key, $step, $member) + public function zIncrBy(string $key, double $step, string $member): float { + } /** @@ -2087,10 +2246,11 @@ public function zIncrBy($key, $step, $member) * * @param string $key 键名 * @param int $expireTime 到期时间 - * @return bool: + * @return bool */ - public function expireAt($key, $expireTime) + public function expireAt(string $key, int $expireTime): bool { + } /** @@ -2099,10 +2259,11 @@ public function expireAt($key, $expireTime) * @example * @param string $key 键名 * @param int $ttl 有效期(毫秒数) - * @return boolean + * @return bool */ - public function pexpire($key, $ttl) + public function pexpire(string $key, int $ttl): bool { + } /** @@ -2118,10 +2279,11 @@ public function pexpire($key, $ttl) * * @param string $key 键名 * @param int $expireTime 到期时间 - * @return bool: + * @return bool */ - public function pexpireAt($key, $expireTime) + public function pexpireAt(string $key, int $expireTime): bool { + } /** @@ -2132,8 +2294,9 @@ public function pexpireAt($key, $expireTime) * @param string $field 字段名 * @return string */ - public function hGet($key, $field) + public function hGet(string $key, string $field): string { + } /** @@ -2150,10 +2313,11 @@ public function hGet($key, $field) * @param string $key 键名 * @param string $field 字段名 * @param string $value 字段值 - * @return long + * @return int */ - public function hSet($key, $field, $value) + public function hSet(string $key, string $field, string $value): int { + } /** @@ -2171,8 +2335,9 @@ public function hSet($key, $field, $value) * @param string $value 字段值 * @return bool */ - public function hSetNx($key, $field, $value) + public function hSetNx(string $key, string $field, string $value): bool { + } /** @@ -2200,8 +2365,9 @@ public function hSetNx($key, $field, $value) * @param string|array $fields 字段名 * @return int */ - public function hDel($key, $fields) + public function hDel(string $key, string $fields): int { + } /** @@ -2217,8 +2383,9 @@ public function hDel($key, $fields) * @param string $key 键名 * @return int */ - public function hLen($key) + public function hLen(string $key): int { + } /** @@ -2248,8 +2415,9 @@ public function hLen($key) * @param string $key 键名 * @return array */ - public function hKeys($key) + public function hKeys(string $key): array { + } /** @@ -2279,8 +2447,9 @@ public function hKeys($key) * @param string $key 键名 * @return array */ - public function hVals($key) + public function hVals(string $key): array { + } /** @@ -2310,8 +2479,9 @@ public function hVals($key) * @param string $key 键名 * @return array */ - public function hGetAll($key) + public function hGetAll(string $key): array { + } /** @@ -2327,8 +2497,9 @@ public function hGetAll($key) * @param string $field 字段名 * @return bool */ - public function hExists($key, $field) + public function hExists(string $key, string $field): bool { + } /** @@ -2345,8 +2516,9 @@ public function hExists($key, $field) * @param int $step 自增步长 * @return int */ - public function hIncrBy($key, $field, $step) + public function hIncrBy(string $key, string $field, int $step): int { + } /** @@ -2373,8 +2545,9 @@ public function hIncrBy($key, $field, $step) * @param double $step 自增步长 * @return */ - public function hIncrByFloat($key, $field, $step) + public function hIncrByFloat(string $key, string $field, double $step) { + } /** @@ -2388,10 +2561,11 @@ public function hIncrByFloat($key, $field, $step) * * @param string $key 键名 * @param array $fields 字段键值对 - * @return boolean + * @return bool */ - public function hMset($key, Array $fields) + public function hMset(string $key, Array $fields): bool { + } /** @@ -2402,8 +2576,9 @@ public function hMset($key, Array $fields) * @param array $fields 字段名列表 * @return array */ - public function hMget($key, Array $fields) + public function hMget(string $key, Array $fields): array { + } /** @@ -2427,6 +2602,7 @@ public function hMget($key, Array $fields) */ public function multi() { + } /** @@ -2437,6 +2613,7 @@ public function multi() */ public function discard() { + } /** @@ -2447,6 +2624,7 @@ public function discard() */ public function exec() { + } /** @@ -2457,6 +2635,7 @@ public function exec() */ public function pipeline() { + } /** @@ -2465,7 +2644,7 @@ public function pipeline() * @example *
      * $redis->watch('x');
-     * // long code here during the execution of which other clients could well modify `x`
+     * // int code here during the execution of which other clients could well modify `x`
      * $ret = $redis->multi()
      * ->incr('x')
      * ->exec();
@@ -2474,8 +2653,9 @@ public function pipeline()
      * @param string|array $keys 键名
      * @return 
      */
-    public function watch($keys)
+    public function watch(string $keys)
     {
+    
     }
 
     /**
@@ -2485,8 +2665,9 @@ public function watch($keys)
      * @param string|array $keys 键名
      * @return 
      */
-    public function unwatch($keys)
+    public function unwatch(string $keys)
     {
+    
     }
 
     /**
@@ -2497,8 +2678,9 @@ public function unwatch($keys)
      * @param string $message 消息
      * @return int
      */
-    public function publish($channel, $message)
+    public function publish(string $channel, string $message): int
     {
+    
     }
 
     /**
@@ -2526,8 +2708,9 @@ public function publish($channel, $message)
      * @param mixed $value 返回值
      * @return mixed
      */
-    public function subscribe(Array $channels, $callback, $value)
+    public function subscribe(Array $channels, string $callback, $value)
     {
+    
     }
 
     /**
@@ -2546,8 +2729,9 @@ public function subscribe(Array $channels, $callback, $value)
      * @param mixed $value 返回值
      * @return 
      */
-    public function psubscribe(Array $patterns, $callback, $value)
+    public function psubscribe(Array $patterns, string $callback, $value)
     {
+    
     }
 
     /**
@@ -2559,6 +2743,7 @@ public function psubscribe(Array $patterns, $callback, $value)
      */
     public function unsubscribe(Array $channels)
     {
+    
     }
 
     /**
@@ -2570,6 +2755,7 @@ public function unsubscribe(Array $channels)
      */
     public function punsubscribe(Array $patterns)
     {
+    
     }
 
     /**
@@ -2585,8 +2771,9 @@ public function punsubscribe(Array $patterns)
      * 
* @return int */ - public function time() + public function time(): int { + } /** @@ -2595,8 +2782,9 @@ public function time() * @example * @return string */ - public function role() + public function role(): string { + } /** @@ -2617,8 +2805,9 @@ public function role() * @param string|... $script 脚本 * @return */ - public function script($command, $script) + public function script(string $command, string $script) { + } /** @@ -2629,6 +2818,7 @@ public function script($command, $script) */ public function debug() { + } /** @@ -2642,8 +2832,9 @@ public function debug() * @param string $key 键名 * @return string */ - public function dump($key) + public function dump(string $key): string { + } /** @@ -2660,8 +2851,9 @@ public function dump($key) * @param string $value dump导出的二进制数据 * @return */ - public function restore($key, $ttl, $value) + public function restore(string $key, int $ttl, string $value) { + } /** @@ -2676,12 +2868,13 @@ public function restore($key, $ttl, $value) * @param string|array $keys 迁移的键 * @param int $database 目标数据库 * @param int $timeout 超时时间 - * @param boolean $copy 是否复制 - * @param boolean $replace 是否替换 + * @param bool $copy 是否复制 + * @param bool $replace 是否替换 * @return */ - public function migrate($host, $port, $keys, $database, $timeout, $copy, $replace) + public function migrate(string $host, int $port, string $keys, int $database, int $timeout, bool $copy, bool $replace) { + } /** @@ -2695,8 +2888,9 @@ public function migrate($host, $port, $keys, $database, $timeout, $copy, $replac * * @return string */ - public function getLastError() + public function getLastError(): string { + } /** @@ -2714,8 +2908,9 @@ public function getLastError() * * @return bool */ - public function clearLastError() + public function clearLastError(): bool { + } /** @@ -2729,8 +2924,9 @@ public function clearLastError() * @param string $prefix 前缀 * @return string */ - public function _prefix($prefix) + public function _prefix(string $prefix): string { + } /** @@ -2748,8 +2944,9 @@ public function _prefix($prefix) * @param string $value 被序列化的值 * @return */ - public function _serialize($value) + public function _serialize(string $value) { + } /** @@ -2763,8 +2960,9 @@ public function _serialize($value) * @param string $value 被反序列化的值 * @return */ - public function _unserialize($value) + public function _unserialize(string $value) { + } /** @@ -2779,8 +2977,9 @@ public function _unserialize($value) * @param string $args 参数 * @return */ - public function client($command, $args) + public function client(string $command, string $args) { + } /** @@ -2789,8 +2988,9 @@ public function client($command, $args) * @example * @return array */ - public function command() + public function command(): array { + } /** @@ -2805,13 +3005,14 @@ public function command() * } * } * - * @param Long|NULL $i_iterator 迭代器 + * @param int|NULL $i_iterator 迭代器 * @param string $str_pattern 匹配的模式 * @param int $i_count 每次迭代的长度 * @return array */ - public function scan($i_iterator, $str_pattern, $i_count) + public function scan(int $i_iterator, string $str_pattern, int $i_count): array { + } /** @@ -2819,13 +3020,14 @@ public function scan($i_iterator, $str_pattern, $i_count) *扫描hash的键 * @example * @param string $str_key 键值 - * @param Long|NULL $i_iterator 迭代器 + * @param int|NULL $i_iterator 迭代器 * @param string $str_pattern 匹配的模式 * @param int $i_count 每次迭代的长度 * @return */ - public function hscan($str_key, $i_iterator, $str_pattern, $i_count) + public function hscan(string $str_key, int $i_iterator, string $str_pattern, int $i_count) { + } /** @@ -2833,13 +3035,14 @@ public function hscan($str_key, $i_iterator, $str_pattern, $i_count) *扫描有序集合的键 * @example * @param string $str_key 键值 - * @param Long|NULL $i_iterator 迭代器 + * @param int|NULL $i_iterator 迭代器 * @param string $str_pattern 匹配的模式 * @param int $i_count 每次迭代的长度 * @return */ - public function zscan($str_key, $i_iterator, $str_pattern, $i_count) + public function zscan(string $str_key, int $i_iterator, string $str_pattern, int $i_count) { + } /** @@ -2847,13 +3050,14 @@ public function zscan($str_key, $i_iterator, $str_pattern, $i_count) *扫描集合的键 * @example * @param string $str_key 键值 - * @param Long|NULL $i_iterator 迭代器 + * @param int|NULL $i_iterator 迭代器 * @param string $str_pattern 匹配的模式 * @param int $i_count 每次迭代的长度 * @return */ - public function sscan($str_key, $i_iterator, $str_pattern, $i_count) + public function sscan(string $str_key, int $i_iterator, string $str_pattern, int $i_count) { + } /** @@ -2864,8 +3068,9 @@ public function sscan($str_key, $i_iterator, $str_pattern, $i_count) * @param string|array|... $element 元素 * @return */ - public function pfadd($key, $element) + public function pfadd(string $key, string $element) { + } /** @@ -2875,8 +3080,9 @@ public function pfadd($key, $element) * @param string|array $keys 键名 * @return */ - public function pfcount($keys) + public function pfcount(string $keys) { + } /** @@ -2887,8 +3093,9 @@ public function pfcount($keys) * @param string|array $sourceKeys 源键名 * @return */ - public function pfmerge($dstKey, $sourceKeys) + public function pfmerge(string $dstKey, string $sourceKeys) { + } /** @@ -2900,8 +3107,9 @@ public function pfmerge($dstKey, $sourceKeys) * @param string $optionName 选项名 * @return int */ - public function getOption($optionName) + public function getOption(string $optionName): int { + } /** @@ -2916,10 +3124,11 @@ public function getOption($optionName) * * @param string $optionName 选项名 * @param string $optionValue 选项值 - * @return bool: + * @return bool */ - public function setOption($optionName, $optionValue) + public function setOption(string $optionName, string $optionValue): bool { + } /** @@ -2935,8 +3144,9 @@ public function setOption($optionName, $optionValue) * @param string $value 配置值 * @return array */ - public function config($operation, $key, $value) + public function config(string $operation, string $key, string $value): array { + } /** @@ -2947,8 +3157,9 @@ public function config($operation, $key, $value) * @param int $length 获取条目数 * @return */ - public function slowlog($command, $length) + public function slowlog(string $command, int $length) { + } /** @@ -2959,8 +3170,9 @@ public function slowlog($command, $length) * @param string|array $args 参数 * @return */ - public function rawcommand($command, $args) + public function rawcommand(string $command, string $args) { + } /** @@ -2971,6 +3183,7 @@ public function rawcommand($command, $args) */ public function getHost() { + } /** @@ -2981,6 +3194,7 @@ public function getHost() */ public function getPort() { + } /** @@ -2991,6 +3205,7 @@ public function getPort() */ public function getDBNum() { + } /** @@ -3001,6 +3216,7 @@ public function getDBNum() */ public function getTimeout() { + } /** @@ -3011,6 +3227,7 @@ public function getTimeout() */ public function getReadTimeout() { + } /** @@ -3021,6 +3238,7 @@ public function getReadTimeout() */ public function getPersistentID() { + } /** @@ -3029,8 +3247,9 @@ public function getPersistentID() * @example * @return string */ - public function getAuth() + public function getAuth(): string { + } /** @@ -3039,8 +3258,9 @@ public function getAuth() * @example * @return bool */ - public function isConnected() + public function isConnected(): bool { + } /** @@ -3049,8 +3269,9 @@ public function isConnected() * @example $redis->getMode(); * @return int */ - public function getMode() + public function getMode(): int { + } /** @@ -3061,8 +3282,9 @@ public function getMode() * @param int $timeout 超时时间 * @return context */ - public function wait($count, $timeout) + public function wait(int $count, int $timeout): context { + } /** @@ -3079,8 +3301,9 @@ public function wait($count, $timeout) * @param string|array $args 参数 * @return array|int */ - public function pubsub($subcommand, $args) + public function pubsub(string $subcommand, string $args): ?array { + } /** @@ -3095,8 +3318,9 @@ public function pubsub($subcommand, $args) * @param float $read_timeout 读操作超时时间 * @return */ - public function open($host, $port, $timeout, $reserved, $retry_interval, $read_timeout) + public function open(string $host, int $port, float $timeout, $reserved, int $retry_interval, float $read_timeout) { + } /** @@ -3111,8 +3335,9 @@ public function open($host, $port, $timeout, $reserved, $retry_interval, $read_t * @param float $read_timeout 读操作超时时间 * @return */ - public function popen($host, $port, $timeout, $reserved, $retry_interval, $read_timeout) + public function popen(string $host, int $port, float $timeout, $reserved, int $retry_interval, float $read_timeout) { + } /** @@ -3120,10 +3345,11 @@ public function popen($host, $port, $timeout, $reserved, $retry_interval, $read_ *返回列表的长度 * @example * @param string|...|array $key 键名 - * @return long | bool + * @return int | bool */ - public function lLen($key) + public function lLen(string $key): ?int { + } /** @@ -3150,8 +3376,9 @@ public function lLen($key) * @param string $key 键名 * @return array */ - public function sGetMembers($key) + public function sGetMembers(string $key): array { + } /** @@ -3180,6 +3407,7 @@ public function sGetMembers($key) */ public function mget(Array $keys) { + } /** @@ -3188,10 +3416,11 @@ public function mget(Array $keys) * @example * @param string $key 键名 * @param int $ttl 有效期(秒数) - * @return boolean + * @return bool */ - public function expire($key, $ttl) + public function expire(string $key, int $ttl): bool { + } /** @@ -3220,8 +3449,9 @@ public function expire($key, $ttl) * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zunionstore(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -3253,8 +3483,9 @@ public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $ag * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zinterstore(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -3265,8 +3496,9 @@ public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $ag * @param string $member 成员值 * @return int */ - public function zRemove($key, $member) + public function zRemove(string $key, string $member): int { + } /** @@ -3277,8 +3509,9 @@ public function zRemove($key, $member) * @param string $member 成员值 * @return int */ - public function zRem($key, $member) + public function zRem(string $key, string $member): int { + } /** @@ -3288,10 +3521,11 @@ public function zRem($key, $member) * @param string $key 集合键名 * @param double $start 开始排序值 * @param double $end 结束排序值 - * @return long + * @return int */ - public function zRemoveRangeByScore($key, $start, $end) + public function zRemoveRangeByScore(string $key, double $start, double $end): int { + } /** @@ -3301,10 +3535,11 @@ public function zRemoveRangeByScore($key, $start, $end) * @param string $key 集合键名 * @param double $start 开始排序值 * @param double $end 结束排序值 - * @return long + * @return int */ - public function zRemRangeByScore($key, $start, $end) + public function zRemRangeByScore(string $key, double $start, double $end): int { + } /** @@ -3323,8 +3558,9 @@ public function zRemRangeByScore($key, $start, $end) * @param double $end 结束排序值 * @return int */ - public function zRemRangeByRank($key, $start, $end) + public function zRemRangeByRank(string $key, double $start, double $end): int { + } /** @@ -3340,8 +3576,9 @@ public function zRemRangeByRank($key, $start, $end) * @param string $key 集合键名 * @return int */ - public function zSize($key) + public function zSize(string $key): int { + } /** @@ -3356,10 +3593,11 @@ public function zSize($key) * @param string $key 键名 * @param int $start 开始位置 * @param int $end 结束位置 - * @return string: + * @return string */ - public function substr($key, $start, $end) + public function substr(string $key, int $start, int $end): string { + } /** @@ -3368,10 +3606,11 @@ public function substr($key, $start, $end) * @example * @param string $srcKey 旧键名 * @param string $dstKey 新键名 - * @return boolean + * @return bool */ - public function rename($srcKey, $dstKey) + public function rename(string $srcKey, string $dstKey): bool { + } /** @@ -3382,8 +3621,9 @@ public function rename($srcKey, $dstKey) * @param array|string $keys 键名 * @return int */ - public function del($keys) + public function del(array $keys): int { + } /** @@ -3395,8 +3635,9 @@ public function del($keys) * @param string $pattern 匹配模式 * @return array */ - public function keys($pattern) + public function keys(string $pattern): array { + } /** @@ -3406,10 +3647,11 @@ public function keys($pattern) * @param string $key 键名 * @param string $value 元素值 * @param int $count 删除的个数 - * @return long | bool + * @return int | bool */ - public function lrem($key, $value, $count) + public function lrem(string $key, string $value, int $count): ?int { + } /** @@ -3419,10 +3661,11 @@ public function lrem($key, $value, $count) * @param string $key 键名 * @param int $start 开始索引 * @param int $end 结束索引 - * @return array | boolean + * @return array | bool */ - public function ltrim($key, $start, $end) + public function ltrim(string $key, int $start, int $end): ?array { + } /** @@ -3431,10 +3674,11 @@ public function ltrim($key, $start, $end) * @example * @param string $key 键名 * @param int $index 索引值 - * @return string | boolean + * @return string | bool */ - public function lindex($key, $index) + public function lindex(string $key, int $index): ?string { + } /** @@ -3446,8 +3690,9 @@ public function lindex($key, $index) * @param int $end 索引结束值 * @return array */ - public function lrange($key, $start, $end) + public function lrange(string $key, int $start, int $end): array { + } /** @@ -3455,10 +3700,11 @@ public function lrange($key, $start, $end) *返回集合的元素个数 * @example * @param string $key 键名 - * @return long + * @return int */ - public function scard($key) + public function scard(string $key): int { + } /** @@ -3467,10 +3713,11 @@ public function scard($key) * @example * @param string $key 键名 * @param string|... $member 成员 - * @return long + * @return int */ - public function srem($key, $member) + public function srem(string $key, string $member): int { + } /** @@ -3479,10 +3726,11 @@ public function srem($key, $member) * @example * @param string $key 键名 * @param string $member 成员值 - * @return boolean + * @return bool */ - public function sismember($key, $member) + public function sismember(string $key, string $member): bool { + } /** @@ -3498,13 +3746,14 @@ public function sismember($key, $member) * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0) * * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 - * @param boolean $withScores 是否返回成员的排序值 + * @param int $start 索引开始值 + * @param int $end 索引结束值 + * @param bool $withScores 是否返回成员的排序值 * @return array */ - public function zReverseRange($key, $start, $end, $withScores) + public function zReverseRange(string $key, int $start, int $end, bool $withScores): array { + } /** @@ -3514,8 +3763,9 @@ public function zReverseRange($key, $start, $end, $withScores) * @param string $str 发送的字符串 * @return string */ - public function sendEcho($str) + public function sendEcho(string $str): string { + } /** @@ -3527,8 +3777,9 @@ public function sendEcho($str) * @param int $num_keys 应该进入KEYS数组的参数个数 * @return mixed */ - public function evaluate($script, Array $args, $num_keys) + public function evaluate(string $script, Array $args, int $num_keys) { + } /** @@ -3540,8 +3791,9 @@ public function evaluate($script, Array $args, $num_keys) * @param int $num_keys 应该进入KEYS数组的参数个数 * @return mixed */ - public function eval($script, Array $args, $num_keys) + public function eval(string $script, Array $args, int $num_keys) { + } /** @@ -3555,8 +3807,9 @@ public function eval($script, Array $args, $num_keys) * @param int $num_keys 应该进入KEYS数组的参数个数 * @return */ - public function evaluateSha($script_sha, Array $args, $num_keys) + public function evaluateSha(string $script_sha, Array $args, int $num_keys) { + } /** @@ -3570,8 +3823,9 @@ public function evaluateSha($script_sha, Array $args, $num_keys) * @param int $num_keys 应该进入KEYS数组的参数个数 * @return */ - public function evalSha($script_sha, Array $args, $num_keys) + public function evalSha(string $script_sha, Array $args, int $num_keys) { + } } diff --git a/src/Redis/RedisArray.php b/src/Redis/RedisArray.php index 617e20a..44b5a24 100644 --- a/src/Redis/RedisArray.php +++ b/src/Redis/RedisArray.php @@ -1,12 +1,12 @@ * @return array */ - public function info() + public function info(): array { + } /** @@ -135,8 +145,9 @@ public function info() * @example * @return string */ - public function ping() + public function ping(): string { + } /** @@ -145,8 +156,9 @@ public function ping() * @example $redis->flushDB(); * @return bool */ - public function flushDB() + public function flushDB(): bool { + } /** @@ -155,8 +167,9 @@ public function flushDB() * @example $redis->flushAll(); * @return bool */ - public function flushAll() + public function flushAll(): bool { + } /** @@ -185,6 +198,7 @@ public function flushAll() */ public function mget(Array $keys) { + } /** @@ -202,8 +216,9 @@ public function mget(Array $keys) * @param array $values 要设置的键值对 * @return bool */ - public function mset(Array $values) + public function mset(Array $values): bool { + } /** @@ -214,8 +229,9 @@ public function mset(Array $values) * @param array|string $keys 键名 * @return int */ - public function del($keys) + public function del(array $keys): int { + } /** @@ -227,8 +243,9 @@ public function del($keys) * @param string $optionName 选项名 * @return int */ - public function getOption($optionName) + public function getOption(string $optionName): int { + } /** @@ -243,10 +260,11 @@ public function getOption($optionName) * * @param string $optionName 选项名 * @param string $optionValue 选项值 - * @return bool: + * @return bool */ - public function setOption($optionName, $optionValue) + public function setOption(string $optionName, string $optionValue): bool { + } /** @@ -258,8 +276,9 @@ public function setOption($optionName, $optionValue) * @param string $pattern 匹配模式 * @return array */ - public function keys($pattern) + public function keys(string $pattern): array { + } /** @@ -268,8 +287,9 @@ public function keys($pattern) * @example $redis->save(); * @return boolean */ - public function save() + public function save(): boolean { + } /** @@ -280,6 +300,7 @@ public function save() */ public function bgSave() { + } /** @@ -303,6 +324,7 @@ public function bgSave() */ public function multi() { + } /** @@ -313,6 +335,7 @@ public function multi() */ public function discard() { + } /** @@ -323,6 +346,7 @@ public function discard() */ public function exec() { + } /** @@ -332,8 +356,9 @@ public function exec() * @param string|array $keys 键名 * @return */ - public function unwatch($keys) + public function unwatch(string $keys) { + } /** @@ -344,8 +369,9 @@ public function unwatch($keys) * @param array|string $keys 键名 * @return int */ - public function delete($keys) + public function delete(array $keys): int { + } /** @@ -362,8 +388,9 @@ public function delete($keys) * @param array $keys 键名数组 * @return array */ - public function getMultiple(Array $keys) + public function getMultiple(Array $keys): array { + } } diff --git a/src/Redis/RedisCluster.php b/src/Redis/RedisCluster.php index 68fb9e4..bd889a9 100644 --- a/src/Redis/RedisCluster.php +++ b/src/Redis/RedisCluster.php @@ -1,8 +1,8 @@ get('key'); * @return string|bool */ - public function get() + public function get(): ?string { + } /** @@ -172,8 +195,9 @@ public function get() * @param int|array $options 附加项,可以是超时时间或者一个选项数组 * @return bool */ - public function set($key, $value, $options) + public function set(string $key, string $value, int $options): bool { + } /** @@ -202,6 +226,7 @@ public function set($key, $value, $options) */ public function mget(Array $keys) { + } /** @@ -219,8 +244,9 @@ public function mget(Array $keys) * @param array $values 要设置的键值对 * @return bool */ - public function mset(Array $values) + public function mset(Array $values): bool { + } /** @@ -238,8 +264,9 @@ public function mset(Array $values) * @param array $values 要设置的键值对 * @return bool */ - public function msetnx(Array $values) + public function msetnx(Array $values): bool { + } /** @@ -250,8 +277,9 @@ public function msetnx(Array $values) * @param array|string $keys 键名 * @return int */ - public function del($keys) + public function del(array $keys): int { + } /** @@ -263,8 +291,9 @@ public function del($keys) * @param int $ttl 有效期 * @return bool */ - public function setex($key, $value, $ttl) + public function setex(string $key, string $value, int $ttl): bool { + } /** @@ -276,8 +305,9 @@ public function setex($key, $value, $ttl) * @param int $ttl 有效期(毫秒为单位) * @return */ - public function psetex($key, $value, $ttl) + public function psetex(string $key, string $value, int $ttl) { + } /** @@ -288,10 +318,11 @@ public function psetex($key, $value, $ttl) * * @param string $key 设置的缓存键 * @param string $value 设置的缓存值 - * @return bool: + * @return bool */ - public function setnx($key, $value) + public function setnx(string $key, string $value): bool { + } /** @@ -307,8 +338,9 @@ public function setnx($key, $value) * @param string $value 设置的缓存值 * @return string */ - public function getset($key, $value) + public function getset(string $key, string $value): string { + } /** @@ -323,8 +355,9 @@ public function getset($key, $value) * @param string $key 键名 * @return bool */ - public function exists($key) + public function exists(string $key): bool { + } /** @@ -336,8 +369,9 @@ public function exists($key) * @param string $pattern 匹配模式 * @return array */ - public function keys($pattern) + public function keys(string $pattern): array { + } /** @@ -347,8 +381,9 @@ public function keys($pattern) * @param string $key 键名 * @return int */ - public function type($key) + public function type(string $key): int { + } /** @@ -364,8 +399,9 @@ public function type($key) * @param string $key 键名 * @return string */ - public function lPop($key) + public function lPop(string $key): string { + } /** @@ -381,8 +417,9 @@ public function lPop($key) * @param string $key 键名 * @return string */ - public function rPop($key) + public function rPop(string $key): string { + } /** @@ -402,8 +439,9 @@ public function rPop($key) * @param string $value 新值 * @return boolean */ - public function lset($key, $index, $value) + public function lset(string $key, int $index, string $value): boolean { + } /** @@ -421,8 +459,9 @@ public function lset($key, $index, $value) * @param int $count 删除个数 * @return string | bool */ - public function spop($key, $count) + public function spop(string $key, int $count): ?string { + } /** @@ -444,8 +483,9 @@ public function spop($key, $count) * @param string $value 元素值 * @return int */ - public function lPush($key, $value) + public function lPush(string $key, string $value): int { + } /** @@ -467,8 +507,9 @@ public function lPush($key, $value) * @param string $value 元素值 * @return int */ - public function rPush($key, $value) + public function rPush(string $key, string $value): int { + } /** @@ -499,8 +540,9 @@ public function rPush($key, $value) * @param int $timeout 超时时间 * @return array */ - public function blPop($key, $timeout) + public function blPop(string $key, int $timeout): array { + } /** @@ -531,8 +573,9 @@ public function blPop($key, $timeout) * @param int $timeout 超时时间 * @return array */ - public function brPop($key, $timeout) + public function brPop(string $key, int $timeout): array { + } /** @@ -551,8 +594,9 @@ public function brPop($key, $timeout) * @param string $value 元素值 * @return int */ - public function lPushx($key, $value) + public function lPushx(string $key, string $value): int { + } /** @@ -571,8 +615,9 @@ public function lPushx($key, $value) * @param string $value 元素值 * @return int */ - public function rPushx($key, $value) + public function rPushx(string $key, string $value): int { + } /** @@ -597,8 +642,9 @@ public function rPushx($key, $value) * @param string $value 新值 * @return int */ - public function linsert($key, $position, $element, $value) + public function linsert(string $key, string $position, string $element, string $value): int { + } /** @@ -609,8 +655,9 @@ public function linsert($key, $position, $element, $value) * @param int $index 索引值 * @return string | boolean */ - public function lindex($key, $index) + public function lindex(string $key, int $index): ?string { + } /** @@ -622,8 +669,9 @@ public function lindex($key, $index) * @param int $count 删除的个数 * @return long | bool */ - public function lrem($key, $value, $count) + public function lrem(string $key, string $value, int $count): ?long { + } /** @@ -660,8 +708,9 @@ public function lrem($key, $value, $count) * @param string $dstKey 要插入元素的队列的键名 * @return string */ - public function rpoplpush($srcKey, $dstKey) + public function rpoplpush(string $srcKey, string $dstKey): string { + } /** @@ -672,8 +721,9 @@ public function rpoplpush($srcKey, $dstKey) * @param string $dstKey 要插入元素的队列的键名 * @return string */ - public function brpoplpush($srcKey, $dstKey) + public function brpoplpush(string $srcKey, string $dstKey): string { + } /** @@ -683,8 +733,9 @@ public function brpoplpush($srcKey, $dstKey) * @param string|...|array $key 键名 * @return long | bool */ - public function llen($key) + public function llen(string $key): ?long { + } /** @@ -694,8 +745,9 @@ public function llen($key) * @param string $key 键名 * @return long */ - public function scard($key) + public function scard(string $key): long { + } /** @@ -722,8 +774,9 @@ public function scard($key) * @param string $key 键名 * @return array */ - public function smembers($key) + public function smembers(string $key): array { + } /** @@ -734,8 +787,9 @@ public function smembers($key) * @param string $member 成员值 * @return boolean */ - public function sismember($key, $member) + public function sismember(string $key, string $member): boolean { + } /** @@ -750,8 +804,9 @@ public function sismember($key, $member) * @param string $value 元素值 * @return int */ - public function sAdd($key, $value) + public function sAdd(string $key, string $value): int { + } /** @@ -762,8 +817,9 @@ public function sAdd($key, $value) * @param array $value 元素值 * @return */ - public function sAddArray($key, Array $value) + public function sAddArray(string $key, Array $value) { + } /** @@ -774,8 +830,9 @@ public function sAddArray($key, Array $value) * @param string|... $member 成员 * @return long */ - public function srem($key, $member) + public function srem(string $key, string $member): long { + } /** @@ -806,8 +863,9 @@ public function srem($key, $member) * @param string|... $key2 键名2 * @return array */ - public function sUnion($key1, $key2) + public function sUnion(string $key1, string $key2): array { + } /** @@ -842,8 +900,9 @@ public function sUnion($key1, $key2) * @param string|... $keyN 键名n * @return int */ - public function sUnionStore($dstKey, $key1, $key2, $keyN) + public function sUnionStore(string $dstKey, string $key1, string $key2, string $keyN): int { + } /** @@ -871,8 +930,9 @@ public function sUnionStore($dstKey, $key1, $key2, $keyN) * @param string $key2 键名2 * @return array | boolean */ - public function sInter($key1, $key2) + public function sInter(string $key1, string $key2): ?array { + } /** @@ -905,8 +965,9 @@ public function sInter($key1, $key2) * @param string|... $keyN 键名n * @return int */ - public function sInterStore($dstKey, $key1, $key2, $keyN) + public function sInterStore(string $dstKey, string $key1, string $key2, string $keyN): int { + } /** @@ -933,8 +994,9 @@ public function sInterStore($dstKey, $key1, $key2, $keyN) * @param string|... $key2 键名2 * @return array */ - public function sDiff($key1, $key2) + public function sDiff(string $key1, string $key2): array { + } /** @@ -963,10 +1025,11 @@ public function sDiff($key1, $key2) * @param string $key1 键名1 * @param string $key2 键名2 * @param string|... $keyN 键名n - * @return int: + * @return int */ - public function sDiffStore($dstKey, $key1, $key2, $keyN) + public function sDiffStore(string $dstKey, string $key1, string $key2, string $keyN): int { + } /** @@ -988,8 +1051,9 @@ public function sDiffStore($dstKey, $key1, $key2, $keyN) * @param string $key 键名 * @return string | bool */ - public function srandmember($key) + public function srandmember(string $key): ?string { + } /** @@ -1003,8 +1067,9 @@ public function srandmember($key) * @param string $key 键名 * @return int */ - public function strlen($key) + public function strlen(string $key): int { + } /** @@ -1012,10 +1077,11 @@ public function strlen($key) *移除指定键的有效期,让它永久有效 * @example $redis->persist('key'); * @param string $key 键名 - * @return bool: + * @return bool */ - public function persist($key) + public function persist(string $key): bool { + } /** @@ -1025,8 +1091,9 @@ public function persist($key) * @param string $key 键名 * @return long */ - public function ttl($key) + public function ttl(string $key): long { + } /** @@ -1036,8 +1103,9 @@ public function ttl($key) * @param string $key 键名 * @return long */ - public function pttl($key) + public function pttl(string $key): long { + } /** @@ -1053,8 +1121,9 @@ public function pttl($key) * @param string $key 集合键名 * @return int */ - public function zcard($key) + public function zcard(string $key): int { + } /** @@ -1072,8 +1141,9 @@ public function zcard($key) * @param double $end 结束排序值 * @return int */ - public function zcount($key, $start, $end) + public function zcount(string $key, double $start, double $end): int { + } /** @@ -1085,8 +1155,9 @@ public function zcount($key, $start, $end) * @param double $end 结束排序值 * @return long */ - public function zremrangebyscore($key, $start, $end) + public function zremrangebyscore(string $key, double $start, double $end): long { + } /** @@ -1101,8 +1172,9 @@ public function zremrangebyscore($key, $start, $end) * @param string $member 成员值 * @return double */ - public function zscore($key, $member) + public function zscore(string $key, string $member): double { + } /** @@ -1126,8 +1198,9 @@ public function zscore($key, $member) * @param string $value 元素值 * @return int */ - public function zadd($key, $score, $value) + public function zadd(string $key, double $score, string $value): int { + } /** @@ -1145,8 +1218,9 @@ public function zadd($key, $score, $value) * @param string $member 成员 * @return float */ - public function zincrby($key, $step, $member) + public function zincrby(string $key, double $step, string $member): float { + } /** @@ -1157,8 +1231,9 @@ public function zincrby($key, $step, $member) * @param string $field 字段名 * @return string */ - public function hGet($key, $field) + public function hGet(string $key, string $field): string { + } /** @@ -1177,8 +1252,9 @@ public function hGet($key, $field) * @param string $value 字段值 * @return long */ - public function hSet($key, $field, $value) + public function hSet(string $key, string $field, string $value): long { + } /** @@ -1196,8 +1272,9 @@ public function hSet($key, $field, $value) * @param string $value 字段值 * @return bool */ - public function hSetNx($key, $field, $value) + public function hSetNx(string $key, string $field, string $value): bool { + } /** @@ -1225,8 +1302,9 @@ public function hSetNx($key, $field, $value) * @param string|array $fields 字段名 * @return int */ - public function hDel($key, $fields) + public function hDel(string $key, string $fields): int { + } /** @@ -1242,8 +1320,9 @@ public function hDel($key, $fields) * @param string $key 键名 * @return int */ - public function hLen($key) + public function hLen(string $key): int { + } /** @@ -1273,8 +1352,9 @@ public function hLen($key) * @param string $key 键名 * @return array */ - public function hKeys($key) + public function hKeys(string $key): array { + } /** @@ -1304,8 +1384,9 @@ public function hKeys($key) * @param string $key 键名 * @return array */ - public function hVals($key) + public function hVals(string $key): array { + } /** @@ -1335,8 +1416,9 @@ public function hVals($key) * @param string $key 键名 * @return array */ - public function hGetAll($key) + public function hGetAll(string $key): array { + } /** @@ -1352,8 +1434,9 @@ public function hGetAll($key) * @param string $field 字段名 * @return bool */ - public function hExists($key, $field) + public function hExists(string $key, string $field): bool { + } /** @@ -1370,8 +1453,9 @@ public function hExists($key, $field) * @param int $step 自增步长 * @return int */ - public function hIncrBy($key, $field, $step) + public function hIncrBy(string $key, string $field, int $step): int { + } /** @@ -1398,8 +1482,9 @@ public function hIncrBy($key, $field, $step) * @param double $step 自增步长 * @return */ - public function hIncrByFloat($key, $field, $step) + public function hIncrByFloat(string $key, string $field, double $step) { + } /** @@ -1415,8 +1500,9 @@ public function hIncrByFloat($key, $field, $step) * @param array $fields 字段键值对 * @return boolean */ - public function hMset($key, Array $fields) + public function hMset(string $key, Array $fields): boolean { + } /** @@ -1427,8 +1513,9 @@ public function hMset($key, Array $fields) * @param array $fields 字段名列表 * @return array */ - public function hMget($key, Array $fields) + public function hMget(string $key, Array $fields): array { + } /** @@ -1442,8 +1529,9 @@ public function hMget($key, Array $fields) * @param string $key 键名 * @return string */ - public function dump($key) + public function dump(string $key): string { + } /** @@ -1463,8 +1551,9 @@ public function dump($key) * @param string $member 成员值 * @return int */ - public function zRank($key, $member) + public function zRank(string $key, string $member): int { + } /** @@ -1475,8 +1564,9 @@ public function zRank($key, $member) * @param string $member 成员值 * @return int */ - public function zRevRank($key, $member) + public function zRevRank(string $key, string $member): int { + } /** @@ -1492,8 +1582,9 @@ public function zRevRank($key, $member) * @param string $key 键名 * @return int */ - public function incr($key) + public function incr(string $key): int { + } /** @@ -1511,8 +1602,9 @@ public function incr($key) * @param int $step 自增步长 * @return int */ - public function incrBy($key, $step) + public function incrBy(string $key, int $step): int { + } /** @@ -1531,8 +1623,9 @@ public function incrBy($key, $step) * @param float $step 自增步长 * @return float */ - public function incrByFloat($key, $step) + public function incrByFloat(string $key, float $step): float { + } /** @@ -1547,8 +1640,9 @@ public function incrByFloat($key, $step) * @param string $key 键名 * @return int */ - public function decr($key) + public function decr(string $key): int { + } /** @@ -1565,8 +1659,9 @@ public function decr($key) * @param float $step 自减步长 * @return int */ - public function decrBy($key, $step) + public function decrBy(string $key, float $step): int { + } /** @@ -1577,8 +1672,9 @@ public function decrBy($key, $step) * @param int $ttl 有效期(秒数) * @return boolean */ - public function expire($key, $ttl) + public function expire(string $key, int $ttl): boolean { + } /** @@ -1594,10 +1690,11 @@ public function expire($key, $ttl) * * @param string $key 键名 * @param int $expireTime 到期时间 - * @return bool: + * @return bool */ - public function expireAt($key, $expireTime) + public function expireAt(string $key, int $expireTime): bool { + } /** @@ -1608,8 +1705,9 @@ public function expireAt($key, $expireTime) * @param int $ttl 有效期(毫秒数) * @return boolean */ - public function pexpire($key, $ttl) + public function pexpire(string $key, int $ttl): boolean { + } /** @@ -1625,10 +1723,11 @@ public function pexpire($key, $ttl) * * @param string $key 键名 * @param int $expireTime 到期时间 - * @return bool: + * @return bool */ - public function pexpireAt($key, $expireTime) + public function pexpireAt(string $key, int $expireTime): bool { + } /** @@ -1644,8 +1743,9 @@ public function pexpireAt($key, $expireTime) * @param string $value 追加的值 * @return int */ - public function append($key, $value) + public function append(string $key, string $value): int { + } /** @@ -1661,8 +1761,9 @@ public function append($key, $value) * @param int $offset 所在位置 * @return int */ - public function getBit($key, $offset) + public function getBit(string $key, int $offset): int { + } /** @@ -1678,10 +1779,11 @@ public function getBit($key, $offset) * @param string $key 键名 * @param int $offset 开始位置 * @param boolean|int $value 新值 - * @return int: + * @return int */ - public function setBit($key, $offset, $value) + public function setBit(string $key, int $offset, int $value): int { + } /** @@ -1695,8 +1797,9 @@ public function setBit($key, $offset, $value) * @param string|... $keyN 键名N * @return long */ - public function bitop($operation, $dstKey, $key1, $key2, $keyN) + public function bitop(string $operation, string $dstKey, string $key1, string $key2, string $keyN): long { + } /** @@ -1706,8 +1809,9 @@ public function bitop($operation, $dstKey, $key1, $key2, $keyN) * @param string $key 键名 * @return long */ - public function bitcount($key) + public function bitcount(string $key): long { + } /** @@ -1727,10 +1831,11 @@ public function bitcount($key) * @param int $bit 位值 * @param int $start 开始位置 * @param int $end 结束位置 - * @return function + * @return callable */ - public function bitpos($key, $bit, $start, $end) + public function bitpos(string $key, int $bit, int $start, int $end): callable { + } /** @@ -1741,8 +1846,9 @@ public function bitpos($key, $bit, $start, $end) * @param int $index 索引值 * @return string | boolean */ - public function lget($key, $index) + public function lget(string $key, int $index): ?string { + } /** @@ -1757,10 +1863,11 @@ public function lget($key, $index) * @param string $key 键名 * @param int $start 开始位置 * @param int $end 结束位置 - * @return string: + * @return string */ - public function getrange($key, $start, $end) + public function getrange(string $key, int $start, int $end): string { + } /** @@ -1772,8 +1879,9 @@ public function getrange($key, $start, $end) * @param int $end 结束索引 * @return array | boolean */ - public function ltrim($key, $start, $end) + public function ltrim(string $key, int $start, int $end): ?array { + } /** @@ -1785,8 +1893,9 @@ public function ltrim($key, $start, $end) * @param int $end 索引结束值 * @return array */ - public function lrange($key, $start, $end) + public function lrange(string $key, int $start, int $end): array { + } /** @@ -1805,8 +1914,9 @@ public function lrange($key, $start, $end) * @param double $end 结束排序值 * @return int */ - public function zremrangebyrank($key, $start, $end) + public function zremrangebyrank(string $key, double $start, double $end): int { + } /** @@ -1817,8 +1927,9 @@ public function zremrangebyrank($key, $start, $end) * @param string $message 消息 * @return int */ - public function publish($channel, $message) + public function publish(string $channel, string $message): int { + } /** @@ -1829,8 +1940,9 @@ public function publish($channel, $message) * @param string $dstKey 新键名 * @return boolean */ - public function rename($srcKey, $dstKey) + public function rename(string $srcKey, string $dstKey): boolean { + } /** @@ -1841,8 +1953,9 @@ public function rename($srcKey, $dstKey) * @param string $dstKey 新键名 * @return boolean */ - public function renamenx($srcKey, $dstKey) + public function renamenx(string $srcKey, string $dstKey): boolean { + } /** @@ -1853,8 +1966,9 @@ public function renamenx($srcKey, $dstKey) * @param string|array|... $element 元素 * @return */ - public function pfadd($key, $element) + public function pfadd(string $key, string $element) { + } /** @@ -1864,8 +1978,9 @@ public function pfadd($key, $element) * @param string|array $keys 键名 * @return */ - public function pfcount($keys) + public function pfcount(string $keys) { + } /** @@ -1876,8 +1991,9 @@ public function pfcount($keys) * @param string|array $sourceKeys 源键名 * @return */ - public function pfmerge($dstKey, $sourceKeys) + public function pfmerge(string $dstKey, string $sourceKeys) { + } /** @@ -1894,8 +2010,9 @@ public function pfmerge($dstKey, $sourceKeys) * @param string $value 被替换的子串的值 * @return string */ - public function setrange($key, $offset, $value) + public function setrange(string $key, int $offset, string $value): string { + } /** @@ -1912,8 +2029,9 @@ public function setrange($key, $offset, $value) * @param string $value dump导出的二进制数据 * @return */ - public function restore($key, $ttl, $value) + public function restore(string $key, int $ttl, string $value) { + } /** @@ -1934,8 +2052,9 @@ public function restore($key, $ttl, $value) * @param string $member 成员 * @return bool */ - public function smove($srcKey, $dstKey, $member) + public function smove(string $srcKey, string $dstKey, string $member): bool { + } /** @@ -1956,8 +2075,9 @@ public function smove($srcKey, $dstKey, $member) * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRange($key, $start, $end, $withScores) + public function zRange(string $key, int $start, int $end, bool $withScores): array { + } /** @@ -1978,8 +2098,9 @@ public function zRange($key, $start, $end, $withScores) * @param boolean $withScores 是否返回成员的排序值 * @return array */ - public function zRevRange($key, $start, $end, $withScores) + public function zRevRange(string $key, int $start, int $end, bool $withScores): array { + } /** @@ -2002,8 +2123,9 @@ public function zRevRange($key, $start, $end, $withScores) * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRangeByScore($key, $start, $end, Array $options) + public function zRangeByScore(string $key, int $start, int $end, Array $options): array { + } /** @@ -2026,8 +2148,9 @@ public function zRangeByScore($key, $start, $end, Array $options) * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) * @return array */ - public function zRevRangeByScore($key, $start, $end, Array $options) + public function zRevRangeByScore(string $key, int $start, int $end, Array $options): array { + } /** @@ -2049,8 +2172,9 @@ public function zRevRangeByScore($key, $start, $end, Array $options) * @param long $limit 成员数 * @return array */ - public function zRangeByLex($key, $min, $max, $offset, $limit) + public function zRangeByLex(string $key, int $min, int $max, int $offset, int $limit): array { + } /** @@ -2064,8 +2188,9 @@ public function zRangeByLex($key, $min, $max, $offset, $limit) * @param long $limit 成员数 * @return */ - public function zRevRangeByLex($key, $min, $max, $offset, $limit) + public function zRevRangeByLex(string $key, int $min, int $max, int $offset, int $limit) { + } /** @@ -2077,8 +2202,9 @@ public function zRevRangeByLex($key, $min, $max, $offset, $limit) * @param long $max 最大的字母 * @return int */ - public function zlexcount($key, $min, $max) + public function zlexcount(string $key, int $min, int $max): int { + } /** @@ -2090,8 +2216,9 @@ public function zlexcount($key, $min, $max) * @param long $max 最大的字母 * @return long */ - public function zremrangebylex($key, $min, $max) + public function zremrangebylex(string $key, int $min, int $max): long { + } /** @@ -2120,8 +2247,9 @@ public function zremrangebylex($key, $min, $max) * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zunionstore(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -2153,8 +2281,9 @@ public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $ag * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) * @return int */ - public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) + public function zinterstore(string $dstKey, Array $zsetKeys, Array $zsetKeysWeight, string $aggregateFunction): int { + } /** @@ -2165,8 +2294,9 @@ public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $ag * @param string $member 成员值 * @return int */ - public function zrem($key, $member) + public function zrem(string $key, string $member): int { + } /** @@ -2188,8 +2318,9 @@ public function zrem($key, $member) * @param array $options 排序参数,如:array('sort' => 'desc') * @return An */ - public function sort($key, Array $options) + public function sort(string $key, Array $options): An { + } /** @@ -2205,8 +2336,9 @@ public function sort($key, Array $options) * @param string $key 键名 * @return string */ - public function object($info, $key) + public function object(string $info, string $key): string { + } /** @@ -2234,8 +2366,9 @@ public function object($info, $key) * @param mixed $value 返回值 * @return mixed */ - public function subscribe(Array $channels, $callback, $value) + public function subscribe(Array $channels, string $callback, $value) { + } /** @@ -2254,8 +2387,9 @@ public function subscribe(Array $channels, $callback, $value) * @param mixed $value 返回值 * @return */ - public function psubscribe(Array $patterns, $callback, $value) + public function psubscribe(Array $patterns, string $callback, $value) { + } /** @@ -2267,6 +2401,7 @@ public function psubscribe(Array $patterns, $callback, $value) */ public function unsubscribe(Array $channels) { + } /** @@ -2278,6 +2413,7 @@ public function unsubscribe(Array $channels) */ public function punsubscribe(Array $patterns) { + } /** @@ -2289,8 +2425,9 @@ public function punsubscribe(Array $patterns) * @param int $num_keys 应该进入KEYS数组的参数个数 * @return mixed */ - public function eval($script, Array $args, $num_keys) + public function eval(string $script, Array $args, int $num_keys) { + } /** @@ -2304,8 +2441,9 @@ public function eval($script, Array $args, $num_keys) * @param int $num_keys 应该进入KEYS数组的参数个数 * @return */ - public function evalsha($script_sha, Array $args, $num_keys) + public function evalsha(string $script_sha, Array $args, int $num_keys) { + } /** @@ -2325,8 +2463,9 @@ public function evalsha($script_sha, Array $args, $num_keys) * @param int $i_count 每次迭代的长度 * @return array */ - public function scan($i_iterator, $str_pattern, $i_count) + public function scan(Long $i_iterator, string $str_pattern, int $i_count): array { + } /** @@ -2339,8 +2478,9 @@ public function scan($i_iterator, $str_pattern, $i_count) * @param int $i_count 每次迭代的长度 * @return */ - public function hscan($str_key, $i_iterator, $str_pattern, $i_count) + public function hscan(string $str_key, Long $i_iterator, string $str_pattern, int $i_count) { + } /** @@ -2353,8 +2493,9 @@ public function hscan($str_key, $i_iterator, $str_pattern, $i_count) * @param int $i_count 每次迭代的长度 * @return */ - public function zscan($str_key, $i_iterator, $str_pattern, $i_count) + public function zscan(string $str_key, Long $i_iterator, string $str_pattern, int $i_count) { + } /** @@ -2367,8 +2508,9 @@ public function zscan($str_key, $i_iterator, $str_pattern, $i_count) * @param int $i_count 每次迭代的长度 * @return */ - public function sscan($str_key, $i_iterator, $str_pattern, $i_count) + public function sscan(string $str_key, Long $i_iterator, string $str_pattern, int $i_count) { + } /** @@ -2377,8 +2519,9 @@ public function sscan($str_key, $i_iterator, $str_pattern, $i_count) * @example $redis->getMode(); * @return int */ - public function getmode() + public function getmode(): int { + } /** @@ -2392,8 +2535,9 @@ public function getmode() * * @return string */ - public function getLastError() + public function getLastError(): string { + } /** @@ -2411,8 +2555,9 @@ public function getLastError() * * @return bool */ - public function clearLastError() + public function clearLastError(): bool { + } /** @@ -2424,8 +2569,9 @@ public function clearLastError() * @param string $optionName 选项名 * @return int */ - public function getOption($optionName) + public function getOption(string $optionName): int { + } /** @@ -2440,10 +2586,11 @@ public function getOption($optionName) * * @param string $optionName 选项名 * @param string $optionValue 选项值 - * @return bool: + * @return bool */ - public function setOption($optionName, $optionValue) + public function setOption(string $optionName, string $optionValue): bool { + } /** @@ -2457,8 +2604,9 @@ public function setOption($optionName, $optionValue) * @param string $prefix 前缀 * @return string */ - public function _prefix($prefix) + public function _prefix(string $prefix): string { + } /** @@ -2476,8 +2624,9 @@ public function _prefix($prefix) * @param string $value 被序列化的值 * @return */ - public function _serialize($value) + public function _serialize(string $value) { + } /** @@ -2491,8 +2640,9 @@ public function _serialize($value) * @param string $value 被反序列化的值 * @return */ - public function _unserialize($value) + public function _unserialize(string $value) { + } /** @@ -2503,8 +2653,9 @@ public function _unserialize($value) * } * @return array */ - public function _masters() + public function _masters(): array { + } /** @@ -2513,8 +2664,9 @@ public function _masters() * @example * @return string|NULL */ - public function _redir() + public function _redir(): ?string { + } /** @@ -2538,6 +2690,7 @@ public function _redir() */ public function multi() { + } /** @@ -2548,6 +2701,7 @@ public function multi() */ public function discard() { + } /** @@ -2558,6 +2712,7 @@ public function discard() */ public function exec() { + } /** @@ -2575,8 +2730,9 @@ public function exec() * @param string|array $keys 键名 * @return */ - public function watch($keys) + public function watch(string $keys) { + } /** @@ -2586,8 +2742,9 @@ public function watch($keys) * @param string|array $keys 键名 * @return */ - public function unwatch($keys) + public function unwatch(string $keys) { + } /** @@ -2596,8 +2753,9 @@ public function unwatch($keys) * @example $redis->save(); * @return boolean */ - public function save() + public function save(): boolean { + } /** @@ -2608,6 +2766,7 @@ public function save() */ public function bgSave() { + } /** @@ -2616,8 +2775,9 @@ public function bgSave() * @example $redis->flushDB(); * @return bool */ - public function flushdb() + public function flushdb(): bool { + } /** @@ -2626,8 +2786,9 @@ public function flushdb() * @example $redis->flushAll(); * @return bool */ - public function flushall() + public function flushall(): bool { + } /** @@ -2640,8 +2801,9 @@ public function flushall() * * @return int */ - public function dbsize() + public function dbsize(): int { + } /** @@ -2650,8 +2812,9 @@ public function dbsize() * @example $redis->bgrewriteaof(); * @return bool */ - public function bgrewriteaof() + public function bgrewriteaof(): bool { + } /** @@ -2660,8 +2823,9 @@ public function bgrewriteaof() * @example $redis->lastSave(); * @return int */ - public function lastsave() + public function lastsave(): int { + } /** @@ -2676,8 +2840,9 @@ public function lastsave() * * @return array */ - public function info() + public function info(): array { + } /** @@ -2686,8 +2851,9 @@ public function info() * @example * @return string */ - public function role() + public function role(): string { + } /** @@ -2703,8 +2869,9 @@ public function role() * * @return int */ - public function time() + public function time(): int { + } /** @@ -2717,8 +2884,9 @@ public function time() * * @return string */ - public function randomkey() + public function randomkey(): string { + } /** @@ -2727,8 +2895,9 @@ public function randomkey() * @example * @return string */ - public function ping() + public function ping(): string { + } /** @@ -2738,8 +2907,9 @@ public function ping() * @param string $str 发送的字符串 * @return string */ - public function echo($str) + public function echo(string $str): string { + } /** @@ -2748,8 +2918,9 @@ public function echo($str) * @example * @return array */ - public function command() + public function command(): array { + } /** @@ -2760,8 +2931,9 @@ public function command() * @param string|array $args 参数 * @return */ - public function rawcommand($command, $args) + public function rawcommand(string $command, string $args) { + } /** @@ -2771,8 +2943,9 @@ public function rawcommand($command, $args) * @param string $args 参数(目前只支持slots) * @return array */ - public function cluster($args) + public function cluster(string $args): array { + } /** @@ -2787,8 +2960,9 @@ public function cluster($args) * @param string $args 参数 * @return */ - public function client($command, $args) + public function client(string $command, string $args) { + } /** @@ -2804,8 +2978,9 @@ public function client($command, $args) * @param string $value 配置值 * @return array */ - public function config($operation, $key, $value) + public function config(string $operation, string $key, string $value): array { + } /** @@ -2822,8 +2997,9 @@ public function config($operation, $key, $value) * @param string|array $args 参数 * @return array|int */ - public function pubsub($subcommand, $args) + public function pubsub(string $subcommand, string $args): ?array { + } /** @@ -2844,8 +3020,9 @@ public function pubsub($subcommand, $args) * @param string|... $script 脚本 * @return */ - public function script($command, $script) + public function script(string $command, string $script) { + } /** @@ -2856,8 +3033,9 @@ public function script($command, $script) * @param int $length 获取条目数 * @return */ - public function slowlog($command, $length) + public function slowlog(string $command, int $length) { + } } diff --git a/src/Redis/RedisClusterException.php b/src/Redis/RedisClusterException.php index 8c68fe5..b180100 100644 --- a/src/Redis/RedisClusterException.php +++ b/src/Redis/RedisClusterException.php @@ -1,14 +1,14 @@ Date: Tue, 28 Aug 2018 14:58:39 +0800 Subject: [PATCH 22/34] update swoole to version 4.1-beta --- README.md | 2 +- src/Swoole/Async.php | 4 +- src/Swoole/Atomic.php | 4 +- src/Swoole/Atomic/Long.php | 4 +- src/Swoole/Buffer.php | 6 +- src/Swoole/Chan.php | 11 ++- src/Swoole/Channel.php | 4 +- src/Swoole/Client.php | 12 +-- src/Swoole/Co.php | 38 +++++---- src/Swoole/Co/Http/Client.php | 32 ++++---- src/Swoole/Co/Http/Server.php | 13 +-- src/Swoole/Co/Http2/Client.php | 23 ++---- src/Swoole/Co/MySQL.php | 6 +- src/Swoole/Co/Redis.php | 12 +-- src/Swoole/Co/Redis/Server.php | 13 +-- src/Swoole/Co/Server.php | 11 +-- src/Swoole/Co/WebSocket/Server.php | 17 ++-- src/Swoole/Connection/Iterator.php | 8 +- src/Swoole/Coroutine.php | 37 +++++---- src/Swoole/Coroutine/Channel.php | 11 ++- src/Swoole/Coroutine/Client.php | 27 +------ src/Swoole/Coroutine/Http/Client.php | 32 ++++---- src/Swoole/Coroutine/Http2/Client.php | 23 ++---- src/Swoole/Coroutine/Iterator.php | 92 +++++++++++++++++++++ src/Swoole/Coroutine/MySQL.php | 6 +- src/Swoole/Coroutine/MySQL/Exception.php | 6 +- src/Swoole/Coroutine/MySQL/Statement.php | 4 +- src/Swoole/Coroutine/PostgreSQL.php | 4 +- src/Swoole/Coroutine/Redis.php | 12 +-- src/Swoole/Coroutine/Socket.php | 4 +- src/Swoole/Coroutine/Socket/Exception.php | 6 +- src/Swoole/Event.php | 4 +- src/Swoole/Exception.php | 4 +- src/Swoole/Http/Client.php | 8 +- src/Swoole/Http/Request.php | 11 ++- src/Swoole/Http/Response.php | 10 +-- src/Swoole/Http/Server.php | 10 +-- src/Swoole/Http2/Client.php | 14 ++-- src/Swoole/Http2/Request.php | 65 +++++++++++++++ src/Swoole/Http2/Response.php | 44 ++++++++-- src/Swoole/Lock.php | 4 +- src/Swoole/Memory/Pool.php | 4 +- src/Swoole/Memory/Pool/Slice.php | 4 +- src/Swoole/Mmap.php | 4 +- src/Swoole/MsgQueue.php | 4 +- src/Swoole/MySQL.php | 4 +- src/Swoole/MySQL/Exception.php | 4 +- src/Swoole/Process.php | 10 +-- src/Swoole/Process/Pool.php | 4 +- src/Swoole/Redis.php | 4 +- src/Swoole/Redis/Server.php | 10 +-- src/Swoole/RingQueue.php | 4 +- src/Swoole/Runtime.php | 38 +++++++++ src/Swoole/Serialize.php | 4 +- src/Swoole/Server.php | 10 +-- src/Swoole/Server/Port.php | 4 +- src/Swoole/Table.php | 6 +- src/Swoole/Table/Row.php | 4 +- src/Swoole/Timer.php | 4 +- src/Swoole/WebSocket/Frame.php | 46 ++++++++++- src/Swoole/WebSocket/Server.php | 14 ++-- src/Swoole/swoole.namespace.php | 98 ++++++++++++++++++++++- src/Swoole/swoole.php | 98 ++++++++++++++++++++++- src/Swoole/swoole_async.php | 4 +- src/Swoole/swoole_atomic.php | 4 +- src/Swoole/swoole_atomic_long.php | 4 +- src/Swoole/swoole_buffer.php | 6 +- src/Swoole/swoole_channel.php | 4 +- src/Swoole/swoole_client.php | 12 +-- src/Swoole/swoole_connection_iterator.php | 8 +- src/Swoole/swoole_coroutine.php | 37 +++++---- src/Swoole/swoole_event.php | 4 +- src/Swoole/swoole_exception.php | 4 +- src/Swoole/swoole_http2_client.php | 14 ++-- src/Swoole/swoole_http_client.php | 8 +- src/Swoole/swoole_http_request.php | 11 ++- src/Swoole/swoole_http_response.php | 10 +-- src/Swoole/swoole_http_server.php | 10 +-- src/Swoole/swoole_lock.php | 4 +- src/Swoole/swoole_mmap.php | 4 +- src/Swoole/swoole_msgqueue.php | 4 +- src/Swoole/swoole_mysql.php | 4 +- src/Swoole/swoole_mysql_exception.php | 4 +- src/Swoole/swoole_process.php | 10 +-- src/Swoole/swoole_process_pool.php | 4 +- src/Swoole/swoole_redis.php | 4 +- src/Swoole/swoole_redis_server.php | 10 +-- src/Swoole/swoole_ringqueue.php | 4 +- src/Swoole/swoole_serialize.php | 4 +- src/Swoole/swoole_server.php | 10 +-- src/Swoole/swoole_server_port.php | 4 +- src/Swoole/swoole_table.php | 6 +- src/Swoole/swoole_table_row.php | 4 +- src/Swoole/swoole_timer.php | 4 +- src/Swoole/swoole_websocket_frame.php | 46 ++++++++++- src/Swoole/swoole_websocket_server.php | 14 ++-- 96 files changed, 911 insertions(+), 413 deletions(-) create mode 100644 src/Swoole/Coroutine/Iterator.php create mode 100644 src/Swoole/Http2/Request.php create mode 100644 src/Swoole/Runtime.php diff --git a/README.md b/README.md index 5ebed2c..a6dbec2 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 5、phpRedis(包括RedisCluster,支持phpredis 4.1.0RC1) -6、swoole扩展(支持swoole 4.0) +6、swoole扩展(支持swoole 4.1-beta) 7、SeasLog(1.8.5) diff --git a/src/Swoole/Async.php b/src/Swoole/Async.php index 5a6045f..fddf8b9 100644 --- a/src/Swoole/Async.php +++ b/src/Swoole/Async.php @@ -1,8 +1,8 @@ Date: Sun, 9 Sep 2018 21:58:50 +0800 Subject: [PATCH 23/34] update swoole to version 4.1.2 --- README.md | 2 +- src/Swoole/Async.php | 4 +- src/Swoole/Atomic.php | 4 +- src/Swoole/Atomic/Long.php | 4 +- src/Swoole/Buffer.php | 4 +- src/Swoole/Chan.php | 4 +- src/Swoole/Channel.php | 4 +- src/Swoole/Client.php | 4 +- src/Swoole/Co.php | 4 +- src/Swoole/Co/Http/Client.php | 14 +- src/Swoole/Co/Http/Server.php | 4 +- src/Swoole/Co/Http2/Client.php | 4 +- src/Swoole/Co/MySQL.php | 4 +- src/Swoole/Co/Redis.php | 10 +- src/Swoole/Co/Redis/Server.php | 4 +- src/Swoole/Co/Server.php | 4 +- src/Swoole/Co/WebSocket/Server.php | 4 +- src/Swoole/Connection/Iterator.php | 4 +- src/Swoole/Coroutine.php | 4 +- src/Swoole/Coroutine/Channel.php | 4 +- src/Swoole/Coroutine/Client.php | 4 +- src/Swoole/Coroutine/Http/Client.php | 14 +- src/Swoole/Coroutine/Http2/Client.php | 4 +- src/Swoole/Coroutine/Iterator.php | 4 +- src/Swoole/Coroutine/MySQL.php | 4 +- src/Swoole/Coroutine/MySQL/Exception.php | 4 +- src/Swoole/Coroutine/MySQL/Statement.php | 4 +- src/Swoole/Coroutine/PostgreSQL.php | 4 +- src/Swoole/Coroutine/Redis.php | 10 +- src/Swoole/Coroutine/Socket.php | 4 +- src/Swoole/Coroutine/Socket/Exception.php | 4 +- src/Swoole/Event.php | 4 +- src/Swoole/Exception.php | 4 +- src/Swoole/ExitException.php | 191 ++++++++++++++++++++++ src/Swoole/Http/Client.php | 4 +- src/Swoole/Http/Request.php | 4 +- src/Swoole/Http/Response.php | 4 +- src/Swoole/Http/Server.php | 4 +- src/Swoole/Http2/Client.php | 4 +- src/Swoole/Http2/Request.php | 10 +- src/Swoole/Http2/Response.php | 26 +-- src/Swoole/Lock.php | 8 +- src/Swoole/Memory/Pool.php | 4 +- src/Swoole/Memory/Pool/Slice.php | 4 +- src/Swoole/Mmap.php | 4 +- src/Swoole/MsgQueue.php | 4 +- src/Swoole/MySQL.php | 4 +- src/Swoole/MySQL/Exception.php | 4 +- src/Swoole/Process.php | 6 +- src/Swoole/Process/Pool.php | 4 +- src/Swoole/Redis.php | 4 +- src/Swoole/Redis/Server.php | 4 +- src/Swoole/RingQueue.php | 4 +- src/Swoole/Runtime.php | 4 +- src/Swoole/Serialize.php | 4 +- src/Swoole/Server.php | 4 +- src/Swoole/Server/Port.php | 4 +- src/Swoole/Table.php | 4 +- src/Swoole/Table/Row.php | 4 +- src/Swoole/Timer.php | 4 +- src/Swoole/WebSocket/Frame.php | 18 +- src/Swoole/WebSocket/Server.php | 4 +- src/Swoole/swoole.namespace.php | 95 +++++++++-- src/Swoole/swoole.php | 95 +++++++++-- src/Swoole/swoole_async.php | 4 +- src/Swoole/swoole_atomic.php | 4 +- src/Swoole/swoole_atomic_long.php | 4 +- src/Swoole/swoole_buffer.php | 4 +- src/Swoole/swoole_channel.php | 4 +- src/Swoole/swoole_client.php | 4 +- src/Swoole/swoole_connection_iterator.php | 4 +- src/Swoole/swoole_coroutine.php | 4 +- src/Swoole/swoole_event.php | 4 +- src/Swoole/swoole_exception.php | 4 +- src/Swoole/swoole_http2_client.php | 4 +- src/Swoole/swoole_http_client.php | 4 +- src/Swoole/swoole_http_request.php | 4 +- src/Swoole/swoole_http_response.php | 4 +- src/Swoole/swoole_http_server.php | 4 +- src/Swoole/swoole_lock.php | 4 +- src/Swoole/swoole_mmap.php | 4 +- src/Swoole/swoole_msgqueue.php | 4 +- src/Swoole/swoole_mysql.php | 4 +- src/Swoole/swoole_mysql_exception.php | 4 +- src/Swoole/swoole_process.php | 4 +- src/Swoole/swoole_process_pool.php | 4 +- src/Swoole/swoole_redis.php | 4 +- src/Swoole/swoole_redis_server.php | 4 +- src/Swoole/swoole_ringqueue.php | 4 +- src/Swoole/swoole_serialize.php | 4 +- src/Swoole/swoole_server.php | 4 +- src/Swoole/swoole_server_port.php | 4 +- src/Swoole/swoole_table.php | 4 +- src/Swoole/swoole_table_row.php | 4 +- src/Swoole/swoole_timer.php | 4 +- src/Swoole/swoole_websocket_frame.php | 18 +- src/Swoole/swoole_websocket_server.php | 4 +- 97 files changed, 581 insertions(+), 268 deletions(-) create mode 100644 src/Swoole/ExitException.php diff --git a/README.md b/README.md index a6dbec2..c2eb30e 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 5、phpRedis(包括RedisCluster,支持phpredis 4.1.0RC1) -6、swoole扩展(支持swoole 4.1-beta) +6、swoole扩展(支持swoole 4.1.2) 7、SeasLog(1.8.5) diff --git a/src/Swoole/Async.php b/src/Swoole/Async.php index fddf8b9..aa68165 100644 --- a/src/Swoole/Async.php +++ b/src/Swoole/Async.php @@ -1,8 +1,8 @@ Date: Wed, 28 Nov 2018 14:40:23 +0800 Subject: [PATCH 24/34] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2eb30e..855fe82 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# phpstorm-for-php-framework +# php-ide-helper php framework and php extension Auto Compelete for phpstorm From af28be0e71c1959beee311a40e2c9affeadbcc50 Mon Sep 17 00:00:00 2001 From: shixinke Date: Wed, 28 Nov 2018 17:25:59 +0800 Subject: [PATCH 25/34] update swoole to version 4.2.9 --- .gitignore | 2 + composer.json | 21 + src/Swoole/Async.php | 4 +- src/Swoole/Atomic.php | 4 +- src/Swoole/Atomic/Long.php | 4 +- src/Swoole/Buffer.php | 4 +- src/Swoole/Chan.php | 4 +- src/Swoole/Channel.php | 4 +- src/Swoole/Client.php | 32 +- src/Swoole/Co.php | 55 +- src/Swoole/Co/Channel.php | 120 - src/Swoole/Co/Client.php | 216 -- src/Swoole/Co/Http/Client.php | 36 +- src/Swoole/Co/Http/Server.php | 7 +- src/Swoole/Co/Http2/Client.php | 4 +- src/Swoole/Co/Http2/Request.php | 51 - src/Swoole/Co/MySQL.php | 4 +- src/Swoole/Co/MySQL/Exception.php | 156 -- src/Swoole/Co/MySQL/Statement.php | 84 - src/Swoole/Co/Redis.php | 4 +- src/Swoole/Co/Redis/Server.php | 7 +- src/Swoole/Co/Server.php | 5 +- src/Swoole/Co/WebSocket/Server.php | 7 +- src/Swoole/Connection/Iterator.php | 4 +- src/Swoole/Coroutine.php | 52 +- src/Swoole/Coroutine/Channel.php | 4 +- src/Swoole/Coroutine/Client.php | 4 +- src/Swoole/Coroutine/Http/Client.php | 36 +- src/Swoole/Coroutine/Http2/Client.php | 4 +- src/Swoole/Coroutine/Iterator.php | 6 +- src/Swoole/Coroutine/MySQL.php | 4 +- src/Swoole/Coroutine/MySQL/Exception.php | 6 +- src/Swoole/Coroutine/MySQL/Statement.php | 4 +- src/Swoole/Coroutine/PostgreSQL.php | 11 +- src/Swoole/Coroutine/Redis.php | 4 +- src/Swoole/Coroutine/Socket.php | 4 +- src/Swoole/Coroutine/Socket/Exception.php | 6 +- src/Swoole/Event.php | 4 +- src/Swoole/Exception.php | 4 +- src/Swoole/ExitException.php | 6 +- src/Swoole/Http/Client.php | 11 +- src/Swoole/Http/Request.php | 4 +- src/Swoole/Http/Response.php | 4 +- src/Swoole/Http/Server.php | 4 +- src/Swoole/Http2/Request.php | 4 +- src/Swoole/Http2/Response.php | 4 +- src/Swoole/Lock.php | 4 +- src/Swoole/Memory/Pool.php | 4 +- src/Swoole/Memory/Pool/Slice.php | 4 +- src/Swoole/Mmap.php | 4 +- src/Swoole/MsgQueue.php | 4 +- src/Swoole/MySQL.php | 4 +- src/Swoole/MySQL/Exception.php | 4 +- src/Swoole/Process.php | 4 +- src/Swoole/Process/Pool.php | 20 +- src/Swoole/Redis.php | 4 +- src/Swoole/Redis/Server.php | 4 +- src/Swoole/RingQueue.php | 4 +- src/Swoole/Runtime.php | 4 +- src/Swoole/Serialize.php | 4 +- src/Swoole/Server.php | 4 +- src/Swoole/Server/Port.php | 4 +- src/Swoole/Table.php | 4 +- src/Swoole/Table/Row.php | 4 +- src/Swoole/Timer.php | 4 +- src/Swoole/WebSocket/CloseFrame.php | 95 + src/Swoole/WebSocket/Frame.php | 10 +- src/Swoole/WebSocket/Server.php | 4 +- src/Swoole/swoole.namespace.php | 269 +- src/Swoole/swoole.php | 269 +- src/Swoole/swoole_async.php | 4 +- src/Swoole/swoole_atomic.php | 4 +- src/Swoole/swoole_atomic_long.php | 4 +- src/Swoole/swoole_buffer.php | 4 +- src/Swoole/swoole_channel.php | 4 +- src/Swoole/swoole_client.php | 32 +- src/Swoole/swoole_client_coro.php | 245 -- src/Swoole/swoole_connection_iterator.php | 4 +- src/Swoole/swoole_coroutine.php | 52 +- src/Swoole/swoole_event.php | 4 +- src/Swoole/swoole_exception.php | 4 +- src/Swoole/swoole_http_client.php | 11 +- src/Swoole/swoole_http_client_coro.php | 278 -- src/Swoole/swoole_http_request.php | 4 +- src/Swoole/swoole_http_response.php | 4 +- src/Swoole/swoole_http_server.php | 4 +- src/Swoole/swoole_lock.php | 8 +- src/Swoole/swoole_mmap.php | 4 +- src/Swoole/swoole_msgqueue.php | 4 +- src/Swoole/swoole_mysql.php | 4 +- src/Swoole/swoole_mysql_coro.php | 220 -- src/Swoole/swoole_mysql_coro_exception.php | 155 -- src/Swoole/swoole_mysql_exception.php | 4 +- src/Swoole/swoole_process.php | 6 +- src/Swoole/swoole_process_pool.php | 20 +- src/Swoole/swoole_redis.php | 4 +- src/Swoole/swoole_redis_coro.php | 2723 ------------------- src/Swoole/swoole_redis_server.php | 4 +- src/Swoole/swoole_ringqueue.php | 4 +- src/Swoole/swoole_serialize.php | 4 +- src/Swoole/swoole_server.php | 4 +- src/Swoole/swoole_server_port.php | 4 +- src/Swoole/swoole_table.php | 4 +- src/Swoole/swoole_table_row.php | 4 +- src/Swoole/swoole_timer.php | 4 +- src/Swoole/swoole_websocke_closet_frame.php | 94 + src/Swoole/swoole_websocket_frame.php | 10 +- src/Swoole/swoole_websocket_server.php | 4 +- 108 files changed, 1128 insertions(+), 4594 deletions(-) create mode 100644 composer.json delete mode 100644 src/Swoole/Co/Channel.php delete mode 100644 src/Swoole/Co/Client.php delete mode 100644 src/Swoole/Co/Http2/Request.php delete mode 100644 src/Swoole/Co/MySQL/Exception.php delete mode 100644 src/Swoole/Co/MySQL/Statement.php create mode 100644 src/Swoole/WebSocket/CloseFrame.php delete mode 100644 src/Swoole/swoole_client_coro.php delete mode 100644 src/Swoole/swoole_http_client_coro.php delete mode 100644 src/Swoole/swoole_mysql_coro.php delete mode 100644 src/Swoole/swoole_mysql_coro_exception.php delete mode 100644 src/Swoole/swoole_redis_coro.php create mode 100644 src/Swoole/swoole_websocke_closet_frame.php diff --git a/.gitignore b/.gitignore index a36861b..67b90b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ # Created by .ignore support plugin (hsz.mobi) .idea + +/vendor/ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..e7276ce --- /dev/null +++ b/composer.json @@ -0,0 +1,21 @@ +{ + "name": "shixinke/php-ide-helper", + "description": "a tool that provides auto-completion for php frameworks and extensions", + "type": "library", + "keywords": [ + "php", + "ide-helper", + "phpstorm-helper", + "swoole-ide-helper" + ], + "license": "Apache-2.0", + "authors": [ + { + "name": "shixinke", + "email": "ishixinke@qq.com" + } + ], + "require": { + "php": ">=7.0" + } +} diff --git a/src/Swoole/Async.php b/src/Swoole/Async.php index aa68165..99170a2 100644 --- a/src/Swoole/Async.php +++ b/src/Swoole/Async.php @@ -1,8 +1,8 @@ on("WorkerStart", function ($pool, $workerId) { + * $process = $pool->getProcess(); + * $process->exec("/bin/sh", ["ls", '-l']); + * }); + * @return \Swoole\Process + */ + public function getProcess() + { + + } + } diff --git a/src/Swoole/Redis.php b/src/Swoole/Redis.php index 1542b35..92a7d2a 100644 --- a/src/Swoole/Redis.php +++ b/src/Swoole/Redis.php @@ -1,8 +1,8 @@ '192.168.56.102', - * 'user' => 'test', - * 'password' => 'test', - * 'database' => 'test', - * 'charset' => 'utf8', - * ); - * 回调函数:function onConnect(swoole_mysql $db, bool $result); - * @param array $server_config 连接配置信息 - * @return - */ - public function connect(Array $server_config) - { - } - - /** - * - *执行sql语句 - * @example - * @param string $sql 要执行的sql语句 - * @param double $timeout 超时时间,超时的话会断开MySQL连接,0表示不设置超时时间 - * @return array | bool - */ - public function query($sql, $timeout) - { - } - - /** - * - *从服务器端接收数据 - * @example - * @param int $size 接收数据的缓存区最大长度,此参数不要设置过大,否则会占用较大内存 - * @param boolean $flag 是否等待所有数据到达后返回 - * @return string - */ - public function recv($size, $flag) - { - } - - /** - * - *启动事务 - * @example - * @return - */ - public function begin() - { - } - - /** - * - *提交事务 - * @example - * @return - */ - public function commit() - { - } - - /** - * - *回滚事务(必须先调用begin启动事务才能调用rollback否则底层会抛出异常) - * @example - * @return - */ - public function rollback() - { - } - - /** - * - *设置是否延迟 - * @example - * @param boolean $defer bool值,为true时,表明该Client要延迟收包,为false时,表明该Client非延迟收包,默认值为true - * @return - */ - public function setDefer($defer) - { - } - - /** - * - *返回当前设置的defer - * @example - * @return boolean - */ - public function getDefer() - { - } - - /** - * - *关闭mysql连接 - * @example - * @return - */ - public function close() - { - } - - /** - * - *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) - * @example - * @return - */ - public function __sleep() - { - } - - /** - * - *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) - * @example - * @return - */ - public function __wakeup() - { - } - -} - diff --git a/src/Swoole/swoole_mysql_coro_exception.php b/src/Swoole/swoole_mysql_coro_exception.php deleted file mode 100644 index 7ef287c..0000000 --- a/src/Swoole/swoole_mysql_coro_exception.php +++ /dev/null @@ -1,155 +0,0 @@ -on("WorkerStart", function ($pool, $workerId) { + * $process = $pool->getProcess(); + * $process->exec("/bin/sh", ["ls", '-l']); + * }); + * @return \Swoole\Process + */ + public function getProcess(): \Swoole\Process + { + + } + } diff --git a/src/Swoole/swoole_redis.php b/src/Swoole/swoole_redis.php index 069f0e4..b6c8dbb 100644 --- a/src/Swoole/swoole_redis.php +++ b/src/Swoole/swoole_redis.php @@ -1,8 +1,8 @@ set('key', 'value'); - * 带有效期的设置: - * $redis->set('key','value', 10); - * 当键不存在时,设置期有效期为10秒: - * $redis->set('key', 'value', Array('nx', 'ex'=>10)); - * 当键存在时,设置期有效期为1000毫秒: - * $redis->set('key', 'value', Array('xx', 'px'=>1000)); - * - * @param string $key 设置的缓存键 - * @param string $value 设置的缓存值 - * @param int|array $options 附加项,可以是超时时间或者一个选项数组 - * @return bool - */ - public function set($key, $value, $options) - { - } - - /** - * - *修改某个键的某个位置的位值 - * @example - *
-     * $redis->set('key', "*");     // ord("*") = 42 = 0x2f = "0010 1010"
-     * $redis->setBit('key', 5, 1); // returns 0
-     * $redis->setBit('key', 7, 1); // returns 0
-     * $redis->get('key');          // chr(0x2f) = "/" = b("0010 1111")
-     * 
- * @param string $key 键名 - * @param int $offset 开始位置 - * @param boolean|int $value 新值 - * @return int: - */ - public function setBit($key, $offset, $value) - { - } - - /** - * - *设置键值并设置有效期 - * @example $redis->setex('key', 3600, 'value'); - * @param string $key 设置的缓存键 - * @param string $value 设置的缓存值 - * @param int $ttl 有效期 - * @return bool - */ - public function setEx($key, $value, $ttl) - { - } - - /** - * - *设置键值并设置有效期(毫秒为单位) - * @example - * @param string $key 设置的缓存键 - * @param string $value 设置的缓存值 - * @param int $ttl 有效期(毫秒为单位) - * @return - */ - public function psetEx($key, $value, $ttl) - { - } - - /** - * - *给列表指定位置设置新值 - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->lGet('key1', 0);     // 'A'
-     * $redis->lSet('key1', 0, 'X');
-     * $redis->lGet('key1', 0);     // 'X'
-     * 
- * @param string $key 键名 - * @param int $index 索引值 - * @param string $value 新值 - * @return boolean - */ - public function lSet($key, $index, $value) - { - } - - /** - * - *获取指定的key的值 - * @example $redis->get('key'); - * @return string|bool - */ - public function get() - { - } - - /** - * - *批量获取键名 - * @example - *
-     * $redis->delete('x', 'y', 'z', 'h');	// remove x y z
-     * $redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'));
-     * $redis->hset('h', 'field', 'value');
-     * var_dump($redis->mget(array('x', 'y', 'z', 'h')));
-     * // Output:
-     * // array(3) {
-     * // [0]=>
-     * // string(1) "a"
-     * // [1]=>
-     * // string(1) "b"
-     * // [2]=>
-     * // string(1) "c"
-     * // [3]=>
-     * // bool(false)
-     * // }
-     * 
- * @param array $keys 键名数组 - * @return - */ - public function mGet(Array $keys) - { - } - - /** - * - *删除一个或多个键 - * @example $redis->delete('key1', 'key2'); - * $redis->delete(array('key3', 'key4')); - * @param array|string $keys 键名 - * @return int - */ - public function del($keys) - { - } - - /** - * - *删除字典的某个或某些字段 - * @example - *
-     * $redis->hMSet('h',
-     * array(
-     * 'f1' => 'v1',
-     * 'f2' => 'v2',
-     * 'f3' => 'v3',
-     * 'f4' => 'v4',
-     * ));
-     * var_dump( $redis->hDel('h', 'f1') );        // int(1)
-     * var_dump( $redis->hDel('h', 'f2', 'f3') );  // int(2)
-     * s
-     * var_dump( $redis->hGetAll('h') );
-     * //// Output:
-     * //  array(1) {
-     * //    ["f4"]=> string(2) "v4"
-     * //  }
-     * 
- * @param string $key 键名 - * @param string|array $fields 字段名 - * @return int - */ - public function hDel($key, $fields) - { - } - - /** - * - *为字典的字段设置值 - * @example - *
-     * $redis->delete('h')
-     * $redis->hSet('h', 'key1', 'hello');  // 1, 'key1' => 'hello' in the hash at "h"
-     * $redis->hGet('h', 'key1');           // returns "hello"
-     * $redis->hSet('h', 'key1', 'plop');   // 0, value was replaced.
-     * $redis->hGet('h', 'key1');           // returns "plop"
-     * 
- * @param string $key 键名 - * @param string $field 字段名 - * @param string $value 字段值 - * @return long - */ - public function hSet($key, $field, $value) - { - } - - /** - * - *批量设置字典字段的值 - * @example - *
-     * $redis->delete('user:1');
-     * $redis->hMset('user:1', array('name' => 'Joe', 'salary' => 2000));
-     * $redis->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now.
-     * 
- * @param string $key 键名 - * @param array $fields 字段键值对 - * @return boolean - */ - public function hMSet($key, Array $fields) - { - } - - /** - * - *当字典的字段不存在时,为其设置值 - * @example - *
-     * $redis->delete('h')
-     * $redis->hSetNx('h', 'key1', 'hello'); // TRUE, 'key1' => 'hello' in the hash at "h"
-     * $redis->hSetNx('h', 'key1', 'world'); // FALSE, 'key1' => 'hello' in the hash at "h". No change since the field
-     * wasn't replaced.
-     * 
- * @param string $key 键名 - * @param string $field 字段名 - * @param string $value 字段值 - * @return bool - */ - public function hSetNx($key, $field, $value) - { - } - - /** - * - *删除一个或多个键 - * @example $redis->delete('key1', 'key2'); - * $redis->delete(array('key3', 'key4')); - * @param array|string $keys 键名 - * @return int - */ - public function delete($keys) - { - } - - /** - * - *批量设置值 - * @example - *
-     * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
-     * var_dump($redis->get('key0'));
-     * var_dump($redis->get('key1'));
-     * // Output:
-     * // string(6) "value0"
-     * // string(6) "value1"
-     * 
- * @param array $values 要设置的键值对 - * @return bool - */ - public function mSet(Array $values) - { - } - - /** - * - *批量设置值(当不存在时设置) - * @example - *
-     * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
-     * var_dump($redis->get('key0'));
-     * var_dump($redis->get('key1'));
-     * // Output:
-     * // string(6) "value0"
-     * // string(6) "value1"
-     * 
- * @param array $values 要设置的键值对 - * @return bool - */ - public function mSetNx(Array $values) - { - } - - /** - * - *根据匹配模式获取键名(如*) - * @example - * $allKeys = $redis->keys('*'); - * $keyWithUserPrefix = $redis->keys('user*'); - * @param string $pattern 匹配模式 - * @return array - */ - public function getKeys($pattern) - { - } - - /** - * - *根据匹配模式获取键名(如*) - * @example - * $allKeys = $redis->keys('*'); - * $keyWithUserPrefix = $redis->keys('user*'); - * @param string $pattern 匹配模式 - * @return array - */ - public function keys($pattern) - { - } - - /** - * - *判断键是否存在 - * @example - *
-     * $redis->set('key', 'value');
-     * $redis->exists('key');               //  TRUE
-     * $redis->exists('NonExistingKey');    // FALSE
-     * 
- * @param string $key 键名 - * @return bool - */ - public function exists($key) - { - } - - /** - * - *获取指定键的数据类型(需要根据常量匹配) - * @example $redis->type('key'); - * @param string $key 键名 - * @return int - */ - public function type($key) - { - } - - /** - * - *获取键值的长度 - * @example - *
-     * $redis->set('key', 'value');
-     * $redis->strlen('key'); // 5
-     * 
- * @param string $key 键名 - * @return int - */ - public function strLen($key) - { - } - - /** - * - *从列表左侧删除一个元素 - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->lPop('key1');        // key1 => [ 'B', 'C' ]
-     * 
- * @param string $key 键名 - * @return string - */ - public function lPop($key) - { - } - - /** - * - *是一个阻塞lPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表头部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,blPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 - * @example - *
-     * // Non blocking feature
-     * $redis->lPush('key1', 'A');
-     * $redis->delete('key2');
-     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * // Blocking feature
-     * // process 1
-     * $redis->delete('key1');
-     * $redis->blPop('key1', 10);
-     * // blocking for 10 seconds
-     * // process 2
-     * $redis->lPush('key1', 'A');
-     * // process 1
-     * // array('key1', 'A') is returned
-     * 
- * @param string|...|array $key 键名 - * @param int $timeout 超时时间 - * @return array - */ - public function blPop($key, $timeout) - { - } - - /** - * - *从列表右侧删除一个元素 - * @example - *
-     * $redis->rPush('key1', 'A');
-     * $redis->rPush('key1', 'B');
-     * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
-     * $redis->rPop('key1');        // key1 => [ 'A', 'B' ]
-     * 
- * @param string $key 键名 - * @return string - */ - public function rPop($key) - { - } - - /** - * - *是一个阻塞rPop原语。 如果至少有一个列表包含至少一个元素,则该元素将从列表尾部弹出并返回给调用者。 如果所有通过参数传递的键标识的列表都是空的,brPop将在指定的超时期间阻塞,直到元素被推送到其中一个列表。 这个元素将被弹出。 - * @example - *
-     * // Non blocking feature
-     * $redis->lPush('key1', 'A');
-     * $redis->delete('key2');
-     * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
-     * // OR
-     * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
-     * // Blocking feature
-     * // process 1
-     * $redis->delete('key1');
-     * $redis->blPop('key1', 10);
-     * // blocking for 10 seconds
-     * // process 2
-     * $redis->lPush('key1', 'A');
-     * // process 1
-     * // array('key1', 'A') is returned
-     * 
- * @param string|...|array $key 键名 - * @param int $timeout 超时时间 - * @return array - */ - public function brPop($key, $timeout) - { - } - - /** - * - *阻塞执行rpoplpush - * @example - * @param string $srcKey 要删除元素的队列键名 - * @param string $dstKey 要插入元素的队列的键名 - * @return string - */ - public function bRPopLPush($srcKey, $dstKey) - { - } - - /** - * - *返回列表的长度 - * @example - * @param string|...|array $key 键名 - * @return long | bool - */ - public function lSize($key) - { - } - - /** - * - *返回列表的长度 - * @example - * @param string|...|array $key 键名 - * @return long | bool - */ - public function lLen($key) - { - } - - /** - * - *返回集合的元素个数 - * @example - * @param string $key 键名 - * @return long - */ - public function sSize($key) - { - } - - /** - * - *返回集合的元素个数 - * @example - * @param string $key 键名 - * @return long - */ - public function scard($key) - { - } - - /** - * - *随机删除元素的某个或某些成员,并返回这个删除的成员. - * @example - *
-     * $redis->sAdd('key1' , 'set1');
-     * $redis->sAdd('key1' , 'set2');
-     * $redis->sAdd('key1' , 'set3');   // 'key1' => {'set3', 'set1', 'set2'}
-     * $redis->sPop('key1');            // 'set1', 'key1' => {'set3', 'set2'}
-     * $redis->sPop('key1');            // 'set3', 'key1' => {'set2'}
-     * 
- * @param string $key 键名 - * @param int $count 删除个数 - * @return string | bool - */ - public function sPop($key, $count) - { - } - - /** - * - *返回集合的所有成员 - * @example - *
-     * $redis->delete('s');
-     * $redis->sAdd('s', 'a');
-     * $redis->sAdd('s', 'b');
-     * $redis->sAdd('s', 'a');
-     * $redis->sAdd('s', 'c');
-     * var_dump($redis->sMembers('s'));
-     * //array(3) {
-     * //  [0]=>
-     * //  string(1) "c"
-     * //  [1]=>
-     * //  string(1) "a"
-     * //  [2]=>
-     * //  string(1) "b"
-     * //}
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @param string $key 键名 - * @return array - */ - public function sMembers($key) - { - } - - /** - * - *返回集合的所有成员 - * @example - *
-     * $redis->delete('s');
-     * $redis->sAdd('s', 'a');
-     * $redis->sAdd('s', 'b');
-     * $redis->sAdd('s', 'a');
-     * $redis->sAdd('s', 'c');
-     * var_dump($redis->sMembers('s'));
-     * //array(3) {
-     * //  [0]=>
-     * //  string(1) "c"
-     * //  [1]=>
-     * //  string(1) "a"
-     * //  [2]=>
-     * //  string(1) "b"
-     * //}
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @param string $key 键名 - * @return array - */ - public function sGetMembers($key) - { - } - - /** - * - *随机返回一个集合的元素(不会删除它) - * @example - *
-     * $redis->sAdd('key1' , 'one');
-     * $redis->sAdd('key1' , 'two');
-     * $redis->sAdd('key1' , 'three');              // 'key1' => {'one', 'two', 'three'}
-     * var_dump( $redis->sRandMember('key1') );     // 'key1' => {'one', 'two', 'three'}
-     * // string(5) "three"
-     * var_dump( $redis->sRandMember('key1', 2) );  // 'key1' => {'one', 'two', 'three'}
-     * // array(2) {
-     * //   [0]=> string(2) "one"
-     * //   [1]=> string(2) "three"
-     * // }
-     * 
- * @param string $key 键名 - * @return string | bool - */ - public function sRandMember($key) - { - } - - /** - * - *移除指定键的有效期,让它永久有效 - * @example $redis->persist('key'); - * @param string $key 键名 - * @return bool: - */ - public function persist($key) - { - } - - /** - * - *返回指定键的有效时间(秒) - * @example $redis->ttl('key'); - * @param string $key 键名 - * @return long - */ - public function ttl($key) - { - } - - /** - * - *返回指定键的有效时间(毫秒) - * @example $redis->pttl('key'); - * @param string $key 键名 - * @return long - */ - public function pttl($key) - { - } - - /** - * - *获取有序集合的成员数 - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zCard('key');            // 3
-     * 
- * @param string $key 集合键名 - * @return int - */ - public function zCard($key) - { - } - - /** - * - *获取有序集合的成员数 - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zCard('key');            // 3
-     * 
- * @param string $key 集合键名 - * @return int - */ - public function zSize($key) - { - } - - /** - * - *获取字典的字段个数 - * @example - *
-     * $redis->delete('h')
-     * $redis->hSet('h', 'key1', 'hello');
-     * $redis->hSet('h', 'key2', 'plop');
-     * $redis->hLen('h'); // returns 2
-     * 
- * @param string $key 键名 - * @return int - */ - public function hLen($key) - { - } - - /** - * - *获取字典的字段名称列表. - * @example - *
-     * $redis->delete('h');
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hSet('h', 'b', 'y');
-     * $redis->hSet('h', 'c', 'z');
-     * $redis->hSet('h', 'd', 't');
-     * var_dump($redis->hKeys('h'));
-     * // Output:
-     * // array(4) {
-     * // [0]=>
-     * // string(1) "a"
-     * // [1]=>
-     * // string(1) "b"
-     * // [2]=>
-     * // string(1) "c"
-     * // [3]=>
-     * // string(1) "d"
-     * // }
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @param string $key 键名 - * @return array - */ - public function hKeys($key) - { - } - - /** - * - *获取字典的字段值列表 - * @example - *
-     * $redis->delete('h');
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hSet('h', 'b', 'y');
-     * $redis->hSet('h', 'c', 'z');
-     * $redis->hSet('h', 'd', 't');
-     * var_dump($redis->hVals('h'));
-     * // Output
-     * // array(4) {
-     * //   [0]=>
-     * //   string(1) "x"
-     * //   [1]=>
-     * //   string(1) "y"
-     * //   [2]=>
-     * //   string(1) "z"
-     * //   [3]=>
-     * //   string(1) "t"
-     * // }
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @param string $key 键名 - * @return array - */ - public function hVals($key) - { - } - - /** - * - *获取字典所有字段键值对 - * @example - *
-     * $redis->delete('h');
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hSet('h', 'b', 'y');
-     * $redis->hSet('h', 'c', 'z');
-     * $redis->hSet('h', 'd', 't');
-     * var_dump($redis->hGetAll('h'));
-     * // Output:
-     * // array(4) {
-     * //   ["a"]=>
-     * //   string(1) "x"
-     * //   ["b"]=>
-     * //   string(1) "y"
-     * //   ["c"]=>
-     * //   string(1) "z"
-     * //   ["d"]=>
-     * //   string(1) "t"
-     * // }
-     * // The order is random and corresponds to redis' own internal representation of the set structure.
-     * 
- * @param string $key 键名 - * @return array - */ - public function hGetAll($key) - { - } - - /** - * - *调试命令(不建议使用) - * @example - * @return - */ - public function debug() - { - } - - /** - * - *将dump导出的二进制数据恢复到可读的字符串. - * @example - *
-     * $redis->set('foo', 'bar');
-     * $val = $redis->dump('foo');
-     * $redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo'
-     * 
- * @param string $key 键名 - * @param int $ttl 有效期 - * @param string $value dump导出的二进制数据 - * @return - */ - public function restore($key, $ttl, $value) - { - } - - /** - * - *将某个键导出为一个二进制数据. - * @example - *
-     * $redis->set('foo', 'bar');
-     * $val = $redis->dump('foo'); // $val will be the Redis encoded key value
-     * 
- * @param string $key 键名 - * @return string - */ - public function dump($key) - { - } - - /** - * - *给键重命名 - * @example - * @param string $srcKey 旧键名 - * @param string $dstKey 新键名 - * @return boolean - */ - public function renameKey($srcKey, $dstKey) - { - } - - /** - * - *给键重命名 - * @example - * @param string $srcKey 旧键名 - * @param string $dstKey 新键名 - * @return boolean - */ - public function rename($srcKey, $dstKey) - { - } - - /** - * - *当目标键名不存在时,给键重命名 - * @example - * @param string $srcKey 旧键名 - * @param string $dstKey 新键名 - * @return boolean - */ - public function renameNx($srcKey, $dstKey) - { - } - - /** - * - *从一个队列的队尾删除一个元素,并将该元素插入到另一个队列的头部 - * @example - *
-     * $redis->delete('x', 'y');
-     * $redis->lPush('x', 'abc');
-     * $redis->lPush('x', 'def');
-     * $redis->lPush('y', '123');
-     * $redis->lPush('y', '456');
-     * // move the last of x to the front of y.
-     * var_dump($redis->rpoplpush('x', 'y'));
-     * var_dump($redis->lRange('x', 0, -1));
-     * var_dump($redis->lRange('y', 0, -1));
-     * //Output:
-     * //
-     * //string(3) "abc"
-     * //array(1) {
-     * //  [0]=>
-     * //  string(3) "def"
-     * //}
-     * //array(3) {
-     * //  [0]=>
-     * //  string(3) "abc"
-     * //  [1]=>
-     * //  string(3) "456"
-     * //  [2]=>
-     * //  string(3) "123"
-     * //}
-     * 
- * @param string $srcKey 要删除元素的队列键名 - * @param string $dstKey 要插入元素的队列的键名 - * @return string - */ - public function rpoplpush($srcKey, $dstKey) - { - } - - /** - * - *返回一个随机的键 - * @example - *
-     * $key = $redis->randomKey();
-     * $surprise = $redis->get($key);  // who knows what's in there.
-     * 
- * @return string - */ - public function randomKey() - { - } - - /** - * - *检查当前redis连接状态(成功时返回PONG) - * @example - * @return string - */ - public function ping() - { - } - - /** - * - *设置连接的认证密码 - * @example $redis->auth('foobared'); - * @param string $password 认证密码 - * @return bool: - */ - public function auth($password) - { - } - - /** - * - *取消观察某个键在其他客户端的变化情况 - * @example - * @param string|array $keys 键名 - * @return - */ - public function unwatch($keys) - { - } - - /** - * - *观察某个键在其他客户端的变化情况. - * @example - *
-     * $redis->watch('x');
-     * // long code here during the execution of which other clients could well modify `x`
-     * $ret = $redis->multi()
-     * ->incr('x')
-     * ->exec();
-     * // $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.
-     * 
- * @param string|array $keys 键名 - * @return - */ - public function watch($keys) - { - } - - /** - * - *将数据同步到硬盘上 - * @example $redis->save(); - * @return boolean - */ - public function save() - { - } - - /** - * - *将数据存入到硬盘上(异步操作) - * @example - * @return - */ - public function bgSave() - { - } - - /** - * - *获取上次数据同步到硬盘的时间 - * @example $redis->lastSave(); - * @return int - */ - public function lastSave() - { - } - - /** - * - *删除当前数据库的所有键 - * @example $redis->flushDB(); - * @return bool - */ - public function flushDB() - { - } - - /** - * - *删除当前实例的所有键 - * @example $redis->flushAll(); - * @return bool - */ - public function flushAll() - { - } - - /** - * - *获取当前数据库的键的个数 - * @example - *
-     * $count = $redis->dbSize();
-     * echo "Redis has $count keys\n";
-     * 
- * @return int - */ - public function dbSize() - { - } - - /** - * - *开启后台写AOF日志操作 - * @example $redis->bgrewriteaof(); - * @return bool - */ - public function bgrewriteaof() - { - } - - /** - * - *返回当前redis服务器时间. - * @example - *
-     * var_dump( $redis->time() );
-     * // array(2) {
-     * //   [0] => string(10) "1342364352"
-     * //   [1] => string(6) "253002"
-     * // }
-     * 
- * @return int - */ - public function time() - { - } - - /** - * - *返回当前连接的服务器的角色,如master、alone、slave、sentinel - * @example - * @return string - */ - public function role() - { - } - - /** - * - *修改某个键的某个位置的值 - * @example - *
-     * $redis->set('key', 'Hello world');
-     * $redis->setRange('key', 6, "redis"); // returns 11
-     * $redis->get('key');                  // "Hello redis"
-     * 
- * @param string $key 键名 - * @param int $offset 开始位置 - * @param string $value 被替换的子串的值 - * @return string - */ - public function setRange($key, $offset, $value) - { - } - - /** - * - *当键不存在时设置其值 - * @example - * $redis->setnx('key', 'value'); - * - * @param string $key 设置的缓存键 - * @param string $value 设置的缓存值 - * @return bool: - */ - public function setNx($key, $value) - { - } - - /** - * - *设置键的值,并返回它的旧的缓存值 - * @example - *
-     * $redis->set('x', '42');
-     * $exValue = $redis->getSet('x', 'lol');   // return '42', replaces x by 'lol'
-     * $newValue = $redis->get('x')'            // return 'lol'
-     * 
- * @param string $key 设置的缓存键 - * @param string $value 设置的缓存值 - * @return string - */ - public function getSet($key, $value) - { - } - - /** - * - *将字符串追加到键值后(返回值的长度) - * @example - *
-     * $redis->set('key', 'value1');
-     * $redis->append('key', 'value2'); // 12
-     * $redis->get('key');              // 'value1value2'
-     * 
- * @param string $key 键名 - * @param string $value 追加的值 - * @return int - */ - public function append($key, $value) - { - } - - /** - * - *如果列表存在,从左侧(头部)向列表插入元素 - * @example - *
-     * $redis->delete('key1');
-     * $redis->lPushx('key1', 'A');     // returns 0
-     * $redis->lPush('key1', 'A');      // returns 1
-     * $redis->lPushx('key1', 'B');     // returns 2
-     * $redis->lPushx('key1', 'C');     // returns 3
-     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
-     * 
- * @param string $key 键名 - * @param string $value 元素值 - * @return int - */ - public function lPushx($key, $value) - { - } - - /** - * - *从左侧(头部)向列表插入元素 - * @example - *
-     * $redis->lPush('l', 'v1', 'v2', 'v3', 'v4')   // int(4)
-     * var_dump( $redis->lRange('l', 0, -1) );
-     * //// Output:
-     * // array(4) {
-     * //   [0]=> string(2) "v4"
-     * //   [1]=> string(2) "v3"
-     * //   [2]=> string(2) "v2"
-     * //   [3]=> string(2) "v1"
-     * // }
-     * 
- * @param string $key 键名 - * @param string $value 元素值 - * @return int - */ - public function lPush($key, $value) - { - } - - /** - * - *从右侧(尾部)向列表插入元素 - * @example - *
-     * $redis->rPush('l', 'v1', 'v2', 'v3', 'v4');    // int(4)
-     * var_dump( $redis->lRange('l', 0, -1) );
-     * //// Output:
-     * // array(4) {
-     * //   [0]=> string(2) "v1"
-     * //   [1]=> string(2) "v2"
-     * //   [2]=> string(2) "v3"
-     * //   [3]=> string(2) "v4"
-     * // }
-     * 
- * @param string $key 键名 - * @param string $value 元素值 - * @return int - */ - public function rPush($key, $value) - { - } - - /** - * - *如果列表存在,从右侧(尾部)向列表插入元素 - * @example - *
-     * $redis->delete('key1');
-     * $redis->rPushx('key1', 'A'); // returns 0
-     * $redis->rPush('key1', 'A'); // returns 1
-     * $redis->rPushx('key1', 'B'); // returns 2
-     * $redis->rPushx('key1', 'C'); // returns 3
-     * // key1 now points to the following list: [ 'A', 'B', 'C' ]
-     * 
- * @param string $key 键名 - * @param string $value 元素值 - * @return int - */ - public function rPushx($key, $value) - { - } - - /** - * - *是否包含某个成员 - * @example - * @param string $key 键名 - * @param string $member 成员值 - * @return boolean - */ - public function sContains($key, $member) - { - } - - /** - * - *是否包含某个成员 - * @example - * @param string $key 键名 - * @param string $member 成员值 - * @return boolean - */ - public function sismember($key, $member) - { - } - - /** - * - *获取指定成员的排序值(分数) - * @example - *
-     * $redis->zAdd('key', 2.5, 'val2');
-     * $redis->zScore('key', 'val2'); // 2.5
-     * 
- * @param string $key 集合键名 - * @param string $member 成员值 - * @return double - */ - public function zScore($key, $member) - { - } - - /** - * - *获取成员的排序值 - * @example - *
-     * $redis->delete('z');
-     * $redis->zAdd('key', 1, 'one');
-     * $redis->zAdd('key', 2, 'two');
-     * $redis->zRank('key', 'one');     // 0
-     * $redis->zRank('key', 'two');     // 1
-     * $redis->zRevRank('key', 'one');  // 1
-     * $redis->zRevRank('key', 'two');  // 0
-     * 
- * @param string $key 集合键名 - * @param string $member 成员值 - * @return int - */ - public function zRank($key, $member) - { - } - - /** - * - *获取成员的排位值(倒数) - * @example - * @param string $key 集合键名 - * @param string $member 成员值 - * @return int - */ - public function zRevRank($key, $member) - { - } - - /** - * - *获取字典的某个字段的值 - * @example - * @param string $key 键名 - * @param string $field 字段名 - * @return string - */ - public function hGet($key, $field) - { - } - - /** - * - *批量获取字典的字段值 - * @example - * @param string $key 键名 - * @param array $fields 字段名列表 - * @return array - */ - public function hMGet($key, Array $fields) - { - } - - /** - * - *判断字典的某个字段是否存在. - * @example - *
-     * $redis->hSet('h', 'a', 'x');
-     * $redis->hExists('h', 'a');               //  TRUE
-     * $redis->hExists('h', 'NonExistingKey');  // FALSE
-     * 
- * @param string $key 键名 - * @param string $field 字段名 - * @return bool - */ - public function hExists($key, $field) - { - } - - /** - * - *将消息发布到消息通道(队列). - * @example $redis->publish('chan-1', 'hello, world!'); // send message. - * @param string $channel 消息频道 - * @param string $message 消息 - * @return int - */ - public function publish($channel, $message) - { - } - - /** - * - *给有序集合成员增加排序值 - * @example - *
-     * $redis->delete('key');
-     * $redis->zIncrBy('key', 2.5, 'member1');  // key or member1 didn't exist, so member1's score is to 0
-     * // before the increment and now has the value 2.5
-     * $redis->zIncrBy('key', 1, 'member1');    // 3.5
-     * 
- * @param string $key 目标集合键名 - * @param double $step 增加的步长 - * @param string $member 成员 - * @return float - */ - public function zIncrBy($key, $step, $member) - { - } - - /** - * - *向有序集合插入元素 - * @example - *
-     * 
-     * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
-     * $redis->zRem('z', 'v2', 'v3');                           // int(2)
-     * var_dump( $redis->zRange('z', 0, -1) );
-     * //// Output:
-     * // array(2) {
-     * //   [0]=> string(2) "v1"
-     * //   [1]=> string(2) "v4"
-     * // }
-     * 
- *
- * @param string $key 集合键名 - * @param double $score 排序值 - * @param string $value 元素值 - * @return int - */ - public function zAdd($key, $score, $value) - { - } - - /** - * - *根据排序值范围来删除成员 - * @example - * @param string $key 集合键名 - * @param double $start 开始排序值 - * @param double $end 结束排序值 - * @return long - */ - public function zDeleteRangeByScore($key, $start, $end) - { - } - - /** - * - *根据排序值范围来删除成员 - * @example - * @param string $key 集合键名 - * @param double $start 开始排序值 - * @param double $end 结束排序值 - * @return long - */ - public function zRemRangeByScore($key, $start, $end) - { - } - - /** - * - *获取指定排序范围的成员数. - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zCount('key', 0, 3); // 2, corresponding to array('val0', 'val2')
-     * 
- * @param string $key 集合键名 - * @param double $start 开始排序值 - * @param double $end 结束排序值 - * @return int - */ - public function zCount($key, $start, $end) - { - } - - /** - * - *获取有序集合中指定范围的成员 - * @example - *
-     * $redis->zAdd('key1', 0, 'val0');
-     * $redis->zAdd('key1', 2, 'val2');
-     * $redis->zAdd('key1', 10, 'val10');
-     * $redis->zRange('key1', 0, -1); // array('val0', 'val2', 'val10')
-     * // with scores
-     * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10)
-     * 
- * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 - * @param boolean $withScores 是否返回成员的排序值 - * @return array - */ - public function zRange($key, $start, $end, $withScores) - { - } - - /** - * - *获取有序集合中指定范围的成员(倒序排列) - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zRevRange('key', 0, -1); // array('val10', 'val2', 'val0')
-     * // with scores
-     * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0)
-     * 
- * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 - * @param boolean $withScores 是否返回成员的排序值 - * @return array - */ - public function zRevRange($key, $start, $end, $withScores) - { - } - - /** - * - *获取有序集合中指定范围的成员(按排序值排列) - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
-     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
-     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
-     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
-     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
-     * 
- * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 - * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) - * @return array - */ - public function zRangeByScore($key, $start, $end, Array $options) - { - } - - /** - * - *获取有序集合中指定范围的成员(按排序值倒序排列) - * @example - *
-     * $redis->zAdd('key', 0, 'val0');
-     * $redis->zAdd('key', 2, 'val2');
-     * $redis->zAdd('key', 10, 'val10');
-     * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
-     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
-     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
-     * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
-     * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
-     * 
- * @param string $key 集合键名 - * @param long $start 索引开始值 - * @param long $end 索引结束值 - * @param array $options 附加选项(可以是:withscores => TRUE, and limit => array($offset, $count)) - * @return array - */ - public function zRevRangeByScore($key, $start, $end, Array $options) - { - } - - /** - * - *按字母字典的顺序返回成员 - * @example - *
-     * foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g') as $char) {
-     * $redis->zAdd('key', $char);
-     * }
-     * $redis->zRangeByLex('key', '-', '[c'); // array('a', 'b', 'c')
-     * $redis->zRangeByLex('key', '-', '(c'); // array('a', 'b')
-     * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c')
-     * 
- * @param string $key 集合键名 - * @param long $min 最小的字母 - * @param long $max 最大的字母 - * @param long $offset 索引开始值 - * @param long $limit 成员数 - * @return array - */ - public function zRangeByLex($key, $min, $max, $offset, $limit) - { - } - - /** - * - *按字母字典的顺序返回成员(倒序排序) - * @example - * @param string $key 集合键名 - * @param long $min 最小的字母 - * @param long $max 最大的字母 - * @param long $offset 索引开始值 - * @param long $limit 成员数 - * @return - */ - public function zRevRangeByLex($key, $min, $max, $offset, $limit) - { - } - - /** - * - *将两个有序集合的交集存入到一个指定的键中 - * @example - *
-     * $redis->delete('k1');
-     * $redis->delete('k2');
-     * $redis->delete('k3');
-     * $redis->delete('ko1');
-     * $redis->delete('ko2');
-     * $redis->delete('ko3');
-     * $redis->delete('ko4');
-     * $redis->zAdd('k1', 0, 'val0');
-     * $redis->zAdd('k1', 1, 'val1');
-     * $redis->zAdd('k1', 3, 'val3');
-     * $redis->zAdd('k2', 2, 'val1');
-     * $redis->zAdd('k2', 3, 'val3');
-     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
-     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
-     * // Weighted zInter
-     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
-     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
-     * 
- * @param string $dstKey 目标集合键名 - * @param array $zsetKeys 集合键名 - * @param array $zsetKeysWeight 集合键对应的权重 - * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) - * @return int - */ - public function zInter($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) - { - } - - /** - * - *将两个有序集合的交集存入到一个指定的键中 - * @example - *
-     * $redis->delete('k1');
-     * $redis->delete('k2');
-     * $redis->delete('k3');
-     * $redis->delete('ko1');
-     * $redis->delete('ko2');
-     * $redis->delete('ko3');
-     * $redis->delete('ko4');
-     * $redis->zAdd('k1', 0, 'val0');
-     * $redis->zAdd('k1', 1, 'val1');
-     * $redis->zAdd('k1', 3, 'val3');
-     * $redis->zAdd('k2', 2, 'val1');
-     * $redis->zAdd('k2', 3, 'val3');
-     * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
-     * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
-     * // Weighted zInter
-     * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
-     * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
-     * 
- * @param string $dstKey 目标集合键名 - * @param array $zsetKeys 集合键名 - * @param array $zsetKeysWeight 集合键对应的权重 - * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) - * @return int - */ - public function zinterstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) - { - } - - /** - * - *将两个有序集合的并集存入到一个指定的键中 - * @example - *
-     * $redis->delete('k1');
-     * $redis->delete('k2');
-     * $redis->delete('k3');
-     * $redis->delete('ko1');
-     * $redis->delete('ko2');
-     * $redis->delete('ko3');
-     * $redis->zAdd('k1', 0, 'val0');
-     * $redis->zAdd('k1', 1, 'val1');
-     * $redis->zAdd('k2', 2, 'val2');
-     * $redis->zAdd('k2', 3, 'val3');
-     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
-     * // Weighted zUnion
-     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
-     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
-     * 
- * @param string $dstKey 目标集合键名 - * @param array $zsetKeys 集合键名 - * @param array $zsetKeysWeight 集合键对应的权重 - * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) - * @return int - */ - public function zUnion($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) - { - } - - /** - * - *将两个有序集合的并集存入到一个指定的键中 - * @example - *
-     * $redis->delete('k1');
-     * $redis->delete('k2');
-     * $redis->delete('k3');
-     * $redis->delete('ko1');
-     * $redis->delete('ko2');
-     * $redis->delete('ko3');
-     * $redis->zAdd('k1', 0, 'val0');
-     * $redis->zAdd('k1', 1, 'val1');
-     * $redis->zAdd('k2', 2, 'val2');
-     * $redis->zAdd('k2', 3, 'val3');
-     * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
-     * // Weighted zUnion
-     * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
-     * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
-     * 
- * @param string $dstKey 目标集合键名 - * @param array $zsetKeys 集合键名 - * @param array $zsetKeysWeight 集合键对应的权重 - * @param string $aggregateFunction 合并使用的函数(SUM, MIN, 或 MAX) - * @return int - */ - public function zunionstore($dstKey, Array $zsetKeys, Array $zsetKeysWeight, $aggregateFunction) - { - } - - /** - * - *按指定步长自增 - * @example - *
-     * $redis->incr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value 1
-     * $redis->incr('key1');        // 2
-     * $redis->incr('key1');        // 3
-     * $redis->incr('key1');        // 4
-     * $redis->incrBy('key1', 10);  // 14
-     * 
- * @param string $key 键名 - * @param int $step 自增步长 - * @return int - */ - public function incrBy($key, $step) - { - } - - /** - * - *为指定字段增加指定的值. - * @example - *
-     * $redis->delete('h');
-     * $redis->hIncrBy('h', 'x', 2); // returns 2: h[x] = 2 now.
-     * $redis->hIncrBy('h', 'x', 1); // h[x] ← 2 + 1. Returns 3
-     * 
- * @param string $key 键名 - * @param string $field 字段名 - * @param int $step 自增步长 - * @return int - */ - public function hIncrBy($key, $field, $step) - { - } - - /** - * - *键值自增 - * @example - *
-     * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
-     * $redis->incr('key1'); // 2
-     * $redis->incr('key1'); // 3
-     * $redis->incr('key1'); // 4
-     * 
- * @param string $key 键名 - * @return int - */ - public function incr($key) - { - } - - /** - * - *按指定步长自减 - * @example - *
-     * $redis->decr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value -1
-     * $redis->decr('key1');        // -2
-     * $redis->decr('key1');        // -3
-     * $redis->decrBy('key1', 10);  // -13
-     * 
- * @param string $key 键名 - * @param float $step 自减步长 - * @return int - */ - public function decrBy($key, $step) - { - } - - /** - * - *键值自减 - * @example - *
-     * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
-     * $redis->decr('key1'); // -2
-     * $redis->decr('key1'); // -3
-     * 
- * @param string $key 键名 - * @return int - */ - public function decr($key) - { - } - - /** - * - *获取某个键的某个位置的位值 - * @example - *
-     * $redis->set('key', "\x7f");  // this is 0111 1111
-     * $redis->getBit('key', 0);    // 0
-     * $redis->getBit('key', 1);    // 1
-     * 
- * @param string $key 键名 - * @param int $offset 所在位置 - * @return int - */ - public function getBit($key, $offset) - { - } - - /** - * - *在列表中,在某个元素的前面或后面插入一个新值 - * @example - *
-     * $redis->delete('key1');
-     * $redis->lInsert('key1', Redis::AFTER, 'A', 'X');     // 0
-     * $redis->lPush('key1', 'A');
-     * $redis->lPush('key1', 'B');
-     * $redis->lPush('key1', 'C');
-     * $redis->lInsert('key1', Redis::BEFORE, 'C', 'X');    // 4
-     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C')
-     * $redis->lInsert('key1', Redis::AFTER, 'C', 'Y');     // 5
-     * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C', 'Y')
-     * $redis->lInsert('key1', Redis::AFTER, 'W', 'value'); // -1
-     * 
- * @param string $key 键名 - * @param string $position 位置(前面或后面,使用Redis::BEFORE | Redis::AFTER) - * @param string $element 元素 - * @param string $value 新值 - * @return int - */ - public function lInsert($key, $position, $element, $value) - { - } - - /** - * - *获取列表中指定索引的值 - * @example - * @param string $key 键名 - * @param int $index 索引值 - * @return string | boolean - */ - public function lGet($key, $index) - { - } - - /** - * - *获取列表中指定索引的值 - * @example - * @param string $key 键名 - * @param int $index 索引值 - * @return string | boolean - */ - public function lIndex($key, $index) - { - } - - /** - * - *设置键的有效期 - * @example - * @param string $key 键名 - * @param int $ttl 有效期(秒数) - * @return boolean - */ - public function setTimeout($key, $ttl) - { - } - - /** - * - *设置键的有效期 - * @example - * @param string $key 键名 - * @param int $ttl 有效期(秒数) - * @return boolean - */ - public function expire($key, $ttl) - { - } - - /** - * - *设置键的有效期(毫秒为单位) - * @example - * @param string $key 键名 - * @param int $ttl 有效期(毫秒数) - * @return boolean - */ - public function pexpire($key, $ttl) - { - } - - /** - * - *为某个键设置有效期为某个时间点 - * @example - *
-     * $redis->set('x', '42');
-     * $now = time(NULL);               // current timestamp
-     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
-     * sleep(5);                        // wait 5 seconds
-     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
-     * 
- * @param string $key 键名 - * @param int $expireTime 到期时间 - * @return bool: - */ - public function expireAt($key, $expireTime) - { - } - - /** - * - *为某个键设置有效期为某个时间点(精确到毫秒) - * @example - *
-     * $redis->set('x', '42');
-     * $now = time(NULL);               // current timestamp
-     * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
-     * sleep(5);                        // wait 5 seconds
-     * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
-     * 
- * @param string $key 键名 - * @param int $expireTime 到期时间 - * @return bool: - */ - public function pexpireAt($key, $expireTime) - { - } - - /** - * - *将某个键移动到其他数据库中 - * @example - *
-     * $redis->select(0);       // switch to DB 0
-     * $redis->set('x', '42');  // write 42 to x
-     * $redis->move('x', 1);    // move to DB 1
-     * $redis->select(1);       // switch to DB 1
-     * $redis->get('x');        // will return 42
-     * 
- * @param string $key 键名 - * @param int $dbIndex 数据库编号 - * @return bool - */ - public function move($key, $dbIndex) - { - } - - /** - * - *切换数据库 - * @example - *
-     * $redis->select(0);       // switch to DB 0
-     * $redis->set('x', '42');  // write 42 to x
-     * $redis->move('x', 1);    // move to DB 1
-     * $redis->select(1);       // switch to DB 1
-     * $redis->get('x');        // will return 42
-     * 
- * @param int $dbIndex 数据库编号 - * @return bool - */ - public function select($dbIndex) - { - } - - /** - * - *获取一个键值的子字符串 - * @example - *
-     * $redis->set('key', 'string value');
-     * $redis->getRange('key', 0, 5);   // 'string'
-     * $redis->getRange('key', -5, -1); // 'value'
-     * 
- * @param string $key 键名 - * @param int $start 开始位置 - * @param int $end 结束位置 - * @return string: - */ - public function getRange($key, $start, $end) - { - } - - /** - * - *删除指定范围外的其他元素 - * @example - * @param string $key 键名 - * @param int $start 开始索引 - * @param int $end 结束索引 - * @return array | boolean - */ - public function listTrim($key, $start, $end) - { - } - - /** - * - *删除指定范围外的其他元素 - * @example - * @param string $key 键名 - * @param int $start 开始索引 - * @param int $end 结束索引 - * @return array | boolean - */ - public function ltrim($key, $start, $end) - { - } - - /** - * - *获取列表指定范围的值 - * @example - * @param string $key 键名 - * @param int $start 索引开始值 - * @param int $end 索引结束值 - * @return array - */ - public function lGetRange($key, $start, $end) - { - } - - /** - * - *获取列表指定范围的值 - * @example - * @param string $key 键名 - * @param int $start 索引开始值 - * @param int $end 索引结束值 - * @return array - */ - public function lRange($key, $start, $end) - { - } - - /** - * - *从列表中删除指定值的元素。 如果count为零,则删除所有匹配的元素。 如果计数是负数,则元素从尾部移到头部。 - * @example - * @param string $key 键名 - * @param string $value 元素值 - * @param int $count 删除的个数 - * @return long | bool - */ - public function lRem($key, $value, $count) - { - } - - /** - * - *从列表中删除指定值的元素。 如果count为零,则删除所有匹配的元素。 如果计数是负数,则元素从尾部移到头部。 - * @example - * @param string $key 键名 - * @param string $value 元素值 - * @param int $count 删除的个数 - * @return long | bool - */ - public function lRemove($key, $value, $count) - { - } - - /** - * - *根据排序范围删除成员 - * @example - *
-     * $redis->zAdd('key', 1, 'one');
-     * $redis->zAdd('key', 2, 'two');
-     * $redis->zAdd('key', 3, 'three');
-     * $redis->zRemRangeByRank('key', 0, 1); // 2
-     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
-     * 
- * @param string $key 集合键名 - * @param double $start 开始排序值 - * @param double $end 结束排序值 - * @return int - */ - public function zDeleteRangeByRank($key, $start, $end) - { - } - - /** - * - *根据排序范围删除成员 - * @example - *
-     * $redis->zAdd('key', 1, 'one');
-     * $redis->zAdd('key', 2, 'two');
-     * $redis->zAdd('key', 3, 'three');
-     * $redis->zRemRangeByRank('key', 0, 1); // 2
-     * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
-     * 
- * @param string $key 集合键名 - * @param double $start 开始排序值 - * @param double $end 结束排序值 - * @return int - */ - public function zRemRangeByRank($key, $start, $end) - { - } - - /** - * - *按指定步长自增 - * @example - *
-     * $redis = new Redis();
-     * $redis->connect('127.0.0.1');
-     * $redis->set('x', 3);
-     * var_dump( $redis->incrByFloat('x', 1.5) );   // float(4.5)
-     * // ! SIC
-     * var_dump( $redis->get('x') );                // string(3) "4.5"
-     * 
- * @param string $key 键名 - * @param float $step 自增步长 - * @return float - */ - public function incrByFloat($key, $step) - { - } - - /** - * - *为指定字段增加指定的值 - * @example - *
-     * $redis = new Redis();
-     * $redis->connect('127.0.0.1');
-     * $redis->hset('h', 'float', 3);
-     * $redis->hset('h', 'int',   3);
-     * var_dump( $redis->hIncrByFloat('h', 'float', 1.5) ); // float(4.5)
-     * var_dump( $redis->hGetAll('h') );
-     * // Output
-     * array(2) {
-     * ["float"]=>
-     * string(3) "4.5"
-     * ["int"]=>
-     * string(1) "3"
-     * }
-     * 
- * @param string $key 键名 - * @param string $field 字段名 - * @param double $step 自增步长 - * @return - */ - public function hIncrByFloat($key, $field, $step) - { - } - - /** - * - *统计字符串的位数 - * @example - * @param string $key 键名 - * @return long - */ - public function bitCount($key) - { - } - - /** - * - *多个键的位操作,并将结果存入到指定的键中 - * @example - * @param string $operation 操作(有 AND, OR, NOT, XOR 4种可选择) - * @param string $dstKey 目标键 - * @param string $key1 键名1 - * @param string $key2 键名2 - * @param string|... $keyN 键名N - * @return long - */ - public function bitOp($operation, $dstKey, $key1, $key2, $keyN) - { - } - - /** - * - *给集合添加元素 - * @example - *
-     * $redis->sAdd('k', 'v1');                // int(1)
-     * $redis->sAdd('k', 'v1', 'v2', 'v3');    // int(2)
-     * 
- * @param string $key 键名 - * @param string $value 元素值 - * @return int - */ - public function sAdd($key, $value) - { - } - - /** - * - *将某个集合中的元素移动到另外一个集合中 - * @example - *
-     * $redis->sAdd('key1' , 'set11');
-     * $redis->sAdd('key1' , 'set12');
-     * $redis->sAdd('key1' , 'set13');          // 'key1' => {'set11', 'set12', 'set13'}
-     * $redis->sAdd('key2' , 'set21');
-     * $redis->sAdd('key2' , 'set22');          // 'key2' => {'set21', 'set22'}
-     * $redis->sMove('key1', 'key2', 'set13');  // 'key1' =>  {'set11', 'set12'}
-     * // 'key2' =>  {'set21', 'set22', 'set13'}
-     * 
- * @param string $srcKey 原集合键名 - * @param string $dstKey 目标集合键名 - * @param string $member 成员 - * @return bool - */ - public function sMove($srcKey, $dstKey, $member) - { - } - - /** - * - *获取多个集合的差集 - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s0', '3');
-     * $redis->sAdd('s0', '4');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * var_dump($redis->sDiff('s0', 's1', 's2'));
-     * //array(2) {
-     * //  [0]=>
-     * //  string(1) "4"
-     * //  [1]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @param string $key1 键名1 - * @param string|... $key2 键名2 - * @return array - */ - public function sDiff($key1, $key2) - { - } - - /** - * - *获取多个集合的差集,并将结果存入到一个新的集合中 - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s0', '3');
-     * $redis->sAdd('s0', '4');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * var_dump($redis->sDiffStore('dst', 's0', 's1', 's2'));
-     * var_dump($redis->sMembers('dst'));
-     * //int(2)
-     * //array(2) {
-     * //  [0]=>
-     * //  string(1) "4"
-     * //  [1]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @param string $dstKey 目标键,存放结果的键 - * @param string $key1 键名1 - * @param string $key2 键名2 - * @param string|... $keyN 键名n - * @return int: - */ - public function sDiffStore($dstKey, $key1, $key2, $keyN) - { - } - - /** - * - *获取集合的并集 - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s1', '3');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * $redis->sAdd('s2', '4');
-     * var_dump($redis->sUnion('s0', 's1', 's2'));
-     * array(4) {
-     * //  [0]=>
-     * //  string(1) "3"
-     * //  [1]=>
-     * //  string(1) "4"
-     * //  [2]=>
-     * //  string(1) "1"
-     * //  [3]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @param string $key1 键名1 - * @param string|... $key2 键名2 - * @return array - */ - public function sUnion($key1, $key2) - { - } - - /** - * - *获取多个集合的并集,并将结果存入到另外一个集合中 - * @example - *
-     * $redis->delete('s0', 's1', 's2');
-     * $redis->sAdd('s0', '1');
-     * $redis->sAdd('s0', '2');
-     * $redis->sAdd('s1', '3');
-     * $redis->sAdd('s1', '1');
-     * $redis->sAdd('s2', '3');
-     * $redis->sAdd('s2', '4');
-     * var_dump($redis->sUnionStore('dst', 's0', 's1', 's2'));
-     * var_dump($redis->sMembers('dst'));
-     * //int(4)
-     * //array(4) {
-     * //  [0]=>
-     * //  string(1) "3"
-     * //  [1]=>
-     * //  string(1) "4"
-     * //  [2]=>
-     * //  string(1) "1"
-     * //  [3]=>
-     * //  string(1) "2"
-     * //}
-     * 
- * @param string $dstKey 目标键,存放结果的键 - * @param string $key1 键名1 - * @param string $key2 键名2 - * @param string|... $keyN 键名n - * @return int - */ - public function sUnionStore($dstKey, $key1, $key2, $keyN) - { - } - - /** - * - *获取两个集合的交集 - * @example - *
-     * $redis->sAdd('key1', 'val1');
-     * $redis->sAdd('key1', 'val2');
-     * $redis->sAdd('key1', 'val3');
-     * $redis->sAdd('key1', 'val4');
-     * $redis->sAdd('key2', 'val3');
-     * $redis->sAdd('key2', 'val4');
-     * $redis->sAdd('key3', 'val3');
-     * $redis->sAdd('key3', 'val4');
-     * var_dump($redis->sInter('key1', 'key2', 'key3'));
-     * //array(2) {
-     * //  [0]=>
-     * //  string(4) "val4"
-     * //  [1]=>
-     * //  string(4) "val3"
-     * //}
-     * 
- * @param string $key1 键名1 - * @param string $key2 键名2 - * @return array | boolean - */ - public function sInter($key1, $key2) - { - } - - /** - * - *获取多个集合的交集,并将结果存入到另外一个集合中 - * @example - *
-     * $redis->sAdd('key1', 'val1');
-     * $redis->sAdd('key1', 'val2');
-     * $redis->sAdd('key1', 'val3');
-     * $redis->sAdd('key1', 'val4');
-     * $redis->sAdd('key2', 'val3');
-     * $redis->sAdd('key2', 'val4');
-     * $redis->sAdd('key3', 'val3');
-     * $redis->sAdd('key3', 'val4');
-     * var_dump($redis->sInterStore('output', 'key1', 'key2', 'key3'));
-     * var_dump($redis->sMembers('output'));
-     * //int(2)
-     * //
-     * //array(2) {
-     * //  [0]=>
-     * //  string(4) "val4"
-     * //  [1]=>
-     * //  string(4) "val3"
-     * //}
-     * 
- * @param string $dstKey 目标键,存放结果的键 - * @param string $key1 键名1 - * @param string $key2 键名2 - * @param string|... $keyN 键名n - * @return int - */ - public function sInterStore($dstKey, $key1, $key2, $keyN) - { - } - - /** - * - *删除集合元素 - * @example - * @param string $key 键名 - * @param string|... $member 成员 - * @return long - */ - public function sRemove($key, $member) - { - } - - /** - * - *删除集合元素 - * @example - * @param string $key 键名 - * @param string|... $member 成员 - * @return long - */ - public function srem($key, $member) - { - } - - /** - * - *删除有序集合中的某个成员 - * @example - * @param string $key 集合键名 - * @param string $member 成员值 - * @return int - */ - public function zDelete($key, $member) - { - } - - /** - * - *删除有序集合中的某个成员 - * @example - * @param string $key 集合键名 - * @param string $member 成员值 - * @return int - */ - public function zRemove($key, $member) - { - } - - /** - * - *删除有序集合中的某个成员 - * @example - * @param string $key 集合键名 - * @param string $member 成员值 - * @return int - */ - public function zRem($key, $member) - { - } - - /** - * - *通过匹配模式来订阅这些匹配的消息频道 - * @example - *
-     * function psubscribe($redis, $pattern, $chan, $msg) {
-     * echo "Pattern: $pattern\n";
-     * echo "Channel: $chan\n";
-     * echo "Payload: $msg\n";
-     * }
-     * 
- * @param array $patterns 匹配模式 - * @param string|array $callback 回调函数名称 - * @param mixed $value 返回值 - * @return - */ - public function pSubscribe(Array $patterns, $callback, $value) - { - } - - /** - * - *订阅消息 - * @example - *
-     * function f($redis, $chan, $msg) {
-     * switch($chan) {
-     * case 'chan-1':
-     * ...
-     * break;
-     * case 'chan-2':
-     * ...
-     * break;
-     * case 'chan-2':
-     * ...
-     * break;
-     * }
-     * }
-     * $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
-     * 
- * @param array $channels 订阅的消息频道 - * @param string|array $callback 回调函数名称 - * @param mixed $value 返回值 - * @return mixed - */ - public function subscribe(Array $channels, $callback, $value) - { - } - - /** - * - *开始一个事务. - * @example - *
-     * $ret = $redis->multi()
-     * ->set('key1', 'val1')
-     * ->get('key1')
-     * ->set('key2', 'val2')
-     * ->get('key2')
-     * ->exec();
-     * //$ret == array (
-     * //    0 => TRUE,
-     * //    1 => 'val1',
-     * //    2 => TRUE,
-     * //    3 => 'val2');
-     * 
- * @return - */ - public function multi() - { - } - - /** - * - *执行事务 - * @example - * @return - */ - public function exec() - { - } - - /** - * - *执行lua脚本 - * @example - * @param string $script 脚本 - * @param array $args 脚本参数 - * @param int $num_keys 应该进入KEYS数组的参数个数 - * @return mixed - */ - public function eval($script, Array $args, $num_keys) - { - } - - /** - * - *从脚本的SHA1散列而不是脚本本身执行LUA脚本 - * @example $script = 'return 1'; - * $sha = $redis->script('load', $script); - * $redis->evalSha($sha); // Returns 1 - * @param string $script_sha 脚本的散列值 - * @param array $args 脚本参数 - * @param int $num_keys 应该进入KEYS数组的参数个数 - * @return - */ - public function evalSha($script_sha, Array $args, $num_keys) - { - } - - /** - * - *在脚本子系统上执行redis命令 - * @example - *
-     * $redis->script('load', $script);
-     * $redis->script('flush');
-     * $redis->script('kill');
-     * $redis->script('exists', $script1, [$script2, $script3, ...]);
-     * 
- * SCRIPT LOAD will return the SHA1 hash of the passed script on success, and FALSE on failure. - * SCRIPT FLUSH should always return TRUE - * SCRIPT KILL will return true if a script was able to be killed and false if not - * SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script - * @param string $command redis命令 - * @param string|... $script 脚本 - * @return - */ - public function script($command, $script) - { - } - - /** - * - *序列化函数调用的魔术方法(在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化) - * @example - * @return - */ - public function __sleep() - { - } - - /** - * - *反序列化函数调用的魔术方法(unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务) - * @example - * @return - */ - public function __wakeup() - { - } - -} - diff --git a/src/Swoole/swoole_redis_server.php b/src/Swoole/swoole_redis_server.php index c3667dd..0d95111 100644 --- a/src/Swoole/swoole_redis_server.php +++ b/src/Swoole/swoole_redis_server.php @@ -1,8 +1,8 @@ Date: Wed, 28 Nov 2018 17:40:36 +0800 Subject: [PATCH 26/34] add composer support --- README.md | 19 +- tests/swoole-project/composer.json | 15 + tests/swoole-project/composer.lock | 65 +++ tests/swoole-project/test.php | 6 + tests/swoole-project/vendor/autoload.php | 7 + .../vendor/composer/ClassLoader.php | 445 ++++++++++++++++++ tests/swoole-project/vendor/composer/LICENSE | 21 + .../vendor/composer/autoload_classmap.php | 9 + .../vendor/composer/autoload_namespaces.php | 9 + .../vendor/composer/autoload_psr4.php | 9 + .../vendor/composer/autoload_real.php | 52 ++ .../vendor/composer/autoload_static.php | 15 + .../vendor/composer/installed.json | 47 ++ .../vendor/shixinke/php-ide-helper | 1 + 14 files changed, 719 insertions(+), 1 deletion(-) create mode 100644 tests/swoole-project/composer.json create mode 100644 tests/swoole-project/composer.lock create mode 100644 tests/swoole-project/test.php create mode 100644 tests/swoole-project/vendor/autoload.php create mode 100644 tests/swoole-project/vendor/composer/ClassLoader.php create mode 100644 tests/swoole-project/vendor/composer/LICENSE create mode 100644 tests/swoole-project/vendor/composer/autoload_classmap.php create mode 100644 tests/swoole-project/vendor/composer/autoload_namespaces.php create mode 100644 tests/swoole-project/vendor/composer/autoload_psr4.php create mode 100644 tests/swoole-project/vendor/composer/autoload_real.php create mode 100644 tests/swoole-project/vendor/composer/autoload_static.php create mode 100644 tests/swoole-project/vendor/composer/installed.json create mode 160000 tests/swoole-project/vendor/shixinke/php-ide-helper diff --git a/README.md b/README.md index 855fe82..0f5b8e1 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 5、phpRedis(包括RedisCluster,支持phpredis 4.1.0RC1) -6、swoole扩展(支持swoole 4.1.2) +6、swoole扩展(支持swoole 4.2.9) 7、SeasLog(1.8.5) @@ -33,6 +33,23 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 ## 使用说明 +#### 一.支持composer的项目通过composer安装 + +##### 1.在项目的composer配置文件composer.json中的require-dev段添加以下内容 +``` +"require-dev": { + "shixinke/php-ide-helper":"dev-master" +} +``` + +##### 2.通过composer install安装包 + +``` +composer install +``` + +#### 二.不支持composer的项目安装 + 1、下载源文件并解压,将src文件夹下面的内容放到任意一个位置(我习惯将它放到我的phpstorm安装路径下的plugins\php\lib下面,然后建立一个vendor文件夹,如C:\Program Files (x86)\JetBrains\PhpStorm 9.0.2\plugins\php\lib\vendor) 2、打开phpstorm,选择File->Settings,打开setting控制面板 diff --git a/tests/swoole-project/composer.json b/tests/swoole-project/composer.json new file mode 100644 index 0000000..d7ab719 --- /dev/null +++ b/tests/swoole-project/composer.json @@ -0,0 +1,15 @@ +{ + "name": "shixinke/swoole-demo", + "authors": [ + { + "name": "shixinke", + "email": "ishixinke@qq.com" + } + ], + "require": { + "php": ">=7.0" + }, + "require-dev":{ + "shixinke/php-ide-helper":"dev-master" + } +} diff --git a/tests/swoole-project/composer.lock b/tests/swoole-project/composer.lock new file mode 100644 index 0000000..ac95d43 --- /dev/null +++ b/tests/swoole-project/composer.lock @@ -0,0 +1,65 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "e09160c3e36c5aeadbdb2b360c5e267a", + "packages": [], + "packages-dev": [ + { + "name": "shixinke/php-ide-helper", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/shixinke/php-ide-helper.git", + "reference": "af28be0e71c1959beee311a40e2c9affeadbcc50" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/shixinke/php-ide-helper/zipball/af28be0e71c1959beee311a40e2c9affeadbcc50", + "reference": "af28be0e71c1959beee311a40e2c9affeadbcc50", + "shasum": "", + "mirrors": [ + { + "url": "https://dl.laravel-china.org/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.0" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "shixinke", + "email": "ishixinke@qq.com" + } + ], + "description": "a tool that provides auto-completion for php frameworks and extensions", + "keywords": [ + "ide-helper", + "php", + "phpstorm-helper", + "swoole-ide-helper" + ], + "time": "2018-11-28T09:25:59+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": { + "shixinke/php-ide-helper": 20 + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.0" + }, + "platform-dev": [] +} diff --git a/tests/swoole-project/test.php b/tests/swoole-project/test.php new file mode 100644 index 0000000..0b3c69e --- /dev/null +++ b/tests/swoole-project/test.php @@ -0,0 +1,6 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + private $classMapAuthoritative = false; + private $missingClasses = array(); + private $apcuPrefix; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/tests/swoole-project/vendor/composer/LICENSE b/tests/swoole-project/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/tests/swoole-project/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/tests/swoole-project/vendor/composer/autoload_classmap.php b/tests/swoole-project/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..7a91153 --- /dev/null +++ b/tests/swoole-project/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require_once __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInitd226cc2fc2afe2b502687a3a995126b1::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + return $loader; + } +} diff --git a/tests/swoole-project/vendor/composer/autoload_static.php b/tests/swoole-project/vendor/composer/autoload_static.php new file mode 100644 index 0000000..d6a65b8 --- /dev/null +++ b/tests/swoole-project/vendor/composer/autoload_static.php @@ -0,0 +1,15 @@ +=7.0" + }, + "time": "2018-11-28T09:25:59+00:00", + "type": "library", + "installation-source": "source", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "shixinke", + "email": "ishixinke@qq.com" + } + ], + "description": "a tool that provides auto-completion for php frameworks and extensions", + "keywords": [ + "ide-helper", + "php", + "phpstorm-helper", + "swoole-ide-helper" + ] + } +] diff --git a/tests/swoole-project/vendor/shixinke/php-ide-helper b/tests/swoole-project/vendor/shixinke/php-ide-helper new file mode 160000 index 0000000..af28be0 --- /dev/null +++ b/tests/swoole-project/vendor/shixinke/php-ide-helper @@ -0,0 +1 @@ +Subproject commit af28be0e71c1959beee311a40e2c9affeadbcc50 From 1d7f00f5a6ee0cb03d8fa550193081dc981df67a Mon Sep 17 00:00:00 2001 From: shixinke Date: Wed, 28 Nov 2018 17:41:30 +0800 Subject: [PATCH 27/34] add composer support --- tests/swoole-project/composer.lock | 65 --- tests/swoole-project/vendor/autoload.php | 7 - .../vendor/composer/ClassLoader.php | 445 ------------------ tests/swoole-project/vendor/composer/LICENSE | 21 - .../vendor/composer/autoload_classmap.php | 9 - .../vendor/composer/autoload_namespaces.php | 9 - .../vendor/composer/autoload_psr4.php | 9 - .../vendor/composer/autoload_real.php | 52 -- .../vendor/composer/autoload_static.php | 15 - .../vendor/composer/installed.json | 47 -- .../vendor/shixinke/php-ide-helper | 1 - 11 files changed, 680 deletions(-) delete mode 100644 tests/swoole-project/composer.lock delete mode 100644 tests/swoole-project/vendor/autoload.php delete mode 100644 tests/swoole-project/vendor/composer/ClassLoader.php delete mode 100644 tests/swoole-project/vendor/composer/LICENSE delete mode 100644 tests/swoole-project/vendor/composer/autoload_classmap.php delete mode 100644 tests/swoole-project/vendor/composer/autoload_namespaces.php delete mode 100644 tests/swoole-project/vendor/composer/autoload_psr4.php delete mode 100644 tests/swoole-project/vendor/composer/autoload_real.php delete mode 100644 tests/swoole-project/vendor/composer/autoload_static.php delete mode 100644 tests/swoole-project/vendor/composer/installed.json delete mode 160000 tests/swoole-project/vendor/shixinke/php-ide-helper diff --git a/tests/swoole-project/composer.lock b/tests/swoole-project/composer.lock deleted file mode 100644 index ac95d43..0000000 --- a/tests/swoole-project/composer.lock +++ /dev/null @@ -1,65 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "e09160c3e36c5aeadbdb2b360c5e267a", - "packages": [], - "packages-dev": [ - { - "name": "shixinke/php-ide-helper", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/shixinke/php-ide-helper.git", - "reference": "af28be0e71c1959beee311a40e2c9affeadbcc50" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/shixinke/php-ide-helper/zipball/af28be0e71c1959beee311a40e2c9affeadbcc50", - "reference": "af28be0e71c1959beee311a40e2c9affeadbcc50", - "shasum": "", - "mirrors": [ - { - "url": "https://dl.laravel-china.org/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.0" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "shixinke", - "email": "ishixinke@qq.com" - } - ], - "description": "a tool that provides auto-completion for php frameworks and extensions", - "keywords": [ - "ide-helper", - "php", - "phpstorm-helper", - "swoole-ide-helper" - ], - "time": "2018-11-28T09:25:59+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "shixinke/php-ide-helper": 20 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=7.0" - }, - "platform-dev": [] -} diff --git a/tests/swoole-project/vendor/autoload.php b/tests/swoole-project/vendor/autoload.php deleted file mode 100644 index f5c5a43..0000000 --- a/tests/swoole-project/vendor/autoload.php +++ /dev/null @@ -1,7 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - * @see http://www.php-fig.org/psr/psr-0/ - * @see http://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - // PSR-4 - private $prefixLengthsPsr4 = array(); - private $prefixDirsPsr4 = array(); - private $fallbackDirsPsr4 = array(); - - // PSR-0 - private $prefixesPsr0 = array(); - private $fallbackDirsPsr0 = array(); - - private $useIncludePath = false; - private $classMap = array(); - private $classMapAuthoritative = false; - private $missingClasses = array(); - private $apcuPrefix; - - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); - } - - return array(); - } - - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array $classMap Class to filename map - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. - * - * @param string|null $apcuPrefix - */ - public function setApcuPrefix($apcuPrefix) - { - $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; - } - - /** - * The APCu prefix in use, or null if APCu caching is not enabled. - * - * @return string|null - */ - public function getApcuPrefix() - { - return $this->apcuPrefix; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - includeFile($file); - - return true; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { - return false; - } - if (null !== $this->apcuPrefix) { - $file = apcu_fetch($this->apcuPrefix.$class, $hit); - if ($hit) { - return $file; - } - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if (false === $file && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if (null !== $this->apcuPrefix) { - apcu_add($this->apcuPrefix.$class, $file); - } - - if (false === $file) { - // Remember that this class does not exist. - $this->missingClasses[$class] = true; - } - - return $file; - } - - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - $subPath = $class; - while (false !== $lastPos = strrpos($subPath, '\\')) { - $subPath = substr($subPath, 0, $lastPos); - $search = $subPath . '\\'; - if (isset($this->prefixDirsPsr4[$search])) { - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); - foreach ($this->prefixDirsPsr4[$search] as $dir) { - if (file_exists($file = $dir . $pathEnd)) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - - return false; - } -} - -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - */ -function includeFile($file) -{ - include $file; -} diff --git a/tests/swoole-project/vendor/composer/LICENSE b/tests/swoole-project/vendor/composer/LICENSE deleted file mode 100644 index f27399a..0000000 --- a/tests/swoole-project/vendor/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/tests/swoole-project/vendor/composer/autoload_classmap.php b/tests/swoole-project/vendor/composer/autoload_classmap.php deleted file mode 100644 index 7a91153..0000000 --- a/tests/swoole-project/vendor/composer/autoload_classmap.php +++ /dev/null @@ -1,9 +0,0 @@ -= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require_once __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInitd226cc2fc2afe2b502687a3a995126b1::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } - - $loader->register(true); - - return $loader; - } -} diff --git a/tests/swoole-project/vendor/composer/autoload_static.php b/tests/swoole-project/vendor/composer/autoload_static.php deleted file mode 100644 index d6a65b8..0000000 --- a/tests/swoole-project/vendor/composer/autoload_static.php +++ /dev/null @@ -1,15 +0,0 @@ -=7.0" - }, - "time": "2018-11-28T09:25:59+00:00", - "type": "library", - "installation-source": "source", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "shixinke", - "email": "ishixinke@qq.com" - } - ], - "description": "a tool that provides auto-completion for php frameworks and extensions", - "keywords": [ - "ide-helper", - "php", - "phpstorm-helper", - "swoole-ide-helper" - ] - } -] diff --git a/tests/swoole-project/vendor/shixinke/php-ide-helper b/tests/swoole-project/vendor/shixinke/php-ide-helper deleted file mode 160000 index af28be0..0000000 --- a/tests/swoole-project/vendor/shixinke/php-ide-helper +++ /dev/null @@ -1 +0,0 @@ -Subproject commit af28be0e71c1959beee311a40e2c9affeadbcc50 From b5c1b8c33572ccb2490b3764c1f7c3dd6e5c92d5 Mon Sep 17 00:00:00 2001 From: wenjiangyi Date: Wed, 24 Apr 2019 15:22:16 +0800 Subject: [PATCH 28/34] =?UTF-8?q?Yar=5FClient=20=5F=5Fconstruct=20$options?= =?UTF-8?q?=20=E5=8F=82=E6=95=B0=E9=BB=98=E8=AE=A4=E7=A9=BA=E6=95=B0?= =?UTF-8?q?=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Yar/Yar_Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Yar/Yar_Client.php b/src/Yar/Yar_Client.php index 4ce7925..a49cf76 100644 --- a/src/Yar/Yar_Client.php +++ b/src/Yar/Yar_Client.php @@ -46,7 +46,7 @@ class Yar_Client * @param array $options 配置选项 * @return */ - public final function __construct(string $url, Array $options) + public final function __construct(string $url, Array $options = []) { } From ef85807fd54dfa62cff0997e3c156f5f04246bec Mon Sep 17 00:00:00 2001 From: York Xiang Date: Fri, 10 May 2019 09:26:56 +0800 Subject: [PATCH 29/34] =?UTF-8?q?Yaconf=E8=A1=A5=E5=85=85=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E8=BF=94=E5=9B=9E=E5=80=BC=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Yaconf/Yaconf.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Yaconf/Yaconf.php b/src/Yaconf/Yaconf.php index 90577dd..27c9405 100644 --- a/src/Yaconf/Yaconf.php +++ b/src/Yaconf/Yaconf.php @@ -34,7 +34,7 @@ class Yaconf * var_dump(Yaconf::get("foo")); * var_dump(Yaconf::get("foo.features.1")); * @param string $name 配置文件名称或配置项名称 - * @return + * @return string */ public static function get(string $name) { @@ -46,7 +46,7 @@ public static function get(string $name) *检查是否有某个配置项 * @example Yaconf::has('foo.name') * @param string $name 配置文件名称或配置项名称 - * @return + * @return bool */ public static function has(string $name) { From 133c25b7fccfa62a2646f63708fe8fa0006956af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=94=E7=8E=8B=E5=8D=B7=E5=AD=90?= Date: Tue, 5 Nov 2019 13:55:25 +0800 Subject: [PATCH 30/34] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bootstrap 参数的返回值并不是void --- src/Yaf/Yaf_Application.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Yaf/Yaf_Application.php b/src/Yaf/Yaf_Application.php index 1ff3793..71ad208 100644 --- a/src/Yaf/Yaf_Application.php +++ b/src/Yaf/Yaf_Application.php @@ -83,9 +83,9 @@ public static function app(): ?Yaf_Application *调用bootstrap * @example * @param Yaf_Bootstrap_Abstract $bootstrap 引导类 - * @return void + * @return Yaf_Application */ - public function bootstrap(Yaf_Bootstrap_Abstract $bootstrap) + public function bootstrap(Yaf_Bootstrap_Abstract $bootstrap):Yaf_Application { } From 0de81b3c278507f2f72bb094f1ee0d897d9328d1 Mon Sep 17 00:00:00 2001 From: shixinke Date: Sat, 14 Dec 2019 18:00:46 +0800 Subject: [PATCH 31/34] update redis to version 5.1.1 --- src/Redis/Redis.php | 89 +++++++++++++++++++++-------- src/Redis/RedisArray.php | 4 +- src/Redis/RedisCluster.php | 24 +++++++- src/Redis/RedisClusterException.php | 4 +- src/Redis/RedisException.php | 4 +- 5 files changed, 94 insertions(+), 31 deletions(-) diff --git a/src/Redis/Redis.php b/src/Redis/Redis.php index f090e30..59190ef 100644 --- a/src/Redis/Redis.php +++ b/src/Redis/Redis.php @@ -1,8 +1,8 @@ setex('key', 3600, 'value'); + * * @param string $key 设置的缓存键 - * @param string $value 设置的缓存值 * @param int $ttl 有效期 + * @param string $value 设置的缓存值 * @return bool */ - public function setex(string $key, string $value, int $ttl): bool + public function setex(string $key, int $ttl, string $value): bool { } @@ -336,13 +378,14 @@ public function setex(string $key, string $value, int $ttl): bool /** * *设置键值并设置有效期(毫秒为单位) - * @example + * @example $redis->pSetEx('key', 100, 'value') + * * @param string $key 设置的缓存键 - * @param string $value 设置的缓存值 * @param int $ttl 有效期(毫秒为单位) - * @return + * @param string $value 设置的缓存值 + * @return bool */ - public function psetex(string $key, string $value, int $ttl) + public function psetex(string $key, int $ttl, string $value): bool { } diff --git a/src/Redis/RedisArray.php b/src/Redis/RedisArray.php index 44b5a24..f5826e9 100644 --- a/src/Redis/RedisArray.php +++ b/src/Redis/RedisArray.php @@ -1,8 +1,8 @@ Date: Sat, 14 Dec 2019 18:02:00 +0800 Subject: [PATCH 32/34] update redis to version 5.1.1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f5b8e1..2353f5f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Yaf、Yar、Yac、Yaconf、Redis、Swoole等框架或C扩展之PhpStrom代码自 4、Yar(2.0.4) -5、phpRedis(包括RedisCluster,支持phpredis 4.1.0RC1) +5、phpRedis(包括RedisCluster,支持phpredis 5.1.1) 6、swoole扩展(支持swoole 4.2.9) From 06d593518cfe87929657627c7ddb31497701866c Mon Sep 17 00:00:00 2001 From: shixinke Date: Sat, 14 Dec 2019 18:09:26 +0800 Subject: [PATCH 33/34] delete yar.php --- src/Yar/yar.php | 110 ------------------------------------------------ 1 file changed, 110 deletions(-) delete mode 100644 src/Yar/yar.php diff --git a/src/Yar/yar.php b/src/Yar/yar.php deleted file mode 100644 index 74e61bb..0000000 --- a/src/Yar/yar.php +++ /dev/null @@ -1,110 +0,0 @@ - Date: Wed, 22 Apr 2020 19:50:13 +0800 Subject: [PATCH 34/34] Create LICENSE --- LICENSE | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License.