Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97443 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51157 invoked from network); 19 Dec 2016 21:00:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Dec 2016 21:00:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=ilija.tovilo@me.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ilija.tovilo@me.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain me.com designates 17.172.80.97 as permitted sender) X-PHP-List-Original-Sender: ilija.tovilo@me.com X-Host-Fingerprint: 17.172.80.97 st11p00im-asmtp003.me.com Received: from [17.172.80.97] ([17.172.80.97:51568] helo=st11p00im-asmtp003.me.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C7/02-36089-07A48585 for ; Mon, 19 Dec 2016 16:00:32 -0500 Received: from process-dkim-sign-daemon.st11p00im-asmtp003.me.com by st11p00im-asmtp003.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) id <0OIG00500ABYXC00@st11p00im-asmtp003.me.com> for internals@lists.php.net; Mon, 19 Dec 2016 21:00:29 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a; t=1482181229; bh=J3Hf6OxAq5aiVCZTcsFyHBH13vQFIOUd2Hi4syirpTM=; h=Date:From:To:Message-id:Subject:MIME-version:Content-type; b=j2yLWMhuyxcDHYpQ2SgajL5GFzuXJOABTxCcqESX7pJyyzhmkOebqEayJmoo2R1b9 jNP0b+nFPefUIvnt9AJAFU1hIcQqo1jME0M4dbPS0mM5+skP6bNggNaoN+/G+mvMUc Mm54eJNOFfdph64OTOxKitD4x3r3rjcqnIojs+wutB/t1EplwVbnznyCphetpZjCaQ 1Hd97mYpsMtNjmgYoaMzo4a9wx1NCs80owG/y7CyTxHUzMBupCVZpwpnV04VYGIZaD 1mlRNxIdyLV6+7usG4xWg83lkXCrgvXUjiTbJTxfOvg2LNksa1+kwUCkt+1QoMhf4K M7mei/VJ9bSag== Received: from [192.168.178.58] (adsl-84-226-160-7.adslplus.ch [84.226.160.7]) by st11p00im-asmtp003.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) with ESMTPSA id <0OIG00C8GACRZP30@st11p00im-asmtp003.me.com> for internals@lists.php.net; Mon, 19 Dec 2016 21:00:29 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-12-19_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1034 suspectscore=44 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1612190230 Date: Mon, 19 Dec 2016 21:57:27 +0100 To: internals@lists.php.net Message-ID: <6d4632cb-93b3-4237-a803-6b7ec13dae4a@Spark> X-Readdle-Message-ID: 6d4632cb-93b3-4237-a803-6b7ec13dae4a@Spark MIME-version: 1.0 Content-type: multipart/alternative; boundary=58584a6a_6b8b4567_25c Subject: Revisit RFC =?utf-8?Q?=E2=80=9CProperty_?=Accessors Syntax =?utf-8?Q?1.2=E2=80=9D?= From: ilija.tovilo@me.com --58584a6a_6b8b4567_25c Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi everyone There was an R=46C about a C=23-like property syntax almost four years ag= o 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. =46irst of all, almost all PHP frameworks hide t= heir variables behind getters and setters. Here are some of the reasons w= hy that 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 we= ll: - Large boilerplate for normal getters/setters - Inconsistent syntax for reading/writing data =C2=A0 =C2=A0 - Calling a method for setting data instead of using the mo= re intuitive =60=3D=60 operator =C2=A0 =C2=A0 - Calling a method for accessing foreign variables while ac= cessing 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 syntactic= al. This is probably why using getters/setters everywhere has been a good= -enough solution for such a long time. Because of that, just like the pos= itives, the negatives have become a part of the language. Clearly, abando= ning getters and setters is no option for anyone. Nonetheless, the R=46C = I linked above offers a way to get rid of the negatives without sacrifici= ng any of the positives. Are there still any people who would like to see this happening just as m= uch as I do=3F I=E2=80=99m wondering if some of the people who have voted against the R=46= C might have changed their opinion or vice versa. Many thanks for reading=21 Regards, Ilija --58584a6a_6b8b4567_25c--