On Tue, Aug 9, 2011 at 6:10 PM, Frank Thynne <frank.thy...@gmail.com> wrote:

> function integer int_func(string $s) {
>  // does something like, say, converting "five" to 5
> }
>

As Stuart pointed out, type-hinting currently only works for classes and
arrays. Scalar type-hinting is planned for the future, but for now you're
left with enforcing it in the function itself. You can create a class with
static helpers to make this easier if you're going to do it frequently.

As for documentation, go with the PHPDoc standard:

/**
 * Converts a spelled-out number to the equivalent integer.
 *
 * @param string $s must be a spelled out number, e.g. "five" rather than
"5".
 * @return int
 */
function int_func($s) { ... }

To confuse me a bit further, I can't find a definitive list of the
> basic type names. For example, is it "integer" or "int"?


I use "int" and "bool" with the rest spelled out which works with casting.

Peace,
David

Reply via email to