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

[email protected] (arnaud-lb)
Newsgroups php.bugs
Message-ID <[email protected]>
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_
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.