Can anyone help me with this? Here is the current function declaration rule: T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING optional_function_return_type { zend_do_begin_function_declaration(&$1, &$4, 0, $3.op_type, NULL, &$5 TSRMLS_CC); } '(' parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); }
I want to move "optional_function_return_type" AFTER the parameter list, but I also need to pass it to zend_do_begin_function_declaration. Is this even possible? What I'm trying to acheive is this: function a($arg1, $arg2) return int { } Currently: function a return int($arg1, $arg2) { } On Fri, 2008-04-25 at 11:30 -0400, Sam Barrow wrote: > 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. > > -- > 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