Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124444 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 8E8101A00B7 for ; Tue, 16 Jul 2024 06:44:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721112342; bh=Tlx/8R6QvjAJyPaUVzLeltClNKlUa76Yg0mCIMGc3d4=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=QoBwUmpiZEHinrCPHDxYdIkaRUJw+HfKuP+xSMscMjMVLpZRXdUsJpHCuz3W+Ae8G 3111Ukrc6X4oP/4t1K4Gf6C4zkXTNzts4tKMknNapKHIlNvfUmB9sanNLQm/PIos3U h8Otk7extHEOXneXyhXkkNTLnfg2GeCX6QUWIXweAmZkd9Lb4cZKpCtQy16fqelWzg XL5SCepl8dJMt2A4DJ2S19tW8m56ihu0DK1xekbQnO5+wIw65qiO3gi9HVsqdMMDDm ITmr6nNTURnqZvRPuzeun7gSr9UIjfRbg9xSf8CS7ibmDA3H4985oyZP7b7Oy6gUoW ImJUMVHzIGDRw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8C93B180039 for ; Tue, 16 Jul 2024 06:45:41 +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=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh1-smtp.messagingengine.com (fhigh1-smtp.messagingengine.com [103.168.172.152]) (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, 16 Jul 2024 06:45:40 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id F397D1148267; Tue, 16 Jul 2024 02:44:10 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Tue, 16 Jul 2024 02:44:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1721112250; x= 1721198650; bh=Tlx/8R6QvjAJyPaUVzLeltClNKlUa76Yg0mCIMGc3d4=; b=M wRriIiFQFRtkGf6xXYIsh15A9UMEJqh1UHcZctNXdNQxuxMfZ0OhsAQPUa1YDjOH 65MGBJjDlwacIV+mbhe/4EX7V3q+YVbc+NtgbQBHDz/C4BFX/w05Gtqx7C9y85SD JBbHhuOOtWvImePESOOtzw3MBy7RXCzp0kiJVNSIfr44qIHxxAlcGaR2D9KQNgog wCPXTcYPX8VeDr4ab3baophowIkja3fvkv6VCys9vQLypoZkd95FCVRejqfKL3ef OmC/BLb4LerBA2SDuLEV1Ma/MiE3jG8/CZCW3k2eojrHiXpTIpPK84RhoqahiD9M 9Z9QKO5F8QNmLy0//pXzg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1721112250; x=1721198650; bh=Tlx/8R6QvjAJyPaUVzLeltClNKlU a76Yg0mCIMGc3d4=; b=k2rqW9so0fVWmX9YPd0tG+72kLYxuGuGHTczcMTpCHv/ +0bDIEydWwBh8GeZOrXYmI86/9Ka49dFRHxDyIq3eXTTCHraZyV6bgc/DE7gMdVO 3MgPTviiJweDK2atzMcSj4W1UelFHX0gvsOModpoDHKH3C36qZQzGE5eAYJjrzH7 i1h1hHyuKCFZjb5wF20GouQQKk6B4cjGMJrEdBw/e29j/s+l/c2wEJsQI/CO3kCY G/vBzeGxeHQEtTQ2JGRQFkhV/XUZmFkZcq5mhRQPnUV7f0EiPd1O/A21D+zXU2EI 6JWR/KVCAJ1G+OG2GIFgbVtGXeGNK1g+gYjonB002g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrgeefgdduuddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsegrtderreerreejnecuhfhrohhmpedftfho sgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrf grthhtvghrnhepvdehkeetleevteefveegkefgffdvuefhleevhedvteeigfegtdefjeeh tefghfeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprhhosgessghothhtlhgvugdrtghouggvsh X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8128515A0092; Tue, 16 Jul 2024 02:44:09 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-568-g843fbadbe-fm-20240701.003-g843fbadb Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: References: <1118bbcd-a7b4-47bf-bf35-1a36ab4628e1@bastelstu.be> <45847b93-02bf-459f-bcd2-81ba35a12c24@bastelstu.be> <46bd4098-2936-4e46-98e9-fe55118325c2@bastelstu.be> <61ab36bc-b045-452a-84e0-87367d4c680e@bastelstu.be> <07e065f2-8f64-4bad-9a98-51f4eaf63ddb@app.fastmail.com> Date: Tue, 16 Jul 2024 08:43:35 +0200 To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , =?UTF-8?Q?Benjamin_Au=C3=9Fenhofer?= Cc: "PHP Internals List" , "Nicolas Grekas" Subject: Re: [PHP-DEV] [RFC] Lazy Objects Content-Type: multipart/alternative; boundary=bd75815e63c8466c9eb7084bdc335f3a From: rob@bottled.codes ("Rob Landers") --bd75815e63c8466c9eb7084bdc335f3a Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Jul 15, 2024, at 21:23, Tim D=C3=BCsterhus wrote: > Hi >=20 > On 7/12/24 08:00, Rob Landers wrote: > > For what it=E2=80=99s worth, I see =E2=80=9CresetAsLazy()=E2=80=9D b= eing most useful for unit testing libraries that build proxies. While th= is feature will remove most of the tricky nuances around proxies, it doe= sn=E2=80=99t make it any easier in generating the code for them, so that= has to be tested. Being able to write a test like this (abbreviated): > >=20 > > $realObj =3D new $foo() > > $proxy =3D clone $realObj; > > makeTestProxy($proxy); // resets as lazy with initializer > > assert($realObj =3D=3D $proxy); > >=20 > > Is really simple. Without a reset method, this isn=E2=80=99t straigh= tforward. > >=20 >=20 > I'm not sure if I follow this example. With the native support for laz= y=20 > objects there should no longer be a need for code generation, no?=20 > Testing that PHP works correctly in your own test suite is not a=20 > value-add, PHP has its own tests for that. >=20 > Best regards > Tim D=C3=BCsterhus >=20 There are ghost objects, and then there are proxies. This RFC allows bot= h. Beyond that, there are many types of proxies. For example, I have a l= ibrary that proxies an interface or class, generates a spy proxy, and wh= en the user calls those methods on it, it records these calls for asynch= ronous RPC (for remote objects) or locally =E2=80=94 kinda like erlang.=20 This code obviously has to be tested, both the generation of the code, a= s well as the execution. Now that properties can exist on interfaces, I = also have to figure out how that will affect things as well, and test th= at. Being able to defer generation and/or state hydration to actual usag= e will be a massive improvement, especially in cases where you may have = nested objects. Now, you asked why I would want to test PHP=E2=80=99s own behavior? Well= , it=E2=80=99s a new language feature. I=E2=80=99m going to test the hel= l out of it, learn its edges, and make sure it works as advertised and m= y use case. If I find any bugs, I will report them. If this feature had = existed for years, I would probably still test it to make sure php upgra= des don=E2=80=99t break expected behavior and it still works on lower PH= P versions. Are you suggesting that I don=E2=80=99t need to have tests f= or this, that PHP will never change this feature? =E2=80=94 Rob --bd75815e63c8466c9eb7084bdc335f3a Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Mon, Jul 15,= 2024, at 21:23, Tim D=C3=BCsterhus wrote:
Hi

On 7/12/= 24 08:00, Rob Landers wrote:
> For what it=E2=80=99s wo= rth, I see =E2=80=9CresetAsLazy()=E2=80=9D being most useful for unit te= sting libraries that build proxies. While this feature will remove most = of the tricky nuances around proxies, it doesn=E2=80=99t make it any eas= ier in generating the code for them, so that has to be tested. Being abl= e to write a test like this (abbreviated):

<= /div>
> $realObj =3D new $foo()
> $proxy =3D clo= ne $realObj;
> makeTestProxy($proxy); // resets as lazy= with initializer
> assert($realObj =3D=3D $proxy);
=

> Is really simple. Without a res= et method, this isn=E2=80=99t straightforward.
> <= br>

I'm not sure if I follow this example. With= the native support for lazy 
objects there should no= longer be a need for code generation, no? 
Testing t= hat PHP works correctly in your own test suite is not a 
<= div>value-add, PHP has its own tests for that.

<= div>Best regards
Tim D=C3=BCsterhus


There are ghost objects, and then the= re are proxies. This RFC allows both. Beyond that, there are many types = of proxies. For example, I have a library that proxies an interface or c= lass, generates a spy proxy, and when the user calls those methods on it= , it records these calls for asynchronous RPC (for remote objects) or lo= cally =E2=80=94 kinda like erlang. 

Th= is code obviously has to be tested, both the generation of the code, as = well as the execution. Now that properties can exist on interfaces, I al= so have to figure out how that will affect things as well, and test that= . Being able to defer generation and/or state hydration to actual usage = will be a massive improvement, especially in cases where you may have ne= sted objects.

Now, you asked why I would wa= nt to test PHP=E2=80=99s own behavior? Well, it=E2=80=99s a new language= feature. I=E2=80=99m going to test the hell out of it, learn its edges,= and make sure it works as advertised and my use case. If I find any bug= s, I will report them. If this feature had existed for years, I would pr= obably still test it to make sure php upgrades don=E2=80=99t break expec= ted behavior and it still works on lower PHP versions. Are you suggestin= g that I don=E2=80=99t need to have tests for this, that PHP will never = change this feature?

=E2= =80=94 Rob
--bd75815e63c8466c9eb7084bdc335f3a--