cvs: ZendEngine2(PHP_5_1) / zend_compile.c
dmitry Tue Nov 15 11:49:44 2005 EDT
Modified files: (Branch: PHP_5_1)
/ZendEngine2 zend_compile.c
Log:
Allow "null" default value for arguments with array type hint
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.647.2.11&r2=1.647.2.12&ty=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.647.2.11 ZendEngine2/zend_compile.c:1.647.2.12
--- ZendEngine2/zend_compile.c:1.647.2.11 Tue Nov 15 10:59:49 2005
+++ ZendEngine2/zend_compile.c Tue Nov 15 11:49:40 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.647.2.11 2005/11/15 15:59:49 derick Exp $ */
+/* $Id: zend_compile.c,v 1.647.2.12 2005/11/15 16:49:40 dmitry Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -1277,7 +1277,6 @@
if (class_type->u.constant.type == IS_STRING) {
cur_arg_info->class_name = class_type->u.constant.value.str.val;
cur_arg_info->class_name_len = class_type->u.constant.value.str.len;
-
if (op == ZEND_RECV_INIT) {
if (Z_TYPE(initialization->u.constant) == IS_NULL || (Z_TYPE(initialization->u.constant)
== IS_CONSTANT && !strcasecmp(Z_STRVAL(initialization->u.constant), "NULL"))) {
cur_arg_info->allow_null = 1;
@@ -1289,6 +1288,13 @@
cur_arg_info->array_type_hint = 1;
cur_arg_info->class_name = NULL;
cur_arg_info->class_name_len = 0;
+ if (op == ZEND_RECV_INIT) {
+ if (Z_TYPE(initialization->u.constant) == IS_NULL || (Z_TYPE(initialization->u.constant)
== IS_CONSTANT && !strcasecmp(Z_STRVAL(initialization->u.constant), "NULL"))) {
+ cur_arg_info->allow_null = 1;
+ } else if (Z_TYPE(initialization->u.constant) != IS_ARRAY &&
Z_TYPE(initialization->u.constant) != IS_CONSTANT_ARRAY) {
+ zend_error(E_COMPILE_ERROR, "Default value for parameters with array type hint can only
be an array or NULL");
+ }
+ }
}
} else {
cur_arg_info->class_name = NULL;
Thread (19 messages)
- Dmitry Stogov