Hi,

Your current implementation seems to be inconsistent with both itself
and the rest of PHP. I hope this can be rectified before it is
included. PHP is inconsisent enough without adding more.


1.) There are a number of is_* functions. It seems obvious that they
should be consistent with this. So you're missing numeric and scalar.
I'm not clear if there is a is_unicode(), but if so, that should be
consistent too. (I believe scalar is particularly important, at a
language level, since mixed and object are provided).

2.) is_int has different semantics to the int type hint. Numeric
strings qualify as the latter, but not the former. In general this is
a problem. It seems type hints can only be made consistent if they
convert the actual parameter to the type which is hinted. (Note that
for call-by-reference, this will change the value in the caller, not
just the copy in the callee - I think this is a good idea). As an
example, this will fail, which it shouldnt: function y (int $x) {
assert (is_int($x); } y ("24");

3.) This doesnt seem to be integrated with class type hints, in the
codebase. I wonder why that is? (I don't care all that much, I'm just
wondering).

I hope we can get these ironed out.

Thanks in advance.
Paul


On Thu, Apr 17, 2008 at 5:50 AM, Felipe Pena <[EMAIL PROTECTED]> wrote:
> Hello again!
>
>  Now with both parameter and return value type hints.
>
>  For parameter type hints, i have completed the actual implementation
>  with the leftover php types:
>  - string (binary string and unicode)
>  - integer (accepting numeric string too)
>  - double (accepting numeric string too)
>  - boolean ('0', '1', true, false)
>  - resource
>  - object
>
>  (Yes, following our dynamic typing)
>
>
>  Since then, the patch also includes new methods to Reflection:
>  - isInt()
>  - isDouble()
>  - isBool()
>  - isString()
>  - isObject()
>  - isResource()
>
>
>  And for return value, i have modified and improved the previous patch,
>  and now it is using only the "(type)" notation. Hence, that
>  implementation doesn't make any BC break.
>
>
>  Examples, patches and tests: http://wiki.php.net/rfc/typehint
>
>
>  Thanks.
>
>  --
>  Regards,
>  Felipe Pena.
>
>
>  --
>  PHP Internals - PHP Runtime Development Mailing List
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Paul Biggar
[EMAIL PROTECTED]

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

Reply via email to