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 <std_disclaimer.h>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php