mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
[RFC] Deprecate returning null from __debugInfo() (#19455)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_debuginfo_returning_null
This commit is contained in:
parent
3d9d68e1ca
commit
3dc962b9f7
3 changed files with 35 additions and 0 deletions
|
@ -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) {
|
||||
}
|
||||
|
|
31
Zend/tests/debug_info/recursion_return_null.phpt
Normal file
31
Zend/tests/debug_info/recursion_return_null.phpt
Normal file
|
@ -0,0 +1,31 @@
|
|||
--TEST--
|
||||
Testing __debugInfo() magic method
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
set_error_handler(
|
||||
static function () {
|
||||
echo "in handler\n";
|
||||
$f = new Foo();
|
||||
var_dump($f);
|
||||
}
|
||||
);
|
||||
|
||||
class Foo {
|
||||
public function __debugInfo() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$f = new Foo;
|
||||
var_dump($f);
|
||||
|
||||
?>
|
||||
--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) {
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue