Skip to content

Commit 4782e8e

Browse files
committed
Return empty string instead of NULL in serialize().
Modifiy its return type accordingly and arginfo.
1 parent 15340be commit 4782e8e

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

ext/standard/basic_functions.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ function var_export($value, bool $return = false): ?string {}
12951295
function debug_zval_dump($value, ...$value): void {}
12961296

12971297
/** @param mixed $value */
1298-
function serialize($value): ?string {}
1298+
function serialize($value): string {}
12991299

13001300
/** @return mixed */
13011301
function unserialize(string $value, array $options = []) {}

ext/standard/basic_functions_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1940,7 +1940,7 @@ ZEND_END_ARG_INFO()
19401940

19411941
#define arginfo_debug_zval_dump arginfo_var_dump
19421942

1943-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_serialize, 0, 1, IS_STRING, 1)
1943+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_serialize, 0, 1, IS_STRING, 0)
19441944
ZEND_ARG_INFO(0, value)
19451945
ZEND_END_ARG_INFO()
19461946

ext/standard/var.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ PHPAPI void php_var_serialize_destroy(php_serialize_data_t d) {
11381138
}
11391139
}
11401140

1141-
/* {{{ proto string|null serialize(mixed variable)
1141+
/* {{{ proto string serialize(mixed variable)
11421142
Returns a string representation of variable (which can later be unserialized) */
11431143
PHP_FUNCTION(serialize)
11441144
{
@@ -1162,7 +1162,7 @@ PHP_FUNCTION(serialize)
11621162
if (buf.s) {
11631163
RETURN_NEW_STR(buf.s);
11641164
} else {
1165-
RETURN_NULL();
1165+
RETURN_EMPTY_STRING();
11661166
}
11671167
}
11681168
/* }}} */

0 commit comments

Comments
 (0)