php-src/tests/lang/operators/overloaded_property_ref.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

21 lines
403 B
PHP

--TEST--
Operators on overloaded property reference
--FILE--
<?php
class C {
private $bar;
function __construct() { $this->bar = str_repeat("1", 2); }
function &__get($x) { return $this->bar; }
function __set($x, $v) { $this->bar = $v; }
}
$x = new C;
var_dump(++$x->foo);
$x = new C;
var_dump($x->foo++);
$x = new C;
var_dump($x->foo += 2);
?>
--EXPECT--
int(12)
string(2) "11"
int(13)