From: Nikita Popov Date: Thu, 6 Jun 2019 07:49:25 +0000 (+0200) Subject: Remove possible false return value from get_object_vars() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=252216b2ded7d3808e2a909bfea1e805ee17cde5;p=php Remove possible false return value from get_object_vars() 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. --- diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 13c6e636c2..4dca3180e1 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -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)) { diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 5d2ec26a68..7fa542a3c8 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -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),