Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127633 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 lists.php.net (Postfix) with ESMTPS id C05F81A00BC for ; Mon, 9 Jun 2025 15:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1749481802; bh=o+oJ5lqBO7joEoaHzQpauyAJa3EA/R+ttqlB7ON+4Ko=; h=Date:From:To:In-Reply-To:References:Subject:From; b=Vr71IvfB2sJee+7MgDDXI1SIjfGMvTpVr1k2QHWKXBh/6irEUagVNazszVKeP2IXx aLt2TW9v8IN8foetA9PzclHvr+C5gPcmb86Z2wbajpFeYDtYlI7SSsrbawALtZDaHc RBFjtWF06dmJrYaes8pzeI4Rm+np1Vn4d4I4utcOERD2YGPCx+BgIphMM73aGbI/et lT63qIDg7cM04bt64e6YSMmv4bh2/foiaQauvdMkNq774/e/0P8Jw8tHFECm0QN/b3 sgYMR7R4+gC99acltpz8o9fbWiiFD2ao0eaaCnf88Q+gUrwsEEIUdyLjZ4iFlEVJ37 CbgUyPBR588Ow== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0AE2F18002F for ; Mon, 9 Jun 2025 15:10:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-a8-smtp.messagingengine.com (fhigh-a8-smtp.messagingengine.com [103.168.172.159]) (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 ; Mon, 9 Jun 2025 15:10:01 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id D3B1611401D2 for ; Mon, 9 Jun 2025 11:12:02 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Mon, 09 Jun 2025 11:12:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=1749481922; x=1749568322; bh=uYO/QNoqFzE4QRtH3cEnb fHd/AFlBK4tnNeQDL8C36E=; b=JPPLvDj4F88AJj9FLEIWOE7BO9URAlNvUNiHM stuJS7YObPpipu5gXP3qDlQN2eW67Z4BSaQBzDJ+CPQDXc7QclS/xVM3wSEtOX/t /oOXkodeNBssmdYMhzOeVQ8t6EupqhJDzGTHfuqFwt3CZuQCVA8AepqVqIqzJTth 00ZAFKdQas6YaV9qM9pGV1tQxUvW9DbRoILcj46w0bkd3YVqeXntnAh01V8dKsjl AUoaD7fFA0kdiGdUFKbgWDGVpE13HnCwlj9t30lA9WSkdV2PlniAd7HaRXB6O9jR GJv/VlmWHb8zKiYW2iMVTJh8L2h+6wQz9KAXFrWLZC9hOfeXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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-sender :x-me-sender:x-sasl-enc; s=fm1; t=1749481922; x=1749568322; bh=u YO/QNoqFzE4QRtH3cEnbfHd/AFlBK4tnNeQDL8C36E=; b=lQBvUiVyeXcPoeUa3 dSpjSWA0LcTPIkPiXIocSU5hAEw0YhJ/+g4tMnWK3xVocSijekmcCIJYQ9AYOq4x klzG3Mb06c1KHWBz5o9DrItu3ng+YZRMs6bX5J6sFpIt1zOx9mt3YpXheHbd+F/I AaTF8aDlQtrTrCjhL2NC35NVgBoj9qu/5thMK+kl2axyV6ZKf2N+SQAB5abAhb8M QcZcBOYOeZ3hW3GFSuANmIkI4N/qdXEXtyx+Y7rm+8JPlEZRm/h4y0lOCGXkvcnh Uay3uuPekbllyPZH2mktp0qkgGVAMGFYE5U7OR4gJdmbKAo5qZPjLB997ghrXQXP kPMsA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddugdelgeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthejredtredttden ucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfih gvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpedugedvlefgueegheefjeet ffduveeltefhfeegjeffffelgedttdevkeegkedugfenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggt hhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpth htohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 87B59700063; Mon, 9 Jun 2025 11:12:02 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: Taa1a9d92243b6726 Date: Mon, 09 Jun 2025 10:11:42 -0500 To: "php internals" Message-ID: In-Reply-To: References: <1e8634d7-ac1a-4025-b4e2-1948aabf5251@app.fastmail.com> Subject: Re: [PHP-DEV] [RFC] Readonly property hooks Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Sun, Jun 8, 2025, at 7:17 AM, Volker Dusch wrote: > Hey Larry, > > Couple points from a first read and from trying to run the examples. > > a) From the "ProductFromDB" i get: > >> Fatal error: Uncaught TypeError: LazyProduct::$category::get(): Return value must be of type Category, none returned in ... > > I assume you're missing a return statement here? Or is there something > I'm missing? > > b) Minor wording gripe in the proposal section > >> On the other hand, there is no shortage of dumb things that people can do with PHP already. > > While I don't disagree that PHP gives people a lot of freedom in how > they want to write their code, I find it a bit crude for an RFC to > phrase it like that. And the __get comparison is strong enough to stand > on its own. Various typos have been fixed, and the code should be valid now. The wording has also been adapted (though I am pretty sure "silly" has appeared in RFCs before). I also fleshed out the __get mention with an example that shows what you can already do today, and in fact could since 8.1 when readonly was introduced. The hard guarantee of idempotency has never actually been there. (This also speaks to Claude's concern.) > c) > >> That is, we feel, an entirely reasonable use of hooks, and would allow for lazy-load behavior per-property on readonly classes. > > I might be misunderstanding the sentence here, but on-demand/Lazy > initialization of properties on readonly classes is already possible in > classic getter/setter classes. If a class uses private properties and getX/setX methods, sure, those methods can be overridden to do whatever you want. The whole point of hooks, though, is to NOT need those methods. We want to enable someone to define a read-model easily, like the Product in the example. That's all they should need to specify. So, yes, technically it's "in a class that is designed with modern features" rather than having a long list of getX/setX methods just to give lazy-loading generated code a place to hook in. > f) Date: 2024-07-10 > > Is this correct? I know you created the page back then, but was there a > discussion already that I wasn't able to find? Yes, this RFC was originally spun off from the hook-improvements RFC, as it needed more discussion while the other half of that RFC was uncontroversial. I've added a link to the prior thread for reference. --Larry Garfield