]> granicus.if.org Git - php/commitdiff
Remove possible false return value from get_object_vars()
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 6 Jun 2019 07:49:25 +0000 (09:49 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 6 Jun 2019 07:49:25 +0000 (09:49 +0200)
I'm not sure this one ever happens in practice (and we might want
to forbid NULL return from get_properties), but if it does, return
an empty array instead of false.

Zend/zend_builtin_functions.c
ext/opcache/Optimizer/zend_func_info.c

index 13c6e636c2aa5c9eb327694cd995769a8bafc3ee..4dca3180e17ce9e86f4133abf6e4f3f15bf30282 100644 (file)
@@ -135,7 +135,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class_vars, 0, 0, 1)
        ZEND_ARG_INFO(0, class_name)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_get_object_vars, 0, 0, 1)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_object_vars, 0, 1, IS_ARRAY, 0)
        ZEND_ARG_INFO(0, obj)
 ZEND_END_ARG_INFO()
 
@@ -1099,7 +1099,7 @@ ZEND_FUNCTION(get_object_vars)
        zobj = Z_OBJ_P(obj);
        properties = zobj->handlers->get_properties(zobj);
        if (properties == NULL) {
-               RETURN_FALSE;
+               RETURN_EMPTY_ARRAY();
        }
 
        if (!zobj->ce->default_properties_count && properties == zobj->properties && !GC_IS_RECURSIVE(properties)) {
index 5d2ec26a68b949265e91e014878896af762c6462..7fa542a3c81131031d558733b620305a4159058d 100644 (file)
@@ -110,7 +110,7 @@ static const func_info_t func_infos[] = {
        F0("is_subclass_of",          MAY_BE_FALSE | MAY_BE_TRUE), // TODO: inline
        F0("is_a",                    MAY_BE_FALSE | MAY_BE_TRUE), // TODO: inline
        F1("get_class_vars",          MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
-       FN("get_object_vars",         MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
+       FN("get_object_vars",         MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
        F1("get_class_methods",       MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
        F0("method_exists",           MAY_BE_FALSE | MAY_BE_TRUE),
        F0("property_exists",         MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),