diff options
author | Dmitry Stogov <dmitry@php.net> | 2005-11-15 16:49:40 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2005-11-15 16:49:40 +0000 |
commit | b58ed261d78a7bcc2f218035f393383acda113b0 (patch) | |
tree | 932e86c23af2f60975018c6ff03aae0be3783234 /Zend | |
parent | aa9ea598516fab375d3307cb0c7f6a6559940ed4 (diff) | |
download | php-git-b58ed261d78a7bcc2f218035f393383acda113b0.tar.gz |
Allow "null" default value for arguments with array type hint
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/zend_compile.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index c10f694ee1..85923e622e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1277,7 +1277,6 @@ void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initia 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 @@ void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initia 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; |