Hello,

attached is a patch (by Markus) that allows you to make typehints 
optionally take NULL as default value too, f.e.:

class P { }
class T {
    function f(P $p = NULL) {
        var_dump($p);
    }
}

$o=new T();
$o->f(new P);
$o->f(NULL);
$o->f();

I would like to commit this patch to HEAD pending any objections.

regards,
Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org
Index: Zend/zend_compile.c
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.c,v
retrieving revision 1.665
diff -u -p -d -r1.665 zend_compile.c
--- Zend/zend_compile.c 3 Oct 2005 08:21:15 -0000       1.665
+++ Zend/zend_compile.c 6 Oct 2005 18:21:02 -0000
@@ -1324,7 +1324,7 @@ void zend_do_receive_arg(zend_uchar op, 
                        cur_arg_info->class_name = NULL;
                        cur_arg_info->class_name_len = 0;
                }
-               cur_arg_info->allow_null = 0;
+               cur_arg_info->allow_null = (op == ZEND_RECV_INIT && 
(Z_TYPE(initialization->u.constant) == IS_NULL || 
(Z_TYPE(initialization->u.constant) == IS_CONSTANT && 
!strcasecmp(Z_STRVAL(initialization->u.constant), "NULL")))) ? 1 : 0;
        } else {
                cur_arg_info->class_name = NULL;
                cur_arg_info->class_name_len = 0;
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to