1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
--TEST--
Dynamic properties deprecation
--FILE--
<?php
class Test {}
$obj = new Test;
$obj->prop = 1; // Deprecated
$obj->prop = 1; // Ok
$obj->prop2 += 1; // Deprecated
$obj->prop2 += 1; // Ok
$obj->prop3++; // Deprecated
$obj->prop3++; // Ok
$obj->prop4[] = 1; // Deprecated
$obj->prop4[] = 1; // Ok
isset($obj->prop5); // Ok
unset($obj->prop6); // Ok
// stdClass should not throw deprecation.
$obj = new stdClass;
$obj->prop = 1;
// Classes with #[AllowDynamicProperties] should not throw deprecation.
#[AllowDynamicProperties]
class Test2 {}
class Test3 extends Test2 {}
$obj = new Test2;
$obj->prop = 1;
$obj = new Test3;
$obj->prop = 1;
?>
--EXPECTF--
Deprecated: Creation of dynamic property Test::$prop is deprecated in %s on line %d
Deprecated: Creation of dynamic property Test::$prop2 is deprecated in %s on line %d
Warning: Undefined property: Test::$prop2 in %s on line %d
Deprecated: Creation of dynamic property Test::$prop3 is deprecated in %s on line %d
Warning: Undefined property: Test::$prop3 in %s on line %d
Deprecated: Creation of dynamic property Test::$prop4 is deprecated in %s on line %d
|