Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109298 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32368 invoked from network); 25 Mar 2020 17:55:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Mar 2020 17:55:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3D0BD1804C6 for ; Wed, 25 Mar 2020 09:20:17 -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.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 144.76.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mail01.nexxes.net (mail01.nexxes.net [144.76.185.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 25 Mar 2020 09:20:16 -0700 (PDT) Received: from [IPv6:2001:4dd7:2167:0:e083:af92:b312:4556] (2001-4dd7-2167-0-e083-af92-b312-4556.ipv6dyn.netcologne.de [IPv6:2001:4dd7:2167:0:e083:af92:b312:4556]) (Authenticated sender: db220660-p0g-1) by mail01.nexxes.net (Postfix) with ESMTPSA id 7473C86063B for ; Wed, 25 Mar 2020 17:20:14 +0100 (CET) To: internals@lists.php.net References: <1b781e1e-3f27-485b-ab47-5eeaf9496548@www.fastmail.com> <56f4f7bf-6086-4e10-addb-aba93ba23c5e@www.fastmail.com> Autocrypt: addr=php@dennis.birkholz.biz; prefer-encrypt=mutual; keydata= mQGiBEnM7DIRBADL+i+aPpq2kqIJbf9Lhgu5Ly8Df2AJpIZnEVT0+vlTyCf1TzX6th5NW1fT VfXq7CBnZ5WJImcq2sibWfjRMEhU4d7PUz4cpUwp8qIDjyK5AnX6Y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ent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <56f4f7bf-6086-4e10-addb-aba93ba23c5e@www.fastmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Improving PHP's Object Egonomics: A broad analysis From: php@dennis.birkholz.biz (Dennis Birkholz) Am 25.03.20 um 15:24 schrieb Larry Garfield: > On Wed, Mar 25, 2020, at 5:57 AM, Nicolas Grekas wrote: >> Máté suggested this syntax and it has my preference over the one you menton >> Larry: doubling the visibility keyword could be enough to express >> read+write access: >> >> public private $property; <= public read access, private write access > > In that syntax, you have to remember which one comes first. There's no indication for the casual reader why > > public private $property; > > and > > private public $property; > > are different. Plus, just looking at it, "wait, it's public and private? WTF? That doesn't even make sense." > > It also doesn't extend gracefully to property accessors. Whatever accessors do, if they ever get resolved, would conflict with that, and thus we'd have that many more weird combinations of property metadata that are incompatible. > > The whole point of the syntax I proposed for asymmetric visibility is that it's gracefully extensible, even if a little more verbose. (If we can find a syntax that is less verbose while still gracefully extensible, I am on board with that.) What about the following syntax: class X { public read private write $property; } That would play nicely with accessors: class Y { public read getProp private write setProp Type $property; // or this way around to make it clear which is the setter // and which is the property type public getProp read private setProp write Type $property; private function getProp() : ?Type {} private function setProp (Type $newValue) {} } It seems to me this would allow a clear syntax where you can selectively add accessor method for reading or writing or both, you can reuse existing setting methods when refactoring. Only the isset/unset accessors are missing. I am not sure if they are necessary: isset could be equivalent to ($obj->getProp() !== null) and unset to setting null, but I have not thought this through yet. Greets Dennis