]> granicus.if.org Git - php/commitdiff
Move custom type checks to ZPP
authorMáté Kocsis <kocsismate@woohoolabs.com>
Mon, 24 Aug 2020 18:42:29 +0000 (20:42 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Wed, 2 Sep 2020 09:11:38 +0000 (11:11 +0200)
Closes GH-6034

19 files changed:
Zend/zend_operators.c
ext/mbstring/mbstring.c
ext/mbstring/mbstring.stub.php
ext/mbstring/mbstring_arginfo.h
ext/oci8/oci8.stub.php
ext/oci8/oci8_arginfo.h
ext/odbc/odbc.stub.php
ext/odbc/odbc_arginfo.h
ext/odbc/php_odbc.c
ext/xml/tests/bug72714.phpt
ext/xml/tests/xml_parser_set_option_variation3.phpt
ext/xml/xml.c
ext/xsl/php_xsl.stub.php
ext/xsl/php_xsl_arginfo.h
ext/xsl/tests/xsltprocessor_setparameter-nostring.phpt
ext/xsl/xsltprocessor.c
ext/zip/php_zip.c
ext/zip/php_zip.stub.php
ext/zip/php_zip_arginfo.h

index 4d20d564648a299952161134bac36ac95e22bddb..e126f784cfead08d4c717ddb3d8652c8e3e49a77 100644 (file)
@@ -816,7 +816,7 @@ try_again:
                                } else {
                                        /* Previously we used strtol here, not is_numeric_string,
                                         * and strtol gives you LONG_MAX/_MIN on overflow.
-                                        * We use use saturating conversion to emulate strtol()'s
+                                        * We use saturating conversion to emulate strtol()'s
                                         * behaviour.
                                         */
                                         return zend_dval_to_lval_cap(dval);
index 1fba2db34c0a574b9bc6c63ebf23f388531c300a..13031d90d3e39c726871701cfe9cc01d491f6989 100644 (file)
@@ -3513,8 +3513,8 @@ PHP_FUNCTION(mb_send_mail)
        size_t message_len;
        char *subject;
        size_t subject_len;
-       zval *headers = NULL;
        zend_string *extra_cmd = NULL;
+       HashTable *headers_ht = NULL;
        zend_string *str_headers = NULL, *tmp_headers;
        size_t n, i;
        char *to_r = NULL;
@@ -3560,30 +3560,24 @@ PHP_FUNCTION(mb_send_mail)
                Z_PARAM_STRING(subject, subject_len)
                Z_PARAM_STRING(message, message_len)
                Z_PARAM_OPTIONAL
-               Z_PARAM_ZVAL(headers)
-               Z_PARAM_STR(extra_cmd)
+               Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(str_headers, headers_ht)
+               Z_PARAM_STR_OR_NULL(extra_cmd)
        ZEND_PARSE_PARAMETERS_END();
 
        /* ASCIIZ check */
        MAIL_ASCIIZ_CHECK_MBSTRING(to, to_len);
        MAIL_ASCIIZ_CHECK_MBSTRING(subject, subject_len);
        MAIL_ASCIIZ_CHECK_MBSTRING(message, message_len);
-       if (headers) {
-               switch(Z_TYPE_P(headers)) {
-                       case IS_STRING:
-                               tmp_headers = zend_string_init(Z_STRVAL_P(headers), Z_STRLEN_P(headers), 0);
-                               MAIL_ASCIIZ_CHECK_MBSTRING(ZSTR_VAL(tmp_headers), ZSTR_LEN(tmp_headers));
-                               str_headers = php_trim(tmp_headers, NULL, 0, 2);
-                               zend_string_release_ex(tmp_headers, 0);
-                               break;
-                       case IS_ARRAY:
-                               str_headers = php_mail_build_headers(Z_ARRVAL_P(headers));
-                               break;
-                       default:
-                               zend_argument_value_error(4, "must be of type string|array|null, %s given", zend_zval_type_name(headers));
-                               RETURN_THROWS();
-               }
+
+       if (str_headers) {
+               tmp_headers = zend_string_init(ZSTR_VAL(str_headers), ZSTR_LEN(str_headers), 0);
+               MAIL_ASCIIZ_CHECK_MBSTRING(ZSTR_VAL(tmp_headers), ZSTR_LEN(tmp_headers));
+               str_headers = php_trim(tmp_headers, NULL, 0, 2);
+               zend_string_release_ex(tmp_headers, 0);
+       } else if (headers_ht) {
+               str_headers = php_mail_build_headers(headers_ht);
        }
+
        if (extra_cmd) {
                MAIL_ASCIIZ_CHECK_MBSTRING(ZSTR_VAL(extra_cmd), ZSTR_LEN(extra_cmd));
        }
index 343a5d103d136d48449c291d57d13b27686d159a..d089c24c194cb8215bd682ec1079de673f9e3934 100644 (file)
@@ -77,8 +77,7 @@ function mb_encode_numericentity(string $string, array $convmap, ?string $encodi
 
 function mb_decode_numericentity(string $string, array $convmap, ?string $encoding = null): string {}
 
-/** @param string|array|null $additional_headers */
-function mb_send_mail(string $to, string $subject, string $message, $additional_headers = null, ?string $additional_parameters = null): bool {}
+function mb_send_mail(string $to, string $subject, string $message, array|string|null $additional_headers = null, ?string $additional_parameters = null): bool {}
 
 function mb_get_info(string $type = "all"): array|string|int|false {}
 
index 7267b943ef06e1683928cb361203c815970ae17f..873a0c86a45cc2975a638d69630cbf419b4f3e74 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 5ad8a8cf20eeae59713d19135ecccbee243754eb */
+ * Stub hash: 84096daa0fd395f57401f11e9e79f7c8420e8a93 */
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_language, 0, 0, MAY_BE_STRING|MAY_BE_BOOL)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, language, IS_STRING, 1, "null")
@@ -178,7 +178,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_send_mail, 0, 3, _IS_BOOL, 0)
        ZEND_ARG_TYPE_INFO(0, to, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO(0, subject, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0)
-       ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, additional_headers, "null")
+       ZEND_ARG_TYPE_MASK(0, additional_headers, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null")
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, additional_parameters, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
index 5c964c16f828c89c5745b1363b87cb3f57984426..7a17430dc0aeab2648ca1d0e8cc32b37b4b5a564 100644 (file)
@@ -266,7 +266,7 @@ function oci_fetch_all($statement_resource, &$output, int $skip = 0, int $maximu
 
 /**
  * @param resource $statement_resource
- * @param mixed $output
+ * @param array $output
  * @alias oci_fetch_all
  * @deprecated
  */
index 77638aa9a0e67afc23f43b20cc09670d06efbae0..729ac02240444b00500a796257d60abd971d3dbe 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: a5a245b354b48a56c274c8f74c974d92ec430853 */
+ * Stub hash: 447880a4bc4add36beab835cc07c09a254dc0c2b */
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0)
        ZEND_ARG_INFO(0, statement_resource)
index 89371024eb9cf2bcc4fc635799c78aad84ecee85..cb318f7ac9d4f75a92699f3e2f4dc644945b24bf 100644 (file)
@@ -57,11 +57,8 @@ function odbc_fetch_into($result_id, &$result_array, int $rownumber = 0): int|fa
 /** @param resource $result_id */
 function odbc_fetch_row($result_id, int $row_number = UNKNOWN): bool {}
 
-/**
- * @param resource $result_id
- * @param string|int $field
- */
-function odbc_result($result_id, $field): string|bool|null {}
+/** @param resource $result_id */
+function odbc_result($result_id, string|int $field): string|bool|null {}
 
 /** @param resource $result_id */
 function odbc_result_all($result_id, string $format = ''): int|false {}
index 2f5ffbe547af0f6f796f439443f0c11483af53c8..778ab242a0b104e4ffaacb54f78aa7154abbd4f2 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 14702a5bd87902871d456de2289f4ae236e5bfa5 */
+ * Stub hash: cf17952d8c3b88f218bbb8d1c21ba40079574c04 */
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_close_all, 0, 0, IS_VOID, 0)
 ZEND_END_ARG_INFO()
@@ -70,7 +70,7 @@ ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_result, 0, 2, MAY_BE_STRING|MAY_BE_BOOL|MAY_BE_NULL)
        ZEND_ARG_INFO(0, result_id)
-       ZEND_ARG_INFO(0, field)
+       ZEND_ARG_TYPE_MASK(0, field, MAY_BE_STRING|MAY_BE_LONG, NULL)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_result_all, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
index 7a4495f0d1f3bcc447c6026a7f2f25407d265c44..af62ecb29dada9a26bc5abf0dad60a11d4aa9948 100644 (file)
@@ -1736,31 +1736,31 @@ PHP_FUNCTION(odbc_fetch_row)
 PHP_FUNCTION(odbc_result)
 {
        char *field;
-       zend_string *field_str;
+       zend_string *field_str, *pv_field_str;
+       zend_long pv_field_long;
        int field_ind;
        SQLSMALLINT sql_c_type = SQL_C_CHAR;
        odbc_result *result;
        int i = 0;
        RETCODE rc;
        SQLLEN  fieldsize;
-       zval *pv_res, *pv_field;
+       zval *pv_res;
 #ifdef HAVE_SQL_EXTENDED_FETCH
        SQLULEN crow;
        SQLUSMALLINT RowStatus[1];
 #endif
 
-       field_ind = -1;
-       field = NULL;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz", &pv_res, &pv_field) == FAILURE) {
-               RETURN_THROWS();
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_RESOURCE(pv_res)
+               Z_PARAM_STR_OR_LONG(pv_field_str, pv_field_long)
+       ZEND_PARSE_PARAMETERS_END();
 
-       if (Z_TYPE_P(pv_field) == IS_STRING) {
-               field = Z_STRVAL_P(pv_field);
+       if (pv_field_str) {
+               field = ZSTR_VAL(pv_field_str);
+               field_ind = -1;
        } else {
-               convert_to_long_ex(pv_field);
-               field_ind = Z_LVAL_P(pv_field) - 1;
+               field = NULL;
+               field_ind = (int) pv_field_long - 1;
        }
 
        if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
index 53b923904534d437fffc0924afd9aaee4559e673..08fff0c06b16be53bd8f8073a1b089bba8be8143 100644 (file)
@@ -28,6 +28,6 @@ parse(3015809298423721);
 parse(20);
 ?>
 --EXPECTF--
-Notice: xml_parser_set_option(): tagstart ignored, because it is out of range in %s%ebug72714.php on line %d
+Warning: xml_parser_set_option(): tagstart ignored, because it is out of range in %s on line %d
 string(9) "NS1:TOTAL"
 string(0) ""
index b9d4b945e711208165b831cbe706ea35d03a1d73..592c9f52e80bcd90d5d61f6ee5107686216d2dfe 100644 (file)
@@ -77,9 +77,9 @@ $values = array(
 // loop through each element of the array for value
 
 foreach($values as $value) {
-      echo @"\nArg value $value \n";
-      var_dump( xml_parser_set_option($parser, $option, $value) );
-};
+  echo @"\nArg value $value \n";
+  var_dump(xml_parser_set_option($parser, $option, $value));
+}
 
 fclose($fp);
 xml_parser_free($parser);
index c670c2ef52e12ac173cc7e281811ad6ffac5daac..00f8798ad0875286c3b495fe533b1ee44c824f3a 100644 (file)
@@ -1427,7 +1427,7 @@ PHP_FUNCTION(xml_parser_set_option)
                case PHP_XML_OPTION_SKIP_TAGSTART:
                        parser->toffset = zval_get_long(val);
                        if (parser->toffset < 0) {
-                               php_error_docref(NULL, E_NOTICE, "tagstart ignored, because it is out of range");
+                               php_error_docref(NULL, E_WARNING, "tagstart ignored, because it is out of range");
                                parser->toffset = 0;
                        }
                        break;
@@ -1445,6 +1445,7 @@ PHP_FUNCTION(xml_parser_set_option)
                                zend_argument_value_error(3, "is not a supported target encoding");
                                RETURN_THROWS();
                        }
+
                        parser->target_encoding = enc->name;
                        break;
                }
index 9e79c9c63489cbc8cc251ea8fe76456d3b4295c7..04cad46cbe8cce0b54d739844e3c10cb8ffca3c2 100644 (file)
@@ -25,11 +25,8 @@ class XSLTProcessor
      */
     public function transformToXml(object $document) {}
 
-    /**
-     * @param string|array $name
-     * @return bool
-     */
-    public function setParameter(string $namespace, $name, string $value = UNKNOWN) {}
+    /** @return bool */
+    public function setParameter(string $namespace, array|string $name, ?string $value = null) {}
 
     /** @return string|false */
     public function getParameter(string $namespace, string $name) {}
@@ -40,11 +37,8 @@ class XSLTProcessor
     /** @return bool */
     public function hasExsltSupport() {}
 
-    /**
-     * @param string|array|null $restrict
-     * @return void
-     */
-    public function registerPHPFunctions($restrict = null) {}
+    /** @return void */
+    public function registerPHPFunctions(array|string|null $restrict = null) {}
 
     /** @return bool */
     public function setProfiling(?string $filename) {}
index d707c72a7dba6b1d00c8f8020d2ad719896d96f2..a776dded68695c3df4f30e70e78e520c2c5eb7db 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 13fd80938fec3bea7ac4bbcfb6e0b69b230fba72 */
+ * Stub hash: 4a3997bafb6c17714ee94443837be2d2842386e2 */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_importStylesheet, 0, 0, 1)
        ZEND_ARG_TYPE_INFO(0, stylesheet, IS_OBJECT, 0)
@@ -21,8 +21,8 @@ ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_setParameter, 0, 0, 2)
        ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0)
-       ZEND_ARG_INFO(0, name)
-       ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
+       ZEND_ARG_TYPE_MASK(0, name, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, value, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_getParameter, 0, 0, 2)
@@ -36,7 +36,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_hasExsltSupport, 0, 0, 0)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_registerPHPFunctions, 0, 0, 0)
-       ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, restrict, "null")
+       ZEND_ARG_TYPE_MASK(0, restrict, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_setProfiling, 0, 0, 1)
index 87d186eb6fd0a62de3950eedc2f3d841f9316fbd..d39c6559a1a6291d2f932070ef5c38decb219488 100644 (file)
@@ -4,20 +4,23 @@ Check xsltprocessor::setparameter error handling with no-string
 Memleak: http://bugs.php.net/bug.php?id=48221
 --SKIPIF--
 <?php
-        if (!extension_loaded('xsl')) {
-                die("skip\n");
-        }
+if (!extension_loaded('xsl')) {
+    die("skip\n");
+}
 ?>
 --FILE--
 <?php
 include __DIR__ .'/prepare.inc';
 $proc->importStylesheet($xsl);
-var_dump($proc->setParameter('', array(4, 'abc')));
+try {
+    $proc->setParameter('', array(4, 'abc'));
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
 $proc->transformToXml($dom);
 ?>
---EXPECTF--
-Warning: XSLTProcessor::setParameter(): Invalid parameter array in %s on line %d
-bool(false)
+--EXPECT--
+XSLTProcessor::setParameter(): Argument #2 ($name) must contain only string keys
 --CREDITS--
 Christian Weiske, cweiske@php.net
 PHP Testfest Berlin 2009-05-09
index 29b3ff5fb34e2287f9f649009b1a08943d4c8002..26edbb9045668c594963f1654166923970693ba3 100644 (file)
@@ -666,21 +666,35 @@ PHP_METHOD(XSLTProcessor, setParameter)
 {
 
        zval *id = ZEND_THIS;
-       zval *array_value, *entry, new_string;
+       zval *entry, new_string;
+       HashTable *array_value;
        xsl_object *intern;
        char *namespace;
        size_t namespace_len;
-       zend_string *string_key, *name, *value;
+       zend_string *string_key, *name, *value = NULL;
+
+       ZEND_PARSE_PARAMETERS_START(2, 3)
+               Z_PARAM_STRING(namespace, namespace_len)
+               Z_PARAM_STR_OR_ARRAY_HT(name, array_value)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STR_OR_NULL(value)
+       ZEND_PARSE_PARAMETERS_END();
+
+       intern = Z_XSL_P(id);
+
+       if (array_value) {
+               if (value) {
+                       zend_argument_value_error(3, "must be null when argument #2 ($name) is an array");
+                       RETURN_THROWS();
+               }
 
-       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sa", &namespace, &namespace_len, &array_value) == SUCCESS) {
-               intern = Z_XSL_P(id);
-               ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(array_value), string_key, entry) {
+               ZEND_HASH_FOREACH_STR_KEY_VAL(array_value, string_key, entry) {
                        zval tmp;
                        zend_string *str;
 
                        if (string_key == NULL) {
-                               php_error_docref(NULL, E_WARNING, "Invalid parameter array");
-                               RETURN_FALSE;
+                               zend_argument_type_error(2, "must contain only string keys");
+                               RETURN_THROWS();
                        }
                        str = zval_try_get_string(entry);
                        if (UNEXPECTED(!str)) {
@@ -690,18 +704,17 @@ PHP_METHOD(XSLTProcessor, setParameter)
                        zend_hash_update(intern->parameter, string_key, &tmp);
                } ZEND_HASH_FOREACH_END();
                RETURN_TRUE;
-       } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sSS", &namespace, &namespace_len, &name, &value) == SUCCESS) {
-
-               intern = Z_XSL_P(id);
+       } else {
+               if (!value) {
+                       zend_argument_value_error(3, "cannot be null when argument #2 ($name) is a string");
+                       RETURN_THROWS();
+               }
 
                ZVAL_STR_COPY(&new_string, value);
 
                zend_hash_update(intern->parameter, name, &new_string);
                RETURN_TRUE;
-       } else {
-               WRONG_PARAM_COUNT;
        }
-
 }
 /* }}} end XSLTProcessor::setParameter */
 
index c1a569afec4a7abcf2a178edbf9de955a208ee8f..6ebbc42858da17a51446597272e1b499b43d6153 100644 (file)
@@ -2712,16 +2712,20 @@ PHP_METHOD(ZipArchive, extractTo)
        struct zip *intern;
 
        zval *self = ZEND_THIS;
-       zval *zval_files = NULL;
+       zend_string *files_str = NULL;
+       HashTable *files_ht = NULL;
+
        zval *zval_file = NULL;
        php_stream_statbuf ssb;
        char *pathto;
        size_t pathto_len;
        int ret;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z", &pathto, &pathto_len, &zval_files) == FAILURE) {
-               RETURN_THROWS();
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_PATH(pathto, pathto_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(files_str, files_ht)
+       ZEND_PARSE_PARAMETERS_END();
 
        ZIP_FROM_OBJECT(intern, self);
 
@@ -2736,37 +2740,29 @@ PHP_METHOD(ZipArchive, extractTo)
                }
        }
 
-       if (zval_files && Z_TYPE_P(zval_files) != IS_NULL) {
-               uint32_t nelems, i;
+       uint32_t nelems, i;
 
-               switch (Z_TYPE_P(zval_files)) {
-                       case IS_STRING:
-                               if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files))) {
-                                       RETURN_FALSE;
-                               }
-                               break;
-                       case IS_ARRAY:
-                               nelems = zend_hash_num_elements(Z_ARRVAL_P(zval_files));
-                               if (nelems == 0 ) {
-                                       RETURN_FALSE;
-                               }
-                               for (i = 0; i < nelems; i++) {
-                                       if ((zval_file = zend_hash_index_find(Z_ARRVAL_P(zval_files), i)) != NULL) {
-                                               switch (Z_TYPE_P(zval_file)) {
-                                                       case IS_LONG:
-                                                               break;
-                                                       case IS_STRING:
-                                                               if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file))) {
-                                                                       RETURN_FALSE;
-                                                               }
-                                                               break;
+       if (files_str) {
+               if (!php_zip_extract_file(intern, pathto, ZSTR_VAL(files_str), ZSTR_LEN(files_str))) {
+                       RETURN_FALSE;
+               }
+       } else if (files_ht) {
+               nelems = zend_hash_num_elements(files_ht);
+               if (nelems == 0 ) {
+                       RETURN_FALSE;
+               }
+               for (i = 0; i < nelems; i++) {
+                       if ((zval_file = zend_hash_index_find(files_ht, i)) != NULL) {
+                               switch (Z_TYPE_P(zval_file)) {
+                                       case IS_LONG:
+                                               break;
+                                       case IS_STRING:
+                                               if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file))) {
+                                                       RETURN_FALSE;
                                                }
-                                       }
+                                               break;
                                }
-                               break;
-                       default:
-                               zend_argument_type_error(2, "must be of type array|string|null, %s given", zend_zval_type_name(zval_files));
-                               RETURN_THROWS();
+                       }
                }
        } else {
                /* Extract all files */
@@ -2784,6 +2780,7 @@ PHP_METHOD(ZipArchive, extractTo)
                        }
                }
        }
+
        RETURN_TRUE;
 }
 /* }}} */
index 01f055f0ab4baa4edf3fa1869ec08a0a70ec710a..cde266261d64000ebce8ec94bd57606256f8f877 100644 (file)
@@ -161,11 +161,8 @@ class ZipArchive
     /** @return bool */
     public function unchangeName(string $name) {}
 
-    /**
-     * @param array|string|null $files
-     * @return bool
-     */
-    public function extractTo(string $pathto, $files = null) {}
+    /** @return bool */
+    public function extractTo(string $pathto, array|string|null $files = null) {}
 
     /** @return string|false */
     public function getFromName(string $entryname, int $len = 0, int $flags = 0) {}
index 87222c9e080756fc61b7509ea3d5e29c1abceb3c..c9f90d57f9873c80ddec713e415dc913685acedc 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 880148896a71ad9bd076bb42c735ff1b83cd0731 */
+ * Stub hash: 49f168c537e48f8a3998d67812a5e2e6a2463533 */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_zip_open, 0, 0, 1)
        ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
@@ -175,7 +175,7 @@ ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ZipArchive_extractTo, 0, 0, 1)
        ZEND_ARG_TYPE_INFO(0, pathto, IS_STRING, 0)
-       ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, files, "null")
+       ZEND_ARG_TYPE_MASK(0, files, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ZipArchive_getFromName, 0, 0, 1)