From 95649ab260fa435ae7950b224ee0f6359ea37a68 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Thu, 4 Sep 2003 16:00:01 +0000 Subject: [PATCH] Tests show updating consts must happen once at runtime (revert optimization). Add tests for static properties. --- Zend/zend_API.c | 3 +- Zend/zend_execute.c | 1 + Zend/zend_object_handlers.c | 1 + .../tests/static_properties_002.phpt | 62 +++++++++++++++++++ tests/classes/static_properties_001.phpt | 27 ++++++++ 5 files changed, 92 insertions(+), 2 deletions(-) create mode 100755 ext/reflection/tests/static_properties_002.phpt create mode 100755 tests/classes/static_properties_001.phpt diff --git a/Zend/zend_API.c b/Zend/zend_API.c index e95be0838c7..136f48a0222 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -700,6 +700,7 @@ ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type if (!class_type->constants_updated) { zend_hash_apply_with_argument(&class_type->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); + zend_hash_apply_with_argument(class_type->static_members, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); class_type->constants_updated = 1; } @@ -1683,8 +1684,6 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_le default: break; } - } else { - zval_update_constant(&property, (void *) 1 TSRMLS_CC); } switch (access_type & ZEND_ACC_PPP_MASK) { case ZEND_ACC_PRIVATE: { diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index c7eccbf33b6..52fc671729e 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -722,6 +722,7 @@ static void zend_fetch_var_address(zend_op *opline, temp_variable *Ts, int type FREE_OP(Ts, &opline->op1, free_op1); break; case ZEND_FETCH_STATIC: + zval_update_constant(retval, (void*) 1 TSRMLS_CC); break; } } diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 3892918bf59..30b02ad95dd 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -736,6 +736,7 @@ zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, i } } + zval_update_constant(retval, (void *) 1 TSRMLS_CC); return retval; } diff --git a/ext/reflection/tests/static_properties_002.phpt b/ext/reflection/tests/static_properties_002.phpt new file mode 100755 index 00000000000..d62d8aca5b1 --- /dev/null +++ b/ext/reflection/tests/static_properties_002.phpt @@ -0,0 +1,62 @@ +--TEST-- +ZE2 Inheriting static properties +--SKIPIF-- + +--FILE-- +getStaticProperties()) . "\n"; + +echo "Done\n"; +?> +--EXPECTF-- +base::show(2) +derived::show(2) +base::inc() +base::show(3) +derived::show(3) +derived::inc() +base::show(4) +derived::show(4) +Number of properties: 1 +Done diff --git a/tests/classes/static_properties_001.phpt b/tests/classes/static_properties_001.phpt new file mode 100755 index 00000000000..1c34f68fc55 --- /dev/null +++ b/tests/classes/static_properties_001.phpt @@ -0,0 +1,27 @@ +--TEST-- +ZE2 Initializing static properties to arrays +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +array(0) { +} +array(1) { + [0]=> + int(1) +} +Done