Re: RFC: Type hinting revisited for PHP 5.3
| From: | Paul Biggar | Date: | Wed, 01 Jul 2009 18:52:41 +0000 |
| Subject: | Re: RFC: Type hinting revisited for PHP 5.3 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44593@lists.php.net to get a copy of this message | ||
On Wed, Jul 1, 2009 at 7:44 PM, Stanislav Malyshev<stas@zend.com> wrote:
> Hi!
>
>> As far as your point goes, numeric hint addresses it.
>
> Numeric hint addresses one scenario only. It doesn't address conversions to
> strings or booleans, for example (even C allows you to use int as boolean!
> :).
I agree. We won't be able to use an int type for something which
should take an int. That might not matter in user code, but if we
cannot actually type hint internals functions then its a problem.
I think it should be a requirement that internals functions should be
able to be type hinted using what the manual says. We don't need to be
too strict on that, but if that manual says int, it should be hintable
with int, and accept "1".
My feeling is that scalars should be automatically coerced to the
correct type, if it makes sense to do so. (ie reject non-numeric
strings for ints).
Thanks,
Paul
--
Paul Biggar
paul.biggar@gmail.com