Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123667 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 9E2791A009C for ; Tue, 18 Jun 2024 19:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718739993; bh=tVLLAWA+5PPsXAWm0KHiY611V8KyrDhIJ+upa4A/O44=; h=In-Reply-To:References:Date:From:To:Subject:From; b=MjsQUoeuweegW1k5ubT4I6CbnV/uvKcAs8DoEaIaBbWDbu4yy/z5J/E21uRD7ZizC 7Ut+9Kp6jZE1i9UNI/IshH4+qC7UdGf7f+mpV8kgFfwuOMzlBljObl1Uut7n01MooO vK3VaY6EDYkAiAKybm2MlYrISHOC5pN+v6P2CVJYTJQ3Vkq0fCXu4QWGg4Jx56RDec bgky6xAHTfgXjJ3Xruxgd4VxVi0xBRpbmVb3sSr4Pp50ePgFSRn+LVP+D6LlNcJRYp V2Klm/Ux10VKpYqvDltFq5Tdsa1MdDFSqaiGhcbptMhZ66moMx3c3JrrSriAKkvcMm RIIbVXCClbibw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2FD181804C1 for ; Tue, 18 Jun 2024 19:46:32 +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,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,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 wfout2-smtp.messagingengine.com (wfout2-smtp.messagingengine.com [64.147.123.145]) (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, 18 Jun 2024 19:46:31 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id DF8A61C000C4 for ; Tue, 18 Jun 2024 15:45:17 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Tue, 18 Jun 2024 15:45:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=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=fm2; t=1718739917; x= 1718826317; bh=tqLxYa2zbYbw6Vu682fhjAHgfyXD4C/YvCtZGsU9PIg=; b=Y KhpJRbHhYQtJKyY0QoaPcu0I/NS692e/2UWu4xq0o8+F4bT+pbB3By7Z26cRnRSu I4OYd4VxO1waHHAKkZNK15v5BdmC5AywzCkHy6hZlNVN7KrQ+k3Uwaol3pQhJ9rP VfIw14ROP5xLqxsIjvb7D9l39z5C1DpO/qe33yWYd+LrotKywflY07gkQt7obZ72 UTEqY8rnBaTFSSrYdyqqmDzyfgSspznpo1ouDrjEwkn9lFbptf3feM65sniB0IfF 7xIemrWJq9VgWAR52XqrHcUdfInF620g5KJRgI6XLy7HfIpZS+XcgdAn+vDhZnYq 1fKc6oBg3Vkp0XKpNS6Fw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=1718739917; x=1718826317; bh=tqLxYa2zbYbw6Vu682fhjAHgfyXD 4C/YvCtZGsU9PIg=; b=R1ujas88vgJa0PEkMBgKx5wMcD3KC2+WtZjcRZCx5/1Q ffEErUX6UFNnME4wknDhIoqNOqcaTBAlC6NXPGexfeb7zoiaq0dLVhX+6WXmQEAc OHfqnKAUZJ71CyqWEjtLe7eTltu7JlbXRWBCS4Sn2GKR8XlP4sy1aWm5oIt0fBLJ oHCVamywkQpmJrNa6h0yOD/V5UGcD08ADMh0aaQGVk3Qeg87ykryyeqpNiVqiqNy y/AoJCpQWPwebW9td1KQy1ahZOXov577/R940LSpvFlkG7JB54XXi7Ycuwr7cIHO eO5lNLZFacsDkoIXd5ZMY1DBdOYf0c+SXnVk3zEJMw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedvkedgudduvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefg ffekudevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 188261700096; Tue, 18 Jun 2024 15:45:17 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-522-ga39cca1d5-fm-20240610.002-ga39cca1d Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <8fc1969d-5f21-400d-a3ae-aee5d741a81d@app.fastmail.com> In-Reply-To: References: <1118bbcd-a7b4-47bf-bf35-1a36ab4628e1@bastelstu.be> Date: Tue, 18 Jun 2024 19:44:55 +0000 To: "php internals" Subject: Re: [PHP-DEV] [RFC] Lazy Objects Content-Type: text/plain From: larry@garfieldtech.com ("Larry Garfield") On Tue, Jun 18, 2024, at 5:45 PM, Arnaud Le Blanc wrote: > Hi Larry, > > Following your feedback we propose to amend the API as follows: > > ``` > class ReflectionClass > { > public function newLazyProxy(callable $factory, int $options): object {} > > public function newLazyGhost(callable $initializer, int $options): object {} > > public function resetAsLazyProxy(object $object, callable > $factory, int $options): void {} > > public function resetAsLazyGhost(object $object, callable > $initializer, int $options): void {} > > public function initialize(object $object): object {} > > public function isInitialized(object $object): bool {} > > // existing methods > } > > class ReflectionProperty > { > public function setRawValueWithoutInitialization(object $object, > mixed $value): void {} > > public function skipInitialization(object $object): void {} > > // existing methods > } > ``` > > Comments / rationale: > - Adding methods on ReflectionClass instead of ReflectionObject is > better from a performance point of view, as mentioned earlier > - Keeping the word "Lazy" in method names is clearer, especially for > "newLazyProxy" as a the "Proxy" pattern has many uses-cases that are > not related to laziness. However we removed the word "Instance" to > make the names shorter. > - We have renamed "make" methods to "reset", following your feedback > about the word "make". It should better convey the behavior of these > methods, and clarify that it's modifying the object in-place as well > as resetting its state > - setRawValueWithoutInitialization() has the same behavior as > setRawValue() (from the hooks RFC), except it doesn't trigger > initialization > - Renamed $initializer to $factory for proxy methods > > WDYT? > > Best Regards, > Arnaud Oh, that looks *so* much more self-explanatory and readable. I love it. Thanks! (Looks like the RFC text hasn't been updated yet.) --Larry Garfield