[php-src] Issue #21478: Property access on lazy proxy may invoke magic method despite real instance guards

From: Date: Fri, 20 Mar 2026 16:22:39 +0000
Subject: [php-src] Issue #21478: Property access on lazy proxy may invoke magic method despite real instance guards
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251827@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/21478 Author: arnaud-lb ### Description The following code: ```php <?php class Foo { public $_; public function __get($name) { global $proxy; printf("__get(\$%s) on %s\n", $name, $this::class); return $proxy->{$name}; } } class Bar extends Foo {} $rc = new ReflectionClass(Bar::class); $proxy = $rc->newLazyProxy(function () { echo "Init\n"; return new Foo(); }); $real = $rc->initializeLazyObject($proxy); $real->x; ?> ``` Resulted in this output: ``` Init __get($x) on Foo __get($x) on Bar ``` But I expected this output instead: ``` Init __get($x) on Foo ``` See https://github.com/php/php-src/pull/21463#pullrequestreview-3969097521. ### PHP Version ```plain PHP 8.4 ``` ### Operating System _No response_

« previous php.bugs (#251827) next »