From fd5ff37db77b52b39d97c5749dcbbf4b09c10d9d Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 10 Feb 2021 12:18:42 +0100 Subject: [PATCH] Make finfo_open() $magic_database nullable Empty string was interpreted as a special value here, which indicates that the default magic database should be used. It makes more sense to use null for this purpose. The documentation also explicitly mentions that null can be used. --- ext/fileinfo/fileinfo.c | 2 +- ext/fileinfo/fileinfo.stub.php | 4 ++-- ext/fileinfo/fileinfo_arginfo.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c index add971b6d64..cfb933bdb8a 100644 --- a/ext/fileinfo/fileinfo.c +++ b/ext/fileinfo/fileinfo.c @@ -215,7 +215,7 @@ PHP_FUNCTION(finfo_open) char resolved_path[MAXPATHLEN]; zend_error_handling zeh; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lp", &options, &file, &file_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lp!", &options, &file, &file_len) == FAILURE) { RETURN_THROWS(); } diff --git a/ext/fileinfo/fileinfo.stub.php b/ext/fileinfo/fileinfo.stub.php index 9355a96a2b1..4ed4e445f1c 100644 --- a/ext/fileinfo/fileinfo.stub.php +++ b/ext/fileinfo/fileinfo.stub.php @@ -5,7 +5,7 @@ class finfo { /** @alias finfo_open */ - public function __construct(int $flags = FILEINFO_NONE, string $magic_database = "") {} + public function __construct(int $flags = FILEINFO_NONE, ?string $magic_database = null) {} /** * @param resource|null $context @@ -29,7 +29,7 @@ class finfo } /** @return resource|false */ -function finfo_open(int $flags = FILEINFO_NONE, string $magic_database = "") {} +function finfo_open(int $flags = FILEINFO_NONE, ?string $magic_database = null) {} /** * @param resource $finfo diff --git a/ext/fileinfo/fileinfo_arginfo.h b/ext/fileinfo/fileinfo_arginfo.h index 80850a6502e..34b36988424 100644 --- a/ext/fileinfo/fileinfo_arginfo.h +++ b/ext/fileinfo/fileinfo_arginfo.h @@ -1,9 +1,9 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: be858509df27550b51d8a7a51a3629eceb6d0aa6 */ + * Stub hash: 648085986695281bd5a8fb536d5ec6c2a9f8c6e8 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_open, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "FILEINFO_NONE") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, magic_database, IS_STRING, 0, "\"\"") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, magic_database, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_finfo_close, 0, 1, _IS_BOOL, 0)