diff --git a/NEWS b/NEWS index 18c343a7b11..28575db948d 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,10 @@ PHP NEWS . Fixed bug #81585 (cached_chunks are not counted to real_size on shutdown). (cmb) +- Hash: + . Fixed bug GH-7759 (Incorrect return types for hash() and hash_hmac()). + (cmb) + - MBString: . Fixed bug #81693 (mb_check_encoding(7bit) segfaults). (cmb) diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 0e18481f407..d0d54989dc7 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -171,9 +171,9 @@ static const func_info_t func_infos[] = { F1("gmp_sqrtrem", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT), F1("gmp_rootrem", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT), F1("gmp_gcdext", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_OBJECT), - F1("hash", MAY_BE_STRING|MAY_BE_FALSE), + F1("hash", MAY_BE_STRING), F1("hash_file", MAY_BE_STRING|MAY_BE_FALSE), - F1("hash_hmac", MAY_BE_STRING|MAY_BE_FALSE), + F1("hash_hmac", MAY_BE_STRING), F1("hash_hmac_file", MAY_BE_STRING|MAY_BE_FALSE), F1("hash_init", MAY_BE_OBJECT), F1("hash_final", MAY_BE_STRING), diff --git a/ext/hash/hash.stub.php b/ext/hash/hash.stub.php index cbe0ed55596..ce439d620fd 100644 --- a/ext/hash/hash.stub.php +++ b/ext/hash/hash.stub.php @@ -3,13 +3,13 @@ /** @generate-class-entries */ /** @refcount 1 */ -function hash(string $algo, string $data, bool $binary = false, array $options = []): string|false {} +function hash(string $algo, string $data, bool $binary = false, array $options = []): string {} /** @refcount 1 */ function hash_file(string $algo, string $filename, bool $binary = false, array $options = []): string|false {} /** @refcount 1 */ -function hash_hmac(string $algo, string $data, string $key, bool $binary = false): string|false {} +function hash_hmac(string $algo, string $data, string $key, bool $binary = false): string {} /** @refcount 1 */ function hash_hmac_file(string $algo, string $data, string $key, bool $binary = false): string|false {} diff --git a/ext/hash/hash_arginfo.h b/ext/hash/hash_arginfo.h index 0b9d151b310..5a8758bfa2d 100644 --- a/ext/hash/hash_arginfo.h +++ b/ext/hash/hash_arginfo.h @@ -1,7 +1,7 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: d0ed07f608581a5700a10ec53a817ca788ef9638 */ + * Stub hash: 715957cf1785912eed75ce92c2a2708defe1ebd7 */ -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash, 0, 2, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary, _IS_BOOL, 0, "false") @@ -15,14 +15,19 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash_file, 0, 2, MAY_BE_STRING|M ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash_hmac, 0, 3, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_hmac, 0, 3, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() -#define arginfo_hash_hmac_file arginfo_hash_hmac +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash_hmac_file, 0, 3, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary, _IS_BOOL, 0, "false") +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_hash_init, 0, 1, HashContext, 0) ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)