Re: RFC: Type hinting revisited for PHP 5.3
| From: | Paul Biggar | Date: | Wed, 01 Jul 2009 17:23:55 +0000 |
| Subject: | Re: RFC: Type hinting revisited for PHP 5.3 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44581@lists.php.net to get a copy of this message | ||
Hi Ilia,
This is great.
On Wed, Jul 1, 2009 at 5:59 PM, Ilia Alshanetsky<ilia@prohost.org> wrote:
> I've taken a few hours this morning to port my 5.2 type hinting patch to
> 5.3. In recognition of a need for a more 'flexible' numeric type I've
> introduced (numeric) type hint that would allow bool/int/float data types as
> well as a string containing a numeric entity as identified by
> is_numeric_string(). For completion i've also added (scalar) data type that
> will allow any scalar data element.
I think this will go a long way to addressing people's concerns when
this came up previously.
> The patch is available here:
> http://ia.gd/patch/type_hint_53.txt
I presume the idea is that some people (if they so chose) would want
to type hint every parameter in their program. To facilitate this, I
might suggest a "mixed" hint (like in the docs), and a null hint
(though I'm not sure if it would be called "null" or "unset" or both).
Finally, I don't want to ruin this, but last time there was
disagreement over whether numbers should be coerced to the specified
types, or left alone. What does your patch do?
ie function x (int $x) { echo is_int ($x); } x ("5");
Thanks,
Paul
> It should be noted that this is not the first idea for type hints, that
> credit goes to Hannes Magnusson who had posted a similar patch on the
> internals list back in 2006. Also, back in 2008 Felipe Pena wrote a type
> hinting patch for PHP that is available on wiki.php.net.
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Paul Biggar
paul.biggar@gmail.com