On June, 4 at 15:32, Nicolas Grekas <[email protected]> wrote:
> Dear all,
>
> Arnaud and I are pleased to share with you the RFC we've been shaping for
> over a year to add native support for lazy objects to PHP.
>
> Please find all the details here:
> https://wiki.php.net/rfc/lazy-objects
>
> We look forward to your thoughts and feedback.
>
> Cheers,
> Nicolas and Arnaud
>
Hi, Nicolas and Arnaud!
I like the idea, thank you for the RFC!
Here are some initial thoughts and questions:
1. It doesn't seem right that calling ReflectionLazyObject::makeLazyGhost
has an implicit side effect on $instance
and returns reflection. It does
2 things and thus breaks the SRP. Having smth like `$lazyGhost = new
ReflectionClass(MyClass)->newLazyGhost($initializer)` and/or
ReflectionLazyObject::makeLazy($object, $initializer): void
seems better.
2. If ReflectionLazyObject extends ReflectionObject
, then how `new
ReflectionLazyObject($object)` will work for non-lazy objects? Will it
throw?
3. Is extending ReflectionObject
really necessary? What about creating
ReflectionLazyObject
as a standalone class without abusing inheritance?
Or simply adding methods to ReflectionObject
/ ReflectionClass
?
4. The RFC says that Virtual state-proxies are necessary because of
circular references. It's difficult to accept this reasoning, because using
circular references is a bad practice and the given example is something I
try to avoid by all means in my code.
--
Best regards,
Valentin