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

28 lines
441 B
PHP

--TEST--
Bug #60536 (Traits Segfault)
--FILE--
<?php
trait T { private $x = 0; }
class X {
use T;
}
class Y extends X {
use T;
function __construct() {
return ++$this->x;
}
}
#[AllowDynamicProperties]
class Z extends Y {
function __construct() {
return ++$this->x;
}
}
$a = new Z();
$a->__construct();
echo "DONE";
?>
--EXPECTF--
Warning: Undefined property: Z::$x in %s on line %d
DONE