cvs: ZendEngine2 / zend_API.c zend_execute.c zend_object_handlers.c php-src/tests/classes static_properties_001.phpt static_properties_002.phpt
| From: | Marcus Boerger | Date: | Thu, 04 Sep 2003 16:00:02 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c zend_execute.c zend_object_handlers.c php-src/tests/classes static_properties_001.phpt static_properties_002.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1809@lists.php.net to get a copy of this message | ||
helly Thu Sep 4 12:00:02 2003 EDT
Added files:
/php-src/tests/classes static_properties_001.phpt
static_properties_002.phpt
Modified files:
/ZendEngine2 zend_API.c zend_execute.c zend_object_handlers.c
Log:
Tests show updating consts must happen once at runtime (revert optimization).
Add tests for static properties.
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.216 ZendEngine2/zend_API.c:1.217
--- ZendEngine2/zend_API.c:1.216 Wed Sep 3 14:01:22 2003
+++ ZendEngine2/zend_API.c Thu Sep 4 12:00:01 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.216 2003/09/03 18:01:22 helly Exp $ */
+/* $Id: zend_API.c,v 1.217 2003/09/04 16:00:01 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -700,6 +700,7 @@
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 @@
default:
break;
}
- } else {
- zval_update_constant(&property, (void *) 1 TSRMLS_CC);
}
switch (access_type & ZEND_ACC_PPP_MASK) {
case ZEND_ACC_PRIVATE: {
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.535 ZendEngine2/zend_execute.c:1.536
--- ZendEngine2/zend_execute.c:1.535 Wed Sep 3 12:13:40 2003
+++ ZendEngine2/zend_execute.c Thu Sep 4 12:00:01 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.535 2003/09/03 16:13:40 helly Exp $ */
+/* $Id: zend_execute.c,v 1.536 2003/09/04 16:00:01 helly Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -722,6 +722,7 @@
FREE_OP(Ts, &opline->op1, free_op1);
break;
case ZEND_FETCH_STATIC:
+ zval_update_constant(retval, (void*) 1 TSRMLS_CC);
break;
}
}
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.67 ZendEngine2/zend_object_handlers.c:1.68
--- ZendEngine2/zend_object_handlers.c:1.67 Wed Sep 3 12:13:40 2003
+++ ZendEngine2/zend_object_handlers.c Thu Sep 4 12:00:01 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_object_handlers.c,v 1.67 2003/09/03 16:13:40 helly Exp $ */
+/* $Id: zend_object_handlers.c,v 1.68 2003/09/04 16:00:01 helly Exp $ */
#include "zend.h"
#include "zend_globals.h"
@@ -736,6 +736,7 @@
}
}
+ zval_update_constant(retval, (void *) 1 TSRMLS_CC);
return retval;
}
Index: php-src/tests/classes/static_properties_001.phpt
+++ php-src/tests/classes/static_properties_001.phpt
--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
Index: php-src/tests/classes/static_properties_002.phpt
+++ php-src/tests/classes/static_properties_002.phpt
--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