Skip to content

Commit

Permalink
updates for Swoole 6.0.0-rc1
Browse files Browse the repository at this point in the history
Signed-off-by: Demin Yin <[email protected]>
  • Loading branch information
deminy committed Dec 2, 2024
1 parent a8a6c7e commit 8b35b19
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 7 deletions.
83 changes: 83 additions & 0 deletions src/swoole/Swoole/Async/Client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

declare(strict_types=1);

namespace Swoole\Async;

/**
* @since 6.0.0-rc1
*/
class Client extends \Swoole\Client
{
public const MSG_OOB = 1;

public const MSG_PEEK = 2;

public const MSG_DONTWAIT = 64;

public const MSG_WAITALL = 256;

public const SHUT_RDWR = 2;

public const SHUT_RD = 0;

public const SHUT_WR = 1;

private $onConnect;

private $onError;

private $onReceive;

private $onClose;

private $onBufferFull;

private $onBufferEmpty;

private $onSSLReady;

public function __construct(int $type)
{
}

public function __destruct()
{
}

public function connect(string $host, int $port = 0, float $timeout = 0.5, int $sock_flag = 0): bool
{
}

public function sleep(): bool
{
}

public function wakeup(): bool
{
}

public function pause(): bool
{
}

public function resume(): bool
{
}

public function enableSSL(?callable $onSslReady = null): bool
{
}

public function isConnected(): bool
{
}

public function close(bool $force = false): bool
{
}

public function on(string $host, callable $callback): bool
{
}
}
2 changes: 2 additions & 0 deletions src/swoole/Swoole/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public function shutdown(int $how): bool
/**
* This method is available only when OpenSSL support is enabled (i.e., when Swoole is installed with configuration
* option "--enable-openssl" included).
*
* @return bool TRUE if SSL handshake is successful; otherwise FALSE.
*/
public function enableSSL(): bool
{
Expand Down
8 changes: 7 additions & 1 deletion src/swoole/Swoole/Coroutine.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,17 @@ public static function waitPid(int $pid, float $timeout = -1): array|false
}

/**
* Wait for given signal(s) with a timeout.
*
* @param int|array<int> $signals An integer or an array of integers representing the signal number(s).
* Before Swoole v6.0.0-rc1, only integer is supported.
* @param float $timeout The timeout value in seconds. Minimum value is 0.001. -1 means no timeout.
* @return bool Returns true on success. Returns false on failure.
* @alias Alias of method \Swoole\Coroutine\System::waitSignal().
* @see \Swoole\Coroutine\System::waitSignal()
* @since 4.5.0
*/
public static function waitSignal(int $signo, float $timeout = -1): bool
public static function waitSignal(int|array $signals, float $timeout = -1): bool
{
}

Expand Down
10 changes: 9 additions & 1 deletion src/swoole/Swoole/Coroutine/Http/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ public function set(array $settings): bool
{
}

public function handle(string $pattern, callable $callback): void
/**
* Register a callback function to handle the HTTP request specified by the URL pattern.
*
* @param string $pattern The URL pattern to match, e.g., "/index".
* @param callable $callback The callback function to handle the HTTP request.
* @return bool Return true on success. Return false on failure.
* Before Swoole v6.0.0-rc1, it returns void.
*/
public function handle(string $pattern, callable $callback): bool
{
}

Expand Down
8 changes: 7 additions & 1 deletion src/swoole/Swoole/Coroutine/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,17 @@ public static function waitPid(int $pid, float $timeout = -1): array|false
}

/**
* Wait for given signal(s) with a timeout.
*
* @param int|array<int> $signals An integer or an array of integers representing the signal number(s).
* Before Swoole v6.0.0-rc1, only integer is supported.
* @param float $timeout The timeout value in seconds. Minimum value is 0.001. -1 means no timeout.
* @return bool Returns true on success. Returns false on failure.
* @alias This method has an alias of \Swoole\Coroutine::waitSignal().
* @see \Swoole\Coroutine::waitSignal()
* @since 4.5.0
*/
public static function waitSignal(int $signo, float $timeout = -1): bool
public static function waitSignal(int|array $signals, float $timeout = -1): bool
{
}

Expand Down
7 changes: 5 additions & 2 deletions src/swoole/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
/*
* Swoole version information.
*/
define('SWOOLE_VERSION', '6.0.0-dev');
define('SWOOLE_VERSION', '6.0.0-RC1');
define('SWOOLE_VERSION_ID', 60000);
define('SWOOLE_MAJOR_VERSION', 6);
define('SWOOLE_MINOR_VERSION', 0);
define('SWOOLE_RELEASE_VERSION', 0);
define('SWOOLE_EXTRA_VERSION', 'dev');
define('SWOOLE_EXTRA_VERSION', '');

/*
* If debug logging is enabled or not in Swoole.
Expand Down Expand Up @@ -304,6 +304,7 @@
#ifdef HAVE_SPINLOCK
define('SWOOLE_SPINLOCK', 5); # Supported only if the Spin Locks option is provided in the POSIX thread (pthread) libraries.
#endif
define('SWOOLE_COROLOCK', 6); # @since v6.0.0-rc1

/*
* Following SIG_* and PRIO_* constants are set only when PHP extension pcntl (to support Process Control) is not
Expand Down Expand Up @@ -564,6 +565,8 @@
*/
define('SOCKET_ECANCELED', 125);

define('TCP_INFO', 11); // @since v6.0.0-rc1

/*
* Constants in this section are used in Swoole servers.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/swoole/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ function swoole_test_kernel_coroutine(int $count = 100, float $sleep_time = 1.0)
* @alias This function has an alias function swoole_select().
* @see swoole_select()
*/
function swoole_client_select(array &$read_array, array &$write_array, array &$error_array, float $timeout = 0.5): int|false
function swoole_client_select(array &$read, array &$write, array &$except, float $timeout = 0.5): int|false
{
}

/**
* @alias This function is an alias of function swoole_client_select().
* @see swoole_client_select()
*/
function swoole_select(array &$read_array, array &$write_array, array &$error_array, float $timeout = 0.5): int|false
function swoole_select(array &$read, array &$write, array &$except, float $timeout = 0.5): int|false
{
}

Expand Down

0 comments on commit 8b35b19

Please sign in to comment.