From: George Peter Banyard Date: Wed, 11 Dec 2019 22:59:13 +0000 (+0100) Subject: Return empty string instead of NULL in serialize(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4782e8e28a0fa21a93a65cbf32a4021cc59bddf3;p=php Return empty string instead of NULL in serialize(). Modifiy its return type accordingly and arginfo. --- diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 88ff210d72..75eeaffedf 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1295,7 +1295,7 @@ function var_export($value, bool $return = false): ?string {} function debug_zval_dump($value, ...$value): void {} /** @param mixed $value */ -function serialize($value): ?string {} +function serialize($value): string {} /** @return mixed */ function unserialize(string $value, array $options = []) {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 74f3ee3998..0ffd3e7ee6 100755 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1940,7 +1940,7 @@ ZEND_END_ARG_INFO() #define arginfo_debug_zval_dump arginfo_var_dump -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_serialize, 0, 1, IS_STRING, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_serialize, 0, 1, IS_STRING, 0) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() diff --git a/ext/standard/var.c b/ext/standard/var.c index bbaf6cde22..cd5ceda889 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -1138,7 +1138,7 @@ PHPAPI void php_var_serialize_destroy(php_serialize_data_t d) { } } -/* {{{ proto string|null serialize(mixed variable) +/* {{{ proto string serialize(mixed variable) Returns a string representation of variable (which can later be unserialized) */ PHP_FUNCTION(serialize) { @@ -1162,7 +1162,7 @@ PHP_FUNCTION(serialize) if (buf.s) { RETURN_NEW_STR(buf.s); } else { - RETURN_NULL(); + RETURN_EMPTY_STRING(); } } /* }}} */