]> granicus.if.org Git - php/commitdiff
Make finfo_open() $magic_database nullable
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 10 Feb 2021 11:18:42 +0000 (12:18 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 10 Feb 2021 11:18:42 +0000 (12:18 +0100)
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
ext/fileinfo/fileinfo.stub.php
ext/fileinfo/fileinfo_arginfo.h

index add971b6d643cb8fa21151da563773dda9ce2c1b..cfb933bdb8ab2718de71e1c996ed0c2a43935453 100644 (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();
        }
 
index 9355a96a2b192bfad2b20ec5110868f9a743c7ec..4ed4e445f1c2756141859547375fe1d8a188e186 100644 (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
index 80850a6502e6117819a29f96eebae7efa6c6f4e9..34b369884248b236caa3e6abb590009354b76ee7 100644 (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)