Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37245 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20380 invoked from network); 26 Apr 2008 18:06:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Apr 2008 18:06:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=dz@bitxtender.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dz@bitxtender.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain bitxtender.com from 80.237.132.12 cause and error) X-PHP-List-Original-Sender: dz@bitxtender.com X-Host-Fingerprint: 80.237.132.12 wp005.webpack.hosteurope.de Received: from [80.237.132.12] ([80.237.132.12:48722] helo=wp005.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/31-11391-21F63184 for ; Sat, 26 Apr 2008 14:06:11 -0400 Received: from dslb-088-066-172-231.pools.arcor-ip.net ([88.66.172.231] helo=[192.168.0.100]); authenticated by wp005.webpack.hosteurope.de running ExIM using esmtpsa (TLSv1:RC4-SHA:128) id 1Jpoml-0001km-R2; Sat, 26 Apr 2008 20:06:07 +0200 Cc: internals@lists.php.net Message-ID: <9484717D-2EC6-44FF-93C8-1A9911294AF6@bitxtender.com> To: Alain Williams In-Reply-To: <20080425231305.GC14490@mint.phcomp.co.uk> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Date: Sat, 26 Apr 2008 20:06:07 +0200 References: <1209137410.6642.9.camel@sbarrow-desktop> <1209147362.20639.7.camel@sbarrow-desktop> <20080425182341.GB14490@mint.phcomp.co.uk> <1209149047.20639.18.camel@sbarrow-desktop> <48122C14.7070705@omegavortex.net> <1209150944.20639.24.camel@sbarrow-desktop> <7dd2dc0b0804251224s750679acn169637efbd8653fa@mail.gmail.com> <1209151505.20639.25.camel@sbarrow-desktop> <20080425231305.GC14490@mint.phcomp.co.uk> X-Mailer: Apple Mail (2.919.2) X-bounce-key: webpack.hosteurope.de;dz@bitxtender.com;1209233171;00e752bb; Subject: Re: [PHP-DEV] Return type hinting patch From: dz@bitxtender.com (=?ISO-8859-1?Q?David_Z=FClke?=) Wouldn't the most consistent way be to omit "function" altogether when using a return type hint? public static function zomg() { return $somethingArbitrary; } public static string foo() { return $mustBeString; } otoh, should there ever be a type "function" (e.g. for anonymous funcs) down the road, that'd mean trouble ;) David Am 26.04.2008 um 01:13 schrieb Alain Williams: > > public function int doThing(string $foo) { return 1; } > > The above is the best (ie omit 'return' or 'returns'). > > This also is consistent with C and with the way that the manual is > written, eg: > > http://www.php.net/manual/en/function.strlen.php > > The only argument is the relative ordering of the keywords. > We keep 'function' - since that is the way that the language works. > Things like 'public' we put before 'function' since that is the way > that > it works in PHP 5 objects. > > So the only thing to decide is where the type goes: > > public function int doThing(string $foo) { return 1; } > > or: > > public int function doThing(string $foo) { return 1; } > > I would favour the first one, this is probably also easier to parse, > as > following 'function' and before '(' you can have: > > * 1 word - which must be the name of the function > * 2 words - the first word is the return type, the second the > function name. > > If the function returns a reference to something of a particular > type, where > does the '&' go: > > public function &int doThing(string $foo) { return 1; } > > or: > > public function int& doThing(string $foo) { return 1; } > > I would suggest the second, ie just before the function name. > > -- > Alain Williams > Linux Consultant - Mail systems, Web sites, Networking, Programmer, > IT Lecturer. > +44 (0) 787 668 0256 http://www.phcomp.co.uk/ > Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php > Chairman of UKUUG: http://www.ukuug.org/ > #include > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >