Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c php-src NEWS

From: Date: Sun, 16 Oct 2005 00:10:58 +0000
Subject: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c php-src NEWS
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-19623@lists.php.net to get a copy of this message
Hey Marcus, Derick, After the millions of discussions on this topic it would have been better to share this patch with everyone before commiting. In any case, as I could never think of a better syntax to deal with the somewhat harmless ambiguity of default value and "allowing" null, I don't mind having this patch. It should be documented though that this syntax comes to serve both purposes. I do suggest though, that you perfect the patch to make sure that using values other than null is a compile-time error and not only caught at run-time. I'm talking about the following function decleration: function testNull(MyClass $obj = 1) { } Thanks, Andi At 05:54 AM 10/15/2005, Derick Rethans wrote:
derick          Sat Oct 15 08:54:20 2005 EDT
Modified files:
    /php-src    NEWS
    /ZendEngine2        zend_compile.c
Log: - Changed type hints so that they take "= NULL" as default value. http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2069&r2=1.2070&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.2069 php-src/NEWS:1.2070 --- php-src/NEWS:1.2069 Mon Oct 3 08:07:19 2005
+++ php-src/NEWS        Sat Oct 15 08:54:18 2005
@@ -2,6 +2,8 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 6.0 - Unicode support. (Andrei, Dmitriy, et al) +- Changed type hints so that they take "= NULL" as default value. (Marcus, + Derick) - Changed __toString() behavior to call it in all necessary places (Marcus, Dmitry) - Changed "instanceof" and "catch" operators, is_a() and is_subclass_of() http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.667&r2=1.668&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.667 ZendEngine2/zend_compile.c:1.668
--- ZendEngine2/zend_compile.c:1.667    Mon Oct 10 06:50:35 2005
+++ ZendEngine2/zend_compile.c Sat Oct 15 08:54:19 2005 @@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
*/ -/* $Id: zend_compile.c,v 1.667 2005/10/10 10:50:35 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.668 2005/10/15 12:54:19 derick Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1337,7 +1337,7 @@
                        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;
-- Zend Engine CVS Mailing List (http://cvs.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Zend/PHP Conference & Expo Power Your Business with PHP October 18-21, 2005 - San Francisco http://zend.kbconferences.com/

« previous php.internals (#19623) next »