php-src/Zend/tests/gc_042.phpt
Nikita Popov 902d64390e Deprecate implicit dynamic properties
Writing to a proprety that hasn't been declared is deprecated,
unless the class uses the #[AllowDynamicProperties] attribute or
defines __get()/__set().

RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
2021-11-26 14:10:11 +01:00

30 lines
429 B
PHP

--TEST--
Object properties HT may need to be removed from nested data
--FILE--
<?php
#[AllowDynamicProperties]
class Test {
public function __destruct() {
$GLOBALS['x'] = $this;
}
}
$t = new Test;
$t->x = new stdClass;
$t->x->t = $t;
$a = (array) $t->x;
unset($t, $a);
gc_collect_cycles();
var_dump($x);
?>
--EXPECT--
object(Test)#1 (1) {
["x"]=>
object(stdClass)#2 (1) {
["t"]=>
*RECURSION*
}
}