]> granicus.if.org Git - php/commitdiff
Fix the bug where the declared properties without init values were not
authorAndrei Zmievski <andrei@php.net>
Thu, 14 Feb 2002 04:01:53 +0000 (04:01 +0000)
committerAndrei Zmievski <andrei@php.net>
Thu, 14 Feb 2002 04:01:53 +0000 (04:01 +0000)
entered into the table.

Zend/zend_compile.c

index 865cdfc1dc8df73f00a11a027342cb5305ba3bc2..143ca3589e19535619b46619b4430c73549c6303 100644 (file)
@@ -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);
 }