diff options
| author | Andi Gutmans <andi@php.net> | 2001-12-26 20:17:34 +0000 | 
|---|---|---|
| committer | Andi Gutmans <andi@php.net> | 2001-12-26 20:17:34 +0000 | 
| commit | 5cb454a8ad212f7d3ededc650466a087ffde2ffe (patch) | |
| tree | 10562e6e9ff689b42c730462e6d71604974fa264 /Zend/zend_execute_API.c | |
| parent | b04acdadf4064f5a788be0a33c124b87afa497b5 (diff) | |
| download | php-git-5cb454a8ad212f7d3ededc650466a087ffde2ffe.tar.gz | |
- Fix scoping issue. The following works now:
<?
	class MyClass {
		static $id = 0;
		function MyClass()
		{
			$this->id = self::$id++;
		}
		function _clone()
		{
			$this->name = $clone->name;
			$this->address = "New York";
			$this->id = self::$id++;
		}
	}
	$obj = new MyClass();
	$obj->name = "Hello";
	$obj->address = "Tel-Aviv";
	print $obj->id;
	print "\n";
	$obj = $obj->_clone();
	print $obj->id;
	print "\n";
	print $obj->name;
	print "\n";
	print $obj->address;
	print "\n";
Diffstat (limited to 'Zend/zend_execute_API.c')
| -rw-r--r-- | Zend/zend_execute_API.c | 9 | 
1 files changed, 9 insertions, 0 deletions
| diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index e9719e0287..834ec351ee 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -440,6 +440,8 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun  	int (*orig_unary_op)(zval *result, zval *op1);  	int (*orig_binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC);  	zval function_name_copy; +	zend_class_entry *current_namespace; +	zend_class_entry *calling_namespace = NULL;  	*retval_ptr_ptr = NULL; @@ -464,6 +466,7 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun  	if (object_pp) {  		if (Z_TYPE_PP(object_pp) == IS_OBJECT) {  			function_table = &Z_OBJCE_PP(object_pp)->function_table; +			calling_namespace = Z_OBJCE_PP(object_pp);  		} else if (Z_TYPE_PP(object_pp) == IS_STRING) {  			zend_class_entry *ce;  			char *lc_class; @@ -477,6 +480,7 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun  				return FAILURE;  			function_table = &ce->function_table; +			calling_namespace = ce;  			object_pp = NULL;  		} else  			return FAILURE; @@ -535,6 +539,9 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun  	EG(function_state_ptr) = &function_state; +	current_namespace = EG(namespace); +	EG(namespace) = calling_namespace; +  	if (function_state.function->type == ZEND_USER_FUNCTION) {  		calling_symbol_table = EG(active_symbol_table);  		if (symbol_table) { @@ -581,6 +588,8 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun  	zend_ptr_stack_clear_multiple(TSRMLS_C);  	EG(function_state_ptr) = original_function_state_ptr; +	EG(namespace) = current_namespace; +  	return SUCCESS;  } | 
