Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114351 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35467 invoked from network); 10 May 2021 19:43:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 May 2021 19:43:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 38E91180211 for ; Mon, 10 May 2021 12:50:38 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-40133.protonmail.ch (mail-40133.protonmail.ch [185.70.40.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 10 May 2021 12:50:36 -0700 (PDT) Date: Mon, 10 May 2021 19:50:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1620676234; bh=f7Fc2rY8IhzRrlQUG938VBG9X1XuPd2khZbL97fFS70=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=ZI8BCUv60j0lUPUxU4I30Mp1oaeBi64I1nqK4KpztT2rAjGgBEXH0jhsw5CMJ8ow5 +KNbNgY/5ILENnc9vGPlq+O3cAGNVDM8N3gj2rjaLEZtDTamVXI8J/7FYcbiC6bsGh xKZlOfym6gvihOawRduZUXqfab4sfNbvqyeUfONI= To: Nikita Popov Cc: PHP internals Reply-To: Trevor Rowbotham Message-ID: <8k-0GSw3SzLqD94K-w_7CKXwcfl7m7Zf8yqom5f1F_reALxX8HLFd_KkBYO-pQnNDaEyknpdP7KZk9NI-mr-vl-sBzcfmS8HdkgGxRoTmpo=@protonmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Property accessors From: trevor.rowbotham@protonmail.com (Trevor Rowbotham) =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Tuesday, May 4th, 2021 at 6:33 AM, Nikita Popov nikita.ppv@gmail.com wro= te: > Hi internals, > > I'd like to present an RFC for property accessors: > > https://wiki.php.net/rfc/property_accessors > > Property accessors are like __get() and __set(), but for a single propert= y. > > They also support read-only properties and properties with asymmetric > > visibility (public read, private write) as a side-effect. > > The proposal is modeled after C#-style accessors (also used by Swift), an= d > > syntactically similar to the previous > > https://wiki.php.net/rfc/propertygetsetsyntax-v1.2 proposal. > > While I put a lot of effort into both the proposal and the implementation= , > > I've grown increasingly uncertain that this is the right direction for us > > to take. The proposal turned out to be significantly more complex than I > > originally anticipated (despite reducing the scope to only "get" and "set= " > > accessors), and I'm sure there are some interactions I still haven't > > accounted for. I'm not convinced the value justifies the complexity. > > So, while I'm putting this up for discussion, it may be that I will not > > pursue landing it. I think a lot of the practical value of this accessors > > proposal would be captured by support for read-only (and/or private-write= ) > > properties. This has been discussed (and declined) in the past, but > > probably should be revisited. > > Regards, > > Nikita Hi, Thank you for the effort put forth in this RFC. I have a few questions after having read it. Will these properties work with the property_exists() function? I don't see it mentioned in the RFC, and seeing as how the function does not work with properties defined in __get() and __set(), the answer to this isn't obvious to me. The RFC also mentions that calling isset() on a write-only property will throw an Error exception. Should a new function along the lines of property_is_readable(), which returns true if the property is readable in the current scope, (and possibly its mirror function property_is_writable()) be introduced? Going through the Reflection API feels overly verbose and error prone to find out if a property is readable/= writable. - Trevor