Skip to content

Commit 3dc962b

Browse files
1 parent 3d9d68e commit 3dc962b

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

Zend/tests/debug_info/debug_info.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@ object(Foo)#%d (3) {
3636
["c":"Foo":private]=>
3737
int(3)
3838
}
39+
40+
Deprecated: Returning null from Bar::__debugInfo() is deprecated, return an empty array instead in %s on line %d
3941
object(Bar)#%d (0) {
4042
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Testing __debugInfo() magic method
3+
--FILE--
4+
<?php
5+
6+
set_error_handler(
7+
static function () {
8+
echo "in handler\n";
9+
$f = new Foo();
10+
var_dump($f);
11+
}
12+
);
13+
14+
class Foo {
15+
public function __debugInfo() {
16+
return null;
17+
}
18+
}
19+
20+
$f = new Foo;
21+
var_dump($f);
22+
23+
?>
24+
--EXPECTF--
25+
in handler
26+
27+
Deprecated: Returning null from Foo::__debugInfo() is deprecated, return an empty array instead in %s on line %d
28+
object(Foo)#3 (0) {
29+
}
30+
object(Foo)#2 (0) {
31+
}

Zend/zend_object_handlers.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp) /
223223
return Z_ARRVAL(retval);
224224
}
225225
} else if (Z_TYPE(retval) == IS_NULL) {
226+
zend_error(E_DEPRECATED, "Returning null from %s::__debugInfo() is deprecated, return an empty array instead",
227+
ZSTR_VAL(ce->name));
226228
*is_temp = 1;
227229
ht = zend_new_array(0);
228230
return ht;

0 commit comments

Comments
 (0)