]> granicus.if.org Git - php/commitdiff
Make Phar $fileNotFoundScript nullable
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 9 Feb 2021 11:55:33 +0000 (12:55 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 9 Feb 2021 11:55:33 +0000 (12:55 +0100)
While "" is already treated the same way as absence, null is the
logically correct default here. Making this one argument non-nullable
is particularly pecular when considering that the preceding $alias
and $index arguments are both nullable.

13 files changed:
ext/phar/phar_object.c
ext/phar/phar_object.stub.php
ext/phar/phar_object_arginfo.h
ext/phar/tests/cache_list/frontcontroller12.phpt
ext/phar/tests/cache_list/frontcontroller13.phpt
ext/phar/tests/cache_list/frontcontroller31.phpt
ext/phar/tests/frontcontroller12.phpt
ext/phar/tests/frontcontroller13.phpt
ext/phar/tests/frontcontroller31.phpt
ext/phar/tests/tar/frontcontroller12.phar.phpt
ext/phar/tests/tar/frontcontroller13.phar.phpt
ext/phar/tests/zip/frontcontroller12.phar.phpt
ext/phar/tests/zip/frontcontroller13.phar.phpt

index e45c187efa4bb3ce51b9e39cdbf91e9072e4255b..5fe9e26af0b92923dc1613bfcfa67595703ca31c 100644 (file)
@@ -552,7 +552,7 @@ PHP_METHOD(Phar, webPhar)
        phar_entry_info *info = NULL;
        size_t sapi_mod_name_len = strlen(sapi_module.name);
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!saf!", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite_fci, &rewrite_fcc) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!af!", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite_fci, &rewrite_fcc) == FAILURE) {
                RETURN_THROWS();
        }
 
index 31663e4b8c68798091a95c3a16298b18a62baf7f..5a1122c74ffce03d13313809a6375816a3e1880f 100644 (file)
@@ -174,7 +174,7 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess
     final public static function unlinkArchive(string $filename): bool {}
 
     final public static function webPhar(
-        ?string $alias = null, ?string $index = null, string $fileNotFoundScript = "",
+        ?string $alias = null, ?string $index = null, ?string $fileNotFoundScript = null,
         array $mimeTypes = [], ?callable $rewrite = null): void {}
 }
 
@@ -470,7 +470,7 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc
 
     /** @implementation-alias Phar::webPhar */
     final public static function webPhar(
-        ?string $alias = null, ?string $index = null, string $fileNotFoundScript = "",
+        ?string $alias = null, ?string $index = null, ?string $fileNotFoundScript = null,
         array $mimeTypes = [], ?callable $rewrite = null): void {}
 }
 
index dd4b8aba7590b4049f60fc606b8155657304d132..ade8f874abae9e4d508016cb1da84d6b6eb12c3c 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 3575a0330ff6102461655bc84add44e8b08b585f */
+ * Stub hash: a8562e63010e127aadb97134733ac328ced3c7bf */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1)
        ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
@@ -204,7 +204,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_webPhar, 0, 0, IS_VOID, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, alias, IS_STRING, 1, "null")
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, index, IS_STRING, 1, "null")
-       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fileNotFoundScript, IS_STRING, 0, "\"\"")
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fileNotFoundScript, IS_STRING, 1, "null")
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mimeTypes, IS_ARRAY, 0, "[]")
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, rewrite, IS_CALLABLE, 1, "null")
 ZEND_END_ARG_INFO()
index 8b78e62c9cd5b508fd2c3e644bd6645dce82350c..857b7dc875869f86cf6b16432049d2ca87083200 100644 (file)
@@ -16,6 +16,6 @@ Content-type: text/html; charset=UTF-8
 --EXPECTF--
 Fatal error: Uncaught PharException: Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller12.php:2
 Stack trace:
-#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
 #1 {main}
   thrown in %sfrontcontroller12.php on line 2
index 9d2f9105dac01f63ffc1d5186576bf11bdd0df26..ddbab34c07a3f8c3d698589eaed564e68905d424 100644 (file)
@@ -16,6 +16,6 @@ Content-type: text/html; charset=UTF-8
 --EXPECTF--
 Fatal error: Uncaught PharException: Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller13.php:2
 Stack trace:
-#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
 #1 {main}
   thrown in %sfrontcontroller13.php on line 2
index 41e36bf6699624abaadfe731138fd7fc11b65b55..3419bb381d6f5de06b59e8c10a6cbc64a3217da4 100644 (file)
@@ -15,6 +15,6 @@ files/frontcontroller16.phar
 --EXPECTF--
 Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #5 ($rewrite) must be a valid callback or null, class "fail" not found in %s:%d
 Stack trace:
-#0 %s(%d): Phar::webPhar('test.phar', '/index.php', '', Array, Array)
+#0 %s(%d): Phar::webPhar('test.phar', '/index.php', NULL, Array, Array)
 #1 {main}
   thrown in %s on line %d
index a7b1a892d6c3c8edc447cbf19a13d5b97d0c03cc..40bd8e333f97e94f37bfdcac4c7efc01e02d7c61 100644 (file)
@@ -15,6 +15,6 @@ Content-type: text/html; charset=UTF-8
 --EXPECTF--
 Fatal error: Uncaught PharException: Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller12.php:2
 Stack trace:
-#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
 #1 {main}
   thrown in %sfrontcontroller12.php on line 2
index 99b769d40630174876b0bc834a1f1f370aac66c0..60d5709c6f35197065a358cc88ecb52914171bd0 100644 (file)
@@ -15,6 +15,6 @@ Content-type: text/html; charset=UTF-8
 --EXPECTF--
 Fatal error: Uncaught PharException: Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller13.php:2
 Stack trace:
-#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
 #1 {main}
   thrown in %sfrontcontroller13.php on line 2
index 721df4849cf48beb8e18b8a232fb758a643beeef..121a9389ee8d7cdf2cec23293731472c2a3b8c89 100644 (file)
@@ -14,6 +14,6 @@ files/frontcontroller16.phar
 --EXPECTF--
 Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #5 ($rewrite) must be a valid callback or null, class "fail" not found in %s:%d
 Stack trace:
-#0 %s(%d): Phar::webPhar('test.phar', '/index.php', '', Array, Array)
+#0 %s(%d): Phar::webPhar('test.phar', '/index.php', NULL, Array, Array)
 #1 {main}
   thrown in %s on line %d
index cbb928ff77e91af7e110efb301b09cf382d1f7fa..cec426b05aef70d1d84bfb5e60b4d48edbf6996a 100644 (file)
@@ -15,6 +15,6 @@ Content-type: text/html; charset=UTF-8
 --EXPECTF--
 Fatal error: Uncaught PharException: Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller12.phar.php:2
 Stack trace:
-#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
 #1 {main}
   thrown in %sfrontcontroller12.phar.php on line 2
index 107961a70fbe7cd86f932ea1c516d9a01d7ad7fe..7d9992cb9d8a35caa406666eb5320f881eff6dfb 100644 (file)
@@ -15,6 +15,6 @@ Content-type: text/html; charset=UTF-8
 --EXPECTF--
 Fatal error: Uncaught PharException: Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller13.phar.php:2
 Stack trace:
-#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
 #1 {main}
   thrown in %sfrontcontroller13.phar.php on line 2
index 9f5b0a13aa988d59130086e54156dff3f1a16112..2169264b64907c74f75368a20df665bd0621da98 100644 (file)
@@ -17,6 +17,6 @@ Content-type: text/html; charset=UTF-8
 --EXPECTF--
 Fatal error: Uncaught PharException: Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller12.phar.php:2
 Stack trace:
-#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
 #1 {main}
   thrown in %sfrontcontroller12.phar.php on line 2
index 5d2a77e4ac255b95603d449aa987c9d3fca06b9b..c9c72a7a60247940831e303b9028275031628e2a 100644 (file)
@@ -17,6 +17,6 @@ Content-type: text/html; charset=UTF-8
 --EXPECTF--
 Fatal error: Uncaught PharException: Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller13.phar.php:2
 Stack trace:
-#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
 #1 {main}
   thrown in %sfrontcontroller13.phar.php on line 2