Attached is my return type hinting patch. It allows type hinting for
parameters and return values. Int, float, bool, string, num, scalar,
resource, object, array, and class names are supported for both
parameters and return values. Objects with __toString methods are
allowed to pass for scalar and string type hints.
function myTypedFunction returns int(string $stuff, bool, $things, num
$amount) {
return 'This will cause an error.'
}
I want to move the returns clause after the parameter list, but I
couldn't get it to work in the parser:
function x($param) returns y {
return new y
}
Parameters and return values are strict. Int means int (to the type),
etc. For type hinted parameters, null is allowed only if it is the
default value.
Implementations of abstract functions must be compatible both in their
parameter and return types. Mismatched types will cause an error.
Note: The parameter type hinting is complete. The return type hinting
works, but there is a small memory leak which I do not know how to fix.
Besides that it's running perfectly, it's very minor obstacle, I'm just
not familiar enough with C to fix this right now.