Skip to content

Commit 6a0827e

Browse files
committed
ext/ftp: declare the false returned by ftp_nb_fget() and ftp_nb_fput()
Both answer an already busy connection with a warning and RETURN_FALSE, the same guard ftp_nb_get() and ftp_nb_put() have, and those two already declare int|false.
1 parent 78c33e0 commit 6a0827e

4 files changed

Lines changed: 30 additions & 5 deletions

File tree

‎UPGRADING‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,11 @@ PHP 8.6 UPGRADE NOTES
645645
null was never returned. filter_input_array() is unaffected: it still
646646
returns null when the requested superglobal does not exist.
647647

648+
- FTP:
649+
. ftp_nb_fget() and ftp_nb_fput() return type has been widened from int to
650+
int|false, matching ftp_nb_get() and ftp_nb_put(). All four return false
651+
when the connection is already in use.
652+
648653
- GMP:
649654
. gmp_fact() now throws a ValueError if $num does not fit into an unsigned
650655
long.

‎ext/ftp/ftp.stub.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function ftp_systype(FTP\Connection $ftp): string|false {}
107107
function ftp_fget(FTP\Connection $ftp, $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): bool {}
108108

109109
/** @param resource $stream */
110-
function ftp_nb_fget(FTP\Connection $ftp, $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): int {}
110+
function ftp_nb_fget(FTP\Connection $ftp, $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): int|false {}
111111
function ftp_pasv(FTP\Connection $ftp, bool $enable): bool {}
112112
function ftp_get(FTP\Connection $ftp, string $local_filename, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): bool {}
113113
function ftp_nb_get(FTP\Connection $ftp, string $local_filename, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): int|false {}
@@ -117,7 +117,7 @@ function ftp_nb_continue(FTP\Connection $ftp): int {}
117117
function ftp_fput(FTP\Connection $ftp, string $remote_filename, $stream, int $mode = FTP_BINARY, int $offset = 0): bool {}
118118

119119
/** @param resource $stream */
120-
function ftp_nb_fput(FTP\Connection $ftp, string $remote_filename, $stream, int $mode = FTP_BINARY, int $offset = 0): int {}
120+
function ftp_nb_fput(FTP\Connection $ftp, string $remote_filename, $stream, int $mode = FTP_BINARY, int $offset = 0): int|false {}
121121
function ftp_put(FTP\Connection $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): bool {}
122122
function ftp_append(FTP\Connection $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY): bool {}
123123
function ftp_nb_put(FTP\Connection $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): int|false {}

‎ext/ftp/ftp_arginfo.h‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
The non-blocking transfer functions declare the false their in_use guard returns
3+
--EXTENSIONS--
4+
ftp
5+
--FILE--
6+
<?php
7+
8+
/* ftp_nb_fget(), ftp_nb_get(), ftp_nb_fput() and ftp_nb_put() all answer an
9+
* already busy connection with false; ftp_nb_continue() has no such guard. */
10+
foreach (['ftp_nb_fget', 'ftp_nb_get', 'ftp_nb_fput', 'ftp_nb_put', 'ftp_nb_continue'] as $function) {
11+
printf("%-17s %s\n", $function, (new ReflectionFunction($function))->getReturnType());
12+
}
13+
14+
?>
15+
--EXPECT--
16+
ftp_nb_fget int|false
17+
ftp_nb_get int|false
18+
ftp_nb_fput int|false
19+
ftp_nb_put int|false
20+
ftp_nb_continue int

0 commit comments

Comments
 (0)