Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37224 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68510 invoked from network); 25 Apr 2008 17:58:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2008 17:58:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=sam@sambarrow.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sam@sambarrow.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain sambarrow.com from 208.70.128.104 cause and error) X-PHP-List-Original-Sender: sam@sambarrow.com X-Host-Fingerprint: 208.70.128.104 smtp-gw78.mailanyone.net Received: from [208.70.128.104] ([208.70.128.104:45778] helo=smtp-gw78.mailanyone.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AE/DD-18287-9BB12184 for ; Fri, 25 Apr 2008 13:58:17 -0400 Received: from mailanyone.net by smtp-gw78.mailanyone.net with esmtpsa (TLSv1:RC4-MD5:128) (MailAnyone extSMTP sam@sambarrow.com) id 1JpSBZ-0005r2-Lr; Fri, 25 Apr 2008 12:58:15 -0500 To: Stanislav Malyshev Cc: internals@lists.php.net In-Reply-To: <48120F8A.30504@zend.com> References: <1209137410.6642.9.camel@sbarrow-desktop> <48120F8A.30504@zend.com> Content-Type: text/plain Date: Fri, 25 Apr 2008 13:55:12 -0400 Message-ID: <1209146112.20639.4.camel@sbarrow-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Return type hinting patch From: sam@sambarrow.com (Sam Barrow) On Fri, 2008-04-25 at 10:06 -0700, Stanislav Malyshev wrote: > Hi! > > In general, it'd be very nice to have some definition of the proposed > feature beyond the patch. It would probably answer some of my questions > that follow :) > > > parameters and return values. Objects with __toString methods are > > allowed to pass for scalar and string type hints. > > What about objects that can be converted to other types (cast_object > handler)? Hadn't thought about these, don't see why it couldn't be added though. > > function myTypedFunction returns int(string $stuff, bool, $things, num > > $amount) { > > return 'This will cause an error.' > > } > > What about return "1"? Also I notice it introduces new keyword - > returns. Is it necessary? Each new keyword means broken code. We could probably find a way to use the return keyword or another syntax, I just did it like this for simplicity. > > Parameters and return values are strict. Int means int (to the type), > > Meaning that int would reject 1.0, true and "1"? bool would reject 1 and > 0 and null? Ouch, ouch, ouch. As it is now, yes, this works just like parameter hints. Could be changed if decided upon.