1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Change long2ip return type (#13395)

This commit is contained in:
Jorg Adam Sowa
2024-02-16 17:11:18 +01:00
committed by GitHub
parent eaaffae555
commit e7b1f2a95b
5 changed files with 12 additions and 9 deletions

View File

@@ -468,7 +468,7 @@ static const func_info_t func_infos[] = {
FN("array_rand", MAY_BE_LONG|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING),
F1("base64_encode", MAY_BE_STRING),
F1("base64_decode", MAY_BE_STRING|MAY_BE_FALSE),
F1("long2ip", MAY_BE_STRING|MAY_BE_FALSE),
F1("long2ip", MAY_BE_STRING),
F1("getenv", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("getopt", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_FALSE|MAY_BE_FALSE),
#if defined(HAVE_NANOSLEEP)

View File

@@ -643,11 +643,10 @@ PHP_FUNCTION(long2ip)
ip = (zend_ulong)sip;
myaddr.s_addr = htonl(ip);
if (inet_ntop(AF_INET, &myaddr, str, sizeof(str))) {
RETURN_STRING(str);
} else {
RETURN_FALSE;
}
const char* result = inet_ntop(AF_INET, &myaddr, str, sizeof(str));
ZEND_ASSERT(result != NULL);
RETURN_STRING(str);
}
/* }}} */

View File

@@ -1945,7 +1945,7 @@ function constant(string $name): mixed {}
function ip2long(string $ip): int|false {}
/** @refcount 1 */
function long2ip(int $ip): string|false {}
function long2ip(int $ip): string {}
/**
* @return string|array<string, string>|false

View File

@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 0bd0ac5d23881670cac81cda3e274cbee1e9a8dc */
* Stub hash: 1350cc5169dbd48df08513f01c10d5706d47b8d4 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
@@ -381,7 +381,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ip2long, 0, 1, MAY_BE_LONG|MAY_B
ZEND_ARG_TYPE_INFO(0, ip, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_long2ip, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_long2ip, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, ip, IS_LONG, 0)
ZEND_END_ARG_INFO()

View File

@@ -26,6 +26,8 @@ var_dump(ip2long("777.777.777.777"));
var_dump(ip2long("111.111.111.111"));
var_dump(long2ip(-110000));
var_dump(long2ip(PHP_INT_MAX));
var_dump(long2ip(PHP_INT_MIN));
echo "Done\n";
?>
@@ -46,4 +48,6 @@ bool(false)
bool(false)
int(1869573999)
string(13) "255.254.82.80"
string(15) "255.255.255.255"
string(7) "0.0.0.0"
Done