Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97444 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57972 invoked from network); 19 Dec 2016 22:30:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Dec 2016 22:30:18 -0000 Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain brzuchalski.com designates 188.165.245.118 as permitted sender) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:54319] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5B/03-36089-C5F58585 for ; Mon, 19 Dec 2016 17:29:52 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id 1D5EB298423B for ; Mon, 19 Dec 2016 23:29:46 +0100 (CET) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eG_mqk5E36MI for ; Mon, 19 Dec 2016 23:29:41 +0100 (CET) Received: from mail-vk0-f43.google.com (unknown [209.85.213.43]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id 585312984239 for ; Mon, 19 Dec 2016 23:29:41 +0100 (CET) Received: by mail-vk0-f43.google.com with SMTP id x186so126814927vkd.1 for ; Mon, 19 Dec 2016 14:29:41 -0800 (PST) X-Gm-Message-State: AIkVDXKik0H9QzeOWa8HBf3IX2rYVB3Zb060/kx3Xc7JFZFeqYoSTOfeQQErSnPktYXlkcUChW9UZUDY2gKAcg== X-Received: by 10.31.166.12 with SMTP id p12mr5722805vke.50.1482186580350; Mon, 19 Dec 2016 14:29:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.7.132 with HTTP; Mon, 19 Dec 2016 14:29:39 -0800 (PST) In-Reply-To: <6d4632cb-93b3-4237-a803-6b7ec13dae4a@Spark> References: <6d4632cb-93b3-4237-a803-6b7ec13dae4a@Spark> Date: Mon, 19 Dec 2016 23:29:39 +0100 X-Gmail-Original-Message-ID: Message-ID: To: ilija.tovilo@me.com Cc: PHP Internals List Content-Type: multipart/alternative; boundary=001a1142e1b69cdebc05440a74ef Subject: =?UTF-8?Q?Re=3A_=5BPHP=2DDEV=5D_Revisit_RFC_=E2=80=9CProperty_Accessors_Synt?= =?UTF-8?Q?ax_1=2E2=E2=80=9D?= From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --001a1142e1b69cdebc05440a74ef Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Ilija, I have no vote rights, but this one is on my "Nice To Have Features in PHP" list too. +1 for property getters/setters Cheers, 2016-12-19 21:57 GMT+01:00 : > Hi everyone > > There was an RFC about a C#-like property syntax almost four years ago > that got declined: > https://wiki.php.net/rfc/propertygetsetsyntax-v1.2 > > It failed by only 2-3 votes. In my opinion, PHP is still in need of this > feature as it would make the language much more expressive. Let me start = by > defining the problem. First of all, almost all PHP frameworks hide their > variables behind getters and setters. Here are some of the reasons why th= at > is a good idea, I=E2=80=99m sure there are many more: > > - Ability to sanitize input > - Ability to lazily load data when requested (getter was called) > - Ability to expose only getter or setter publicly > - Easily mockable accessors for unit tests > - Ability to execute arbitrary code when accessors are called > - Modifiable business logic without breaking the API > > Here are some of the negatives, though there are probably more here as > well: > > - Large boilerplate for normal getters/setters > - Inconsistent syntax for reading/writing data > - Calling a method for setting data instead of using the more > intuitive `=3D` operator > - Calling a method for accessing foreign variables while accessing > private variables directly > - Inability to use built in assignment operators like .=3D, +=3D, -=3D, e= tc. > - Disregard of the DRY principle > > The positives clearly outweigh the negatives as they are mostly > syntactical. This is probably why using getters/setters everywhere has be= en > a good-enough solution for such a long time. Because of that, just like t= he > positives, the negatives have become a part of the language. Clearly, > abandoning getters and setters is no option for anyone. Nonetheless, the > RFC I linked above offers a way to get rid of the negatives without > sacrificing any of the positives. > > Are there still any people who would like to see this happening just as > much as I do? > I=E2=80=99m wondering if some of the people who have voted against the RF= C might > have changed their opinion or vice versa. > > Many thanks for reading! > > Regards, > Ilija > > --=20 regards / pozdrawiam, -- Micha=C5=82 Brzuchalski about.me/brzuchal brzuchalski.com --001a1142e1b69cdebc05440a74ef--