I have a curious example of what to me, appears to be a discrepancy
(intentional or not, I don't know) between how ARGINFO is treated in
extensions and Type Hinting is treated in userspace and I would appreciate
some aid in clarification.

For example, IteratorIterator::__construct(), the ARGINFO is
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0). Whenever a non-Traversable
value is passed, a Catchable Fatal Error is thrown as I would expect. If
however, you do:

<?php

    $it = new IteratorIterator();

?>

the code does not cause error and continues into the method body until an
InvalidArgumentException is thrown by zend_parse_parameters (This can all
be found in spl_iterators.c). On the other hand however, if you were to run
the following userspace code:

<?php

    class A {
        function test(Iterator $it) {
        }
    }

    $a = new A();
    $a->test();

?>

then you get a Catchable Fatal Error.

Firstly, and quite possibly, am I missing a flag that sets this behavior?
Secondly, If I am not missing anything, should hinted methods be treating
calls with no arguments the same and if so, which version is correct?
Perhaps of course, this behavior is intentional and would cause problems
if/shouldn't be changed. Either way, I would appreciate any help in
clarifying this.

Thanks,

William Martin


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

Reply via email to