Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57065 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2950 invoked from network); 23 Dec 2011 23:32:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Dec 2011 23:32:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=ar@ez.no; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ar@ez.no; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ez.no from 209.85.210.42 cause and error) X-PHP-List-Original-Sender: ar@ez.no X-Host-Fingerprint: 209.85.210.42 mail-pz0-f42.google.com Received: from [209.85.210.42] ([209.85.210.42:39591] helo=mail-pz0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/F2-16446-78F05FE4 for ; Fri, 23 Dec 2011 18:32:24 -0500 Received: by dadp13 with SMTP id p13so8402821dad.29 for ; Fri, 23 Dec 2011 15:32:20 -0800 (PST) Received: by 10.68.189.163 with SMTP id gj3mr34538893pbc.86.1324683140240; Fri, 23 Dec 2011 15:32:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.68.2.233 with HTTP; Fri, 23 Dec 2011 15:31:59 -0800 (PST) In-Reply-To: References: <2095305E-D4E3-4D7E-8218-32EE99688E0C@GMAIL.COM> <2C90FB94-38C4-4270-8C6A-B89304BA8ED8@gmail.com> <159A7CA2-8561-40DA-9434-CAAE12304DDB@gmail.com> <4EF3B56A.4040809@gmail.com> <-2451498990672032588@unknownmsgid> <4EF3BD21.2040301@sugarcrm.com> <-6952580475866195972@unknownmsgid> <4EF3C7F7.9010404@sugarcrm.com> <4841689055873111589@unknownmsgid> <4EF3D18B.7040900@sugarcrm.com> <11CFB4E4-F2DA-4766-AA23-D08180C3910B@gmail.com> Date: Sat, 24 Dec 2011 00:31:59 +0100 Message-ID: To: John Crenshaw Cc: Will Fitch , Stas Malyshev , PHP Developers Mailing List , =?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?= Content-Type: multipart/alternative; boundary=e89a8ff1ccd203930304b4cad44c Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: ar@ez.no (=?UTF-8?B?QW5kcsOpIFLDuG1ja2U=?=) --e89a8ff1ccd203930304b4cad44c Content-Type: text/plain; charset=UTF-8 2011/12/23 John Crenshaw > > From: Will Fitch [mailto:will.fitch@gmail.com] > > > > I would like to take this opportunity to query on a consensus: > > > > Would you prefer to allow methods with type hinted return values to > return null at will, or add a marker noting that it *may* return null? > > > > Example: Return null at will > > > > public ArrayIterator getIterator() > > { > > // something happened, will return null > > return null; > > } > > > > Example: Return only if identified as such > > > > public ArrayIterator? getIterator() > > { > > return null; > > } > > I hate the syntax in the second example (using ?). > It looks strange, but easy to get used to. Two examples from C#: public decimal? Grade { get; set; } public Nullable Time { get; set; } > > IMO allowing null should be the default unless specifically disallowed. I disagree for the reasons mentioned by for instance Robert. Type hints should be strict/explicit or not done at all. --e89a8ff1ccd203930304b4cad44c--