]> granicus.if.org Git - php/commitdiff
Use string|array type in DOMXPath::registerPhpFunctions()
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 17 Jul 2020 14:10:49 +0000 (16:10 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 17 Jul 2020 14:10:49 +0000 (16:10 +0200)
ext/dom/php_dom.stub.php
ext/dom/php_dom_arginfo.h
ext/dom/xpath.c

index 5b553b803544d265b187dcf4931855a0f36d0ce9..f84282542dfa27ed1a173c8309d6ff4d2eeabc03 100644 (file)
@@ -425,11 +425,8 @@ class DOMXPath
     /** @return bool */
     public function registerNamespace(string $prefix, string $namespaceURI) {}
 
-    /**
-     * @param string|array $restrict
-     * @return bool|null
-     */
-    public function registerPhpFunctions($restrict = null) {}
+    /** @return bool|null */
+    public function registerPhpFunctions(string|array|null $restrict = null) {}
 }
 #endif
 
index de2ea0d73a87bc5b7e023bac61bf9069f51856ad..5724b98b79b01cca7381e6c4d375f5938f832943 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: ce4644d8cb6fdf0f3b9f5d1cbac773b406884ad9 */
+ * Stub hash: a9c30985948768261ea275fdbde598cf9119029e */
 
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 1)
        ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0)
@@ -441,7 +441,7 @@ ZEND_END_ARG_INFO()
 
 #if defined(LIBXML_XPATH_ENABLED)
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMXPath_registerPhpFunctions, 0, 0, 0)
-       ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, restrict, "null")
+       ZEND_ARG_TYPE_MASK(0, restrict, MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_NULL, "null")
 ZEND_END_ARG_INFO()
 #endif
 
index b3181972cadc043b635e4cfec1e831da49aa9ed4..e45ca84d8c08742a23b404653e078631659278d2 100644 (file)
@@ -492,29 +492,30 @@ PHP_METHOD(DOMXPath, evaluate)
 PHP_METHOD(DOMXPath, registerPhpFunctions)
 {
        zval *id = ZEND_THIS;
-       dom_xpath_object *intern;
-       zval *array_value, *entry, new_string;
-       zend_string *name;
-
-       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "a",  &array_value) == SUCCESS) {
-               intern = Z_XPATHOBJ_P(id);
-               ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array_value), entry) {
+       dom_xpath_object *intern = Z_XPATHOBJ_P(id);
+       zval *entry, new_string;
+       zend_string *name = NULL;
+       HashTable *ht = NULL;
+
+       ZEND_PARSE_PARAMETERS_START(0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(name, ht)
+       ZEND_PARSE_PARAMETERS_END();
+
+       if (ht) {
+               ZEND_HASH_FOREACH_VAL(ht, entry) {
                        zend_string *str = zval_get_string(entry);
-                       ZVAL_LONG(&new_string,1);
+                       ZVAL_LONG(&new_string, 1);
                        zend_hash_update(intern->registered_phpfunctions, str, &new_string);
                        zend_string_release_ex(str, 0);
                } ZEND_HASH_FOREACH_END();
                intern->registerPhpFunctions = 2;
                RETURN_TRUE;
-
-       } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "S",  &name) == SUCCESS) {
-               intern = Z_XPATHOBJ_P(id);
-
+       } else if (name) {
                ZVAL_LONG(&new_string, 1);
                zend_hash_update(intern->registered_phpfunctions, name, &new_string);
                intern->registerPhpFunctions = 2;
        } else {
-               intern = Z_XPATHOBJ_P(id);
                intern->registerPhpFunctions = 1;
        }