summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_API.c3
-rw-r--r--Zend/zend_execute.c1
-rw-r--r--Zend/zend_object_handlers.c1
-rwxr-xr-xext/reflection/tests/static_properties_002.phpt62
-rwxr-xr-xtests/classes/static_properties_001.phpt27
5 files changed, 92 insertions, 2 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index e95be0838c..136f48a022 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 c7eccbf33b..52fc671729 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 3892918bf5..30b02ad95d 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 0000000000..d62d8aca5b
--- /dev/null
+++ b/ext/reflection/tests/static_properties_002.phpt
@@ -0,0 +1,62 @@
+--TEST--
+ZE2 Inheriting static properties
+--SKIPIF--
+<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
+--FILE--
+<?php
+
+class base {
+ static protected $prop = 2;
+
+ static function show() {
+ echo __METHOD__ . '(' . self::$prop . ")\n";
+ }
+
+ static function inc() {
+ base::$prop++;
+ echo __METHOD__ . "()\n";
+ }
+}
+
+class derived extends base {
+ static public $prop;
+
+ static function show() {
+ echo __METHOD__ . '(' . self::$prop . ")\n";
+ }
+
+ static function inc() {
+ derived::$prop++;
+ echo __METHOD__ . "()\n";
+ }
+}
+
+base::show();
+derived::show();
+
+base::inc();
+
+base::show();
+derived::show();
+
+derived::inc();
+
+base::show();
+derived::show();
+
+$r = new reflection_class('derived');
+echo 'Number of properties: '. count($r->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 0000000000..1c34f68fc5
--- /dev/null
+++ b/tests/classes/static_properties_001.phpt
@@ -0,0 +1,27 @@
+--TEST--
+ZE2 Initializing static properties to arrays
+--SKIPIF--
+<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
+--FILE--
+<?php
+
+class test {
+ static public $ar = array();
+}
+
+var_dump(test::$ar);
+
+test::$ar[] = 1;
+
+var_dump(test::$ar);
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(0) {
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+Done