Skip to content

Commit fd5ff37

Browse files
committed
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.
1 parent ce7935e commit fd5ff37

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

ext/fileinfo/fileinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ PHP_FUNCTION(finfo_open)
215215
char resolved_path[MAXPATHLEN];
216216
zend_error_handling zeh;
217217

218-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lp", &options, &file, &file_len) == FAILURE) {
218+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lp!", &options, &file, &file_len) == FAILURE) {
219219
RETURN_THROWS();
220220
}
221221

ext/fileinfo/fileinfo.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class finfo
66
{
77
/** @alias finfo_open */
8-
public function __construct(int $flags = FILEINFO_NONE, string $magic_database = "") {}
8+
public function __construct(int $flags = FILEINFO_NONE, ?string $magic_database = null) {}
99

1010
/**
1111
* @param resource|null $context
@@ -29,7 +29,7 @@ public function set_flags(int $flags) {}
2929
}
3030

3131
/** @return resource|false */
32-
function finfo_open(int $flags = FILEINFO_NONE, string $magic_database = "") {}
32+
function finfo_open(int $flags = FILEINFO_NONE, ?string $magic_database = null) {}
3333

3434
/**
3535
* @param resource $finfo

ext/fileinfo/fileinfo_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: be858509df27550b51d8a7a51a3629eceb6d0aa6 */
2+
* Stub hash: 648085986695281bd5a8fb536d5ec6c2a9f8c6e8 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_open, 0, 0, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "FILEINFO_NONE")
6-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, magic_database, IS_STRING, 0, "\"\"")
6+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, magic_database, IS_STRING, 1, "null")
77
ZEND_END_ARG_INFO()
88

99
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_finfo_close, 0, 1, _IS_BOOL, 0)

0 commit comments

Comments
 (0)