Skip to content

Commit 44192ce

Browse files
committed
Make Phar $fileNotFoundScript nullable
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.
1 parent 3549f48 commit 44192ce

13 files changed

+15
-15
lines changed

ext/phar/phar_object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ PHP_METHOD(Phar, webPhar)
552552
phar_entry_info *info = NULL;
553553
size_t sapi_mod_name_len = strlen(sapi_module.name);
554554

555-
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) {
555+
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) {
556556
RETURN_THROWS();
557557
}
558558

ext/phar/phar_object.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ final public static function mungServer(array $variables): void {}
174174
final public static function unlinkArchive(string $filename): bool {}
175175

176176
final public static function webPhar(
177-
?string $alias = null, ?string $index = null, string $fileNotFoundScript = "",
177+
?string $alias = null, ?string $index = null, ?string $fileNotFoundScript = null,
178178
array $mimeTypes = [], ?callable $rewrite = null): void {}
179179
}
180180

@@ -470,7 +470,7 @@ final public static function unlinkArchive(string $filename): bool {}
470470

471471
/** @implementation-alias Phar::webPhar */
472472
final public static function webPhar(
473-
?string $alias = null, ?string $index = null, string $fileNotFoundScript = "",
473+
?string $alias = null, ?string $index = null, ?string $fileNotFoundScript = null,
474474
array $mimeTypes = [], ?callable $rewrite = null): void {}
475475
}
476476

ext/phar/phar_object_arginfo.h

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

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
@@ -204,7 +204,7 @@ ZEND_END_ARG_INFO()
204204
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_webPhar, 0, 0, IS_VOID, 0)
205205
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, alias, IS_STRING, 1, "null")
206206
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, index, IS_STRING, 1, "null")
207-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fileNotFoundScript, IS_STRING, 0, "\"\"")
207+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fileNotFoundScript, IS_STRING, 1, "null")
208208
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mimeTypes, IS_ARRAY, 0, "[]")
209209
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, rewrite, IS_CALLABLE, 1, "null")
210210
ZEND_END_ARG_INFO()

ext/phar/tests/cache_list/frontcontroller12.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ Content-type: text/html; charset=UTF-8
1616
--EXPECTF--
1717
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
1818
Stack trace:
19-
#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
19+
#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
2020
#1 {main}
2121
thrown in %sfrontcontroller12.php on line 2

ext/phar/tests/cache_list/frontcontroller13.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ Content-type: text/html; charset=UTF-8
1616
--EXPECTF--
1717
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
1818
Stack trace:
19-
#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
19+
#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
2020
#1 {main}
2121
thrown in %sfrontcontroller13.php on line 2

ext/phar/tests/cache_list/frontcontroller31.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ files/frontcontroller16.phar
1515
--EXPECTF--
1616
Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #5 ($rewrite) must be a valid callback or null, class "fail" not found in %s:%d
1717
Stack trace:
18-
#0 %s(%d): Phar::webPhar('test.phar', '/index.php', '', Array, Array)
18+
#0 %s(%d): Phar::webPhar('test.phar', '/index.php', NULL, Array, Array)
1919
#1 {main}
2020
thrown in %s on line %d

ext/phar/tests/frontcontroller12.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ Content-type: text/html; charset=UTF-8
1515
--EXPECTF--
1616
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
1717
Stack trace:
18-
#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
18+
#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
1919
#1 {main}
2020
thrown in %sfrontcontroller12.php on line 2

ext/phar/tests/frontcontroller13.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ Content-type: text/html; charset=UTF-8
1515
--EXPECTF--
1616
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
1717
Stack trace:
18-
#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
18+
#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
1919
#1 {main}
2020
thrown in %sfrontcontroller13.php on line 2

ext/phar/tests/frontcontroller31.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ files/frontcontroller16.phar
1414
--EXPECTF--
1515
Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #5 ($rewrite) must be a valid callback or null, class "fail" not found in %s:%d
1616
Stack trace:
17-
#0 %s(%d): Phar::webPhar('test.phar', '/index.php', '', Array, Array)
17+
#0 %s(%d): Phar::webPhar('test.phar', '/index.php', NULL, Array, Array)
1818
#1 {main}
1919
thrown in %s on line %d

ext/phar/tests/tar/frontcontroller12.phar.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ Content-type: text/html; charset=UTF-8
1515
--EXPECTF--
1616
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
1717
Stack trace:
18-
#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
18+
#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
1919
#1 {main}
2020
thrown in %sfrontcontroller12.phar.php on line 2

ext/phar/tests/tar/frontcontroller13.phar.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ Content-type: text/html; charset=UTF-8
1515
--EXPECTF--
1616
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
1717
Stack trace:
18-
#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
18+
#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
1919
#1 {main}
2020
thrown in %sfrontcontroller13.phar.php on line 2

ext/phar/tests/zip/frontcontroller12.phar.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ Content-type: text/html; charset=UTF-8
1717
--EXPECTF--
1818
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
1919
Stack trace:
20-
#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
20+
#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
2121
#1 {main}
2222
thrown in %sfrontcontroller12.phar.php on line 2

ext/phar/tests/zip/frontcontroller13.phar.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ Content-type: text/html; charset=UTF-8
1717
--EXPECTF--
1818
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
1919
Stack trace:
20-
#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
20+
#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array)
2121
#1 {main}
2222
thrown in %sfrontcontroller13.phar.php on line 2

0 commit comments

Comments
 (0)