Hi Larry, Thank you for the feedback.
I think you got the two strategies right. However, there is a use-case in which an object manages its own laziness by making itself lazy: ``` class C { public function __construct() { ReflectionLazyObject::makeLazyGhost($this, $this->init(...)); } } ``` This one can not be addressed by a newInstance*() method since the object to be made lazy already exists. The makeLazyGhost() / makeLazyProxy() methods are the minimal methods necessary to address all use-cases, but the methods you are suggesting are a better API most of the time, so we are adding approximately this to the proposal [1]. We are keeping them in a separate class to not pollute ReflectionClass. > It also suggests that perhaps the function should be using $this, not $foo, > as it's running within the context of the object (I presume? Can it call > private methods? I assume so since it can set private properties.) The function is not running in the context of the object. It can only access private members via Reflection or if the closure was bound to the right scope by the user. This should not be an issue when the initializer just calls a public constructor. > In which case $object is the proxy, and gets "swapped out" for the return > value of the $initializer on first use. Just to be sure: $object continues to be the proxy instance after the initializer is called, but it forwards all property accesses to the return value of the $initializer. [1] https://news-web.php.net/php.internals/123518 Best Regards, Arnaud