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.
This commit is contained in:
Nikita Popov 2021-02-10 12:18:42 +01:00
parent ce7935e82a
commit fd5ff37db7
3 changed files with 5 additions and 5 deletions

View file

@ -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();
}

View file

@ -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

View file

@ -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)