diff --git a/Zend/tests/debug_info/debug_info.phpt b/Zend/tests/debug_info/debug_info.phpt index 6f559eb40b7..bff5876777b 100644 --- a/Zend/tests/debug_info/debug_info.phpt +++ b/Zend/tests/debug_info/debug_info.phpt @@ -36,5 +36,7 @@ object(Foo)#%d (3) { ["c":"Foo":private]=> int(3) } + +Deprecated: Returning null from Bar::__debugInfo() is deprecated, return an empty array instead in %s on line %d object(Bar)#%d (0) { } diff --git a/Zend/tests/debug_info/recursion_return_null.phpt b/Zend/tests/debug_info/recursion_return_null.phpt new file mode 100644 index 00000000000..b6ca9c824cb --- /dev/null +++ b/Zend/tests/debug_info/recursion_return_null.phpt @@ -0,0 +1,31 @@ +--TEST-- +Testing __debugInfo() magic method +--FILE-- + +--EXPECTF-- +in handler + +Deprecated: Returning null from Foo::__debugInfo() is deprecated, return an empty array instead in %s on line %d +object(Foo)#3 (0) { +} +object(Foo)#2 (0) { +} diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index a3f852abc80..cca69e5d792 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -223,6 +223,8 @@ ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp) / return Z_ARRVAL(retval); } } else if (Z_TYPE(retval) == IS_NULL) { + zend_error(E_DEPRECATED, "Returning null from %s::__debugInfo() is deprecated, return an empty array instead", + ZSTR_VAL(ce->name)); *is_temp = 1; ht = zend_new_array(0); return ht;