Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124580 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 2AF2B1ADAE5 for ; Wed, 24 Jul 2024 19:44:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721850354; bh=eY0a59bbHw7pIeYM5b5YErJhaZaFld9OGCdOn5Ye9A0=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=YZQbtBmtLEFjUcWCAgezSY8ZrdGV0+0TXDY1yhpLOzh3CznbtEGt8Q2eNniKGZgNv 1jqpmZtbhPL40wq+IN0YaIh4/JB6PXdl9CVdigKMc0cCFGknzGo+fcyg3wl6sjzwkR PwCNVFq2SKnZl32xw3/tR6qFlij7clwPx/rtKRyX4FqeDRa+sXVerwUodFzxDKa431 eOtTmLEP4OIXeS+cSH54ZoM/11aWzldMARkkQZoZidJn403MZb+ARXnQpXIPmZi1X3 9Y7uf9MmUYsQIhjKVJLDXLJF6BxL5rHxdv6o4KoAOR768jnQXWluEv5DSHQb9MaPpi O6zQ40hGxYfmQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 39CC01801DA for ; Wed, 24 Jul 2024 19:45:51 +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,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh7-smtp.messagingengine.com (fhigh7-smtp.messagingengine.com [103.168.172.158]) (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 ; Wed, 24 Jul 2024 19:45:48 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 9BFC61140189; Wed, 24 Jul 2024 15:44:13 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute3.internal (MEProxy); Wed, 24 Jul 2024 15:44:13 -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=fm1; t=1721850253; x= 1721936653; bh=SjlLUxL3btx91v486rVETA6xfR4oSDCq7dOo6rPg8mM=; b=s MEGzF6+6XzmBfyPm1cZKU2GA73rWqdP3ej7DCOQ6Kxa/gkcXSjhMga8wz64OBPV5 MfDObMJhu7rlSMNgB/tysjkbmiBjhUu19cz0ylSJOTLOMSXKLr8WwuuUMwogITCC R9B7i6YQibDtmEJPSUFe49HpIN4abs6rNrrtpgudCsHxkXKakJEiTHa9G1i7rxVG stgOlJtBtdPlwLT7rAThsaaPqf8hrtApKL4gjlv0rDiXk0HRVPE10kxlMNP4cmy2 L3PWyg1V2+YS/T2AfSQ+Ym+AlXapVDxB/wMkdJnva+Tf7JDBujaIK+FT7IlOIND8 lCyxKjTdwrojr4QU/7ssA== 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= fm3; t=1721850253; x=1721936653; bh=SjlLUxL3btx91v486rVETA6xfR4o SDCq7dOo6rPg8mM=; b=myxElqFoOg0ow0AXhj3CF47m9KXzzqPK9M4i1DSbq91m fUgS1Xn7IwpC9tS0ESeWS4p1yEDniH5zcDxFzClaqy3+iyED4BknDusvhgL/7RYV 1VXOLoYZpl0U+bYlyS98WOzy48+zuZWhQhMjOBknSn90zOvRJghE6WHqZeotLic3 Hg2HkdGM9S4fWLvfqRItzemOz5Ov8cYrDKlqSl7dbdhBNfVNJYVpXo6gcTSMXYVm QpEoPjDO92ZSZ6MvspZyllDtRYsEZs3t854BAiasvydV8l8V4l2YuLVENPNZRMrh QlOBGt9INDwt6vMCdbZ7nMx2xLP3BnGIFwCXYbsQiw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddriedugddugeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsegrtderreerreejnecuhfhrohhmpedftfho sgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrf grthhtvghrnhepvdehkeetleevteefveegkefgffdvuefhleevhedvteeigfegtdefjeeh tefghfeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprhhosgessghothhtlhgvugdrtghouggvshdpnhgspghrtghpthhtoheptd X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4D77015A0093; Wed, 24 Jul 2024 15:44:13 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-582-g5a02f8850-fm-20240719.002-g5a02f885 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Message-ID: <72131a21-1349-47fe-9267-ebad44575995@app.fastmail.com> 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> <2a0a4650-c2c5-4c6d-ad3a-25365b3391b2@bastelstu.be> <2fd6d80d-a55c-4aad-aeee-6d07d4b930a1@app.fastmail.com> Date: Wed, 24 Jul 2024 21:43:51 +0200 To: "Nicolas Grekas" , "Larry Garfield" Cc: "php internals" Subject: Re: [PHP-DEV] [RFC] Lazy Objects Content-Type: multipart/alternative; boundary=7e4046c484254311be2d56390c5b7b06 From: rob@bottled.codes ("Rob Landers") --7e4046c484254311be2d56390c5b7b06 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Jul 24, 2024, at 16:28, Nicolas Grekas wrote: >=20 > To Rob: proxying by interface can be implemented using regular code ge= neration so it's not a blocker. Symfony does it already, and will contin= ue to do it to cover the use case. I'm not sure what you mean, as the RFC makes it look this should be comp= letely legal, until you get to the end: interface Fancy { function sayHi(): void; } class A implements Fancy { function sayHi(): void { echo "hi!"; } } $container->register(proxyType: Fancy::class, factory: fn() =3D> new A()= ); // Now container only knows that it needs to return a FancyClass and thi= s is "legal looking": $lazy =3D new ReflectionClass($proxyType)->newLazyProxy($factory); // same as $lazy =3D new ReflectionClass(Fancy::class)->newLazyProxy(fn() =3D> new = A()); This ^ compiles, it's perfectly legal and makes 100% sense that I should= be able to call $lazy->sayHi() and it calls A::sayHi(), which is what y= ou would expect. Instead, this is runtime error. =E2=80=94 Rob --7e4046c484254311be2d56390c5b7b06 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Wed, Jul 24, 2024, at 16:28, Nicolas Grekas wrote:
=

To Rob: prox= ying by interface can be implemented using regular code generation so it= 's not a blocker. Symfony does it already, and will continue to do it to= cover the use case.

I'm not sure what you mean, as the RFC makes it look this should be c= ompletely legal, until you get to the end:

= interface Fancy {
  function sayHi(): void;
}
class A implements Fancy {
  functio= n sayHi(): void { echo "hi!"; }
}

$container->register(proxyType: Fancy::class, factory: fn() =3D> = new A());

// Now container only knows that = it needs to return a FancyClass and this is "legal looking":

$lazy =3D new ReflectionClass($proxyType)->newLazyP= roxy($factory);
// same as
$lazy =3D new ReflectionC= lass(Fancy::class)->newLazyProxy(fn() =3D> new A());

This ^ compiles, it's perfectly legal and makes 100% sen= se that I should be able to call $lazy->sayHi() and it calls A::sayHi= (), which is what you would expect. Instead, this is runtime error.

=E2=80=94 R= ob
--7e4046c484254311be2d56390c5b7b06--