Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64671 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93607 invoked from network); 8 Jan 2013 10:16:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jan 2013 10:16:57 -0000 Authentication-Results: pb1.pair.com header.from=linepogl@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=linepogl@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.176 as permitted sender) X-PHP-List-Original-Sender: linepogl@gmail.com X-Host-Fingerprint: 209.85.223.176 mail-ie0-f176.google.com Received: from [209.85.223.176] ([209.85.223.176:34370] helo=mail-ie0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/32-16636-912FBE05 for ; Tue, 08 Jan 2013 05:16:57 -0500 Received: by mail-ie0-f176.google.com with SMTP id 13so255067iea.21 for ; Tue, 08 Jan 2013 02:16:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=OjiQCUTy0f/WVAlGaJLC+S8atVItpPfNPO9Q6rcxGnk=; b=mJDOWYat4RvfCHov0Hnm8xNc5chcft/e1DnkXx4i63duL4PC1Tylo2z1DwI6xXbt5N 4g+TSbVvw7b3f/eLlrPoXONy+JgQYbDZpqcY6JfFEeIlnwTg5hkRMYz47R5hfpOYOh+e 64bcd6DUdnIma+8AAKMYb9DkDSG+Xh/AKbuz3Qy5ISAvxeQtUphC5yfyJMLWi3Njvs8n sDGuF09mG2LklAGYM3I5iNMSO5F4/0kqOJnUTSCVeOsyuh+q3rTm31LBg9XIK6nPml6k O0oNWzTmxAGWkJh2uHSJ40Ibz9C0GXc2eVgYi5Rg4eVaQhNGpO6kYeYABmb7Jz6xgI9/ 95nQ== Received: by 10.42.72.132 with SMTP id o4mr37049471icj.44.1357640214811; Tue, 08 Jan 2013 02:16:54 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.143.67 with HTTP; Tue, 8 Jan 2013 02:16:33 -0800 (PST) In-Reply-To: <50EBEC0E.50908@toolpark.com> References: <4ED7146272E04A47B986ED49E771E347BB3D6ABCB3@Ikarus.ameusgmbh.intern> <50EBD4C4.8090703@toolpark.com> <50EBEC0E.50908@toolpark.com> Date: Tue, 8 Jan 2013 11:16:33 +0100 Message-ID: To: Lars Schultz Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=90e6ba3fcd55bc95c504d2c43efd Subject: Re: [PHP-DEV] [RFC] Alternative typehinting syntax for accessors From: linepogl@gmail.com (Lazare Inepologlou) --90e6ba3fcd55bc95c504d2c43efd Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2013/1/8 Lars Schultz > Am 08.01.2013 10:03, schrieb Lazare Inepologlou: > >> The fact is that the existing syntax for nullable type hinting has its o= wn >> problems. For example, this is not possible: >> function foo( Bar $bar =3D null , $mandatory ) { ... } >> > > Sure it's possible;) I did not get a syntax error for that...I even use > that case many times in my code exactly for that purpose, to allow $bar t= o > be null but require $mandatory to be defined explicitly. > Seems you are right. Sorry. > > I would love to have the question mark syntax for both properties and >> argument type hinting. >> > > Introducing a BC-Break and/or yet another syntax? Is that worth it? > > This does not apply in all cases. Here is an example of a property that = is >> guaranteed not to be null: >> >> class Foo { >> private $_date; >> public DateTime $date { >> get { >> return is_null($date) ? new DateTime() : $this->date; >> } >> set { >> $this->date =3D $value; >> } >> } >> } >> > > The property is still null;) Only the return value of the getter will not > be null. But that's not the issue, is it? I am not arguing the case of NO= T > allowing null, Stas wanted to always allow null because of this reason an= d > not have a special syntax to declare this. > > > No, the field $_date can be null. The property $date is not null, cannot be set to null and cannot return null. Furthermore, it cannot be unset (should fail with an error) and isset always returns true. Lazare INEPOLOGLOU Ing=C3=A9nieur Logiciel --90e6ba3fcd55bc95c504d2c43efd--