Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64667 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86758 invoked from network); 8 Jan 2013 09:51:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jan 2013 09:51:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=lars.schultz@toolpark.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=lars.schultz@toolpark.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain toolpark.com from 195.49.42.12 cause and error) X-PHP-List-Original-Sender: lars.schultz@toolpark.com X-Host-Fingerprint: 195.49.42.12 mail1.screenlight.ch Received: from [195.49.42.12] ([195.49.42.12:51516] helo=mail1.screenlight.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/D0-16636-21CEBE05 for ; Tue, 08 Jan 2013 04:51:15 -0500 Received: from [192.168.1.112] ([192.168.1.112]) (authenticated user lars.schultz@toolpark.com) by mail1.screenlight.ch (Kerio Connect 7.0.2 patch 1) (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)) for internals@lists.php.net; Tue, 8 Jan 2013 10:51:10 +0100 Message-ID: <50EBEC0E.50908@toolpark.com> Date: Tue, 08 Jan 2013 10:51:10 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: internals@lists.php.net References: <4ED7146272E04A47B986ED49E771E347BB3D6ABCB3@Ikarus.ameusgmbh.intern> <50EBD4C4.8090703@toolpark.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Alternative typehinting syntax for accessors From: lars.schultz@toolpark.com (Lars Schultz) Am 08.01.2013 10:03, schrieb Lazare Inepologlou: > The fact is that the existing syntax for nullable type hinting has its own > problems. For example, this is not possible: > function foo( Bar $bar = 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 to be null but require $mandatory to be defined explicitly. > 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 = $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 NOT allowing null, Stas wanted to always allow null because of this reason and not have a special syntax to declare this.