Closed
Description
Description
Access to properties of a lazy proxy are forwarded to the real instance. But if the access is made by a magic method, forwarding to the real instance may call the magic method again:
#[AllowDynamicProperties]
class C {
public $_;
public function __set($name, $value)
{
var_dump(__METHOD__);
$this->$name = $value * 2;
}
}
$rc = new ReflectionClass(C::class);
$obj = $rc->newLazyProxy(function () {
echo "init\n";
return new C;
});
$obj->prop = 1;
var_dump($obj->prop);
Resulted in this output:
string(8) "C::__set"
init
string(8) "C::__set"
int(4)
But I expected this output instead:
string(8) "C::__set"
init
int(2)
PHP Version
PHP 8.4
Operating System
No response