Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123505 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 6540F1ADA78 for ; Tue, 4 Jun 2024 14:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717513007; bh=4RsmPSlWDQDs5gobmj7+qCtGlZyBhu2WeVhqlJQ4rkg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KLVbqgLA1NMQwggidzW+54mY7zyfpUott1CzzeLKbsRwTGzR1z20XCVG4QNDXj8y2 ue6/SFkPLAZoeGXktlahHlZLm4Vi4fLGor+KTM17vd/YexZu1rcl5lBKcRjKZks7Fd qgxPUOJ/U/7+hoiYUl7lZMRaq2sUNL+Ap/SPA3YcK3VF7ASJ7Eh9CaF7+jD8KuGK0t aAer9lFXX6oM6btCgclf3+8hYUUvziL7WO2nGktQ21zKz9esMOHwYvCfYpsnneRO8P 6qXpNBKqbl7sqiz+LUOLMKXCZVftyW1yvWPXNfQ/nnVfN2cCZCaqC6vkcpUXwvGnuN cIYdwPJyomBkw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CB9C318059E for ; Tue, 4 Jun 2024 14:56:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 4 Jun 2024 14:56:41 +0000 (UTC) Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so33209485e9.1 for ; Tue, 04 Jun 2024 07:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717512936; x=1718117736; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zUxi3u+tIY3Ke9PGsKv3J9IrcOwScdbyL6QADC5ZEqw=; b=iwLOursEduWRjkPfbRSeIiekvpFDK4ERXXK6RLVJNz7165enqfZRXg4Ea4CGX/H6TK 5Qh/10YnRzi4+Kz3cJcxJK73lEvcAoH9vTdfw6dZkL8RdiVaLO4TsIggXXNDBrIndXBZ VAFV033iAaX81wg87GnnE+t8Yku0TeiXjPg1sFC37gEQsfvQyB7DtwYGCJQvReOj4Gn+ 1DkFf8sMQxljPCXYLD0gwLR9y4hRWthm1s+I0XxFAiUKyxaZnBI9K4FT9hLnL/ulDDCi Cpp2jr5b9mdHZ03pkv3UfDFt+eQ/vdSQ3o0JI0RB0CYBUQpVrHVc0YlWdFpYd7itLye4 QJzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717512936; x=1718117736; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zUxi3u+tIY3Ke9PGsKv3J9IrcOwScdbyL6QADC5ZEqw=; b=kf7rSrtlEg1d0d1d4rVjHkG45lF6hNDmKhy7F2t6ZRl48Cr1Bs2wnmmBEV1hF8qpYx XVEiEwqHOdjhf8Hssj+zIw4qS7E4kSYCS12K1p1lAKib4PEsoQHddi88gbo+IsSHTWXb 0N+xN7pqEnyrrX/3oO4ZVV1sf2PEBBRnAi0p6k89zI8EdrxJYDQPRRgkH940RkzvdaOz HSUf2KLDOuBdwKtf3L4rYl2d2bZmndigNdwXbh5OnSxoz6WEOxBJ1Q3Dr29luwUODr2O KxEVSE2YM90uHDysY27CoUWqJtRz0E1UURFLva//j45ht0GOni1ZLb9wzyUb15lGJp+l XEMA== X-Gm-Message-State: AOJu0YwC1FizrWeOum4rVTDIUa55wosO582iW9k5aovDvJPjSLmWo101 y2bn01ag+jGdeMnmQ/1dRrB/NKTeat7q3amCUXQKV0RVqFzqHRVWQhBqZqJnepD36UuVI4BUzu/ 72jWRrnj2cfeDSFSB7ODVmmYi2qkR82w= X-Google-Smtp-Source: AGHT+IEz7LpCV7kkImVieRzv4Dxf5jiQRU080XEaAUGEK6FzpxK76ZJW5Zy9a6/NbwhnvtenlsqnseJYu5nUsWnkjTo= X-Received: by 2002:a05:600c:35c8:b0:41b:9427:562e with SMTP id 5b1f17b1804b1-4214511d0b0mr26082645e9.12.1717512936358; Tue, 04 Jun 2024 07:55:36 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 4 Jun 2024 17:55:25 +0300 Message-ID: Subject: Re: [PHP-DEV] [RFC] Lazy Objects To: Nicolas Grekas Cc: PHP Internals List , Arnaud Le Blanc Content-Type: multipart/alternative; boundary="000000000000780c76061a11a45f" From: udaltsov.valentin@gmail.com (Valentin Udaltsov) --000000000000780c76061a11a45f Content-Type: text/plain; charset="UTF-8" On June, 4 at 15:32, Nicolas Grekas 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 --000000000000780c76061a11a45f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, Nicolas and Arnaud!

I like= the idea,=C2=A0thank you for the=C2=A0RFC!

Here are some= initial thoughts and questions:

1. It doesn't seem right that c= alling `ReflectionLazyObject::makeLazyGhost` has an implicit side effect on= `$instance` and returns reflection. It does 2 things and thus breaks the S= RP. Having smth like `$lazyGhost =3D new ReflectionClass(MyClass)->newLa= zyGhost($initializer)` and/or `ReflectionLazyObject::makeLazy($object, $ini= tializer): void` seems better.
2. If `ReflectionLazyObject ex= tends ReflectionObject`, then how `new ReflectionLazyObject($object)` will = work for non-lazy objects? Will it throw?
3. Is extending=C2=A0`Reflecti= onObject` 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=C2= =A0Virtual state-proxies are necessary because of circular references. It&#= 39;s=C2=A0difficult to accept=C2=A0this reasoning, because using circular= =C2=A0references is a bad=C2=A0practice and the given example is something= =C2=A0I try to avoid by all means in my code.

--
Best regards,
Valentin
--000000000000780c76061a11a45f--