Skip to content

Commit

Permalink
Merge branch 'main' into 0.3x
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Mar 13, 2023
2 parents 2d0c045 + f4d1cbf commit eb5c963
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
12 changes: 12 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins:
- jekyll-relative-links
relative_links:
enabled: true
collections: true
include:
- README.md
- LICENSE.md
- ISSUE_TEMPLATE.md
- PULL_REQUEST_TEMPLATE.md

theme: jekyll-theme-dinky
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"require": {
"php": ">7.4",
"ext-ffi": "*",
"symplely/zend-ffi": "~0.12.3"
"symplely/zend-ffi": "~0.12.5"
},
"autoload": {
"files": [
Expand Down
7 changes: 7 additions & 0 deletions src/UVFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function uv_run(\UVLoop $loop = null, int $mode = \UV::RUN_DEFAULT): void
*
* @return void
* @deprecated 1.0
* @codeCoverageIgnore
*/
function uv_loop_delete(\UVLoop $loop): void
{
Expand All @@ -110,6 +111,7 @@ function uv_loop_delete(\UVLoop $loop): void
*
* @return void
* @link http://docs.libuv.org/en/v1.x/misc.html?highlight=file%20to%20fd#c.uv_library_shutdown
* @codeCoverageIgnore
*/
function uv_library_shutdown(): void
{
Expand Down Expand Up @@ -245,6 +247,7 @@ function uv_async_send(\UVAsync $handle)
* @param integer $write_flags
* @return array<resource,resource>|int
* @link http://docs.libuv.org/en/v1.x/pipe.html?highlight=uv_pipe_bind#c.uv_pipe
* @codeCoverageIgnore
*/
function uv_pipe(int $read_flags = \UV::NONBLOCK_PIPE, int $write_flags = \UV::NONBLOCK_PIPE)
{
Expand Down Expand Up @@ -689,6 +692,7 @@ function uv_tcp_connect6(\UVTcp $handle, \UVSockAddrIPv6 $ipv6_addr, callable $c
* @param string $filename
* @return UVLib|int
* @link http://docs.libuv.org/en/v1.x/dll.html?highlight=uv_lib_t#c.uv_dlopen
* @codeCoverageIgnore
*/
function uv_dlopen(string $filename)
{
Expand All @@ -701,6 +705,7 @@ function uv_dlopen(string $filename)
* @param UVLib $lib
* @return void
* @link http://docs.libuv.org/en/v1.x/dll.html?highlight=uv_lib_t#c.uv_dlclose
* @codeCoverageIgnore
*/
function uv_dlclose(\UVLib $lib)
{
Expand All @@ -716,6 +721,7 @@ function uv_dlclose(\UVLib $lib)
* @param string $symbol
* @return object|int definition
* @link http://docs.libuv.org/en/v1.x/dll.html?highlight=uv_lib_t#c.uv_dlsym
* @codeCoverageIgnore
*/
function uv_dlsym(\UVLib $lib, string $symbol)
{
Expand All @@ -728,6 +734,7 @@ function uv_dlsym(\UVLib $lib, string $symbol)
* @param \UVLib $lib
* @return string
* @link http://docs.libuv.org/en/v1.x/dll.html?highlight=uv_lib_t#c.uv_dlerror
* @codeCoverageIgnore
*/
function uv_dlerror(\UVLib $lib)
{
Expand Down
31 changes: 14 additions & 17 deletions src/UVHandles.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public function stop(): void
\zval_del_ref($this);
}

/**
* @codeCoverageIgnore
*/
public function delete(): void
{
\uv_destruct_set();
Expand Down Expand Up @@ -232,6 +235,9 @@ function (CData $stream, int $nRead, CData $data) use ($callback, $handle) {
*/
final class UVPipe extends \UVStream
{
/**
* @codeCoverageIgnore
*/
protected function emulated($io): void
{
$pipe = new static('struct _php_uv_s', 'pipe');
Expand Down Expand Up @@ -278,10 +284,12 @@ public function open($pipe, bool $emulated = true)
if (\get_resource_type($io) === 'uv_pipe') {
$io = \resource_get_fd((int)$pipe, false, true)[0];
} elseif (\IS_WINDOWS && $emulated) {
// @codeCoverageIgnoreStart
$which = ($io === \STDOUT || $io === \STDERR) ? 1 : 0;
$pipe = static::pair(\UV::NONBLOCK_PIPE, \UV::NONBLOCK_PIPE, false);
$io = $pipe[$which];
$isPipeEmulated = true;
// @codeCoverageIgnoreEnd
} else {
$io = \get_fd_resource($pipe, 'uv_file');
}
Expand Down Expand Up @@ -313,6 +321,7 @@ function (CData $connect, int $status) use ($callback, $req) {
* @param int $write_flags
* @param boolean $getResource
* @return array<resource,resource>|int
* @codeCoverageIgnore
*/
public static function pair(
int $read_flags = \UV::NONBLOCK_PIPE,
Expand Down Expand Up @@ -1041,8 +1050,6 @@ public function spawn(
int $flags = \UV::PROCESS_WINDOWS_HIDE,
array $uid_gid = []
) {
$h = \zval_stack(2);

$process_options = \c_struct_type('uv_process_options_s', 'uv');
$process_options->memset(0, $process_options->sizeof());

Expand Down Expand Up @@ -1071,19 +1078,8 @@ public function spawn(
}
$this->streams = $streams;

/* process args */
$n = 0;
$hash_len = $h->macro(\ZE::ARRVAL_P)->nNumOfElements;
$commands = \ffi_char($command);
$command_args = \FFI::new('char*[' . ($hash_len + 2) . ']', false);
$command_args[$n] = $commands;

$n++;
foreach ($args as $value) {
$command_args[$n] = \ffi_char($value);
$n++;
}
$command_args[$n] = NULL;
\array_unshift($args, $command);
$command_args = \ffi_char_variadic(...$args);

/* process env */
$i = 0;
Expand All @@ -1100,7 +1096,7 @@ public function spawn(
$gid = \IS_LINUX && \array_key_exists('gid', $uid_gid) ? $uid_gid['gid'] : null;

$options = $process_options();
$options->file = $commands;
$options->file = $command_args[0];
$options->stdio = \uv_cast('uv_stdio_container_t*', $container);
$options->exit_cb = function (CData $process, int $exit_status, int $term_signal) use ($callback, $process_options) {
if (!\is_null($callback)) {
Expand All @@ -1116,7 +1112,7 @@ public function spawn(

$options->stdio_count = $stdio_count;
$options->env = \FFI::cast('char**', $zenv);
$options->args = \FFI::cast('char**', $command_args);
$options->args = $command_args;

if (\is_null($cwd)) {
$cwd = \uv_cwd();
Expand Down Expand Up @@ -2327,6 +2323,7 @@ public static function cpu_info()
* Provides cross platform way of loading shared libraries and retrieving a `symbol` from them.
*
* @return symbol _definition_ **pointer** by invoking `$UVLib()`
* @codeCoverageIgnore
*/
final class UVLib extends \UVTypes
{
Expand Down
2 changes: 1 addition & 1 deletion src/ext_uv.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function module_clear(): void

public function module_shutdown(int $type, int $module_number): int
{
if (!$this->module_destructor_linked) {
if (!$this->destructor_linked) {
$this->module_clear();
}

Expand Down

0 comments on commit eb5c963

Please sign in to comment.