Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13351 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28652 invoked by uid 1010); 16 Oct 2004 21:52:39 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 28617 invoked from network); 16 Oct 2004 21:52:39 -0000 Received: from unknown (HELO bobsilva.com) (198.237.84.92) by pb1.pair.com with SMTP; 16 Oct 2004 21:52:39 -0000 Received: from [198.237.84.90] (account me HELO salty) by bobsilva.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 463612 for internals@lists.php.net; Sat, 16 Oct 2004 14:26:19 -0700 To: Date: Sat, 16 Oct 2004 14:50:58 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 In-Reply-To: <20041016191353.85746.qmail@pb1.pair.com> Thread-Index: AcSzsJ4FH1qg1kk2RH67pTOQLofqIQADZ7PQ Message-ID: Subject: RE: [PHP-DEV] Type hints with null default values From: junkmail@bobsilva.com ("Robert Silva") References: <20041016191353.85746.qmail@pb1.pair.com> I think Marcus B's final comments in the original discussion are right on track. Stab: I voted for NULL type hinted arguments before I voted against them. The main thing that changed my mind, is that in PHP there is no such thing as a NULL object. I came to the conclusion that PHP wasn't broken, my programming style/code was. My opinion is that they should stay as they are now although personally. Now with that said, I do think there needs to be a method to allow a type hinted parameter to be optional (but not necessarily null). class a { function b(Obj c=null) {}; } $a->b(null) or $a->b($anything_not_an_Obj) would be an error. $a->b() would be valid. function Format(ZIFormatter $formatter=null) { if (isset($formatter)) return $formatter->Format($this); else return $this; } Now the argument can be made to not type hint $formatter to begin with, but I don't want to have to check that it isnt null and instanceof ZIFormatter interface. I just want to know if it was passed, that I can use it as a ZIFormatter object. Bob Silva -----Original Message----- From: Cristiano Duarte [mailto:cunha17@uol.com.br] Sent: Saturday, October 16, 2004 12:14 PM To: internals@lists.php.net Subject: [PHP-DEV] Type hints with null default values Hi @ll, Now that 5.0.3 is out, maybe it's time to bring back that old problem left in May: type hints and null default values. This feature was dropped since no one could come with a reasonable solution. So, for now, there is no (engine) way to have a parameter that can only be of some class or null. Am I right ? The use of null (I know it's not a value it's a type...) is justified because we don't have a "value" to represent a NULL OBJECT(or NO OBJECT). IMO, this is a necessary feature (maybe others thing this way too) and that's why I brought it back. Cristiano Duarte -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php