Hi

2010/7/29 Ferenc Kovacs <i...@tyrael.hu>

> >> Hi, I would love this feature.
> >> But I have some concerns.
> >> AFAIK you can declare classes with the name int ,scalar, etc. so
> >> hinting anything else than class names can be ambiguous.
> >> Or we have to set these keywords as reserved, so nobody could declare
> >> classes with such names.
> >
> > Weren't they already made reserved with the parameter type hinting patch?
> >
>
> As I said:
>
> > Maybe this was resolved with the last scalar type hinting patch, which
> > got merged to the trunk, I don't know.
>

Currently on trunk version, if you use the php native types as type-hint it
will check for the php type, not the user class.

Trunk:
<?php

class int { }

function test(int $a) { }

test(1); // ok
test(new int); // error

Which is just like the return type-hint is working. I do prefer offer a way
to continue using the user class 'Int', as we not going to add new
keywords... My suggestion (I guess already told it in some mail...) is to
identify the native php type just when it's lowercased (case-sensitive).
(Java-style)

Patch: http://felipe.ath.cx/diff/param-typehint-native-type.diff

Example:
<?php

class int { }

function test(Int $a) { } // user class 'Int'
function test2(int $a) { } // native type 'int'

test(new int); // ok
test2(1); // ok



Thanks for the feedbacks. :-)

-- 
Regards,
Felipe Pena

Reply via email to