Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122685 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 A2B831AD8F6 for ; Tue, 19 Mar 2024 11:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1710846998; bh=3DAtVZDY7Z11yPX+vkmvc7A9vLStHAWW/VIcf4CstdA=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=dsnsG8v75kBLfUiMTm/n0/A4E7svG9UXD4k+AKpCXicXxHDLuY3an0WF7hKdDpbQ5 08i+POOHcwKI4S/LMLAcy1dvh/9LrWQZL7/mL0Cd1wuoKhKwgpjy8WjNBjHS6M1gcI QUoqCmRXGb70Q+Y6AlVbyMbT7ganBUmy0UgL+p6ZlhxVztCp5BtAXMHAurwOtltLJM ZWr+4tN4dTZTrC/d1xBripChq44QcT9fKxCUmaairEkcySUnXcOPQpb6XvBub9s3zQ 5ACxgfBgITuDYkZfoRgOE3b3kI4pgZf9sJmJYS55S8bMz4l3MRr+exu4d51bJkuQYp faZfMutziE0vQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 254BE180074 for ; Tue, 19 Mar 2024 11:16:37 +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=3.0 required=5.0 tests=BAYES_40,DMARC_MISSING, SPF_HELO_PASS,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from xdebug.org (xdebug.org [82.113.146.227]) by php-smtp4.php.net (Postfix) with ESMTP for ; Tue, 19 Mar 2024 11:16:36 +0000 (UTC) Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 761FF10C0AF; Tue, 19 Mar 2024 11:16:15 +0000 (GMT) Date: Tue, 19 Mar 2024 12:16:15 +0100 (CET) To: Larry Garfield cc: php internals Subject: Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2 In-Reply-To: Message-ID: References: Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1053242878-1710846975=:29878" From: derick@php.net (Derick Rethans) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1053242878-1710846975=:29878 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Fri, 8 Mar 2024, Larry Garfield wrote: > Hi folks. Based on earlier discussions, we've made a number of=20 > changes to the RFC that should address some of the concerns people=20 > raised. We also had some very fruitful discussions off-list with=20 > several developers from the Foundation, which led to what we feel are=20 > some solid improvements. >=20 > https://wiki.php.net/rfc/property-hooks Some comments and questions: =09Be aware, the detection logic works on $this->[propertyName] directly at= =20 =09compile time, not on dynamic forms of it like $prop =3D 'beep';=20 =09$this->$prop. That will not trigger a backing value.=20 How can that not cause issues? =09 The set hook's return type is unspecified, and will silently be=20 =09treated as void.=20 What happens if you *do* specify a return type? Will it Error? =09Implicit ''set'' parameter =09If the write-type of a property is the same as its defined type=20 =09(this is the common case), then the argument may be omitted=20 =09entirely.=20 =09=E2=80=A6 =09If the parameter is not specified, it defaults to $value. I am not a fan of this "magical" behaviour. Do we *need* this short cut,=20 and the following "Short-set"? =09With asymmetric visibility that was previously proposed, the=20 =09example can be further simplified.=20 But it isn't here, so why is this example (and the next one) in the RFC?=20 :-) =09Interaction with constructor property promotion =09=E2=80=A6 In particular, the shorthand version of hook bodies and the=20 =09ability to call out to private methods if they get complicated=20 =09partially obviate the concern about syntactic complexity.=20 Although that is true, it *does* add more complexity in tools that needs=20 to parse PHP, as there is now another piece of new syntax that needs to=20 be added (and tested with). =09ReflectionProperty has several new methods to work with hooks. =09getHooks(): array returns an array of \ReflectionMethod objects =20 =09keyed by the hook they are for. What will the name for the &get hook be? And shouldn't there be an enum=20 case for that as well? cheers, Derick --8323329-1053242878-1710846975=:29878--