]> granicus.if.org Git - php/commitdiff
Fix UNKNOWN default values in ext/spl
authorMáté Kocsis <kocsismate@woohoolabs.com>
Sun, 3 May 2020 11:19:44 +0000 (13:19 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Wed, 6 May 2020 17:15:39 +0000 (19:15 +0200)
ext/spl/php_spl.c
ext/spl/php_spl.stub.php
ext/spl/php_spl_arginfo.h

index 11fec690723ee73a15f183779970fa1cc8e32ef3..b6b04cb269f48301b01d01732ba9e25af9bc00e4 100644 (file)
@@ -310,12 +310,16 @@ PHP_FUNCTION(spl_autoload)
 {
        int pos_len, pos1_len;
        char *pos, *pos1;
-       zend_string *class_name, *lc_name, *file_exts = SPL_G(autoload_extensions);
+       zend_string *class_name, *lc_name, *file_exts = NULL;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|S", &class_name, &file_exts) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|S!", &class_name, &file_exts) == FAILURE) {
                RETURN_THROWS();
        }
 
+       if (!file_exts) {
+               file_exts = SPL_G(autoload_extensions);
+       }
+
        if (file_exts == NULL) { /* autoload_extensions is not initialized, set to defaults */
                pos = SPL_DEFAULT_FILE_EXTENSIONS;
                pos_len = sizeof(SPL_DEFAULT_FILE_EXTENSIONS) - 1;
@@ -347,9 +351,10 @@ PHP_FUNCTION(spl_autoload_extensions)
 {
        zend_string *file_exts = NULL;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &file_exts) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!", &file_exts) == FAILURE) {
                RETURN_THROWS();
        }
+
        if (file_exts) {
                if (SPL_G(autoload_extensions)) {
                        zend_string_release_ex(SPL_G(autoload_extensions), 0);
@@ -513,11 +518,11 @@ PHP_FUNCTION(spl_autoload_register)
        zend_object *obj_ptr;
        zend_fcall_info_cache fcc;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zbb", &zcallable, &do_throw, &prepend) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z!bb", &zcallable, &do_throw, &prepend) == FAILURE) {
                RETURN_THROWS();
        }
 
-       if (ZEND_NUM_ARGS()) {
+       if (zcallable) {
                if (!zend_is_callable_ex(zcallable, NULL, 0, &func_name, &fcc, &error)) {
                        alfi.ce = fcc.calling_scope;
                        alfi.func_ptr = fcc.function_handler;
index 8811e1913a2bef19b363a9723b269577606354a4..8e2a6edf0a93ea185bcdd885bb4b8fae1cd2806a 100755 (executable)
@@ -8,16 +8,16 @@ function class_parents($instance, bool $autoload = true): array|false {}
 
 function class_uses($what, bool $autoload = true): array|false {}
 
-function spl_autoload(string $class_name, string $file_extensions = UNKNOWN): void {}
+function spl_autoload(string $class_name, ?string $file_extensions = null): void {}
 
 // This silently ignores non-string class names
 function spl_autoload_call($class_name): void {}
 
-function spl_autoload_extensions(string $file_extensions = UNKNOWN): string {}
+function spl_autoload_extensions(?string $file_extensions = null): string {}
 
 function spl_autoload_functions(): array|false {}
 
-function spl_autoload_register($autoload_function = UNKNOWN, bool $throw = true, bool $prepend = false): bool {}
+function spl_autoload_register($autoload_function = null, bool $throw = true, bool $prepend = false): bool {}
 
 function spl_autoload_unregister($autoload_function): bool {}
 
index 0b19431fd45a72dbce914bfbd139e28d385f5160..f02c9d22e3284b4f41d8e9adfe5bab501cc8fc45 100644 (file)
@@ -14,7 +14,7 @@ ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_autoload, 0, 1, IS_VOID, 0)
        ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, file_extensions, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, file_extensions, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_autoload_call, 0, 1, IS_VOID, 0)
@@ -22,14 +22,14 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_autoload_call, 0, 1, IS_VOID
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_autoload_extensions, 0, 0, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, file_extensions, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, file_extensions, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_spl_autoload_functions, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_autoload_register, 0, 0, _IS_BOOL, 0)
-       ZEND_ARG_INFO(0, autoload_function)
+       ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, autoload_function, "null")
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, throw, _IS_BOOL, 0, "true")
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, prepend, _IS_BOOL, 0, "false")
 ZEND_END_ARG_INFO()