Description
The following code:
try {
class Test {
public string $Foo = 'Bar';
}
$proxy = new ReflectionClass(Test::class)->newLazyProxy(fn() => null);
$proxy->Foo;
} catch (Throwable $x) {
// do something...
}
Resulted in this output:
Error: Lazy proxy factory must return an instance of a class compatible with Zok\System\Test, null returned
But I expected instead:
- allow "null" to be returned from the closure, so that its signature be like:
function($ghost):?object
- allow the error thrown to be captured and instead return null, and replace the proxy shell with null
BTW this would could collapse ghosts and proxies to a single lazy concept, allowing to return
- a previously empty shell object, now filled with
- a freshly created object
- null. This is important if -for example- a database lookup returned no result
### PHP Version
```plain
PHP 8.4
Operating System
macOS