Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37242 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96306 invoked from network); 25 Apr 2008 23:13:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2008 23:13:10 -0000 Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 213.152.38.186 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 213.152.38.186 freshmint.phcomp.co.uk Linux 2.5 (sometimes 2.4) (4) Received: from [213.152.38.186] ([213.152.38.186:62473] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 04/F9-18287-48562184 for ; Fri, 25 Apr 2008 19:13:09 -0400 Received: from addw by mint.phcomp.co.uk with local (Exim 4.69) (envelope-from ) id 1JpX6H-0006vc-PS for internals@lists.php.net; Sat, 26 Apr 2008 00:13:05 +0100 Date: Sat, 26 Apr 2008 00:13:05 +0100 To: internals@lists.php.net Message-ID: <20080425231305.GC14490@mint.phcomp.co.uk> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i Organization: Parliament Hill Computers Ltd Subject: Re: [PHP-DEV] Return type hinting patch From: addw@phcomp.co.uk (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