Hi Ilia,

Your patch doesn't support a "null" (or maybe it should be called
"unset") type check. Its uses would be rare, but I think it should be
present for completeness.

Thanks,
Paul



On Wed, Jul 1, 2009 at 5:59 PM, Ilia Alshanetsky<i...@prohost.org> wrote:
> There has been quite a bit of discussion on this list, IRC, developer
> meetings, etc... about introduction of type hinting to PHP. Most people
> appear to think that this would be a good idea, but there is a reason why it
> is not in PHP already. The main source of conflict appears to be that in
> some cases typical type hinting is just too strict for PHP's typeless nature
> (most people expect that "1" == 1, while int type hint would definitely
> reject string "1").  Personally, I disagree with that opinion, but I can
> understand people who raise that issue. At work we've been using PHP 5.2
> with type hinting for nearly 2 years now with great success, it makes code
> much easier to read and understand and the security benefit of type hinting
> is not to be under valued. In many cases type hinting can present a last
> line of defense against unexpected input for numeric fields, which are
> typically abused to do SQL injection.
>
> 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.
>
> The patch is available here: http://ia.gd/patch/type_hint_53.txt
>
> It should be noted that this patch is fully compatible with opcode caches
> and and requires no changes on the part of an opcode cache such as APC to
> work.
>
> My hope is that the latest changes will allow this to become a standard part
> of PHP.
>
> Ilia Alshanetsky
>
> P.S.
>
> 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.big...@gmail.com

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to