php-src/Zend/tests/bug69446.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

35 lines
551 B
PHP

--TEST--
Bug #69446 (GC leak relating to removal of nested data after dtors run)
--INI--
zend.enable_gc = 1
--FILE--
<?php
$bar = NULL;
#[AllowDynamicProperties]
class bad {
public function __destruct() {
global $bar;
$bar = $this;
$bar->y = new stdClass;
}
}
$foo = new stdClass;
$foo->foo = $foo;
$foo->bad = new bad;
$foo->bad->x = new stdClass;
unset($foo);
gc_collect_cycles();
var_dump($bar);
?>
--EXPECT--
object(bad)#2 (2) {
["x"]=>
object(stdClass)#3 (0) {
}
["y"]=>
object(stdClass)#4 (0) {
}
}