diff options
author | Andrei Zmievski <andrei@php.net> | 2002-02-14 04:01:53 +0000 |
---|---|---|
committer | Andrei Zmievski <andrei@php.net> | 2002-02-14 04:01:53 +0000 |
commit | 68a82f14a2d8469baca28d6b8347eff8dfdcca4c (patch) | |
tree | da0059127a32a3f48aaaaf3bf622c8b1cc2d334a | |
parent | e305585605faf906d979dfa670ca46938c331ca3 (diff) | |
download | php-git-68a82f14a2d8469baca28d6b8347eff8dfdcca4c.tar.gz |
Fix the bug where the declared properties without init values were not
entered into the table.
-rw-r--r-- | Zend/zend_compile.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 865cdfc1dc..143ca3589e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1966,23 +1966,27 @@ void zend_do_end_class_declaration(znode *class_token TSRMLS_DC) void zend_do_declare_property(znode *var_name, znode *value, int declaration_type TSRMLS_DC) { - if (value) { - zval *property; + zval *property; - ALLOC_ZVAL(property); + ALLOC_ZVAL(property); + if (value) { *property = value->u.constant; - switch (declaration_type) { - case T_VAR: - zend_hash_update(&CG(active_class_entry)->default_properties, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); - break; - case T_STATIC: - zend_hash_update(CG(active_class_entry)->static_members, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); - break; - case T_CONST: - zend_hash_update(&CG(active_class_entry)->constants_table, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); - break; - } + } else { + INIT_PZVAL(property); + property->type = IS_NULL; + } + + switch (declaration_type) { + case T_VAR: + zend_hash_update(&CG(active_class_entry)->default_properties, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); + break; + case T_STATIC: + zend_hash_update(CG(active_class_entry)->static_members, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); + break; + case T_CONST: + zend_hash_update(&CG(active_class_entry)->constants_table, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); + break; } FREE_PNODE(var_name); } |