From: Simon Schick [mailto:[email protected]]
>
> Hi, John
>
> Therefore I think it would be easy to explain how a type-hint for scalar
> could work.
>
> You can explain it as saying that the following two functions should be end
> up in exactly the same result, whatever you're pasting into:
>
> function foo_one(scalar $bar) {}
>
> function foo_two($bar) {
> if (!is_scalar($bar))
> trigger_error("Catchable fatal error: Argument ? passed to ? must be a
>scalar, ? given,", E_RECOVERABLE_ERROR);
> }
Type hints that only ensure that something is a scalar are a non-starter for
me. I'm not going to waste my time on something like that. You're not going to
get any better core support with this, and you'll alienate support from a
majority of userland as well. The average function doesn't need "just a scalar,
but any scalar will do". Most functions need something specific, like a string,
or a number. sqrt('foo') doesn't make any sense, it needs a number, not just a
scalar.
John Crenshaw
Priacta, Inc.