初始化代码

This commit is contained in:
2025-12-22 14:34:25 +08:00
parent c2c5ae2fdd
commit a77dbc743f
1510 changed files with 213008 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
<?php
class_alias(Swoole\Coroutine\Channel::class, Co\Channel::class);
class_alias(Swoole\Coroutine\Client::class, Co\Client::class);
class_alias(Swoole\Coroutine\Context::class, Co\Context::class);
class_alias(Swoole\Coroutine\Http2\Client::class, Co\Http2\Client::class);
class_alias(Swoole\Coroutine\Http2\Client\Exception::class, Co\Http2\Client\Exception::class);
class_alias(Swoole\Coroutine\Http\Client::class, Co\Http\Client::class);
class_alias(Swoole\Coroutine\Http\Client\Exception::class, Co\Http\Client\Exception::class);
class_alias(Swoole\Coroutine\Http\Server::class, Co\Http\Server::class);
class_alias(Swoole\Coroutine\Iterator::class, Co\Iterator::class);
class_alias(Swoole\Coroutine\MySQL::class, Co\MySQL::class);
class_alias(Swoole\Coroutine\MySQL\Exception::class, Co\MySQL\Exception::class);
class_alias(Swoole\Coroutine\MySQL\Statement::class, Co\MySQL\Statement::class);
class_alias(Swoole\Coroutine\Redis::class, Co\Redis::class);
class_alias(Swoole\Coroutine\Scheduler::class, Co\Scheduler::class);
class_alias(Swoole\Coroutine\Socket::class, Co\Socket::class);
class_alias(Swoole\Coroutine\Socket\Exception::class, Co\Socket\Exception::class);
class_alias(Swoole\Coroutine\System::class, Co\System::class);
class_alias(Swoole\Atomic::class, swoole_atomic::class);
class_alias(Swoole\Atomic\Long::class, swoole_atomic_long::class);
class_alias(Swoole\Buffer::class, swoole_buffer::class);
class_alias(Swoole\Client::class, swoole_client::class);
class_alias(Swoole\Connection\Iterator::class, swoole_connection_iterator::class);
class_alias(Swoole\Coroutine::class, co::class);
class_alias(Swoole\Coroutine\Channel::class, chan::class);
class_alias(Swoole\Error::class, swoole_error::class);
class_alias(Swoole\Event::class, swoole_event::class);
class_alias(Swoole\Exception::class, swoole_exception::class);
class_alias(Swoole\Http2\Request::class, swoole_http2_request::class);
class_alias(Swoole\Http2\Response::class, swoole_http2_response::class);
class_alias(Swoole\Http\Request::class, swoole_http_request::class);
class_alias(Swoole\Http\Response::class, swoole_http_response::class);
class_alias(Swoole\Http\Server::class, swoole_http_server::class);
class_alias(Swoole\Lock::class, swoole_lock::class);
class_alias(Swoole\Process::class, swoole_process::class);
class_alias(Swoole\Process\Pool::class, swoole_process_pool::class);
class_alias(Swoole\Redis\Server::class, swoole_redis_server::class);
class_alias(Swoole\Runtime::class, swoole_runtime::class);
class_alias(Swoole\Server::class, swoole_server::class);
class_alias(Swoole\Server\Port::class, swoole_server_port::class);
class_alias(Swoole\Server\Task::class, swoole_server_task::class);
class_alias(Swoole\Table::class, swoole_table::class);
class_alias(Swoole\Table\Row::class, swoole_table_row::class);
class_alias(Swoole\Timer::class, swoole_timer::class);
class_alias(Swoole\Timer\Iterator::class, swoole_timer_iterator::class);
class_alias(Swoole\Websocket\Closeframe::class, swoole_websocket_closeframe::class);
class_alias(Swoole\Websocket\Frame::class, swoole_websocket_frame::class);
class_alias(Swoole\Websocket\Server::class, swoole_websocket_server::class);

View File

@@ -0,0 +1,360 @@
<?php
define('SWOOLE_VERSION', '4.4.12');
define('SWOOLE_VERSION_ID', 40412);
define('SWOOLE_MAJOR_VERSION', 4);
define('SWOOLE_MINOR_VERSION', 4);
define('SWOOLE_RELEASE_VERSION', 12);
define('SWOOLE_EXTRA_VERSION', '');
define('SWOOLE_DEBUG', '1');
define('SWOOLE_HAVE_ZLIB', '1');
define('SWOOLE_USE_HTTP2', '1');
define('SWOOLE_BASE', 1);
define('SWOOLE_PROCESS', 2);
define('SWOOLE_IPC_UNSOCK', 1);
define('SWOOLE_IPC_MSGQUEUE', 2);
define('SWOOLE_IPC_PREEMPTIVE', 3);
define('SWOOLE_SOCK_TCP', 1);
define('SWOOLE_SOCK_TCP6', 3);
define('SWOOLE_SOCK_UDP', 2);
define('SWOOLE_SOCK_UDP6', 4);
define('SWOOLE_SOCK_UNIX_DGRAM', 6);
define('SWOOLE_SOCK_UNIX_STREAM', 5);
define('SWOOLE_TCP', 1);
define('SWOOLE_TCP6', 3);
define('SWOOLE_UDP', 2);
define('SWOOLE_UDP6', 4);
define('SWOOLE_UNIX_DGRAM', 6);
define('SWOOLE_UNIX_STREAM', 5);
define('SWOOLE_SOCK_SYNC', '');
define('SWOOLE_SOCK_ASYNC', '1');
define('SWOOLE_SYNC', 2048);
define('SWOOLE_ASYNC', 1024);
define('SWOOLE_KEEP', 4096);
define('SWOOLE_SSL', 512);
define('SWOOLE_SSLv3_METHOD', 1);
define('SWOOLE_SSLv3_SERVER_METHOD', 2);
define('SWOOLE_SSLv3_CLIENT_METHOD', 3);
define('SWOOLE_SSLv23_METHOD', 0);
define('SWOOLE_SSLv23_SERVER_METHOD', 4);
define('SWOOLE_SSLv23_CLIENT_METHOD', 5);
define('SWOOLE_TLSv1_METHOD', 6);
define('SWOOLE_TLSv1_SERVER_METHOD', 7);
define('SWOOLE_TLSv1_CLIENT_METHOD', 8);
define('SWOOLE_TLSv1_1_METHOD', 9);
define('SWOOLE_TLSv1_1_SERVER_METHOD', 10);
define('SWOOLE_TLSv1_1_CLIENT_METHOD', 11);
define('SWOOLE_TLSv1_2_METHOD', 12);
define('SWOOLE_TLSv1_2_SERVER_METHOD', 13);
define('SWOOLE_TLSv1_2_CLIENT_METHOD', 14);
define('SWOOLE_DTLSv1_METHOD', 15);
define('SWOOLE_DTLSv1_SERVER_METHOD', 16);
define('SWOOLE_DTLSv1_CLIENT_METHOD', 17);
define('SWOOLE_EVENT_READ', 512);
define('SWOOLE_EVENT_WRITE', 1024);
define('SWOOLE_STRERROR_SYSTEM', 0);
define('SWOOLE_STRERROR_GAI', 1);
define('SWOOLE_STRERROR_DNS', 2);
define('SWOOLE_STRERROR_SWOOLE', 9);
define('SWOOLE_ERROR_MALLOC_FAIL', 501);
define('SWOOLE_ERROR_SYSTEM_CALL_FAIL', 502);
define('SWOOLE_ERROR_PHP_FATAL_ERROR', 503);
define('SWOOLE_ERROR_NAME_TOO_LONG', 504);
define('SWOOLE_ERROR_INVALID_PARAMS', 505);
define('SWOOLE_ERROR_QUEUE_FULL', 506);
define('SWOOLE_ERROR_OPERATION_NOT_SUPPORT', 507);
define('SWOOLE_ERROR_PROTOCOL_ERROR', 508);
define('SWOOLE_ERROR_FILE_NOT_EXIST', 700);
define('SWOOLE_ERROR_FILE_TOO_LARGE', 701);
define('SWOOLE_ERROR_FILE_EMPTY', 702);
define('SWOOLE_ERROR_DNSLOOKUP_DUPLICATE_REQUEST', 703);
define('SWOOLE_ERROR_DNSLOOKUP_RESOLVE_FAILED', 704);
define('SWOOLE_ERROR_DNSLOOKUP_RESOLVE_TIMEOUT', 705);
define('SWOOLE_ERROR_BAD_IPV6_ADDRESS', 706);
define('SWOOLE_ERROR_UNREGISTERED_SIGNAL', 707);
define('SWOOLE_ERROR_SESSION_CLOSED_BY_SERVER', 1001);
define('SWOOLE_ERROR_SESSION_CLOSED_BY_CLIENT', 1002);
define('SWOOLE_ERROR_SESSION_CLOSING', 1003);
define('SWOOLE_ERROR_SESSION_CLOSED', 1004);
define('SWOOLE_ERROR_SESSION_NOT_EXIST', 1005);
define('SWOOLE_ERROR_SESSION_INVALID_ID', 1006);
define('SWOOLE_ERROR_SESSION_DISCARD_TIMEOUT_DATA', 1007);
define('SWOOLE_ERROR_OUTPUT_BUFFER_OVERFLOW', 1008);
define('SWOOLE_ERROR_OUTPUT_SEND_YIELD', 1009);
define('SWOOLE_ERROR_SSL_NOT_READY', 1010);
define('SWOOLE_ERROR_SSL_CANNOT_USE_SENFILE', 1011);
define('SWOOLE_ERROR_SSL_EMPTY_PEER_CERTIFICATE', 1012);
define('SWOOLE_ERROR_SSL_VEFIRY_FAILED', 1013);
define('SWOOLE_ERROR_SSL_BAD_CLIENT', 1014);
define('SWOOLE_ERROR_SSL_BAD_PROTOCOL', 1015);
define('SWOOLE_ERROR_SSL_RESET', 1016);
define('SWOOLE_ERROR_PACKAGE_LENGTH_TOO_LARGE', 1201);
define('SWOOLE_ERROR_PACKAGE_LENGTH_NOT_FOUND', 1202);
define('SWOOLE_ERROR_DATA_LENGTH_TOO_LARGE', 1203);
define('SWOOLE_ERROR_TASK_PACKAGE_TOO_BIG', 2001);
define('SWOOLE_ERROR_TASK_DISPATCH_FAIL', 2002);
define('SWOOLE_ERROR_TASK_TIMEOUT', 2003);
define('SWOOLE_ERROR_HTTP2_STREAM_ID_TOO_BIG', 3001);
define('SWOOLE_ERROR_HTTP2_STREAM_NO_HEADER', 3002);
define('SWOOLE_ERROR_HTTP2_STREAM_NOT_FOUND', 3003);
define('SWOOLE_ERROR_AIO_BAD_REQUEST', 4001);
define('SWOOLE_ERROR_AIO_CANCELED', 4002);
define('SWOOLE_ERROR_AIO_TIMEOUT', 4003);
define('SWOOLE_ERROR_CLIENT_NO_CONNECTION', 5001);
define('SWOOLE_ERROR_SOCKET_CLOSED', 5002);
define('SWOOLE_ERROR_SOCKS5_UNSUPPORT_VERSION', 7001);
define('SWOOLE_ERROR_SOCKS5_UNSUPPORT_METHOD', 7002);
define('SWOOLE_ERROR_SOCKS5_AUTH_FAILED', 7003);
define('SWOOLE_ERROR_SOCKS5_SERVER_ERROR', 7004);
define('SWOOLE_ERROR_HTTP_PROXY_HANDSHAKE_ERROR', 8001);
define('SWOOLE_ERROR_HTTP_INVALID_PROTOCOL', 8002);
define('SWOOLE_ERROR_WEBSOCKET_BAD_CLIENT', 8501);
define('SWOOLE_ERROR_WEBSOCKET_BAD_OPCODE', 8502);
define('SWOOLE_ERROR_WEBSOCKET_UNCONNECTED', 8503);
define('SWOOLE_ERROR_WEBSOCKET_HANDSHAKE_FAILED', 8504);
define('SWOOLE_ERROR_SERVER_MUST_CREATED_BEFORE_CLIENT', 9001);
define('SWOOLE_ERROR_SERVER_TOO_MANY_SOCKET', 9002);
define('SWOOLE_ERROR_SERVER_WORKER_TERMINATED', 9003);
define('SWOOLE_ERROR_SERVER_INVALID_LISTEN_PORT', 9004);
define('SWOOLE_ERROR_SERVER_TOO_MANY_LISTEN_PORT', 9005);
define('SWOOLE_ERROR_SERVER_PIPE_BUFFER_FULL', 9006);
define('SWOOLE_ERROR_SERVER_NO_IDLE_WORKER', 9007);
define('SWOOLE_ERROR_SERVER_ONLY_START_ONE', 9008);
define('SWOOLE_ERROR_SERVER_SEND_IN_MASTER', 9009);
define('SWOOLE_ERROR_SERVER_INVALID_REQUEST', 9010);
define('SWOOLE_ERROR_SERVER_CONNECT_FAIL', 9011);
define('SWOOLE_ERROR_SERVER_WORKER_EXIT_TIMEOUT', 9012);
define('SWOOLE_ERROR_CO_OUT_OF_COROUTINE', 10001);
define('SWOOLE_ERROR_CO_HAS_BEEN_BOUND', 10002);
define('SWOOLE_ERROR_CO_HAS_BEEN_DISCARDED', 10003);
define('SWOOLE_ERROR_CO_MUTEX_DOUBLE_UNLOCK', 10004);
define('SWOOLE_ERROR_CO_BLOCK_OBJECT_LOCKED', 10005);
define('SWOOLE_ERROR_CO_BLOCK_OBJECT_WAITING', 10006);
define('SWOOLE_ERROR_CO_YIELD_FAILED', 10007);
define('SWOOLE_ERROR_CO_GETCONTEXT_FAILED', 10008);
define('SWOOLE_ERROR_CO_SWAPCONTEXT_FAILED', 10009);
define('SWOOLE_ERROR_CO_MAKECONTEXT_FAILED', 10010);
define('SWOOLE_ERROR_CO_IOCPINIT_FAILED', 10011);
define('SWOOLE_ERROR_CO_PROTECT_STACK_FAILED', 10012);
define('SWOOLE_ERROR_CO_STD_THREAD_LINK_ERROR', 10013);
define('SWOOLE_ERROR_CO_DISABLED_MULTI_THREAD', 10014);
define('SWOOLE_TRACE_SERVER', 2);
define('SWOOLE_TRACE_CLIENT', 4);
define('SWOOLE_TRACE_BUFFER', 8);
define('SWOOLE_TRACE_CONN', 16);
define('SWOOLE_TRACE_EVENT', 32);
define('SWOOLE_TRACE_WORKER', 64);
define('SWOOLE_TRACE_REACTOR', 256);
define('SWOOLE_TRACE_PHP', 512);
define('SWOOLE_TRACE_HTTP', 1024);
define('SWOOLE_TRACE_HTTP2', 2048);
define('SWOOLE_TRACE_EOF_PROTOCOL', 4096);
define('SWOOLE_TRACE_LENGTH_PROTOCOL', 8192);
define('SWOOLE_TRACE_CLOSE', 16384);
define('SWOOLE_TRACE_REDIS_CLIENT', 65536);
define('SWOOLE_TRACE_MYSQL_CLIENT', 131072);
define('SWOOLE_TRACE_HTTP_CLIENT', 262144);
define('SWOOLE_TRACE_AIO', 524288);
define('SWOOLE_TRACE_SSL', 1048576);
define('SWOOLE_TRACE_NORMAL', 2097152);
define('SWOOLE_TRACE_CHANNEL', 4194304);
define('SWOOLE_TRACE_TIMER', 8388608);
define('SWOOLE_TRACE_SOCKET', 16777216);
define('SWOOLE_TRACE_COROUTINE', 33554432);
define('SWOOLE_TRACE_CONTEXT', 67108864);
define('SWOOLE_TRACE_CO_HTTP_SERVER', 134217728);
define('SWOOLE_TRACE_ALL', 4294967295);
define('SWOOLE_LOG_DEBUG', 0);
define('SWOOLE_LOG_TRACE', 1);
define('SWOOLE_LOG_INFO', 2);
define('SWOOLE_LOG_NOTICE', 3);
define('SWOOLE_LOG_WARNING', 4);
define('SWOOLE_LOG_ERROR', 5);
define('SWOOLE_LOG_NONE', 6);
define('SWOOLE_IPC_NONE', 0);
define('SWOOLE_IPC_UNIXSOCK', 1);
define('SWOOLE_IPC_SOCKET', 3);
define('SWOOLE_FILELOCK', 2);
define('SWOOLE_MUTEX', 3);
define('SWOOLE_SEM', 4);
define('SWOOLE_RWLOCK', 1);
define('SWOOLE_SPINLOCK', 5);
define('SIGHUP', 1);
define('SIGINT', 2);
define('SIGQUIT', 3);
define('SIGILL', 4);
define('SIGTRAP', 5);
define('SIGABRT', 6);
define('SIGBUS', 7);
define('SIGFPE', 8);
define('SIGKILL', 9);
define('SIGUSR1', 10);
define('SIGSEGV', 11);
define('SIGUSR2', 12);
define('SIGPIPE', 13);
define('SIGALRM', 14);
define('SIGTERM', 15);
define('SIGSTKFLT', 16);
define('SIGCHLD', 17);
define('SIGCONT', 18);
define('SIGSTOP', 19);
define('SIGTSTP', 20);
define('SIGTTIN', 21);
define('SIGTTOU', 22);
define('SIGURG', 23);
define('SIGXCPU', 24);
define('SIGXFSZ', 25);
define('SIGVTALRM', 26);
define('SIGPROF', 27);
define('SIGWINCH', 28);
define('SIGIO', 29);
define('SIGPWR', 30);
define('SIGSYS', 31);
define('SIG_IGN', 1);
define('SWOOLE_TIMER_MIN_MS', 1);
define('SWOOLE_TIMER_MIN_SEC', 0.001);
define('SWOOLE_TIMER_MAX_MS', 9223372036854775807);
define('SWOOLE_TIMER_MAX_SEC', 9.2233720368548E+15);
define('SWOOLE_DEFAULT_MAX_CORO_NUM', 100000);
define('SWOOLE_CORO_MAX_NUM_LIMIT', 9223372036854775807);
define('SWOOLE_CORO_INIT', 0);
define('SWOOLE_CORO_WAITING', 1);
define('SWOOLE_CORO_RUNNING', 2);
define('SWOOLE_CORO_END', 3);
define('SWOOLE_EXIT_IN_COROUTINE', 2);
define('SWOOLE_EXIT_IN_SERVER', 4);
define('SWOOLE_CHANNEL_OK', 0);
define('SWOOLE_CHANNEL_TIMEOUT', -1);
define('SWOOLE_CHANNEL_CLOSED', -2);
define('SWOOLE_HOOK_TCP', 2);
define('SWOOLE_HOOK_UDP', 4);
define('SWOOLE_HOOK_UNIX', 8);
define('SWOOLE_HOOK_UDG', 16);
define('SWOOLE_HOOK_SSL', 32);
define('SWOOLE_HOOK_TLS', 64);
define('SWOOLE_HOOK_STREAM_FUNCTION', 128);
define('SWOOLE_HOOK_STREAM_SELECT', 128);
define('SWOOLE_HOOK_FILE', 256);
define('SWOOLE_HOOK_SLEEP', 512);
define('SWOOLE_HOOK_PROC', 1024);
define('SWOOLE_HOOK_CURL', 268435456);
define('SWOOLE_HOOK_BLOCKING_FUNCTION', 1073741824);
define('SWOOLE_HOOK_ALL', 1879048191);
define('SOCKET_ECANCELED', 125);
define('SWOOLE_HTTP_CLIENT_ESTATUS_CONNECT_FAILED', -1);
define('SWOOLE_HTTP_CLIENT_ESTATUS_REQUEST_TIMEOUT', -2);
define('SWOOLE_HTTP_CLIENT_ESTATUS_SERVER_RESET', -3);
define('SWOOLE_MYSQLND_CR_UNKNOWN_ERROR', 2000);
define('SWOOLE_MYSQLND_CR_CONNECTION_ERROR', 2002);
define('SWOOLE_MYSQLND_CR_SERVER_GONE_ERROR', 2006);
define('SWOOLE_MYSQLND_CR_OUT_OF_MEMORY', 2008);
define('SWOOLE_MYSQLND_CR_SERVER_LOST', 2013);
define('SWOOLE_MYSQLND_CR_COMMANDS_OUT_OF_SYNC', 2014);
define('SWOOLE_MYSQLND_CR_CANT_FIND_CHARSET', 2019);
define('SWOOLE_MYSQLND_CR_MALFORMED_PACKET', 2027);
define('SWOOLE_MYSQLND_CR_NOT_IMPLEMENTED', 2054);
define('SWOOLE_MYSQLND_CR_NO_PREPARE_STMT', 2030);
define('SWOOLE_MYSQLND_CR_PARAMS_NOT_BOUND', 2031);
define('SWOOLE_MYSQLND_CR_INVALID_PARAMETER_NO', 2034);
define('SWOOLE_MYSQLND_CR_INVALID_BUFFER_USE', 2035);
define('SWOOLE_REDIS_MODE_MULTI', 0);
define('SWOOLE_REDIS_MODE_PIPELINE', 1);
define('SWOOLE_REDIS_TYPE_NOT_FOUND', 0);
define('SWOOLE_REDIS_TYPE_STRING', 1);
define('SWOOLE_REDIS_TYPE_SET', 2);
define('SWOOLE_REDIS_TYPE_LIST', 3);
define('SWOOLE_REDIS_TYPE_ZSET', 4);
define('SWOOLE_REDIS_TYPE_HASH', 5);
define('SWOOLE_REDIS_ERR_IO', 1);
define('SWOOLE_REDIS_ERR_OTHER', 2);
define('SWOOLE_REDIS_ERR_EOF', 3);
define('SWOOLE_REDIS_ERR_PROTOCOL', 4);
define('SWOOLE_REDIS_ERR_OOM', 5);
define('SWOOLE_REDIS_ERR_CLOSED', 6);
define('SWOOLE_REDIS_ERR_NOAUTH', 7);
define('SWOOLE_REDIS_ERR_ALLOC', 8);
define('SWOOLE_HTTP2_TYPE_DATA', 0);
define('SWOOLE_HTTP2_TYPE_HEADERS', 1);
define('SWOOLE_HTTP2_TYPE_PRIORITY', 2);
define('SWOOLE_HTTP2_TYPE_RST_STREAM', 3);
define('SWOOLE_HTTP2_TYPE_SETTINGS', 4);
define('SWOOLE_HTTP2_TYPE_PUSH_PROMISE', 5);
define('SWOOLE_HTTP2_TYPE_PING', 6);
define('SWOOLE_HTTP2_TYPE_GOAWAY', 7);
define('SWOOLE_HTTP2_TYPE_WINDOW_UPDATE', 8);
define('SWOOLE_HTTP2_TYPE_CONTINUATION', 9);
define('SWOOLE_HTTP2_ERROR_NO_ERROR', 0);
define('SWOOLE_HTTP2_ERROR_PROTOCOL_ERROR', 1);
define('SWOOLE_HTTP2_ERROR_INTERNAL_ERROR', 2);
define('SWOOLE_HTTP2_ERROR_FLOW_CONTROL_ERROR', 3);
define('SWOOLE_HTTP2_ERROR_SETTINGS_TIMEOUT', 4);
define('SWOOLE_HTTP2_ERROR_STREAM_CLOSED', 5);
define('SWOOLE_HTTP2_ERROR_FRAME_SIZE_ERROR', 6);
define('SWOOLE_HTTP2_ERROR_REFUSED_STREAM', 7);
define('SWOOLE_HTTP2_ERROR_CANCEL', 8);
define('SWOOLE_HTTP2_ERROR_COMPRESSION_ERROR', 9);
define('SWOOLE_HTTP2_ERROR_CONNECT_ERROR', 10);
define('SWOOLE_HTTP2_ERROR_ENHANCE_YOUR_CALM', 11);
define('SWOOLE_HTTP2_ERROR_INADEQUATE_SECURITY', 12);
define('SWOOLE_DISPATCH_RESULT_DISCARD_PACKET', -1);
define('SWOOLE_DISPATCH_RESULT_CLOSE_CONNECTION', -2);
define('SWOOLE_DISPATCH_RESULT_USERFUNC_FALLBACK', -3);
define('SWOOLE_TASK_TMPFILE', 1);
define('SWOOLE_TASK_SERIALIZE', 2);
define('SWOOLE_TASK_NONBLOCK', 4);
define('SWOOLE_TASK_CALLBACK', 8);
define('SWOOLE_TASK_WAITALL', 16);
define('SWOOLE_TASK_COROUTINE', 32);
define('SWOOLE_TASK_PEEK', 64);
define('SWOOLE_TASK_NOREPLY', 128);
define('SWOOLE_WEBSOCKET_STATUS_CONNECTION', 1);
define('SWOOLE_WEBSOCKET_STATUS_HANDSHAKE', 2);
define('SWOOLE_WEBSOCKET_STATUS_ACTIVE', 3);
define('SWOOLE_WEBSOCKET_STATUS_CLOSING', 4);
define('SWOOLE_WEBSOCKET_OPCODE_CONTINUATION', 0);
define('SWOOLE_WEBSOCKET_OPCODE_TEXT', 1);
define('SWOOLE_WEBSOCKET_OPCODE_BINARY', 2);
define('SWOOLE_WEBSOCKET_OPCODE_CLOSE', 8);
define('SWOOLE_WEBSOCKET_OPCODE_PING', 9);
define('SWOOLE_WEBSOCKET_OPCODE_PONG', 10);
define('SWOOLE_WEBSOCKET_FLAG_FIN', 1);
define('SWOOLE_WEBSOCKET_FLAG_RSV1', 4);
define('SWOOLE_WEBSOCKET_FLAG_RSV2', 8);
define('SWOOLE_WEBSOCKET_FLAG_RSV3', 16);
define('SWOOLE_WEBSOCKET_FLAG_MASK', 32);
define('SWOOLE_WEBSOCKET_FLAG_COMPRESS', 2);
define('SWOOLE_WEBSOCKET_CLOSE_NORMAL', 1000);
define('SWOOLE_WEBSOCKET_CLOSE_GOING_AWAY', 1001);
define('SWOOLE_WEBSOCKET_CLOSE_PROTOCOL_ERROR', 1002);
define('SWOOLE_WEBSOCKET_CLOSE_DATA_ERROR', 1003);
define('SWOOLE_WEBSOCKET_CLOSE_STATUS_ERROR', 1005);
define('SWOOLE_WEBSOCKET_CLOSE_ABNORMAL', 1006);
define('SWOOLE_WEBSOCKET_CLOSE_MESSAGE_ERROR', 1007);
define('SWOOLE_WEBSOCKET_CLOSE_POLICY_ERROR', 1008);
define('SWOOLE_WEBSOCKET_CLOSE_MESSAGE_TOO_BIG', 1009);
define('SWOOLE_WEBSOCKET_CLOSE_EXTENSION_MISSING', 1010);
define('SWOOLE_WEBSOCKET_CLOSE_SERVER_ERROR', 1011);
define('SWOOLE_WEBSOCKET_CLOSE_TLS', 1015);
define('WEBSOCKET_STATUS_CONNECTION', 1);
define('WEBSOCKET_STATUS_HANDSHAKE', 2);
define('WEBSOCKET_STATUS_FRAME', 3);
define('WEBSOCKET_STATUS_ACTIVE', 3);
define('WEBSOCKET_STATUS_CLOSING', 4);
define('WEBSOCKET_OPCODE_CONTINUATION', 0);
define('WEBSOCKET_OPCODE_TEXT', 1);
define('WEBSOCKET_OPCODE_BINARY', 2);
define('WEBSOCKET_OPCODE_CLOSE', 8);
define('WEBSOCKET_OPCODE_PING', 9);
define('WEBSOCKET_OPCODE_PONG', 10);
define('WEBSOCKET_CLOSE_NORMAL', 1000);
define('WEBSOCKET_CLOSE_GOING_AWAY', 1001);
define('WEBSOCKET_CLOSE_PROTOCOL_ERROR', 1002);
define('WEBSOCKET_CLOSE_DATA_ERROR', 1003);
define('WEBSOCKET_CLOSE_STATUS_ERROR', 1005);
define('WEBSOCKET_CLOSE_ABNORMAL', 1006);
define('WEBSOCKET_CLOSE_MESSAGE_ERROR', 1007);
define('WEBSOCKET_CLOSE_POLICY_ERROR', 1008);
define('WEBSOCKET_CLOSE_MESSAGE_TOO_BIG', 1009);
define('WEBSOCKET_CLOSE_EXTENSION_MISSING', 1010);
define('WEBSOCKET_CLOSE_SERVER_ERROR', 1011);
define('WEBSOCKET_CLOSE_TLS', 1015);

View File

@@ -0,0 +1,244 @@
<?php
/**
* @return mixed
*/
function swoole_version(){}
/**
* @return mixed
*/
function swoole_cpu_num(){}
/**
* @return mixed
*/
function swoole_last_error(){}
/**
* @param $domain_name[required]
* @param $timeout[optional]
* @return mixed
*/
function swoole_async_dns_lookup_coro($domain_name, $timeout = null){}
/**
* @param $settings[required]
* @return mixed
*/
function swoole_async_set($settings){}
/**
* @param $func[required]
* @param $params[optional]
* @return mixed
*/
function swoole_coroutine_create($func, $params = null){}
/**
* @param $callback[required]
* @return mixed
*/
function swoole_coroutine_defer($callback){}
/**
* @param $func[required]
* @param $params[optional]
* @return mixed
*/
function go($func, $params = null){}
/**
* @param $callback[required]
* @return mixed
*/
function defer($callback){}
/**
* @param $read_array[required]
* @param $write_array[required]
* @param $error_array[required]
* @param $timeout[optional]
* @return mixed
*/
function swoole_client_select(&$read_array, &$write_array, &$error_array, $timeout = null){}
/**
* @param $read_array[required]
* @param $write_array[required]
* @param $error_array[required]
* @param $timeout[optional]
* @return mixed
*/
function swoole_select(&$read_array, &$write_array, &$error_array, $timeout = null){}
/**
* @param $process_name[required]
* @return mixed
*/
function swoole_set_process_name($process_name){}
/**
* @return mixed
*/
function swoole_get_local_ip(){}
/**
* @return mixed
*/
function swoole_get_local_mac(){}
/**
* @param $errno[required]
* @param $error_type[optional]
* @return mixed
*/
function swoole_strerror($errno, $error_type = null){}
/**
* @return mixed
*/
function swoole_errno(){}
/**
* @param $data[required]
* @param $type[optional]
* @return mixed
*/
function swoole_hashcode($data, $type = null){}
/**
* @param $filename[required]
* @return mixed
*/
function swoole_get_mime_type($filename){}
/**
* @return mixed
*/
function swoole_clear_dns_cache(){}
/**
* @return mixed
*/
function swoole_internal_call_user_shutdown_begin(){}
/**
* @param $fd[required]
* @param $read_callback[required]
* @param $write_callback[optional]
* @param $events[optional]
* @return mixed
*/
function swoole_event_add($fd, $read_callback, $write_callback = null, $events = null){}
/**
* @param $fd[required]
* @return mixed
*/
function swoole_event_del($fd){}
/**
* @param $fd[required]
* @param $read_callback[optional]
* @param $write_callback[optional]
* @param $events[optional]
* @return mixed
*/
function swoole_event_set($fd, $read_callback = null, $write_callback = null, $events = null){}
/**
* @param $fd[required]
* @param $events[optional]
* @return mixed
*/
function swoole_event_isset($fd, $events = null){}
/**
* @return mixed
*/
function swoole_event_dispatch(){}
/**
* @param $callback[required]
* @return mixed
*/
function swoole_event_defer($callback){}
/**
* @param $callback[required]
* @param $before[optional]
* @return mixed
*/
function swoole_event_cycle($callback, $before = null){}
/**
* @param $fd[required]
* @param $data[required]
* @return mixed
*/
function swoole_event_write($fd, $data){}
/**
* @return mixed
*/
function swoole_event_wait(){}
/**
* @return mixed
*/
function swoole_event_exit(){}
/**
* @param $settings[required]
* @return mixed
*/
function swoole_timer_set($settings){}
/**
* @param $ms[required]
* @param $callback[required]
* @return mixed
*/
function swoole_timer_after($ms, $callback){}
/**
* @param $ms[required]
* @param $callback[required]
* @return mixed
*/
function swoole_timer_tick($ms, $callback){}
/**
* @param $timer_id[required]
* @return mixed
*/
function swoole_timer_exists($timer_id){}
/**
* @param $timer_id[required]
* @return mixed
*/
function swoole_timer_info($timer_id){}
/**
* @return mixed
*/
function swoole_timer_stats(){}
/**
* @return mixed
*/
function swoole_timer_list(){}
/**
* @param $timer_id[required]
* @return mixed
*/
function swoole_timer_clear($timer_id){}
/**
* @return mixed
*/
function swoole_timer_clear_all(){}

View File

@@ -0,0 +1,62 @@
<?php
namespace Swoole;
class Atomic
{
public function __construct($value = null)
{
}
/**
* @return mixed
*/
public function add($add_value = null)
{
}
/**
* @return mixed
*/
public function sub($sub_value = null)
{
}
/**
* @return mixed
*/
public function get()
{
}
/**
* @return mixed
*/
public function set($value)
{
}
/**
* @return mixed
*/
public function wait($timeout = null)
{
}
/**
* @return mixed
*/
public function wakeup($count = null)
{
}
/**
* @return mixed
*/
public function cmpset($cmp_value, $new_value)
{
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Swoole\Atomic;
class Long
{
public function __construct($value = null)
{
}
/**
* @return mixed
*/
public function add($add_value = null)
{
}
/**
* @return mixed
*/
public function sub($sub_value = null)
{
}
/**
* @return mixed
*/
public function get()
{
}
/**
* @return mixed
*/
public function set($value)
{
}
/**
* @return mixed
*/
public function cmpset($cmp_value, $new_value)
{
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace Swoole;
class Buffer
{
public $capacity = 128;
public $length = 0;
public function __construct($size = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function __toString()
{
}
/**
* @return mixed
*/
public function substr($offset, $length = null, $remove = null)
{
}
/**
* @return mixed
*/
public function write($offset, $data)
{
}
/**
* @return mixed
*/
public function read($offset, $length)
{
}
/**
* @return mixed
*/
public function append($data)
{
}
/**
* @return mixed
*/
public function expand($size)
{
}
/**
* @return mixed
*/
public function recycle()
{
}
/**
* @return mixed
*/
public function clear()
{
}
}

View File

@@ -0,0 +1,150 @@
<?php
namespace Swoole;
class Client
{
const MSG_OOB = 1;
const MSG_PEEK = 2;
const MSG_DONTWAIT = 64;
const MSG_WAITALL = 256;
const SHUT_RDWR = 2;
const SHUT_RD = 0;
const SHUT_WR = 1;
public $errCode = 0;
public $sock = -1;
public $reuse = false;
public $reuseCount = 0;
public $type = 0;
public $id = null;
public $setting = null;
public function __construct($type, $async = null, $id = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function connect($host, $port = null, $timeout = null, $sock_flag = null)
{
}
/**
* @return mixed
*/
public function recv($size = null, $flag = null)
{
}
/**
* @return mixed
*/
public function send($data, $flag = null)
{
}
/**
* @return mixed
*/
public function sendfile($filename, $offset = null, $length = null)
{
}
/**
* @return mixed
*/
public function sendto($ip, $port, $data)
{
}
/**
* @return mixed
*/
public function shutdown($how)
{
}
/**
* @return mixed
*/
public function enableSSL()
{
}
/**
* @return mixed
*/
public function getPeerCert()
{
}
/**
* @return mixed
*/
public function verifyPeerCert()
{
}
/**
* @return mixed
*/
public function isConnected()
{
}
/**
* @return mixed
*/
public function getsockname()
{
}
/**
* @return mixed
*/
public function getpeername()
{
}
/**
* @return mixed
*/
public function close($force = null)
{
}
/**
* @return mixed
*/
public function getSocket()
{
}
}

View File

@@ -0,0 +1,87 @@
<?php
namespace Swoole\Connection;
class Iterator implements \Iterator, \Traversable, \ArrayAccess, \Countable
{
public function __construct()
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function rewind()
{
}
/**
* @return mixed
*/
public function next()
{
}
/**
* @return mixed
*/
public function current()
{
}
/**
* @return mixed
*/
public function key()
{
}
/**
* @return mixed
*/
public function valid()
{
}
/**
* @return mixed
*/
public function count()
{
}
/**
* @return mixed
*/
public function offsetExists($fd)
{
}
/**
* @return mixed
*/
public function offsetGet($fd)
{
}
/**
* @return mixed
*/
public function offsetSet($fd, $value)
{
}
/**
* @return mixed
*/
public function offsetUnset($fd)
{
}
}

View File

@@ -0,0 +1,205 @@
<?php
namespace Swoole;
class Coroutine
{
/**
* @return mixed
*/
public static function create(callable $func, ... $params)
{
}
/**
* @return mixed
*/
public static function defer($callback)
{
}
/**
* @return mixed
*/
public static function set($options)
{
}
/**
* @return mixed
*/
public static function exists($cid)
{
}
/**
* @return mixed
*/
public static function yield()
{
}
/**
* @return mixed
*/
public static function suspend()
{
}
/**
* @return mixed
*/
public static function resume($cid)
{
}
/**
* @return mixed
*/
public static function stats()
{
}
/**
* @return mixed
*/
public static function getCid()
{
}
/**
* @return mixed
*/
public static function getuid()
{
}
/**
* @return mixed
*/
public static function getPcid($cid = null)
{
}
/**
* @return mixed
*/
public static function getContext($cid = null)
{
}
/**
* @return mixed
*/
public static function getBackTrace($cid = null, $options = null, $limit = null)
{
}
/**
* @return mixed
*/
public static function list()
{
}
/**
* @return mixed
*/
public static function listCoroutines()
{
}
/**
* @return mixed
*/
public static function enableScheduler()
{
}
/**
* @return mixed
*/
public static function disableScheduler()
{
}
/**
* @return mixed
*/
public static function gethostbyname($domain_name, $family = null, $timeout = null)
{
}
/**
* @return mixed
*/
public static function dnsLookup($domain_name, $timeout = null)
{
}
/**
* @return mixed
*/
public static function exec($command, $get_error_stream = null)
{
}
/**
* @return mixed
*/
public static function sleep($seconds)
{
}
/**
* @return mixed
*/
public static function fread($handle, $length = null)
{
}
/**
* @return mixed
*/
public static function fgets($handle)
{
}
/**
* @return mixed
*/
public static function fwrite($handle, $string, $length = null)
{
}
/**
* @return mixed
*/
public static function readFile($filename)
{
}
/**
* @return mixed
*/
public static function writeFile($filename, $data, $flags = null)
{
}
/**
* @return mixed
*/
public static function getaddrinfo($hostname, $family = null, $socktype = null, $protocol = null, $service = null, $timeout = null)
{
}
/**
* @return mixed
*/
public static function statvfs($path)
{
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Swoole\Coroutine;
class Channel
{
public $capacity = 0;
public $errCode = 0;
public function __construct($size = null)
{
}
/**
* @return mixed
*/
public function push($data, $timeout = null)
{
}
/**
* @return mixed
*/
public function pop($timeout = null)
{
}
/**
* @return mixed
*/
public function isEmpty()
{
}
/**
* @return mixed
*/
public function isFull()
{
}
/**
* @return mixed
*/
public function close()
{
}
/**
* @return mixed
*/
public function stats()
{
}
/**
* @return mixed
*/
public function length()
{
}
}

View File

@@ -0,0 +1,151 @@
<?php
namespace Swoole\Coroutine;
class Client
{
const MSG_OOB = 1;
const MSG_PEEK = 2;
const MSG_DONTWAIT = 64;
const MSG_WAITALL = 256;
public $errCode = 0;
public $errMsg = '';
public $fd = -1;
private $socket = null;
public $type = 0;
public $setting = null;
public $connected = false;
public function __construct($type)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function connect($host, $port = null, $timeout = null, $sock_flag = null)
{
}
/**
* @return mixed
*/
public function recv($timeout = null)
{
}
/**
* @return mixed
*/
public function peek($length = null)
{
}
/**
* @return mixed
*/
public function send($data)
{
}
/**
* @return mixed
*/
public function sendfile($filename, $offset = null, $length = null)
{
}
/**
* @return mixed
*/
public function sendto($address, $port, $data)
{
}
/**
* @return mixed
*/
public function recvfrom($length, &$address, &$port = null)
{
}
/**
* @return mixed
*/
public function enableSSL()
{
}
/**
* @return mixed
*/
public function getPeerCert()
{
}
/**
* @return mixed
*/
public function verifyPeerCert()
{
}
/**
* @return mixed
*/
public function isConnected()
{
}
/**
* @return mixed
*/
public function getsockname()
{
}
/**
* @return mixed
*/
public function getpeername()
{
}
/**
* @return mixed
*/
public function close()
{
}
/**
* @return mixed
*/
public function exportSocket()
{
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Swoole\Coroutine;
class Context extends \ArrayObject
{
const STD_PROP_LIST = 1;
const ARRAY_AS_PROPS = 2;
}

View File

@@ -0,0 +1,214 @@
<?php
namespace Swoole\Coroutine\Http;
class Client
{
public $errCode = 0;
public $errMsg = '';
public $connected = false;
public $host = '';
public $port = 0;
public $ssl = false;
public $setting = null;
public $requestMethod = null;
public $requestHeaders = null;
public $requestBody = null;
public $uploadFiles = null;
public $downloadFile = null;
public $downloadOffset = 0;
public $statusCode = 0;
public $headers = null;
public $set_cookie_headers = null;
public $cookies = null;
public $body = '';
public function __construct($host, $port = null, $ssl = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function getDefer()
{
}
/**
* @return mixed
*/
public function setDefer($defer = null)
{
}
/**
* @return mixed
*/
public function setMethod($method)
{
}
/**
* @return mixed
*/
public function setHeaders(array $headers)
{
}
/**
* @return mixed
*/
public function setBasicAuth($username, $password)
{
}
/**
* @return mixed
*/
public function setCookies(array $cookies)
{
}
/**
* @return mixed
*/
public function setData($data)
{
}
/**
* @return mixed
*/
public function addFile($path, $name, $type = null, $filename = null, $offset = null, $length = null)
{
}
/**
* @return mixed
*/
public function addData($path, $name, $type = null, $filename = null)
{
}
/**
* @return mixed
*/
public function execute($path)
{
}
/**
* @return mixed
*/
public function get($path)
{
}
/**
* @return mixed
*/
public function post($path, $data)
{
}
/**
* @return mixed
*/
public function download($path, $file, $offset = null)
{
}
/**
* @return mixed
*/
public function getBody()
{
}
/**
* @return mixed
*/
public function getHeaders()
{
}
/**
* @return mixed
*/
public function getCookies()
{
}
/**
* @return mixed
*/
public function getStatusCode()
{
}
/**
* @return mixed
*/
public function getHeaderOut()
{
}
/**
* @return mixed
*/
public function upgrade($path)
{
}
/**
* @return mixed
*/
public function push($data, $opcode = null, $finish = null)
{
}
/**
* @return mixed
*/
public function recv($timeout = null)
{
}
/**
* @return mixed
*/
public function close()
{
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Swoole\Coroutine\Http\Client;
class Exception extends \Swoole\Exception
{
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Swoole\Coroutine\Http;
class Server
{
public $fd = -1;
public $host = null;
public $port = -1;
public $ssl = false;
public $settings = null;
public $errCode = 0;
public $errMsg = '';
public function __construct($host, $port = null, $ssl = null, $reuse_port = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function handle($pattern, callable $callback)
{
}
/**
* @return mixed
*/
public function onAccept()
{
}
/**
* @return mixed
*/
public function start()
{
}
/**
* @return mixed
*/
public function shutdown()
{
}
}

View File

@@ -0,0 +1,105 @@
<?php
namespace Swoole\Coroutine\Http2;
class Client
{
public $errCode = 0;
public $errMsg = 0;
public $sock = -1;
public $type = 0;
public $setting = null;
public $connected = false;
public $host = null;
public $port = 0;
public $ssl = false;
public function __construct($host, $port = null, $ssl = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function connect()
{
}
/**
* @return mixed
*/
public function stats($key = null)
{
}
/**
* @return mixed
*/
public function isStreamExist($stream_id)
{
}
/**
* @return mixed
*/
public function send($request)
{
}
/**
* @return mixed
*/
public function write($stream_id, $data, $end_stream = null)
{
}
/**
* @return mixed
*/
public function recv($timeout = null)
{
}
/**
* @return mixed
*/
public function goaway($error_code = null, $debug_data = null)
{
}
/**
* @return mixed
*/
public function ping()
{
}
/**
* @return mixed
*/
public function close()
{
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Swoole\Coroutine\Http2\Client;
class Exception extends \Swoole\Exception
{
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Swoole\Coroutine;
class Iterator extends \ArrayIterator
{
const STD_PROP_LIST = 1;
const ARRAY_AS_PROPS = 2;
}

View File

@@ -0,0 +1,133 @@
<?php
namespace Swoole\Coroutine;
class MySQL
{
public $serverInfo = null;
public $sock = -1;
public $connected = false;
public $connect_errno = 0;
public $connect_error = '';
public $affected_rows = 0;
public $insert_id = 0;
public $error = '';
public $errno = 0;
public function __construct()
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function getDefer()
{
}
/**
* @return mixed
*/
public function setDefer($defer = null)
{
}
/**
* @return mixed
*/
public function connect(array $server_config = null)
{
}
/**
* @return mixed
*/
public function query($sql, $timeout = null)
{
}
/**
* @return mixed
*/
public function fetch()
{
}
/**
* @return mixed
*/
public function fetchAll()
{
}
/**
* @return mixed
*/
public function nextResult()
{
}
/**
* @return mixed
*/
public function prepare($query, $timeout = null)
{
}
/**
* @return mixed
*/
public function recv()
{
}
/**
* @return mixed
*/
public function begin($timeout = null)
{
}
/**
* @return mixed
*/
public function commit($timeout = null)
{
}
/**
* @return mixed
*/
public function rollback($timeout = null)
{
}
/**
* @return mixed
*/
public function escape($string, $flags = null)
{
}
/**
* @return mixed
*/
public function close()
{
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Swoole\Coroutine\MySQL;
class Exception extends \Swoole\Exception
{
}

View File

@@ -0,0 +1,61 @@
<?php
namespace Swoole\Coroutine\MySQL;
class Statement
{
public $id = 0;
public $affected_rows = 0;
public $insert_id = 0;
public $error = '';
public $errno = 0;
/**
* @return mixed
*/
public function execute($params = null, $timeout = null)
{
}
/**
* @return mixed
*/
public function fetch($timeout = null)
{
}
/**
* @return mixed
*/
public function fetchAll($timeout = null)
{
}
/**
* @return mixed
*/
public function nextResult($timeout = null)
{
}
/**
* @return mixed
*/
public function recv($timeout = null)
{
}
/**
* @return mixed
*/
public function close()
{
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,39 @@
<?php
namespace Swoole\Coroutine;
class Scheduler
{
private $_list = null;
/**
* @return mixed
*/
public function add(callable $func, ... $params)
{
}
/**
* @return mixed
*/
public function parallel($n, callable $func = null, ... $params)
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function start()
{
}
}

View File

@@ -0,0 +1,159 @@
<?php
namespace Swoole\Coroutine;
class Socket
{
public $fd = -1;
public $errCode = 0;
public $errMsg = '';
public function __construct($domain, $type, $protocol = null)
{
}
/**
* @return mixed
*/
public function bind($address, $port = null)
{
}
/**
* @return mixed
*/
public function listen($backlog = null)
{
}
/**
* @return mixed
*/
public function accept($timeout = null)
{
}
/**
* @return mixed
*/
public function connect($host, $port = null, $timeout = null)
{
}
/**
* @return mixed
*/
public function recv($length = null, $timeout = null)
{
}
/**
* @return mixed
*/
public function recvPacket($timeout = null)
{
}
/**
* @return mixed
*/
public function send($data, $timeout = null)
{
}
/**
* @return mixed
*/
public function sendFile($filename, $offset = null, $length = null)
{
}
/**
* @return mixed
*/
public function recvAll($length = null, $timeout = null)
{
}
/**
* @return mixed
*/
public function sendAll($data, $timeout = null)
{
}
/**
* @return mixed
*/
public function recvfrom(&$peername, $timeout = null)
{
}
/**
* @return mixed
*/
public function sendto($addr, $port, $data)
{
}
/**
* @return mixed
*/
public function getOption($level, $opt_name)
{
}
/**
* @return mixed
*/
public function setProtocol(array $settings)
{
}
/**
* @return mixed
*/
public function setOption($level, $opt_name, $opt_value)
{
}
/**
* @return mixed
*/
public function shutdown($how = null)
{
}
/**
* @return mixed
*/
public function cancel($event = null)
{
}
/**
* @return mixed
*/
public function close()
{
}
/**
* @return mixed
*/
public function getpeername()
{
}
/**
* @return mixed
*/
public function getsockname()
{
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Swoole\Coroutine\Socket;
class Exception extends \Swoole\Exception
{
}

View File

@@ -0,0 +1,86 @@
<?php
namespace Swoole\Coroutine;
class System
{
/**
* @return mixed
*/
public static function gethostbyname($domain_name, $family = null, $timeout = null)
{
}
/**
* @return mixed
*/
public static function dnsLookup($domain_name, $timeout = null)
{
}
/**
* @return mixed
*/
public static function exec($command, $get_error_stream = null)
{
}
/**
* @return mixed
*/
public static function sleep($seconds)
{
}
/**
* @return mixed
*/
public static function fread($handle, $length = null)
{
}
/**
* @return mixed
*/
public static function fwrite($handle, $string, $length = null)
{
}
/**
* @return mixed
*/
public static function fgets($handle)
{
}
/**
* @return mixed
*/
public static function getaddrinfo($hostname, $family = null, $socktype = null, $protocol = null, $service = null, $timeout = null)
{
}
/**
* @return mixed
*/
public static function readFile($filename)
{
}
/**
* @return mixed
*/
public static function writeFile($filename, $data, $flags = null)
{
}
/**
* @return mixed
*/
public static function statvfs($path)
{
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Swoole;
class Error extends \Error
{
}

View File

@@ -0,0 +1,86 @@
<?php
namespace Swoole;
class Event
{
/**
* @return mixed
*/
public static function add($fd, ?callable $read_callback, ?callable $write_callback = null, $events = null)
{
}
/**
* @return mixed
*/
public static function del($fd)
{
}
/**
* @return mixed
*/
public static function set($fd, ?callable $read_callback = null, ?callable $write_callback = null, $events = null)
{
}
/**
* @return mixed
*/
public static function isset($fd, $events = null)
{
}
/**
* @return mixed
*/
public static function dispatch()
{
}
/**
* @return mixed
*/
public static function defer(callable $callback)
{
}
/**
* @return mixed
*/
public static function cycle(?callable $callback, $before = null)
{
}
/**
* @return mixed
*/
public static function write($fd, $data)
{
}
/**
* @return mixed
*/
public static function wait()
{
}
/**
* @return mixed
*/
public static function rshutdown()
{
}
/**
* @return mixed
*/
public static function exit()
{
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Swoole;
class Exception extends \Exception
{
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Swoole;
class ExitException extends Exception
{
private $flags = 0;
private $status = 0;
/**
* @return mixed
*/
public function getFlags()
{
}
/**
* @return mixed
*/
public function getStatus()
{
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace Swoole\Http;
class Request
{
public $fd = 0;
public $streamId = 0;
public $header = null;
public $server = null;
public $cookie = null;
public $get = null;
public $files = null;
public $post = null;
public $tmpfiles = null;
/**
* @return mixed
*/
public function rawContent()
{
}
/**
* @return mixed
*/
public function getData()
{
}
public function __destruct()
{
}
}

View File

@@ -0,0 +1,163 @@
<?php
namespace Swoole\Http;
class Response
{
public $fd = 0;
public $socket = null;
public $header = null;
public $cookie = null;
public $trailer = null;
/**
* @return mixed
*/
public function initHeader()
{
}
/**
* @return mixed
*/
public function cookie($name, $value = null, $expires = null, $path = null, $domain = null, $secure = null, $httponly = null, $samesite = null)
{
}
/**
* @return mixed
*/
public function setCookie($name, $value = null, $expires = null, $path = null, $domain = null, $secure = null, $httponly = null, $samesite = null)
{
}
/**
* @return mixed
*/
public function rawcookie($name, $value = null, $expires = null, $path = null, $domain = null, $secure = null, $httponly = null, $samesite = null)
{
}
/**
* @return mixed
*/
public function status($http_code, $reason = null)
{
}
/**
* @return mixed
*/
public function setStatusCode($http_code, $reason = null)
{
}
/**
* @return mixed
*/
public function header($key, $value, $ucwords = null)
{
}
/**
* @return mixed
*/
public function setHeader($key, $value, $ucwords = null)
{
}
/**
* @return mixed
*/
public function trailer($key, $value)
{
}
/**
* @return mixed
*/
public function ping()
{
}
/**
* @return mixed
*/
public function write($content)
{
}
/**
* @return mixed
*/
public function end($content = null)
{
}
/**
* @return mixed
*/
public function sendfile($filename, $offset = null, $length = null)
{
}
/**
* @return mixed
*/
public function redirect($location, $http_code = null)
{
}
/**
* @return mixed
*/
public function detach()
{
}
/**
* @return mixed
*/
public static function create($fd)
{
}
/**
* @return mixed
*/
public function upgrade()
{
}
/**
* @return mixed
*/
public function push()
{
}
/**
* @return mixed
*/
public function recv()
{
}
/**
* @return mixed
*/
public function close()
{
}
public function __destruct()
{
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Swoole\Http;
class Server extends \Swoole\Server
{
private $onRequest = null;
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Swoole\Http2;
class Request
{
public $path = '/';
public $method = 'GET';
public $headers = null;
public $cookies = null;
public $data = '';
public $pipeline = false;
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Swoole\Http2;
class Response
{
public $streamId = 0;
public $errCode = 0;
public $statusCode = 0;
public $pipeline = false;
public $headers = null;
public $set_cookie_headers = null;
public $cookies = null;
public $data = null;
}

View File

@@ -0,0 +1,78 @@
<?php
namespace Swoole;
class Lock
{
const FILELOCK = 2;
const MUTEX = 3;
const SEM = 4;
const RWLOCK = 1;
const SPINLOCK = 5;
public $errCode = 0;
public function __construct($type = null, $filename = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function lock()
{
}
/**
* @return mixed
*/
public function lockwait($timeout = null)
{
}
/**
* @return mixed
*/
public function trylock()
{
}
/**
* @return mixed
*/
public function lock_read()
{
}
/**
* @return mixed
*/
public function trylock_read()
{
}
/**
* @return mixed
*/
public function unlock()
{
}
/**
* @return mixed
*/
public function destroy()
{
}
}

View File

@@ -0,0 +1,193 @@
<?php
namespace Swoole;
class Process
{
const IPC_NOWAIT = 256;
const PIPE_MASTER = 1;
const PIPE_WORKER = 2;
const PIPE_READ = 3;
const PIPE_WRITE = 4;
public $pipe = null;
public $callback = null;
public $msgQueueId = null;
public $msgQueueKey = null;
public $pid = null;
public $id = null;
public function __construct(callable $callback, $redirect_stdin_and_stdout = null, $pipe_type = null, $enable_coroutine = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public static function wait($blocking = null)
{
}
/**
* @return mixed
*/
public static function signal($signal_no, $callback)
{
}
/**
* @return mixed
*/
public static function alarm($usec, $type = null)
{
}
/**
* @return mixed
*/
public static function kill($pid, $signal_no = null)
{
}
/**
* @return mixed
*/
public static function daemon($nochdir = null, $noclose = null, $pipes = null)
{
}
/**
* @return mixed
*/
public static function setaffinity(array $cpu_settings)
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function setTimeout($seconds)
{
}
/**
* @return mixed
*/
public function setBlocking($blocking)
{
}
/**
* @return mixed
*/
public function useQueue($key = null, $mode = null, $capacity = null)
{
}
/**
* @return mixed
*/
public function statQueue()
{
}
/**
* @return mixed
*/
public function freeQueue()
{
}
/**
* @return mixed
*/
public function start()
{
}
/**
* @return mixed
*/
public function write($data)
{
}
/**
* @return mixed
*/
public function close()
{
}
/**
* @return mixed
*/
public function read($size = null)
{
}
/**
* @return mixed
*/
public function push($data)
{
}
/**
* @return mixed
*/
public function pop($size = null)
{
}
/**
* @return mixed
*/
public function exit($exit_code = null)
{
}
/**
* @return mixed
*/
public function exec($exec_file, $args)
{
}
/**
* @return mixed
*/
public function exportSocket()
{
}
/**
* @return mixed
*/
public function name($process_name)
{
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace Swoole\Process;
class Pool
{
public $master_pid = -1;
public $workers = null;
public function __construct($worker_num, $ipc_type = null, $msgqueue_key = null, $enable_coroutine = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function on($event_name, callable $callback)
{
}
/**
* @return mixed
*/
public function getProcess($worker_id = null)
{
}
/**
* @return mixed
*/
public function listen($host, $port = null, $backlog = null)
{
}
/**
* @return mixed
*/
public function write($data)
{
}
/**
* @return mixed
*/
public function start()
{
}
/**
* @return mixed
*/
public function shutdown()
{
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace Swoole\Redis;
class Server extends \Swoole\Server
{
const NIL = 1;
const ERROR = 0;
const STATUS = 2;
const INT = 3;
const STRING = 4;
const SET = 5;
const MAP = 6;
/**
* @return mixed
*/
public function start()
{
}
/**
* @return mixed
*/
public function setHandler($command, callable $callback)
{
}
/**
* @return mixed
*/
public function getHandler($command)
{
}
/**
* @return mixed
*/
public static function format($type, $value = null)
{
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Swoole;
class Runtime
{
/**
* @return mixed
*/
public static function enableStrictMode()
{
}
/**
* @return mixed
*/
public static function enableCoroutine($enable = null, $flags = null)
{
}
/**
* @return mixed
*/
public static function getHookFlags()
{
}
}

View File

@@ -0,0 +1,315 @@
<?php
namespace Swoole;
class Server
{
private $onStart = null;
private $onShutdown = null;
private $onWorkerStart = null;
private $onWorkerStop = null;
private $onWorkerExit = null;
private $onWorkerError = null;
private $onTask = null;
private $onFinish = null;
private $onManagerStart = null;
private $onManagerStop = null;
private $onPipeMessage = null;
public $setting = null;
public $connections = null;
public $host = '';
public $port = 0;
public $type = 0;
public $mode = 0;
public $ports = null;
public $master_pid = 0;
public $manager_pid = 0;
public $worker_id = -1;
public $taskworker = false;
public $worker_pid = 0;
public function __construct($host, $port = null, $mode = null, $sock_type = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function listen($host, $port, $sock_type)
{
}
/**
* @return mixed
*/
public function addlistener($host, $port, $sock_type)
{
}
/**
* @return mixed
*/
public function on($event_name, callable $callback)
{
}
/**
* @return mixed
*/
public function getCallback($event_name)
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function start()
{
}
/**
* @return mixed
*/
public function send($fd, $send_data, $server_socket = null)
{
}
/**
* @return mixed
*/
public function sendto($ip, $port, $send_data, $server_socket = null)
{
}
/**
* @return mixed
*/
public function sendwait($conn_fd, $send_data)
{
}
/**
* @return mixed
*/
public function exists($fd)
{
}
/**
* @return mixed
*/
public function exist($fd)
{
}
/**
* @return mixed
*/
public function protect($fd, $is_protected = null)
{
}
/**
* @return mixed
*/
public function sendfile($conn_fd, $filename, $offset = null, $length = null)
{
}
/**
* @return mixed
*/
public function close($fd, $reset = null)
{
}
/**
* @return mixed
*/
public function confirm($fd)
{
}
/**
* @return mixed
*/
public function pause($fd)
{
}
/**
* @return mixed
*/
public function resume($fd)
{
}
/**
* @return mixed
*/
public function task($data, $worker_id = null, ?callable $finish_callback = null)
{
}
/**
* @return mixed
*/
public function taskwait($data, $timeout = null, $worker_id = null)
{
}
/**
* @return mixed
*/
public function taskWaitMulti(array $tasks, $timeout = null)
{
}
/**
* @return mixed
*/
public function taskCo(array $tasks, $timeout = null)
{
}
/**
* @return mixed
*/
public function finish($data)
{
}
/**
* @return mixed
*/
public function reload()
{
}
/**
* @return mixed
*/
public function shutdown()
{
}
/**
* @return mixed
*/
public function stop($worker_id = null)
{
}
/**
* @return mixed
*/
public function getLastError()
{
}
/**
* @return mixed
*/
public function heartbeat($reactor_id)
{
}
/**
* @return mixed
*/
public function getClientInfo($fd, $reactor_id = null)
{
}
/**
* @return mixed
*/
public function getClientList($start_fd, $find_count = null)
{
}
/**
* @return mixed
*/
public function connection_info($fd, $reactor_id = null)
{
}
/**
* @return mixed
*/
public function connection_list($start_fd, $find_count = null)
{
}
/**
* @return mixed
*/
public function sendMessage($message, $dst_worker_id)
{
}
/**
* @return mixed
*/
public function addProcess(\swoole_process $process)
{
}
/**
* @return mixed
*/
public function stats()
{
}
/**
* @return mixed
*/
public function getSocket($port = null)
{
}
/**
* @return mixed
*/
public function bind($fd, $uid)
{
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace Swoole\Server;
class Port
{
private $onConnect = null;
private $onReceive = null;
private $onClose = null;
private $onPacket = null;
private $onBufferFull = null;
private $onBufferEmpty = null;
private $onRequest = null;
private $onHandShake = null;
private $onOpen = null;
private $onMessage = null;
public $host = null;
public $port = 0;
public $type = 0;
public $sock = -1;
public $setting = null;
public $connections = null;
private function __construct()
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function on($event_name, callable $callback)
{
}
/**
* @return mixed
*/
public function getCallback($event_name)
{
}
/**
* @return mixed
*/
public function getSocket()
{
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Swoole\Server;
class Task
{
public $data = null;
public $id = -1;
public $worker_id = -1;
public $flags = 0;
/**
* @return mixed
*/
public function finish($data)
{
}
/**
* @return mixed
*/
public static function pack($data)
{
}
}

View File

@@ -0,0 +1,166 @@
<?php
namespace Swoole;
class Table implements \Iterator, \Traversable, \ArrayAccess, \Countable
{
const TYPE_INT = 1;
const TYPE_STRING = 7;
const TYPE_FLOAT = 6;
public function __construct($table_size, $conflict_proportion = null)
{
}
/**
* @return mixed
*/
public function column($name, $type, $size = null)
{
}
/**
* @return mixed
*/
public function create()
{
}
/**
* @return mixed
*/
public function destroy()
{
}
/**
* @return mixed
*/
public function set($key, array $value)
{
}
/**
* @return mixed
*/
public function get($key, $field = null)
{
}
/**
* @return mixed
*/
public function count()
{
}
/**
* @return mixed
*/
public function del($key)
{
}
/**
* @return mixed
*/
public function exists($key)
{
}
/**
* @return mixed
*/
public function exist($key)
{
}
/**
* @return mixed
*/
public function incr($key, $column, $incrby = null)
{
}
/**
* @return mixed
*/
public function decr($key, $column, $decrby = null)
{
}
/**
* @return mixed
*/
public function getMemorySize()
{
}
/**
* @return mixed
*/
public function offsetExists($offset)
{
}
/**
* @return mixed
*/
public function offsetGet($offset)
{
}
/**
* @return mixed
*/
public function offsetSet($offset, $value)
{
}
/**
* @return mixed
*/
public function offsetUnset($offset)
{
}
/**
* @return mixed
*/
public function rewind()
{
}
/**
* @return mixed
*/
public function next()
{
}
/**
* @return mixed
*/
public function current()
{
}
/**
* @return mixed
*/
public function key()
{
}
/**
* @return mixed
*/
public function valid()
{
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace Swoole\Table;
class Row implements \ArrayAccess
{
public $key = null;
public $value = null;
/**
* @return mixed
*/
public function offsetExists($offset)
{
}
/**
* @return mixed
*/
public function offsetGet($offset)
{
}
/**
* @return mixed
*/
public function offsetSet($offset, $value)
{
}
/**
* @return mixed
*/
public function offsetUnset($offset)
{
}
public function __destruct()
{
}
}

View File

@@ -0,0 +1,72 @@
<?php
namespace Swoole;
class Timer
{
/**
* @return mixed
*/
public static function set(array $settings)
{
}
/**
* @return mixed
*/
public static function tick($ms, callable $callback, ... $params)
{
}
/**
* @return mixed
*/
public static function after($ms, callable $callback, ... $params)
{
}
/**
* @return mixed
*/
public static function exists($timer_id)
{
}
/**
* @return mixed
*/
public static function info($timer_id)
{
}
/**
* @return mixed
*/
public static function stats()
{
}
/**
* @return mixed
*/
public static function list()
{
}
/**
* @return mixed
*/
public static function clear($timer_id)
{
}
/**
* @return mixed
*/
public static function clearAll()
{
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Swoole\Timer;
class Iterator extends \ArrayIterator
{
const STD_PROP_LIST = 1;
const ARRAY_AS_PROPS = 2;
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Swoole\WebSocket;
class CloseFrame extends Frame
{
public $opcode = 8;
public $code = 1000;
public $reason = '';
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Swoole\WebSocket;
class Frame
{
public $fd = 0;
public $data = '';
public $opcode = 1;
public $flags = 1;
public $finish = null;
/**
* @return mixed
*/
public function __toString()
{
}
/**
* @return mixed
*/
public static function pack($data, $opcode = null, $finish = null, $mask = null)
{
}
/**
* @return mixed
*/
public static function unpack($data)
{
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace Swoole\WebSocket;
class Server extends \Swoole\Http\Server
{
private $onHandshake = null;
/**
* @return mixed
*/
public function push($fd, $data, $opcode = null, $finish = null)
{
}
/**
* @return mixed
*/
public function disconnect($fd, $code = null, $reason = null)
{
}
/**
* @return mixed
*/
public function isEstablished($fd)
{
}
/**
* @return mixed
*/
public static function pack($data, $opcode = null, $finish = null, $mask = null)
{
}
/**
* @return mixed
*/
public static function unpack($data)
{
}
}

View File

@@ -0,0 +1,14 @@
<?php
class_alias(Swoole\Async::class, swoole_async::class);
class_alias(Swoole\Async\Client::class, swoole_async_client::class);
class_alias(Swoole\Channel::class, swoole_channel::class);
class_alias(Swoole\Http\Client::class, swoole_http_client::class);
class_alias(Swoole\Memory\Pool::class, swoole_memory_pool::class);
class_alias(Swoole\Memory\Pool\Slice::class, swoole_memory_pool_slice::class);
class_alias(Swoole\Mmap::class, swoole_mmap::class);
class_alias(Swoole\Msgqueue::class, swoole_msgqueue::class);
class_alias(Swoole\Mysql::class, swoole_mysql::class);
class_alias(Swoole\Mysql\Exception::class, swoole_mysql_exception::class);
class_alias(Swoole\Redis::class, swoole_redis::class);
class_alias(Swoole\Ringqueue::class, swoole_ringqueue::class);

View File

@@ -0,0 +1,43 @@
<?php
/**
* @param $filename[required]
* @param $callback[required]
* @param $chunk_size[optional]
* @param $offset[optional]
* @return mixed
*/
function swoole_async_read($filename, $callback, $chunk_size = null, $offset = null){}
/**
* @param $filename[required]
* @param $content[required]
* @param $offset[optional]
* @param $callback[optional]
* @return mixed
*/
function swoole_async_write($filename, $content, $offset = null, $callback = null){}
/**
* @param $filename[required]
* @param $callback[required]
* @return mixed
*/
function swoole_async_readfile($filename, $callback){}
/**
* @param $filename[required]
* @param $content[required]
* @param $callback[optional]
* @param $flags[optional]
* @return mixed
*/
function swoole_async_writefile($filename, $content, $callback = null, $flags = null){}
/**
* @param $hostname[required]
* @param $callback[required]
* @return mixed
*/
function swoole_async_dns_lookup($hostname, $callback){}

View File

@@ -0,0 +1,58 @@
<?php
namespace Swoole;
class Async
{
/**
* @return mixed
*/
public static function read($filename, $callback, $chunk_size = null, $offset = null)
{
}
/**
* @return mixed
*/
public static function write($filename, $content, $offset = null, $callback = null)
{
}
/**
* @return mixed
*/
public static function readFile($filename, $callback)
{
}
/**
* @return mixed
*/
public static function writeFile($filename, $content, $callback = null, $flags = null)
{
}
/**
* @return mixed
*/
public static function dnsLookup($hostname, $callback)
{
}
/**
* @return mixed
*/
public static function set(array $settings)
{
}
/**
* @return mixed
*/
public static function exec($command, $callback)
{
}
}

View File

@@ -0,0 +1,186 @@
<?php
namespace Swoole\Async;
class Client
{
const MSG_OOB = 1;
const MSG_PEEK = 2;
const MSG_DONTWAIT = 64;
const MSG_WAITALL = 256;
const SHUT_RDWR = 2;
const SHUT_RD = 0;
const SHUT_WR = 1;
public $errCode = 0;
public $sock = -1;
public $type = 0;
public $setting = null;
private $onConnect = null;
private $onError = null;
private $onReceive = null;
private $onClose = null;
private $onBufferFull = null;
private $onBufferEmpty = null;
private $onSSLReady = null;
public function __construct($type)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function connect($host, $port = null, $timeout = null, $sock_flag = null)
{
}
/**
* @return mixed
*/
public function send($data, $flag = null)
{
}
/**
* @return mixed
*/
public function sendfile($filename, $offset = null, $length = null)
{
}
/**
* @return mixed
*/
public function sendto($ip, $port, $data)
{
}
/**
* @return mixed
*/
public function sleep()
{
}
/**
* @return mixed
*/
public function wakeup()
{
}
/**
* @return mixed
*/
public function pause()
{
}
/**
* @return mixed
*/
public function resume()
{
}
/**
* @return mixed
*/
public function shutdown($how)
{
}
/**
* @return mixed
*/
public function enableSSL(callable $callback)
{
}
/**
* @return mixed
*/
public function getPeerCert()
{
}
/**
* @return mixed
*/
public function verifyPeerCert()
{
}
/**
* @return mixed
*/
public function isConnected()
{
}
/**
* @return mixed
*/
public function getsockname()
{
}
/**
* @return mixed
*/
public function getpeername()
{
}
/**
* @return mixed
*/
public function close($force = null)
{
}
/**
* @return mixed
*/
public function on($event_name, callable $callback)
{
}
/**
* @return mixed
*/
public function getSocket()
{
}
}

View File

@@ -0,0 +1,162 @@
<?php
namespace Swoole\Http;
class Client
{
public $type = 0;
public $errCode = 0;
public $errMsg = '';
public $statusCode = 0;
public $host = null;
public $port = 0;
public $ssl = false;
public $requestMethod = null;
public $requestHeaders = null;
public $requestBody = null;
public $uploadFiles = null;
public $set_cookie_headers = null;
public $downloadFile = null;
public $headers = null;
public $cookies = null;
public $body = null;
public $onConnect = null;
public $onError = null;
public $onMessage = null;
public $onClose = null;
public function __construct($host, $port = null, $ssl = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function setMethod($method)
{
}
/**
* @return mixed
*/
public function setHeaders(array $headers)
{
}
/**
* @return mixed
*/
public function setCookies(array $cookies)
{
}
/**
* @return mixed
*/
public function setData($data)
{
}
/**
* @return mixed
*/
public function addFile($path, $name, $type = null, $filename = null, $offset = null, $length = null)
{
}
/**
* @return mixed
*/
public function execute($path, $callback)
{
}
/**
* @return mixed
*/
public function push($data, $opcode = null, $finish = null)
{
}
/**
* @return mixed
*/
public function get($path, $callback)
{
}
/**
* @return mixed
*/
public function post($path, $data, $callback)
{
}
/**
* @return mixed
*/
public function upgrade($path, $callback)
{
}
/**
* @return mixed
*/
public function download($path, $file, $callback, $offset = null)
{
}
/**
* @return mixed
*/
public function isConnected()
{
}
/**
* @return mixed
*/
public function close()
{
}
/**
* @return mixed
*/
public function on($event_name, $callback)
{
}
}

View File

@@ -0,0 +1,114 @@
<?php
namespace Swoole;
class MySQL
{
const STATE_QUERY = 0;
const STATE_READ_START = 1;
const STATE_READ_FIELD = 2;
const STATE_READ_ROW = 3;
const STATE_READ_END = 5;
const STATE_CLOSED = 6;
public $serverInfo = null;
public $sock = -1;
public $connected = false;
public $errno = 0;
public $connect_errno = 0;
public $error = null;
public $connect_error = null;
public $insert_id = null;
public $affected_rows = null;
public $onConnect = null;
public $onClose = null;
public function __construct()
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function connect(array $server_config, $callback)
{
}
/**
* @return mixed
*/
public function begin($callback)
{
}
/**
* @return mixed
*/
public function commit($callback)
{
}
/**
* @return mixed
*/
public function rollback($callback)
{
}
/**
* @return mixed
*/
public function escape($string, $flags = null)
{
}
/**
* @return mixed
*/
public function query($sql, $callback)
{
}
/**
* @return mixed
*/
public function close()
{
}
/**
* @return mixed
*/
public function getState()
{
}
/**
* @return mixed
*/
public function on($event_name, $callback)
{
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace Swoole;
class Redis
{
const STATE_CONNECT = 0;
const STATE_READY = 1;
const STATE_WAIT_RESULT = 2;
const STATE_SUBSCRIBE = 3;
const STATE_CLOSED = 4;
public $onConnect = null;
public $onClose = null;
public $onMessage = null;
public $setting = null;
public $host = null;
public $port = null;
public $sock = null;
public $errCode = null;
public $errMsg = null;
public function __construct(?array $setting = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function on($event_name, $callback)
{
}
/**
* @return mixed
*/
public function connect($host, $port, $callback)
{
}
/**
* @return mixed
*/
public function close()
{
}
/**
* @return mixed
*/
public function getState()
{
}
/**
* @return mixed
*/
public function __call($command, $params)
{
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace Swoole;
class Channel
{
public function __construct($size)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function push($data)
{
}
/**
* @return mixed
*/
public function pop()
{
}
/**
* @return mixed
*/
public function peek()
{
}
/**
* @return mixed
*/
public function stats()
{
}
}

View File

@@ -0,0 +1,162 @@
<?php
namespace Swoole\Http;
class Client
{
public $type = 0;
public $errCode = 0;
public $errMsg = '';
public $statusCode = 0;
public $host = null;
public $port = 0;
public $ssl = false;
public $requestMethod = null;
public $requestHeaders = null;
public $requestBody = null;
public $uploadFiles = null;
public $set_cookie_headers = null;
public $downloadFile = null;
public $headers = null;
public $cookies = null;
public $body = null;
public $onConnect = null;
public $onError = null;
public $onMessage = null;
public $onClose = null;
public function __construct($host, $port = null, $ssl = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function set(array $settings)
{
}
/**
* @return mixed
*/
public function setMethod($method)
{
}
/**
* @return mixed
*/
public function setHeaders(array $headers)
{
}
/**
* @return mixed
*/
public function setCookies(array $cookies)
{
}
/**
* @return mixed
*/
public function setData($data)
{
}
/**
* @return mixed
*/
public function addFile($path, $name, $type = null, $filename = null, $offset = null, $length = null)
{
}
/**
* @return mixed
*/
public function execute($path, $callback)
{
}
/**
* @return mixed
*/
public function push($data, $opcode = null, $finish = null)
{
}
/**
* @return mixed
*/
public function get($path, $callback)
{
}
/**
* @return mixed
*/
public function post($path, $data, $callback)
{
}
/**
* @return mixed
*/
public function upgrade($path, $callback)
{
}
/**
* @return mixed
*/
public function download($path, $file, $callback, $offset = null)
{
}
/**
* @return mixed
*/
public function isConnected()
{
}
/**
* @return mixed
*/
public function close()
{
}
/**
* @return mixed
*/
public function on($event_name, $callback)
{
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Swoole\Memory;
class Pool
{
const TYPE_RING = 1;
const TYPE_GLOBAL = 2;
const TYPE_FIXED = 0;
const TYPE_MALLOC = 3;
const TYPE_EMALLOC = 4;
public function __construct($size, $type, $slice_size = null, $shared = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function alloc($size = null)
{
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Swoole\Memory\Pool;
class Slice
{
/**
* @return mixed
*/
public function read($size = null, $offset = null)
{
}
/**
* @return mixed
*/
public function write($data, $offset = null)
{
}
public function __destruct()
{
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace Swoole;
class Mmap
{
/**
* @return mixed
*/
public static function open($filename, $size = null, $offset = null)
{
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Swoole;
class MsgQueue
{
public function __construct($len)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function push($data, $type = null)
{
}
/**
* @return mixed
*/
public function pop($type = null)
{
}
/**
* @return mixed
*/
public function setBlocking($blocking)
{
}
/**
* @return mixed
*/
public function stats()
{
}
/**
* @return mixed
*/
public function destroy()
{
}
}

View File

@@ -0,0 +1,114 @@
<?php
namespace Swoole;
class MySQL
{
const STATE_QUERY = 0;
const STATE_READ_START = 1;
const STATE_READ_FIELD = 2;
const STATE_READ_ROW = 3;
const STATE_READ_END = 5;
const STATE_CLOSED = 6;
public $serverInfo = null;
public $sock = -1;
public $connected = false;
public $errno = 0;
public $connect_errno = 0;
public $error = null;
public $connect_error = null;
public $insert_id = null;
public $affected_rows = null;
public $onConnect = null;
public $onClose = null;
public function __construct()
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function connect(array $server_config, $callback)
{
}
/**
* @return mixed
*/
public function begin($callback)
{
}
/**
* @return mixed
*/
public function commit($callback)
{
}
/**
* @return mixed
*/
public function rollback($callback)
{
}
/**
* @return mixed
*/
public function escape($string, $flags = null)
{
}
/**
* @return mixed
*/
public function query($sql, $callback)
{
}
/**
* @return mixed
*/
public function close()
{
}
/**
* @return mixed
*/
public function getState()
{
}
/**
* @return mixed
*/
public function on($event_name, $callback)
{
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Swoole\MySQL;
class Exception extends \Swoole\Exception
{
}

View File

@@ -0,0 +1,80 @@
<?php
namespace Swoole;
class Redis
{
const STATE_CONNECT = 0;
const STATE_READY = 1;
const STATE_WAIT_RESULT = 2;
const STATE_SUBSCRIBE = 3;
const STATE_CLOSED = 4;
public $onConnect = null;
public $onClose = null;
public $onMessage = null;
public $setting = null;
public $host = null;
public $port = null;
public $sock = null;
public $errCode = null;
public $errMsg = null;
public function __construct(?array $setting = null)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function on($event_name, $callback)
{
}
/**
* @return mixed
*/
public function connect($host, $port, $callback)
{
}
/**
* @return mixed
*/
public function close()
{
}
/**
* @return mixed
*/
public function getState()
{
}
/**
* @return mixed
*/
public function __call($command, $params)
{
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Swoole;
class RingQueue
{
public function __construct($len)
{
}
public function __destruct()
{
}
/**
* @return mixed
*/
public function push($data)
{
}
/**
* @return mixed
*/
public function pop()
{
}
/**
* @return mixed
*/
public function count()
{
}
/**
* @return mixed
*/
public function isFull()
{
}
/**
* @return mixed
*/
public function isEmpty()
{
}
}

View File

@@ -0,0 +1,5 @@
<?php
if (SWOOLE_USE_SHORTNAME) {
class_alias(Swoole\Coroutine\WaitGroup::class, Co\WaitGroup::class, false);
class_alias(Swoole\Coroutine\Server::class, Co\Server::class, false);
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Swoole\Coroutine {
function run(callable $fn, ...$args)
{
$s = new Scheduler();
$s->add($fn, ...$args);
return $s->start();
}
}
namespace Co {
if (SWOOLE_USE_SHORTNAME) {
function run(callable $fn, ...$args)
{
return \Swoole\Coroutine\Run($fn, ...$args);
}
}
}

View File

@@ -0,0 +1,6 @@
<?php
define('SWOOLE_LIBRARY', true);
$useShortname = ini_get_all('swoole')['swoole.use_shortname']['local_value'];
$useShortname = strtolower(trim(str_replace('0', '', $useShortname)));
define('SWOOLE_USE_SHORTNAME', !in_array($useShortname, ['', 'off', 'false'], true));

View File

@@ -0,0 +1,665 @@
<?php
namespace Swoole;
use ArrayAccess;
use Countable;
use Iterator;
use RuntimeException;
use Serializable;
class ArrayObject implements ArrayAccess, Serializable, Countable, Iterator
{
/**
* @var array
*/
protected $array;
/**
* ArrayObject constructor.
* @param array $array
*/
public function __construct(array $array = [])
{
$this->array = $array;
}
/**
* @return bool
*/
public function isEmpty(): bool
{
return empty($this->array);
}
/**
* @return int
*/
public function count(): int
{
return count($this->array);
}
/**
* @return mixed
*/
public function current()
{
return current($this->array);
}
/**
* @return mixed
*/
public function key()
{
return key($this->array);
}
/**
* @return bool
*/
public function valid(): bool
{
return array_key_exists($this->key(), $this->array);
}
/**
* @return mixed
*/
public function rewind()
{
return reset($this->array);
}
/**
* @return mixed
*/
public function next()
{
return next($this->array);
}
/**
* @param $key
* @return ArrayObject|StringObject|mixed
*/
public function get($key)
{
return static::detectType($this->array[$key]);
}
/**
* @param $key
* @param $value
* @return $this
*/
public function set($key, $value): self
{
$this->array[$key] = $value;
return $this;
}
/**
* @param $key
* @return $this
*/
public function delete($key): self
{
unset($this->array[$key]);
return $this;
}
/**
* @param $value
* @param bool $strict
* @param bool $loop
* @return $this
*/
public function remove($value, bool $strict = true, bool $loop = false): self
{
do {
$key = $this->search($value, $strict);
if ($key) {
unset($this->array[$key]);
} else {
break;
}
} while ($loop);
return $this;
}
/**
* @return $this
*/
public function clear(): self
{
$this->array = [];
return $this;
}
/**
* @param mixed $key
* @return mixed|null
*/
public function offsetGet($key)
{
if (!array_key_exists($key, $this->array)) {
return null;
}
return $this->array[$key];
}
/**
* @param mixed $key
* @param mixed $value
*/
public function offsetSet($key, $value)
{
$this->array[$key] = $value;
}
/**
* @param mixed $key
*/
public function offsetUnset($key)
{
unset($this->array[$key]);
}
/**
* @param mixed $key
* @return bool
*/
public function offsetExists($key)
{
return isset($this->array[$key]);
}
/**
* @param $key
* @return bool
*/
public function exists($key): bool
{
return array_key_exists($key, $this->array);
}
/**
* @param $value
* @param bool $strict
* @return bool
*/
public function contains($value, bool $strict = true): bool
{
return in_array($value, $this->array, $strict);
}
/**
* @param $value
* @param bool $strict
* @return mixed
*/
public function indexOf($value, bool $strict = true)
{
return $this->search($value, $strict);
}
/**
* @param $value
* @param bool $strict
* @return mixed
*/
public function lastIndexOf($value, bool $strict = true)
{
$array = $this->array;
for (end($array); ($currentKey = key($array)) !== null; prev($array)) {
$currentValue = current($array);
if ($currentValue == $value) {
if ($strict && $currentValue !== $value) {
continue;
}
break;
}
}
return $currentKey;
}
/**
* @param $needle
* @param $strict
* @return mixed
*/
public function search($needle, $strict = true)
{
return array_search($needle, $this->array, $strict);
}
/**
* @param string $glue
* @return StringObject
*/
public function join(string $glue = ''): StringObject
{
return static::detectStringType(implode($glue, $this->array));
}
/**
* @return StringObject
*/
public function serialize(): StringObject
{
return static::detectStringType(serialize($this->array));
}
/**
* @param string $string
* @return $this
*/
public function unserialize($string): self
{
$this->array = (array)unserialize($string);
return $this;
}
/**
* @return float|int
*/
public function sum()
{
return array_sum($this->array);
}
/**
* @return float|int
*/
public function product()
{
return array_product($this->array);
}
/**
* @param $value
* @return int
*/
public function push($value)
{
return array_push($this->array, $value);
}
/**
* @param $value
* @return int
*/
public function pushBack($value)
{
return array_unshift($this->array, $value);
}
/**
* @param int $offset
* @param $value
* @return $this
*/
public function insert(int $offset, $value): self
{
if (is_array($value) || is_object($value) || is_null($value)) {
$value = [$value];
}
array_splice($this->array, $offset, 0, $value);
return $this;
}
/**
* @return mixed
*/
public function pop()
{
return array_pop($this->array);
}
/**
* @return mixed
*/
public function popFront()
{
return array_shift($this->array);
}
/**
* @param $offset
* @param int $length
* @param bool $preserve_keys
* @return static
*/
public function slice($offset, int $length = null, bool $preserve_keys = false): self
{
return new static(array_slice($this->array, ...func_get_args()));
}
/**
* @return ArrayObject|StringObject|mixed
*/
public function randomGet()
{
return static::detectType($this->array[array_rand($this->array, 1)]);
}
/**
* @param $fn callable
* @return $this
*/
public function each(callable $fn): self
{
if (array_walk($this->array, $fn) === false) {
throw new RuntimeException('array_walk() failed');
}
return $this;
}
/**
* @param $fn callable
* @return static
*/
public function map(callable $fn): self
{
return new static(array_map($fn, $this->array));
}
/**
* @param $fn callable
* @return mixed
*/
public function reduce(callable $fn)
{
return array_reduce($this->array, $fn);
}
/**
* @param int $search_value
* @param bool $strict
* @return static
*/
public function keys(int $search_value = null, $strict = false): self
{
return new static(array_keys($this->array, $search_value, $strict));
}
/**
* @return static
*/
public function values(): self
{
return new static(array_values($this->array));
}
/**
* @param $column_key
* @param mixed ...$index
* @return static
*/
public function column($column_key, ...$index): self
{
return new static(array_column($this->array, $column_key, ...$index));
}
/**
* @param int $sort_flags
* @return static
*/
public function unique(int $sort_flags = SORT_STRING): self
{
return new static(array_unique($this->array, $sort_flags));
}
/**
* @param bool $preserve_keys
* @return static
*/
public function reverse(bool $preserve_keys = false): self
{
return new static(array_reverse($this->array, $preserve_keys));
}
/**
* @param int $size
* @param bool $preserve_keys
* @return static
*/
public function chunk(int $size, bool $preserve_keys = false): self
{
return new static(array_chunk($this->array, $size, $preserve_keys));
}
/**
* Swap keys and values in an array
* @return static
*/
public function flip(): self
{
return new static(array_flip($this->array));
}
/**
* @param $fn callable
* @param int $flag
* @return static
*/
public function filter(callable $fn, int $flag = 0): self
{
return new static(array_filter($this->array, $fn, $flag));
}
/**
* | Function name | Sorts by | Maintains key association | Order of sort | Related functions |
* | :---------------- | :------- | :-------------------------- | :-------------------------- | :---------------- |
* | array_multisort() | value | associative yes, numeric no | first array or sort options | array_walk() |
* | asort() | value | yes | low to high | arsort() |
* | arsort() | value | yes | high to low | asort() |
* | krsort() | key | yes | high to low | ksort() |
* | ksort() | key | yes | low to high | asort() |
* | natcasesort() | value | yes | natural, case insensitive | natsort() |
* | natsort() | value | yes | natural | natcasesort() |
* | rsort() | value | no | high to low | sort() |
* | shuffle() | value | no | random | array_rand() |
* | sort() | value | no | low to high | rsort() |
* | uasort() | value | yes | user defined | uksort() |
* | uksort() | key | yes | user defined | uasort() |
* | usort() | value | no | user defined | uasort() |
*/
/**
* @param int $sort_order
* @param int $sort_flags
* @return $this
*/
public function multiSort(int $sort_order = SORT_ASC, int $sort_flags = SORT_REGULAR): self
{
if (array_multisort($this->array, $sort_order, $sort_flags) !== true) {
throw new RuntimeException('array_multisort() failed');
}
return $this;
}
/**
* @param int $sort_flags
* @return $this
*/
public function asort(int $sort_flags = SORT_REGULAR): self
{
if (asort($this->array, $sort_flags) !== true) {
throw new RuntimeException('asort() failed');
}
return $this;
}
/**
* @param int $sort_flags
* @return $this
*/
public function arsort(int $sort_flags = SORT_REGULAR): self
{
if (arsort($this->array, $sort_flags) !== true) {
throw new RuntimeException('arsort() failed');
}
return $this;
}
/**
* @param int $sort_flags
* @return $this
*/
public function krsort(int $sort_flags = SORT_REGULAR): self
{
if (krsort($this->array, $sort_flags) !== true) {
throw new RuntimeException('krsort() failed');
}
return $this;
}
/**
* @param int $sort_flags
* @return $this
*/
public function ksort(int $sort_flags = SORT_REGULAR): self
{
if (ksort($this->array, $sort_flags) !== true) {
throw new RuntimeException('ksort() failed');
}
return $this;
}
/**
* @return $this
*/
public function natcasesort(): self
{
if (natcasesort($this->array) !== true) {
throw new RuntimeException('natcasesort() failed');
}
return $this;
}
/**
* @return $this
*/
public function natsort(): self
{
if (natsort($this->array) !== true) {
throw new RuntimeException('natsort() failed');
}
return $this;
}
/**
* @param int $sort_flags
* @return $this
*/
public function rsort(int $sort_flags = SORT_REGULAR): self
{
if (rsort($this->array, $sort_flags) !== true) {
throw new RuntimeException('rsort() failed');
}
return $this;
}
/**
* @return $this
*/
public function shuffle(): self
{
if (shuffle($this->array) !== true) {
throw new RuntimeException('shuffle() failed');
}
return $this;
}
/**
* @param int $sort_flags
* @return $this
*/
public function sort(int $sort_flags = SORT_REGULAR): self
{
if (sort($this->array, $sort_flags) !== true) {
throw new RuntimeException('sort() failed');
}
return $this;
}
/**
* @param callable $value_compare_func
* @return $this
*/
public function uasort(callable $value_compare_func): self
{
if (uasort($this->array, $value_compare_func) !== true) {
throw new RuntimeException('uasort() failed');
}
return $this;
}
/**
* @param callable $value_compare_func
* @return $this
*/
public function uksort(callable $value_compare_func): self
{
if (uksort($this->array, $value_compare_func) !== true) {
throw new RuntimeException('uksort() failed');
}
return $this;
}
/**
* @param callable $value_compare_func
* @return $this
*/
public function usort(callable $value_compare_func): self
{
if (usort($this->array, $value_compare_func) !== true) {
throw new RuntimeException('usort() failed');
}
return $this;
}
/**
* @return array
*/
public function __toArray(): array
{
return $this->array;
}
/**
* @param $value
* @return ArrayObject|StringObject|mixed
*/
protected static function detectType($value)
{
if (is_string($value)) {
return static::detectStringType($value);
} elseif (is_array($value)) {
return static::detectArrayType($value);
} else {
return $value;
}
}
/**
* @param string $value
* @return StringObject
*/
protected static function detectStringType(string $value): StringObject
{
return new StringObject($value);
}
/**
* @param array $value
* @return static
*/
protected static function detectArrayType(array $value): self
{
return new static($value);
}
}

View File

@@ -0,0 +1,186 @@
<?php
namespace Swoole;
class Constant
{
const EVENT_RECEIVE = 'receive';
const EVENT_CONNECT = 'connect';
const EVENT_CLOSE = 'close';
const EVENT_PACKET = 'packet';
const EVENT_REQUEST = 'request';
const EVENT_MESSAGE = 'message';
const EVENT_OPEN = 'open';
const EVENT_HANDSHAKE = 'handshake';
const EVENT_TASK = 'task';
const EVENT_FINISH = 'finish';
const EVENT_START = 'start';
const EVENT_SHUTDOWN = 'shutdown';
const EVENT_WORKER_START = 'workerStart';
const EVENT_WORKER_EXIT = 'workerExit';
const EVENT_WORKER_ERROR = 'workerError';
const EVENT_WORKER_STOP = 'workerStop';
const EVENT_PIPE_MESSAGE = 'pipeMessage';
const EVENT_MANAGER_START = 'managerStart';
const EVENT_MANAGER_STOP = 'managerStop';
const EVENT_ERROR = 'error';
/* {{{ OPTION */
const OPTION_ENABLE_SIGNALFD = 'enable_signalfd';
const OPTION_DNS_CACHE_REFRESH_TIME = 'dns_cache_refresh_time';
const OPTION_SOCKET_BUFFER_SIZE = 'socket_buffer_size';
const OPTION_SOCKET_SEND_TIMEOUT = 'socket_send_timeout';
const OPTION_LOG_LEVEL = 'log_level';
const OPTION_THREAD_NUM = 'thread_num';
const OPTION_MIN_THREAD_NUM = 'min_thread_num';
const OPTION_MAX_THREAD_NUM = 'max_thread_num';
const OPTION_DISPLAY_ERRORS = 'display_errors';
const OPTION_SOCKET_DONTWAIT = 'socket_dontwait';
const OPTION_DNS_LOOKUP_RANDOM = 'dns_lookup_random';
const OPTION_DNS_SERVER = 'dns_server';
const OPTION_USE_ASYNC_RESOLVER = 'use_async_resolver';
const OPTION_ENABLE_COROUTINE = 'enable_coroutine';
const OPTION_ENABLE_REUSE_PORT = 'enable_reuse_port';
const OPTION_SSL_METHOD = 'ssl_method';
const OPTION_SSL_PROTOCOLS = 'ssl_protocols';
const OPTION_SSL_COMPRESS = 'ssl_compress';
const OPTION_SSL_CERT_FILE = 'ssl_cert_file';
const OPTION_SSL_KEY_FILE = 'ssl_key_file';
const OPTION_SSL_PASSPHRASE = 'ssl_passphrase';
const OPTION_SSL_HOST_NAME = 'ssl_host_name';
const OPTION_SSL_VERIFY_PEER = 'ssl_verify_peer';
const OPTION_SSL_ALLOW_SELF_SIGNED = 'ssl_allow_self_signed';
const OPTION_SSL_CAFILE = 'ssl_cafile';
const OPTION_SSL_CAPATH = 'ssl_capath';
const OPTION_SSL_VERIFY_DEPTH = 'ssl_verify_depth';
const OPTION_OPEN_EOF_CHECK = 'open_eof_check';
const OPTION_OPEN_EOF_SPLIT = 'open_eof_split';
const OPTION_PACKAGE_EOF = 'package_eof';
const OPTION_OPEN_MQTT_PROTOCOL = 'open_mqtt_protocol';
const OPTION_OPEN_LENGTH_CHECK = 'open_length_check';
const OPTION_PACKAGE_LENGTH_TYPE = 'package_length_type';
const OPTION_PACKAGE_LENGTH_OFFSET = 'package_length_offset';
const OPTION_PACKAGE_BODY_OFFSET = 'package_body_offset';
const OPTION_PACKAGE_LENGTH_FUNC = 'package_length_func';
const OPTION_PACKAGE_MAX_LENGTH = 'package_max_length';
const OPTION_BUFFER_HIGH_WATERMARK = 'buffer_high_watermark';
const OPTION_BUFFER_LOW_WATERMARK = 'buffer_low_watermark';
const OPTION_BIND_PORT = 'bind_port';
const OPTION_BIND_ADDRESS = 'bind_address';
const OPTION_OPEN_TCP_NODELAY = 'open_tcp_nodelay';
const OPTION_SOCKS5_HOST = 'socks5_host';
const OPTION_SOCKS5_PORT = 'socks5_port';
const OPTION_SOCKS5_USERNAME = 'socks5_username';
const OPTION_SOCKS5_PASSWORD = 'socks5_password';
const OPTION_HTTP_PROXY_HOST = 'http_proxy_host';
const OPTION_HTTP_PROXY_PORT = 'http_proxy_port';
const OPTION_HTTP_PROXY_USERNAME = 'http_proxy_username';
const OPTION_HTTP_PROXY_USER = 'http_proxy_user';
const OPTION_HTTP_PROXY_PASSWORD = 'http_proxy_password';
const OPTION_TIMEOUT = 'timeout';
const OPTION_CONNECT_TIMEOUT = 'connect_timeout';
const OPTION_READ_TIMEOUT = 'read_timeout';
const OPTION_WRITE_TIMEOUT = 'write_timeout';
const OPTION_SSL_DISABLE_COMPRESSION = 'ssl_disable_compression';
const OPTION_MAX_COROUTINE = 'max_coroutine';
const OPTION_HOOK_FLAGS = 'hook_flags';
const OPTION_C_STACK_SIZE = 'c_stack_size';
const OPTION_STACK_SIZE = 'stack_size';
const OPTION_SOCKET_CONNECT_TIMEOUT = 'socket_connect_timeout';
const OPTION_SOCKET_TIMEOUT = 'socket_timeout';
const OPTION_SOCKET_READ_TIMEOUT = 'socket_read_timeout';
const OPTION_SOCKET_WRITE_TIMEOUT = 'socket_write_timeout';
const OPTION_TRACE_FLAGS = 'trace_flags';
const OPTION_DNS_CACHE_EXPIRE = 'dns_cache_expire';
const OPTION_DNS_CACHE_CAPACITY = 'dns_cache_capacity';
const OPTION_AIO_CORE_WORKER_NUM = 'aio_core_worker_num';
const OPTION_AIO_WORKER_NUM = 'aio_worker_num';
const OPTION_AIO_MAX_WAIT_TIME = 'aio_max_wait_time';
const OPTION_AIO_MAX_IDLE_TIME = 'aio_max_idle_time';
const OPTION_RECONNECT = 'reconnect';
const OPTION_DEFER = 'defer';
const OPTION_KEEP_ALIVE = 'keep_alive';
const OPTION_WEBSOCKET_MASK = 'websocket_mask';
const OPTION_WEBSOCKET_COMPRESSION = 'websocket_compression';
const OPTION_HOST = 'host';
const OPTION_PORT = 'port';
const OPTION_SSL = 'ssl';
const OPTION_USER = 'user';
const OPTION_PASSWORD = 'password';
const OPTION_DATABASE = 'database';
const OPTION_CHARSET = 'charset';
const OPTION_STRICT_TYPE = 'strict_type';
const OPTION_FETCH_MODE = 'fetch_mode';
const OPTION_SERIALIZE = 'serialize';
const OPTION_COMPATIBILITY_MODE = 'compatibility_mode';
const OPTION_CHROOT = 'chroot';
const OPTION_GROUP = 'group';
const OPTION_DAEMONIZE = 'daemonize';
const OPTION_DEBUG_MODE = 'debug_mode';
const OPTION_PID_FILE = 'pid_file';
const OPTION_REACTOR_NUM = 'reactor_num';
const OPTION_SINGLE_THREAD = 'single_thread';
const OPTION_WORKER_NUM = 'worker_num';
const OPTION_MAX_WAIT_TIME = 'max_wait_time';
const OPTION_MAX_CORO_NUM = 'max_coro_num';
const OPTION_SEND_TIMEOUT = 'send_timeout';
const OPTION_DISPATCH_MODE = 'dispatch_mode';
const OPTION_SEND_YIELD = 'send_yield';
const OPTION_DISPATCH_FUNC = 'dispatch_func';
const OPTION_LOG_FILE = 'log_file';
const OPTION_DISCARD_TIMEOUT_REQUEST = 'discard_timeout_request';
const OPTION_ENABLE_UNSAFE_EVENT = 'enable_unsafe_event';
const OPTION_ENABLE_DELAY_RECEIVE = 'enable_delay_receive';
const OPTION_TASK_USE_OBJECT = 'task_use_object';
const OPTION_TASK_ENABLE_COROUTINE = 'task_enable_coroutine';
const OPTION_TASK_WORKER_NUM = 'task_worker_num';
const OPTION_TASK_IPC_MODE = 'task_ipc_mode';
const OPTION_TASK_TMPDIR = 'task_tmpdir';
const OPTION_TASK_MAX_REQUEST = 'task_max_request';
const OPTION_TASK_MAX_REQUEST_GRACE = 'task_max_request_grace';
const OPTION_MAX_CONNECTION = 'max_connection';
const OPTION_MAX_CONN = 'max_conn';
const OPTION_HEARTBEAT_CHECK_INTERVAL = 'heartbeat_check_interval';
const OPTION_HEARTBEAT_IDLE_TIME = 'heartbeat_idle_time';
const OPTION_MAX_REQUEST = 'max_request';
const OPTION_MAX_REQUEST_GRACE = 'max_request_grace';
const OPTION_RELOAD_ASYNC = 'reload_async';
const OPTION_OPEN_CPU_AFFINITY = 'open_cpu_affinity';
const OPTION_CPU_AFFINITY_IGNORE = 'cpu_affinity_ignore';
const OPTION_HTTP_PARSE_COOKIE = 'http_parse_cookie';
const OPTION_HTTP_PARSE_POST = 'http_parse_post';
const OPTION_HTTP_PARSE_FILES = 'http_parse_files';
const OPTION_HTTP_COMPRESSION = 'http_compression';
const OPTION_HTTP_GZIP_LEVEL = 'http_gzip_level';
const OPTION_HTTP_COMPRESSION_LEVEL = 'http_compression_level';
const OPTION_UPLOAD_TMP_DIR = 'upload_tmp_dir';
const OPTION_ENABLE_STATIC_HANDLER = 'enable_static_handler';
const OPTION_DOCUMENT_ROOT = 'document_root';
const OPTION_STATIC_HANDLER_LOCATIONS = 'static_handler_locations';
const OPTION_BUFFER_INPUT_SIZE = 'buffer_input_size';
const OPTION_BUFFER_OUTPUT_SIZE = 'buffer_output_size';
const OPTION_MESSAGE_QUEUE_KEY = 'message_queue_key';
const OPTION_BACKLOG = 'backlog';
const OPTION_KERNEL_SOCKET_RECV_BUFFER_SIZE = 'kernel_socket_recv_buffer_size';
const OPTION_KERNEL_SOCKET_SEND_BUFFER_SIZE = 'kernel_socket_send_buffer_size';
const OPTION_TCP_DEFER_ACCEPT = 'tcp_defer_accept';
const OPTION_OPEN_TCP_KEEPALIVE = 'open_tcp_keepalive';
const OPTION_OPEN_HTTP_PROTOCOL = 'open_http_protocol';
const OPTION_OPEN_WEBSOCKET_PROTOCOL = 'open_websocket_protocol';
const OPTION_WEBSOCKET_SUBPROTOCOL = 'websocket_subprotocol';
const OPTION_OPEN_WEBSOCKET_CLOSE_FRAME = 'open_websocket_close_frame';
const OPTION_OPEN_HTTP2_PROTOCOL = 'open_http2_protocol';
const OPTION_OPEN_REDIS_PROTOCOL = 'open_redis_protocol';
const OPTION_TCP_KEEPIDLE = 'tcp_keepidle';
const OPTION_TCP_KEEPINTERVAL = 'tcp_keepinterval';
const OPTION_TCP_KEEPCOUNT = 'tcp_keepcount';
const OPTION_TCP_FASTOPEN = 'tcp_fastopen';
const OPTION_PACKAGE_BODY_START = 'package_body_start';
const OPTION_SSL_CLIENT_CERT_FILE = 'ssl_client_cert_file';
const OPTION_SSL_PREFER_SERVER_CIPHERS = 'ssl_prefer_server_ciphers';
const OPTION_SSL_CIPHERS = 'ssl_ciphers';
const OPTION_SSL_ECDH_CURVE = 'ssl_ecdh_curve';
const OPTION_SSL_DHPARAM = 'ssl_dhparam';
const OPTION_OPEN_SSL = 'open_ssl';
/* }}} OPTION */
}

View File

@@ -0,0 +1,76 @@
<?php
namespace Swoole\Coroutine;
use BadMethodCallException;
use InvalidArgumentException;
use RuntimeException;
use Swoole\Coroutine;
abstract class ObjectPool
{
protected static $context = [];
protected $object_pool;
protected $busy_pool;
protected $type;
public function __construct($type, $pool_size = 10, $concurrency = 10)
{
if (empty($type)) {
throw new InvalidArgumentException('ObjectPool misuse: parameter type can not be empty');
}
if (!is_numeric($concurrency) || $concurrency <= 0) {
throw new InvalidArgumentException('ObjectPool misuse: parameter concurrency must larger than 0');
}
$this->object_pool = new Channel($pool_size);
$this->busy_pool = new Channel($concurrency);
$this->type = $type;
}
public function get()
{
$context = Coroutine::getContext();
if (!$context) {
throw new BadMethodCallException('ObjectPool misuse: get must be used in coroutine');
}
$type = $this->type;
Coroutine::defer(function () {
$this->free();
});
if (isset($context[$type])) {
return $context[$type];
}
if (!$this->object_pool->isEmpty()) {
$object = $this->object_pool->pop();
$context["new"] = false;
} else {
/* create concurrency control */
$this->busy_pool->push(true);
$object = $this->create();
if (empty($object)) {
throw new RuntimeException('ObjectPool misuse: create object failed');
}
$context["new"] = true;
}
$context[$type] = $object;
return $object;
}
public function free()
{
$context = Coroutine::getContext();
if (!$context) {
throw new BadMethodCallException('ObjectPool misuse: free must be used in coroutine');
}
$type = $this->type;
$object = $context[$type];
$this->object_pool->push($object);
if ($context["new"]) {
$this->busy_pool->pop();
}
}
public abstract function create();
}

View File

@@ -0,0 +1,125 @@
<?php
namespace Swoole\Coroutine;
use Swoole\Coroutine;
use Swoole\Coroutine\Server\Connection;
use Swoole\Exception;
class Server
{
/** @var string */
public $host = '';
/** @var int */
public $port = 0;
/** @var int */
public $type = AF_INET;
/** @var int */
public $fd = -1;
/** @var int */
public $errCode = 0;
/** @var array */
public $setting = [];
/** @var bool */
protected $running = false;
/** @var callable|null */
protected $fn;
/** @var Socket */
protected $socket;
/**
* Server constructor.
* @param string $host
* @param int $port
* @param bool $ssl
* @param bool $reuse_port
* @throws Exception
*/
public function __construct(string $host, int $port = 0, bool $ssl = false, bool $reuse_port = false)
{
$_host = swoole_string($host);
if ($_host->contains('::')) {
$this->type = AF_INET6;
} else {
if ($_host->startsWith('unix:/')) {
$host = $_host->substr(5)->__toString();
$this->type = AF_UNIX;
} else {
$this->type = AF_INET;
}
}
$this->host = $host;
$socket = new Socket($this->type, SOCK_STREAM, 0);
if ($reuse_port and defined('SO_REUSEPORT')) {
$socket->setOption(SOL_SOCKET, SO_REUSEPORT, true);
}
if (!$socket->bind($this->host, $port)) {
throw new Exception("bind({$this->host}:{$port}) failed", $socket->errCode);
}
if (!$socket->listen()) {
throw new Exception("listen() failed", $socket->errCode);
}
$this->port = $socket->getsockname()['port'] ?? 0;
$this->fd = $socket->fd;
$this->socket = $socket;
$this->setting['open_ssl'] = $ssl;
}
public function set(array $setting): void
{
$this->setting = array_merge($this->setting, $setting);
}
public function handle(callable $fn): void
{
$this->fn = $fn;
}
public function shutdown(): bool
{
$this->running = false;
return $this->socket->cancel();
}
public function start(): bool
{
$this->running = true;
if ($this->fn == null) {
$this->errCode = SOCKET_EINVAL;
return false;
}
$socket = $this->socket;
if (!$socket->setProtocol($this->setting)) {
$this->errCode = SOCKET_EINVAL;
return false;
}
while ($this->running) {
/** @var $conn Socket */
$conn = $socket->accept();
if ($conn) {
$conn->setProtocol($this->setting);
if (Coroutine::create($this->fn, new Connection($conn)) < 0) {
goto _wait;
}
} else {
if ($socket->errCode == SOCKET_EMFILE or $socket->errCode == SOCKET_ENFILE) {
_wait:
Coroutine::sleep(1);
continue;
} elseif ($socket->errCode == SOCKET_ETIMEDOUT) {
continue;
} elseif ($socket->errCode == SOCKET_ECANCELED) {
break;
} else {
trigger_error("accept failed, Error: {$socket->errMsg}[{$socket->errCode}]", E_USER_WARNING);
break;
}
}
}
return true;
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Swoole\Coroutine\Server;
use Swoole\Coroutine\Socket;
class Connection
{
public $socket;
public function __construct(Socket $conn)
{
$this->socket = $conn;
}
public function recv($timeout = 0)
{
return $this->socket->recvPacket($timeout);
}
public function send($data)
{
return $this->socket->sendAll($data);
}
public function close()
{
return $this->socket->close();
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace Swoole\Coroutine;
use BadMethodCallException;
use InvalidArgumentException;
class WaitGroup
{
protected $chan;
protected $count = 0;
protected $waiting = false;
public function __construct()
{
$this->chan = new Channel(1);
}
public function add(int $delta = 1): void
{
if ($this->waiting) {
throw new BadMethodCallException('WaitGroup misuse: add called concurrently with wait');
}
$count = $this->count + $delta;
if ($count < 0) {
throw new InvalidArgumentException('negative WaitGroup counter');
}
$this->count = $count;
}
public function done(): void
{
$count = $this->count - 1;
if ($count < 0) {
throw new BadMethodCallException('negative WaitGroup counter');
}
$this->count = $count;
if ($count === 0 && $this->waiting) {
$this->chan->push(true);
}
}
public function wait(float $timeout = -1): bool
{
if ($this->count > 0) {
$this->waiting = true;
$done = $this->chan->pop($timeout);
$this->waiting = false;
return $done;
}
return true;
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Swoole\Curl;
use Swoole;
class Exception extends Swoole\Exception
{
}

View File

@@ -0,0 +1,560 @@
<?php
namespace Swoole\Curl;
use Swoole;
use Swoole\Coroutine\Http\Client;
use CURLFile;
use Iterator;
class Handler
{
private const ERRORS = [
CURLE_URL_MALFORMAT => 'No URL set!',
];
/**
* @var Client
*/
private $client;
private $info = [
'url' => '',
'content_type' => '',
'http_code' => 0,
'header_size' => 0,
'request_size' => 0,
'filetime' => -1,
'ssl_verify_result' => 0,
'redirect_count' => 0,
'total_time' => 5.3E-5,
'namelookup_time' => 0.0,
'connect_time' => 0.0,
'pretransfer_time' => 0.0,
'size_upload' => 0.0,
'size_download' => 0.0,
'speed_download' => 0.0,
'speed_upload' => 0.0,
'download_content_length' => -1.0,
'upload_content_length' => -1.0,
'starttransfer_time' => 0.0,
'redirect_time' => 0.0,
'redirect_url' => '',
'primary_ip' => '',
'certinfo' => [],
'primary_port' => 0,
'local_ip' => '',
'local_port' => 0,
'http_version' => 0,
'protocol' => 0,
'ssl_verifyresult' => 0,
'scheme' => '',
];
private $withHeaderOut = false;
private $withFileTime = false;
private $urlInfo;
private $postData;
private $outputStream;
private $proxy;
private $clientOptions = [];
private $followLocation = false;
private $autoReferer = false;
private $maxRedirs;
private $withHeader = false;
private $nobody = false;
/** @var callable */
private $headerFunction;
/** @var callable */
private $readFunction;
/** @var callable */
private $writeFunction;
/** @var callable */
private $progressFunction;
public $returnTransfer = false;
public $method = 'GET';
public $headers = [];
public $transfer;
public $errCode = 0;
public $errMsg = '';
public function __construct($url = null)
{
if ($url) {
$this->create($url);
}
}
private function create(string $url): void
{
if (!swoole_string($url)->contains('://')) {
$url = 'http://' . $url;
}
$this->info['url'] = $url;
$info = parse_url($url);
$proto = swoole_array_default_value($info, 'scheme');
if ($proto != 'http' and $proto != 'https') {
$this->setError(CURLE_UNSUPPORTED_PROTOCOL, "Protocol \"{$proto}\" not supported or disabled in libcurl");
return;
}
$ssl = $proto === 'https';
if (empty($info['port'])) {
$port = $ssl ? 443 : 80;
} else {
$port = intval($info['port']);
}
$this->urlInfo = $info;
$this->client = new Client($info['host'], $port, $ssl);
}
public function execute()
{
$this->info['redirect_count'] = $this->info['starttransfer_time'] = 0;
$this->info['redirect_url'] = '';
$timeBegin = microtime(true);
/**
* Socket
*/
$client = $this->client;
if (!$client) {
if (!$this->errCode) {
$this->setError(CURLE_URL_MALFORMAT);
}
return false;
}
$isRedirect = false;
do {
if ($isRedirect and !$client) {
$proto = swoole_array_default_value($this->urlInfo, 'scheme');
if ($proto != 'http' and $proto != 'https') {
$this->setError(CURLE_UNSUPPORTED_PROTOCOL, "Protocol \"{$proto}\" not supported or disabled in libcurl");
return false;
}
$ssl = $proto === 'https';
if (empty($this->urlInfo['port'])) {
$port = $ssl ? 443 : 80;
} else {
$port = intval($this->urlInfo['port']);
}
$client = new Client($this->urlInfo['host'], $port, $ssl);
}
/**
* Http Proxy
*/
if ($this->proxy) {
list($proxy_host, $proxy_port) = explode(':', $this->proxy);
if (!filter_var($proxy_host, FILTER_VALIDATE_IP)) {
$ip = Swoole\Coroutine::gethostbyname($proxy_host);
if (!$ip) {
$this->setError(CURLE_COULDNT_RESOLVE_PROXY, 'Could not resolve proxy: ' . $proxy_host);
return false;
} else {
$proxy_host = $ip;
}
}
$client->set(['http_proxy_host' => $proxy_host, 'http_proxy_port' => $proxy_port]);
}
/**
* Client Options
*/
if ($this->clientOptions) {
$client->set($this->clientOptions);
}
$client->setMethod($this->method);
/**
* Upload File
*/
if ($this->postData and is_array($this->postData)) {
foreach ($this->postData as $k => $v) {
if ($v instanceof CURLFile) {
$client->addFile($v->getFilename(), $k, $v->getMimeType() ?: 'application/octet-stream', $v->getPostFilename());
unset($this->postData[$k]);
}
}
}
/**
* Post Data
*/
if ($this->postData) {
if (is_string($this->postData) and empty($this->headers['Content-Type'])) {
$this->headers['Content-Type'] = 'application/x-www-form-urlencoded';
}
$client->setData($this->postData);
$this->postData = [];
}
/**
* Http Header
*/
$this->headers['Host'] = $this->urlInfo['host'] . (isset($this->urlInfo['port']) ? (':' . $this->urlInfo['port']) : '');
$client->setHeaders($this->headers);
/**
* Execute
*/
$executeResult = $client->execute($this->getUrl());
if (!$executeResult) {
$errCode = $client->errCode;
if ($errCode == SWOOLE_ERROR_DNSLOOKUP_RESOLVE_FAILED or $errCode == SWOOLE_ERROR_DNSLOOKUP_RESOLVE_TIMEOUT) {
$this->setError(CURLE_COULDNT_RESOLVE_HOST, 'Could not resolve host: ' . $client->host);
}
$this->info['total_time'] = microtime(true) - $timeBegin;
return false;
}
if ($client->statusCode >= 300 and $client->statusCode < 400 and isset($client->headers['location'])) {
$redirectParsedUrl = $this->getRedirectUrl($client->headers['location']);
$redirectUrl = $this->unparseUrl($redirectParsedUrl);
if ($this->followLocation and (null === $this->maxRedirs or $this->info['redirect_count'] < $this->maxRedirs)) {
$isRedirect = true;
if (0 === $this->info['redirect_count']) {
$this->info['starttransfer_time'] = microtime(true) - $timeBegin;
$redirectBeginTime = microtime(true);
}
// force GET
if (in_array($client->statusCode, [301, 302, 303])) {
$this->method = 'GET';
}
if ($this->urlInfo['host'] !== $redirectParsedUrl['host'] or ($this->urlInfo['port'] ?? null) !== ($redirectParsedUrl['port'] ?? null) or $this->urlInfo['scheme'] !== $redirectParsedUrl['scheme']) {
// If host, port, and scheme are the same, reuse $client. Otherwise, release the old $client
$client = null;
}
if ($this->autoReferer) {
$this->headers['Referer'] = $this->info['url'];
}
$this->urlInfo = $redirectParsedUrl;
$this->info['url'] = $redirectUrl;
$this->info['redirect_count']++;
} else {
$this->info['redirect_url'] = $redirectUrl;
break;
}
} else {
break;
}
} while (true);
$this->info['total_time'] = microtime(true) - $timeBegin;
$this->info['http_code'] = $client->statusCode;
$this->info['content_type'] = $client->headers['content-type'] ?? '';
$this->info['size_download'] = $this->info['download_content_length'] = strlen($client->body);;
$this->info['speed_download'] = 1 / $this->info['total_time'] * $this->info['size_download'];
if (isset($redirectBeginTime)) {
$this->info['redirect_time'] = microtime(true) - $redirectBeginTime;
}
$headerContent = '';
if ($client->headers) {
$cb = $this->headerFunction;
if ($client->statusCode > 0) {
$row = 'HTTP/1.1 ' . $client->statusCode . ' ' . Swoole\Http\StatusCode::getReasonPhrase($client->statusCode) . "\r\n";
if ($cb) {
$cb($this, $row);
}
$headerContent .= $row;
}
foreach ($client->headers as $k => $v) {
$row = "$k: $v\r\n";
if ($cb) {
$cb($this, $row);
}
$headerContent .= $row;
}
$headerContent .= "\r\n";
$this->info['header_size'] = strlen($headerContent);
if ($cb) {
$cb($this, '');
}
} else {
$this->info['header_size'] = 0;
}
if ($client->body and $this->readFunction) {
$cb = $this->readFunction;
$cb($this, $this->outputStream, strlen($client->body));
}
if ($this->withHeader) {
$transfer = $headerContent . $client->body;
} else {
$transfer = $client->body;
}
if ($this->withHeaderOut) {
$headerOutContent = $client->getHeaderOut();
$this->info['request_header'] = $headerOutContent ? $headerOutContent . "\r\n\r\n" : '';
}
if ($this->withFileTime) {
if (!empty($client->headers['last-modified'])) {
$this->info['filetime'] = strtotime($client->headers['last-modified']);
} else {
$this->info['filetime'] = -1;
}
}
if ($this->returnTransfer) {
return $this->transfer = $transfer;
} else {
if ($this->outputStream) {
return fwrite($this->outputStream, $transfer) === strlen($transfer);
} else {
echo $transfer;
}
return true;
}
}
public function close(): void
{
$this->client = null;
}
private function setError($code, $msg = ''): void
{
$this->errCode = $code;
$this->errMsg = $msg ? $msg : self::ERRORS[$code];
}
private function getUrl(): string
{
if (empty($this->urlInfo['path'])) {
$url = '/';
} else {
$url = $this->urlInfo['path'];
}
if (!empty($this->urlInfo['query'])) {
$url .= '?' . $this->urlInfo['query'];
}
if (!empty($this->urlInfo['fragment'])) {
$url .= '#' . $this->urlInfo['fragment'];
}
return $url;
}
/**
* @param int $opt
* @param $value
* @return bool
* @throws Swoole\Curl\Exception
*/
public function setOption(int $opt, $value): bool
{
switch ($opt) {
/**
* Basic
*/
case CURLOPT_URL:
$this->create($value);
break;
case CURLOPT_RETURNTRANSFER:
$this->returnTransfer = $value;
$this->transfer = '';
break;
case CURLOPT_ENCODING:
if (empty($value)) {
$value = 'gzip';
}
$this->headers['Accept-Encoding'] = $value;
break;
case CURLOPT_PROXY:
$this->proxy = $value;
break;
case CURLOPT_NOBODY:
$this->nobody = boolval($value);
$this->method = 'HEAD';
break;
/**
* Ignore options
*/
case CURLOPT_SSLVERSION:
case CURLOPT_NOSIGNAL:
case CURLOPT_FRESH_CONNECT:
/**
* From PHP 5.1.3, this option has no effect: the raw output will always be returned when CURLOPT_RETURNTRANSFER is used.
*/
case CURLOPT_BINARYTRANSFER:
/**
* TODO
*/
case CURLOPT_VERBOSE:
case CURLOPT_DNS_CACHE_TIMEOUT:
break;
/**
* SSL
*/
case CURLOPT_SSL_VERIFYHOST:
break;
case CURLOPT_SSL_VERIFYPEER:
$this->clientOptions['ssl_verify_peer'] = $value;
break;
/**
* Http Post
*/
case CURLOPT_POST:
$this->method = 'POST';
break;
case CURLOPT_POSTFIELDS:
$this->postData = $value;
$this->method = 'POST';
break;
/**
* Upload
*/
case CURLOPT_SAFE_UPLOAD:
if (!$value) {
trigger_error('curl_setopt(): Disabling safe uploads is no longer supported', E_USER_WARNING);
}
break;
/**
* Http Header
*/
case CURLOPT_HTTPHEADER:
if (!is_array($value) and !($value instanceof Iterator)) {
trigger_error('swoole_curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER argument', E_USER_WARNING);
return false;
}
foreach ($value as $header) {
list($k, $v) = explode(':', $header);
$v = trim($v);
if ($v) {
$this->headers[$k] = $v;
}
}
break;
case CURLOPT_REFERER:
$this->headers['Referer'] = $value;
break;
case CURLINFO_HEADER_OUT:
$this->withHeaderOut = boolval($value);
break;
case CURLOPT_FILETIME:
$this->withFileTime = boolval($value);
break;
case CURLOPT_USERAGENT:
$this->headers['User-Agent'] = $value;
break;
case CURLOPT_CUSTOMREQUEST:
break;
case CURLOPT_PROTOCOLS:
if ($value > 3) {
throw new Swoole\Curl\Exception("option[{$opt}={$value}] not supported");
}
break;
case CURLOPT_HTTP_VERSION:
if ($value != CURL_HTTP_VERSION_1_1) {
trigger_error("swoole_curl: http version[{$value}] not supported", E_USER_WARNING);
}
break;
/**
* Http Cookie
*/
case CURLOPT_COOKIE:
$this->headers['Cookie'] = $value;
break;
case CURLOPT_CONNECTTIMEOUT:
$this->clientOptions['connect_timeout'] = $value;
break;
case CURLOPT_CONNECTTIMEOUT_MS:
$this->clientOptions['connect_timeout'] = $value / 1000;
break;
case CURLOPT_TIMEOUT:
$this->clientOptions['timeout'] = $value;
break;
case CURLOPT_TIMEOUT_MS:
$this->clientOptions['timeout'] = $value / 1000;
break;
case CURLOPT_FILE:
$this->outputStream = $value;
break;
case CURLOPT_HEADER:
$this->withHeader = $value;
break;
case CURLOPT_HEADERFUNCTION:
$this->headerFunction = $value;
break;
case CURLOPT_READFUNCTION:
$this->readFunction = $value;
break;
case CURLOPT_WRITEFUNCTION:
$this->writeFunction = $value;
break;
case CURLOPT_PROGRESSFUNCTION:
$this->progressFunction = $value;
break;
case CURLOPT_USERPWD:
$this->headers['Authorization'] = 'Basic ' . base64_encode($value);
break;
case CURLOPT_FOLLOWLOCATION:
$this->followLocation = $value;
break;
case CURLOPT_AUTOREFERER:
$this->autoReferer = $value;
break;
case CURLOPT_MAXREDIRS:
$this->maxRedirs = $value;
break;
default:
throw new Swoole\Curl\Exception("option[{$opt}] not supported");
}
return true;
}
public function reset(): void
{
}
public function getInfo()
{
return $this->info;
}
private function unparseUrl(array $parsedUrl): string
{
$scheme = ($parsedUrl['scheme'] ?? 'http') . '://';
$host = $parsedUrl['host'] ?? '';
$port = isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : '';
$user = $parsedUrl['user'] ?? '';
$pass = isset($parsedUrl['pass']) ? ':' . $parsedUrl['pass'] : '';
$pass = ($user or $pass) ? "$pass@" : '';
$path = $parsedUrl['path'] ?? '';
$query = (isset($parsedUrl['query']) and '' !== $parsedUrl['query']) ? '?' . $parsedUrl['query'] : '';
$fragment = isset($parsedUrl['fragment']) ? '#' . $parsedUrl['fragment'] : '';
return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
}
private function getRedirectUrl(string $location): array
{
$uri = parse_url($location);
if (isset($uri['host'])) {
$redirectUri = $uri;
} else {
if (!isset($location[0])) {
return [];
}
$redirectUri = $this->urlInfo;
$redirectUri['query'] = '';
if ('/' === $location[0]) {
$redirectUri['path'] = $location;
} else {
$path = dirname($redirectUri['path'] ?? '');
if ('.' === $path) {
$path = '/';
}
if (isset($location[1]) and './' === substr($location, 0, 2)) {
$location = substr($location, 2);
}
$redirectUri['path'] = $path . $location;
}
foreach ($uri as $k => $v) {
if (!in_array($k, ['path', 'query'])) {
$redirectUri[$k] = $v;
}
}
}
return $redirectUri;
}
}

View File

@@ -0,0 +1,142 @@
<?php
namespace Swoole\Http;
abstract class StatusCode
{
const CONTINUE = 100;
const SWITCHING_PROTOCOLS = 101;
const PROCESSING = 102;
const OK = 200;
const CREATED = 201;
const ACCEPTED = 202;
const NON_AUTHORITATIVE_INFORMATION = 203;
const NO_CONTENT = 204;
const RESET_CONTENT = 205;
const PARTIAL_CONTENT = 206;
const MULTI_STATUS = 207;
const ALREADY_REPORTED = 208;
const IM_USED = 226;
const MULTIPLE_CHOICES = 300;
const MOVED_PERMANENTLY = 301;
const FOUND = 302;
const SEE_OTHER = 303;
const NOT_MODIFIED = 304;
const USE_PROXY = 305;
const SWITCH_PROXY = 306;
const TEMPORARY_REDIRECT = 307;
const PERMANENT_REDIRECT = 308;
const BAD_REQUEST = 400;
const UNAUTHORIZED = 401;
const PAYMENT_REQUIRED = 402;
const FORBIDDEN = 403;
const NOT_FOUND = 404;
const METHOD_NOT_ALLOWED = 405;
const NOT_ACCEPTABLE = 406;
const PROXY_AUTHENTICATION_REQUIRED = 407;
const REQUEST_TIME_OUT = 408;
const CONFLICT = 409;
const GONE = 410;
const LENGTH_REQUIRED = 411;
const PRECONDITION_FAILED = 412;
const REQUEST_ENTITY_TOO_LARGE = 413;
const REQUEST_URI_TOO_LARGE = 414;
const UNSUPPORTED_MEDIA_TYPE = 415;
const REQUESTED_RANGE_NOT_SATISFIABLE = 416;
const EXPECTATION_FAILED = 417;
const MISDIRECTED_REQUEST = 421;
const UNPROCESSABLE_ENTITY = 422;
const LOCKED = 423;
const FAILED_DEPENDENCY = 424;
const UNORDERED_COLLECTION = 425;
const UPGRADE_REQUIRED = 426;
const PRECONDITION_REQUIRED = 428;
const TOO_MANY_REQUESTS = 429;
const REQUEST_HEADER_FIELDS_TOO_LARGE = 431;
const UNAVAILABLE_FOR_LEGAL_REASONS = 451;
const INTERNAL_SERVER_ERROR = 500;
const NOT_IMPLEMENTED = 501;
const BAD_GATEWAY = 502;
const SERVICE_UNAVAILABLE = 503;
const GATEWAY_TIME_OUT = 504;
const HTTP_VERSION_NOT_SUPPORTED = 505;
const VARIANT_ALSO_NEGOTIATES = 506;
const INSUFFICIENT_STORAGE = 507;
const LOOP_DETECTED = 508;
const NOT_EXTENDED = 510;
const NETWORK_AUTHENTICATION_REQUIRED = 511;
protected static $reasonPhrases = [
self::CONTINUE => 'Continue',
self::SWITCHING_PROTOCOLS => 'Switching Protocols',
self::PROCESSING => 'Processing',
self::OK => 'OK',
self::CREATED => 'Created',
self::ACCEPTED => 'Accepted',
self::NON_AUTHORITATIVE_INFORMATION => 'Non-Authoritative Information',
self::NO_CONTENT => 'No Content',
self::RESET_CONTENT => 'Reset Content',
self::PARTIAL_CONTENT => 'Partial Content',
self::MULTI_STATUS => 'Multi-status',
self::ALREADY_REPORTED => 'Already Reported',
self::IM_USED => 'IM Used',
self::MULTIPLE_CHOICES => 'Multiple Choices',
self::MOVED_PERMANENTLY => 'Moved Permanently',
self::FOUND => 'Found',
self::SEE_OTHER => 'See Other',
self::NOT_MODIFIED => 'Not Modified',
self::USE_PROXY => 'Use Proxy',
self::SWITCH_PROXY => 'Switch Proxy',
self::TEMPORARY_REDIRECT => 'Temporary Redirect',
self::PERMANENT_REDIRECT => 'Permanent Redirect',
self::BAD_REQUEST => 'Bad Request',
self::UNAUTHORIZED => 'Unauthorized',
self::PAYMENT_REQUIRED => 'Payment Required',
self::FORBIDDEN => 'Forbidden',
self::NOT_FOUND => 'Not Found',
self::METHOD_NOT_ALLOWED => 'Method Not Allowed',
self::NOT_ACCEPTABLE => 'Not Acceptable',
self::PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required',
self::REQUEST_TIME_OUT => 'Request Time-out',
self::CONFLICT => 'Conflict',
self::GONE => 'Gone',
self::LENGTH_REQUIRED => 'Length Required',
self::PRECONDITION_FAILED => 'Precondition Failed',
self::REQUEST_ENTITY_TOO_LARGE => 'Request Entity Too Large',
self::REQUEST_URI_TOO_LARGE => 'Request-URI Too Large',
self::UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type',
self::REQUESTED_RANGE_NOT_SATISFIABLE => 'Requested range not satisfiable',
self::EXPECTATION_FAILED => 'Expectation Failed',
self::MISDIRECTED_REQUEST => 'Unprocessable Entity',
self::UNPROCESSABLE_ENTITY => 'Unprocessable Entity',
self::LOCKED => 'Locked',
self::FAILED_DEPENDENCY => 'Failed Dependency',
self::UNORDERED_COLLECTION => 'Unordered Collection',
self::UPGRADE_REQUIRED => 'Upgrade Required',
self::PRECONDITION_REQUIRED => 'Precondition Required',
self::TOO_MANY_REQUESTS => 'Too Many Requests',
self::REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large',
self::UNAVAILABLE_FOR_LEGAL_REASONS => 'Unavailable For Legal Reasons',
self::INTERNAL_SERVER_ERROR => 'Internal Server Error',
self::NOT_IMPLEMENTED => 'Not Implemented',
self::BAD_GATEWAY => 'Bad Gateway',
self::SERVICE_UNAVAILABLE => 'Service Unavailable',
self::GATEWAY_TIME_OUT => 'Gateway Time-out',
self::HTTP_VERSION_NOT_SUPPORTED => 'HTTP Version not supported',
self::VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates',
self::INSUFFICIENT_STORAGE => 'Insufficient Storage',
self::LOOP_DETECTED => 'Loop Detected',
self::NOT_EXTENDED => 'Not Extended',
self::NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required'
];
/**
* getReasonPhrase
* @param int $value
* @return string
*/
public static function getReasonPhrase(int $value): string
{
return static::$reasonPhrases[$value] ?? 'Unknown';
}
}

View File

@@ -0,0 +1,237 @@
<?php
namespace Swoole;
class StringObject
{
/**
* @var string
*/
protected $string;
/**
* StringObject constructor.
* @param $string
*/
public function __construct(string $string = '')
{
$this->string = $string;
}
/**
* @return int
*/
public function length(): int
{
return strlen($this->string);
}
/**
* @param string $needle
* @param int $offset
* @return bool|int
*/
public function indexOf(string $needle, int $offset = 0)
{
return strpos($this->string, $needle, $offset);
}
/**
* @param string $needle
* @param int $offset
* @return bool|int
*/
public function lastIndexOf(string $needle, int $offset = 0)
{
return strrpos($this->string, $needle, $offset);
}
/**
* @param string $needle
* @param int $offset
* @return bool|int
*/
public function pos(string $needle, int $offset = 0)
{
return strpos($this->string, $needle, $offset);
}
/**
* @param string $needle
* @param int $offset
* @return bool|int
*/
public function rpos(string $needle, int $offset = 0)
{
return strrpos($this->string, $needle, $offset);
}
/**
* @param string $needle
* @return bool|int
*/
public function ipos(string $needle)
{
return stripos($this->string, $needle);
}
/**
* @return static
*/
public function lower(): self
{
return new static(strtolower($this->string));
}
/**
* @return static
*/
public function upper(): self
{
return new static(strtoupper($this->string));
}
/**
* @return static
*/
public function trim(): self
{
return new static(trim($this->string));
}
/**
* @return static
*/
public function lrim(): self
{
return new static(ltrim($this->string));
}
/**
* @return static
*/
public function rtrim(): self
{
return new static(rtrim($this->string));
}
/**
* @param int $offset
* @param mixed ...$length
* @return static
*/
public function substr(int $offset, ...$length): self
{
return new static(substr($this->string, $offset, ...$length));
}
/**
* @param $n
* @return StringObject
*/
public function repeat($n)
{
return new static(str_repeat($this->string, $n));
}
/**
* @param string $search
* @param string $replace
* @param null $count
* @return static
*/
public function replace(string $search, string $replace, &$count = null): self
{
return new static(str_replace($search, $replace, $this->string, $count));
}
/**
* @param string $needle
* @return bool
*/
public function startsWith(string $needle): bool
{
return strpos($this->string, $needle) === 0;
}
/**
* @param string $subString
* @return bool
*/
public function contains(string $subString): bool
{
return strpos($this->string, $subString) !== false;
}
/**
* @param string $needle
* @return bool
*/
public function endsWith(string $needle): bool
{
return strrpos($this->string, $needle) === (strlen($needle) - 1);
}
/**
* @param string $delimiter
* @param int $limit
* @return ArrayObject
*/
public function split(string $delimiter, int $limit = PHP_INT_MAX): ArrayObject
{
return static::detectArrayType(explode($delimiter, $this->string, $limit));
}
/**
* @param int $index
* @return string
*/
public function char(int $index): string
{
return $this->string[$index];
}
/**
* @param int $chunkLength
* @param string $chunkEnd
* @return static
*/
public function chunkSplit(int $chunkLength = 1, string $chunkEnd = ''): self
{
return new static(chunk_split($this->string, $chunkLength, $chunkEnd));
}
/**
* @param int $splitLength
* @return ArrayObject
*/
public function chunk($splitLength = 1): ArrayObject
{
return static::detectArrayType(str_split($this->string, $splitLength));
}
/**
* @return string
*/
public function toString()
{
return $this->string;
}
/**
* @return string
*/
public function __toString(): string
{
return $this->string;
}
/**
* @param array $value
* @return ArrayObject
*/
protected static function detectArrayType(array $value): ArrayObject
{
return new ArrayObject($value);
}
}

View File

@@ -0,0 +1,49 @@
<?php
if (SWOOLE_USE_SHORTNAME) {
/**
* @param string $string
* @return Swoole\StringObject
*/
function _string(string $string = ''): Swoole\StringObject
{
return new Swoole\StringObject($string);
}
/**
* @param array $array
* @return Swoole\ArrayObject
*/
function _array(array $array = []): Swoole\ArrayObject
{
return new Swoole\ArrayObject($array);
}
}
/**
* @param string $string
* @return Swoole\StringObject
*/
function swoole_string(string $string = ''): Swoole\StringObject
{
return new Swoole\StringObject($string);
}
/**
* @param array $array
* @return Swoole\ArrayObject
*/
function swoole_array(array $array = []): Swoole\ArrayObject
{
return new Swoole\ArrayObject($array);
}
/**
* @param array $array
* @param $key
* @param $default_value
* @return mixed
*/
function swoole_array_default_value(array $array, $key, $default_value = '')
{
return array_key_exists($key, $array) ? $array[$key] : $default_value;
}

View File

@@ -0,0 +1,3 @@
<?php
class_alias(Swoole\Orm::class, swoole_orm::class);

View File

@@ -0,0 +1,7 @@
<?php
/**
* @return mixed
*/
function swoole_orm_version(){}

View File

@@ -0,0 +1,3 @@
<?php
class_alias(Swoole\Coroutine\PostgreSQL::class, Co\PostgreSQL::class);

View File

@@ -0,0 +1,5 @@
<?php
define('SW_PGSQL_ASSOC', 1);
define('SW_PGSQL_NUM', 2);
define('SW_PGSQL_BOTH', 3);

View File

@@ -0,0 +1,103 @@
<?php
namespace Swoole\Coroutine;
class PostgreSQL
{
public $error = null;
public function __construct()
{
}
/**
* @return mixed
*/
public function connect($conninfo)
{
}
/**
* @return mixed
*/
public function query($query = null)
{
}
/**
* @return mixed
*/
public function prepare($stmtname, $query)
{
}
/**
* @return mixed
*/
public function execute($stmtname, $pv_param_arr)
{
}
/**
* @return mixed
*/
public function fetchAll($result = null, $result_type = null)
{
}
/**
* @return mixed
*/
public function affectedRows($result = null)
{
}
/**
* @return mixed
*/
public function numRows($result = null)
{
}
/**
* @return mixed
*/
public function metaData($table_name)
{
}
/**
* @return mixed
*/
public function fetchObject($result, $row = null, $class_name = null, $l = null, $ctor_params = null)
{
}
/**
* @return mixed
*/
public function fetchAssoc($result, $row = null)
{
}
/**
* @return mixed
*/
public function fetchArray($result, $row = null, $result_type = null)
{
}
/**
* @return mixed
*/
public function fetchRow($result, $row = null, $result_type = null)
{
}
public function __destruct()
{
}
}

View File

@@ -0,0 +1,3 @@
<?php
class_alias(Swoole\Serialize::class, swoole_serialize::class);

View File

@@ -0,0 +1,5 @@
<?php
define('SWOOLE_FAST_PACK', 1);
define('UNSERIALIZE_OBJECT_TO_ARRAY', 1);
define('UNSERIALIZE_OBJECT_TO_STDCLASS', 2);

View File

@@ -0,0 +1,23 @@
<?php
namespace Swoole;
class Serialize
{
/**
* @return mixed
*/
public static function pack($data, $flag = null)
{
}
/**
* @return mixed
*/
public static function unpack($string, $flag = null)
{
}
}

View File

@@ -0,0 +1,2 @@
<?php

View File

@@ -0,0 +1,5 @@
<?php
define('ZOO_VERSION', '3.4.12');
define('ZOO_EPHEMERAL', 1);
define('ZOO_SEQUENCE', 2);

View File

@@ -0,0 +1,157 @@
<?php
namespace swoole;
class zookeeper
{
const PERM_READ = 1;
const PERM_WRITE = 2;
const PERM_ALL = 31;
const PERM_ADMIN = 16;
const PERM_CREATE = 4;
const PERM_DELETE = 8;
public $errCode = 0;
private $logStream = null;
private $watcher = null;
public function __construct()
{
}
/**
* @return mixed
*/
public function create()
{
}
/**
* @return mixed
*/
public function addAuth()
{
}
/**
* @return mixed
*/
public function set()
{
}
/**
* @return mixed
*/
public function get()
{
}
/**
* @return mixed
*/
public function exists()
{
}
/**
* @return mixed
*/
public function delete()
{
}
/**
* @return mixed
*/
public function setAcl()
{
}
/**
* @return mixed
*/
public function getAcl()
{
}
/**
* @return mixed
*/
public function getChildren()
{
}
/**
* @return mixed
*/
public function watch()
{
}
/**
* @return mixed
*/
public function watchChildren()
{
}
/**
* @return mixed
*/
public function waitEvent()
{
}
/**
* @return mixed
*/
public static function setDebugLevel()
{
}
/**
* @return mixed
*/
public function getState()
{
}
/**
* @return mixed
*/
public function getClientId()
{
}
/**
* @return mixed
*/
public function setDeterministicConnOrder()
{
}
/**
* @return mixed
*/
public function setLogStream()
{
}
/**
* @return mixed
*/
public function setWatcher()
{
}
}