mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
902d64390e
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
30 lines
562 B
PHP
30 lines
562 B
PHP
--TEST--
|
|
Bug #66609 (php crashes with __get() and ++ operator in some cases)
|
|
--FILE--
|
|
<?php
|
|
$bar = new Bar;
|
|
$foo = new Foo;
|
|
class Bar {
|
|
public function __get($x) {
|
|
global $foo;
|
|
return $foo->foo;
|
|
}
|
|
}
|
|
#[AllowDynamicProperties]
|
|
class Foo {
|
|
public function __get($x) {
|
|
global $bar;
|
|
return $bar->bar;
|
|
}
|
|
}
|
|
$foo->blah += 1; //crash
|
|
++$foo->blah; //crash
|
|
$foo->blah++; //crash
|
|
$foo->blah--; //crash
|
|
--$foo->blah; //crash
|
|
echo "okey";
|
|
?>
|
|
--EXPECTF--
|
|
Warning: Undefined property: Bar::$bar in %s on line %d
|
|
okey
|