Hi Gina, On Tue, Jun 25, 2024 at 5:59 PM Gina P. Banyard <intern...@gpb.moe> wrote:
> The fact that an initialize() method has a $skipInitializer parameter > doesn't make a lot of sense to me. > Because at a glance, I don't see how passing true to it, and not calling > the method is different? > Calling initialize() with $skipInitializer set to true has the same effect as calling skipLazyInitialization() on all properties that are still lazy on the object. This can be used to manually initialize a lazy object afterwards, as property accesses will not trigger initialization anymore. This also ensures that the initializer function can be decref'ed. This should probably be split into two distinct methods. > Agreed > Does get_mangled_object_vars() trigger initialization or not? > No. get_mangled_object_vars() and array cast are among the few cases that do not trigger initialization. They are listed in https://wiki.php.net/rfc/lazy-objects#initialization_triggers. > This should behave like an (array) cast (and should be favoured instead of > an array cast as it was introduced for that purpose). > Exactly > How does a lazy object look like when it has been dumped? > The output of var_dump() on a lazy object is the same as on an object whose all properties have been unset() (except those initialized with setRawValueWithoutLazyInitialization() or skipLazyInitialization()). For convenience we also prefix the output with either `lazy ghost` or `lazy proxy`. I've added a var_dump section in the RFC. > > The initializer must return null or no value > *Technically* all functions in PHP return a value, which by default is > null, so this is somewhat redundant. > Agreed. I believe that formulating this like that makes it clear that any of "return null;", "return;", or implicit return, will work. Also, would this throw a TypeError if a value other than null is returned? > Agreed. Currently we throw an Error, but I will change that to TypeError. Best Regards, Arnaud