Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122710 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 246F91AD8EA for ; Thu, 21 Mar 2024 16:11:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1711037531; bh=H0+qwRWyVGtBHsgXjaJqUpOTK4jW9SWh+cIp0hZoFAs=; h=In-Reply-To:References:Date:From:To:Subject:From; b=Q3vxQFzudCJa9Wak3NqYcx135Pg6heUk863DenwyzDPdmjNI2hPTFsYnlHFda/mcb fpcy3K+OLpbo8EGlwDpNZc8X9O++3AXUoBM/bahKDc3o66mihinjuNkMg5Br+2QCqv OeP3impNsIYqXUL/1ivmamXXqbPYZw16Xlw3RHUFlKLIVPVjK75rFfrStcC74AoiCg 8+rk6HAb9qMTClSQx7JCAbav9fQ854tv+SDZGLBsQ3bqLcgWOw0T3O7Zq5POVgxi8A EWz7kCD+2vntx+2ky/3Ww9k7ww6I6YMZ8G208o+p+3NdHsv9LglpdE8WWzAR9rnTX2 wCzuG8uDKjhvw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CE6C1180818 for ; Thu, 21 Mar 2024 16:12:09 +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: No X-Envelope-From: Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 21 Mar 2024 16:12:08 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id DC4F43200A10 for ; Thu, 21 Mar 2024 12:11:45 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Thu, 21 Mar 2024 12:11:46 -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=1711037505; x= 1711123905; bh=8MwVEBlkkguah4XbNMHQ47XSH2TtnLdkhjdlCsHVo7c=; b=a u9v/XVzCnxTppGHx9G7KpngnisydFOTpZ7hzrWrl1BHh7yG7bu9b6NemttpSQmA0 JXOGd0sgf+Nekjr/WUkvdQtJV4Se6cuwPhb8FomX5DM2dspyAYjwa7mNOEkdTvUy iNeVC98BMUv9QioVuXTrCtCDbPlMYZVzhlIYGurFj1SYV7Mq77RGp1ehMwlvIfkN pNasN5ZDl05KVsUDLqi0pem7ZcukTiBkNxdeOA33NIcqkmsYTNs+PNYBEymqDpP8 CV/KFalurcn06ULyako1JkCjQGkU6Qf3vUco+gQSgdQWUobbU/J/np9qbZ+ibulQ 2XuG4lKwI1ixlzPGfBK+Q== 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=1711037505; x=1711123905; bh=8MwVEBlkkguah4XbNMHQ47XSH2Tt nLdkhjdlCsHVo7c=; b=r4qY55P3T48YG3lyrfD8Nlkqo9Pk0sj260G/1zTp0vyk y0bRXjMpHdgY/md4jWfFwwO+iu4aCCSIFJMmJgC38+FZkNuHvX1LPvCehr9JNtWC E1VL10yEkhhXoIT8SuFCSCzR6ueHcyq/mEs8pXPOLphOGbS8GRVk77foEOuy/X91 VV5hewYGUdhPkplauReCueKKlJ2SvL0winW+J8cLcbE2xyCsvP7YlfKz4AAK9LrG tRN1ZiZ2v7XvnsQD0zvP4eGLZUfU8qgr5YUpIN/YH3rCfzHOR5ZIwCXBYxl+Y0je lcmww0YeZ7a9cMGhEpin2qtAdU7BO5JoRDCYa9yXlg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrleejgddvfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefgffek udevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 1D9291700093; Thu, 21 Mar 2024 12:11:45 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-332-gdeb4194079-fm-20240319.002-gdeb41940 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: References: <452aae1b-8929-4f08-a388-45b374d2a365@app.fastmail.com> Date: Thu, 21 Mar 2024 16:11:19 +0000 To: "php internals" Subject: Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2 Content-Type: text/plain From: larry@garfieldtech.com ("Larry Garfield") On Thu, Mar 21, 2024, at 9:10 AM, Robert Landers wrote: > Hello, > > I'm a bit confused on inheritance. In the following example of a > proxy, do I need to be aware of a parent's hook and handle it > specially? > > class Loud > { > public string $name { > get { > return strtoupper($this->name); > } > } > } > > class LoudProxy extends Loud > { > public string $name { > get { > // detected the parent has a hook? // > $return = parent::$name::get(); > // do something with return // > return $return; > } > } > } > > what happens if the Loud class later removes its hook implementation > (ex: moves it to the set hook)? Will my proxy now cause an error? > > Would simply calling $this->name call the parents hook? Per the RFC: "If there is no hook on the parent property, its default get/set behavior will be used. " so parent::$name::get() will "read the parent property", which will go through a hook if one is defined, and just read the raw value if not. So there is no detection logic needed, and the parent can add/remove a hook without affecting the child. Calling $this->name in LoudProxy's get hook will access backing property on LoudProxy itself, ignoring the parent entirely. --Larry Garfield