Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65065 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34054 invoked from network); 22 Jan 2013 08:07:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jan 2013 08:07:13 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.50 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.215.50 mail-la0-f50.google.com Received: from [209.85.215.50] ([209.85.215.50:58540] helo=mail-la0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1E/40-28294-FA84EF05 for ; Tue, 22 Jan 2013 03:07:12 -0500 Received: by mail-la0-f50.google.com with SMTP id ec20so2829478lab.23 for ; Tue, 22 Jan 2013 00:07:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=XRiAVcaCmgnJvesCvbn+LTbVIZJUNxnJd61NzsKoEAM=; b=NO+zN2RHT/Mo/7YBypI6nxofDIiiKD1sqXCTTdz4eXe2r495ar0XYTAQqa1HF02+6T FW+84yZXwONk7ZB7bMd+bWzdj0qqPi8AdDvhJ3vjM4rbeQkZ+5HPDAgZW7sM6hQtcnt5 l3d5Uc+YTLM5uwxKcYjXc7jOHAopzjG7oj+lD67qrpJiRnaXWpymofKpyjOQ7NK34QTa tr/mQ/WOI5Z1Ft4Y3W1L+OuPPr1PQHY4CyuwXLNlH8/+evousC+NMMRxHjhrOtPEjMw2 ejpJQ/nEAvpVVTfAJNrpNPB5k00cBalQJMr6tf9ujPTP+t2X0e1tPYHpwOjb8MqCl7+N f5Vg== MIME-Version: 1.0 X-Received: by 10.112.46.37 with SMTP id s5mr8765040lbm.67.1358842028917; Tue, 22 Jan 2013 00:07:08 -0800 (PST) Received: by 10.112.138.131 with HTTP; Tue, 22 Jan 2013 00:07:08 -0800 (PST) In-Reply-To: References: Date: Tue, 22 Jan 2013 09:07:08 +0100 Message-ID: To: Gustavo Lopes Cc: PHP internals Content-Type: multipart/alternative; boundary=bcaec554e15670834904d3dc10d6 Subject: Re: [PHP-DEV] [VOTE] Alternative typehinting syntax for accessors From: nikita.ppv@gmail.com (Nikita Popov) --bcaec554e15670834904d3dc10d6 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Jan 21, 2013 at 7:54 PM, Gustavo Lopes wrote: > * It's a promise that's not guaranteed. As long as the getter is allowed > to reference the value of the variable can arbitrarily be changed to > whatever type. It may also be possible to do the same with unserialization. > Yes, that's a good point. One can't see this proposal as an introduction of strict typing, that fully guarantees that the property has one type and one type only. The typehints are there to help the programmer find mistakes. If he assigns a wrong type, then he'll get an error. But yes, it will break down if he actively tries to work against the system. If you start modifying unserialization input and stuff like that, you will be able to work around this. Just like you can also work around the method typehints if you feel like it. I still find them useful. > * The benefits are minimal. The only real benefit is cutting maybe two > lines of code in an indisputably common scenario. > It's not just about the lines of code. It's about having a more readable and more intuitive syntax. Am I the only one who thinks that "public $date { get; set(DateTime $date); }" looks pretty ugly/unclear compared to "public DateTime $date;"? Thanks, Nikita --bcaec554e15670834904d3dc10d6--