]> granicus.if.org Git - php/commitdiff
Reverted "Rebind closure when binding to property"
authorDmitry Stogov <dmitry@php.net>
Wed, 14 Jan 2009 10:28:22 +0000 (10:28 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 14 Jan 2009 10:28:22 +0000 (10:28 +0000)
Zend/tests/closure_034.phpt [deleted file]
Zend/tests/closure_035.phpt [deleted file]
Zend/tests/closure_036.phpt [deleted file]
Zend/zend_closures.c
Zend/zend_closures.h
Zend/zend_object_handlers.c

diff --git a/Zend/tests/closure_034.phpt b/Zend/tests/closure_034.phpt
deleted file mode 100755 (executable)
index c919671..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
---TEST--
-Closure 034: var_dump() of a Closure
---FILE--
-<?php
-
-$outer = 25;
-
-class Test {
-       public $func1;
-       public $var = 42;
-       function __construct() {
-               global $outer;
-               $this->func1 = function($param, $other = "default") use ($outer) {
-               };
-       }
-}
-
-$o = new Test;
-var_dump($o->func1);
-
-$o->func2 = function($param, $other = "default") use ($outer) {
-};
-
-var_dump($o->func2);
-
-$func3 = function($param, $other = "default") use ($outer) {
-};
-
-var_dump($func3);
-
-?>
-===DONE===
---EXPECTF--
-object(Closure)#%d (3) {
-  ["this"]=>
-  object(Test)#%d (2) {
-    ["func1"]=>
-    object(Closure)#%d (3) {
-      ["this"]=>
-      object(Test)#%d (2) {
-        ["func1"]=>
-        object(Closure)#%d (3) {
-          ["this"]=>
-          *RECURSION*
-          ["static"]=>
-          array(1) {
-            ["outer"]=>
-            int(25)
-          }
-          ["parameter"]=>
-          array(2) {
-            ["$param"]=>
-            string(10) "<required>"
-            ["$other"]=>
-            string(10) "<optional>"
-          }
-        }
-        ["var"]=>
-        int(42)
-      }
-      ["static"]=>
-      array(1) {
-        ["outer"]=>
-        int(25)
-      }
-      ["parameter"]=>
-      array(2) {
-        ["$param"]=>
-        string(10) "<required>"
-        ["$other"]=>
-        string(10) "<optional>"
-      }
-    }
-    ["var"]=>
-    int(42)
-  }
-  ["static"]=>
-  array(1) {
-    ["outer"]=>
-    int(25)
-  }
-  ["parameter"]=>
-  array(2) {
-    ["$param"]=>
-    string(10) "<required>"
-    ["$other"]=>
-    string(10) "<optional>"
-  }
-}
-object(Closure)#%d (3) {
-  ["this"]=>
-  object(Test)#%d (3) {
-    ["func1"]=>
-    object(Closure)#%d (3) {
-      ["this"]=>
-      object(Test)#%d (3) {
-        ["func1"]=>
-        object(Closure)#%d (3) {
-          ["this"]=>
-          *RECURSION*
-          ["static"]=>
-          array(1) {
-            ["outer"]=>
-            int(25)
-          }
-          ["parameter"]=>
-          array(2) {
-            ["$param"]=>
-            string(10) "<required>"
-            ["$other"]=>
-            string(10) "<optional>"
-          }
-        }
-        ["var"]=>
-        int(42)
-        ["func2"]=>
-        object(Closure)#%d (3) {
-          ["this"]=>
-          *RECURSION*
-          ["static"]=>
-          array(1) {
-            ["outer"]=>
-            &int(25)
-          }
-          ["parameter"]=>
-          array(2) {
-            ["$param"]=>
-            string(10) "<required>"
-            ["$other"]=>
-            string(10) "<optional>"
-          }
-        }
-      }
-      ["static"]=>
-      array(1) {
-        ["outer"]=>
-        int(25)
-      }
-      ["parameter"]=>
-      array(2) {
-        ["$param"]=>
-        string(10) "<required>"
-        ["$other"]=>
-        string(10) "<optional>"
-      }
-    }
-    ["var"]=>
-    int(42)
-    ["func2"]=>
-    object(Closure)#%d (3) {
-      ["this"]=>
-      object(Test)#%d (3) {
-        ["func1"]=>
-        object(Closure)#%d (3) {
-          ["this"]=>
-          *RECURSION*
-          ["static"]=>
-          array(1) {
-            ["outer"]=>
-            int(25)
-          }
-          ["parameter"]=>
-          array(2) {
-            ["$param"]=>
-            string(10) "<required>"
-            ["$other"]=>
-            string(10) "<optional>"
-          }
-        }
-        ["var"]=>
-        int(42)
-        ["func2"]=>
-        object(Closure)#%d (3) {
-          ["this"]=>
-          *RECURSION*
-          ["static"]=>
-          array(1) {
-            ["outer"]=>
-            &int(25)
-          }
-          ["parameter"]=>
-          array(2) {
-            ["$param"]=>
-            string(10) "<required>"
-            ["$other"]=>
-            string(10) "<optional>"
-          }
-        }
-      }
-      ["static"]=>
-      array(1) {
-        ["outer"]=>
-        &int(25)
-      }
-      ["parameter"]=>
-      array(2) {
-        ["$param"]=>
-        string(10) "<required>"
-        ["$other"]=>
-        string(10) "<optional>"
-      }
-    }
-  }
-  ["static"]=>
-  array(1) {
-    ["outer"]=>
-    &int(25)
-  }
-  ["parameter"]=>
-  array(2) {
-    ["$param"]=>
-    string(10) "<required>"
-    ["$other"]=>
-    string(10) "<optional>"
-  }
-}
-object(Closure)#%d (3) {
-  ["this"]=>
-  NULL
-  ["static"]=>
-  array(1) {
-    ["outer"]=>
-    int(25)
-  }
-  ["parameter"]=>
-  array(2) {
-    ["$param"]=>
-    string(10) "<required>"
-    ["$other"]=>
-    string(10) "<optional>"
-  }
-}
-===DONE===
diff --git a/Zend/tests/closure_035.phpt b/Zend/tests/closure_035.phpt
deleted file mode 100755 (executable)
index 9f0d02d..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
---TEST--
-Closure 035: Rebinding closure $this on property access
---FILE--
-<?php
-
-$instance = 0;
-
-class Test {
-       function __construct() {
-               global $instance;
-               $this->instance = ++$instance;
-       }
-}
-
-$o = new Test;
-$o->func = function () {
-       var_dump($this);
-};
-$func = $o->func;
-$func();
-
-var_dump($instance);
-?>
-===DONE===
---EXPECTF--
-object(Test)#%d (2) {
-  ["instance"]=>
-  int(1)
-  ["func"]=>
-  object(Closure)#%d (1) {
-    ["this"]=>
-    object(Test)#%d (2) {
-      ["instance"]=>
-      int(1)
-      ["func"]=>
-      object(Closure)#%d (1) {
-        ["this"]=>
-        *RECURSION*
-      }
-    }
-  }
-}
-int(1)
-===DONE===
\ No newline at end of file
diff --git a/Zend/tests/closure_036.phpt b/Zend/tests/closure_036.phpt
deleted file mode 100755 (executable)
index 301f860..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
---TEST--
-Closure 036: Rebinding closure $this on property access, using scope
---FILE--
-<?php
-
-$instance = 0;
-
-class Test {
-       private $value = 42;
-       function __construct() {
-               global $instance;
-               $this->instance = ++$instance;
-       }
-}
-
-$o = new Test;
-$o->func = function () {
-       var_dump($this->value);
-};
-$func = $o->func;
-$func();
-
-var_dump($instance);
-?>
-===DONE===
---EXPECTF--
-int(42)
-int(1)
-===DONE===
\ No newline at end of file
index a069fd3a52010036bd34f7d29ac488fb171a363e..00426e0431cdb5ef26e5917482599ac1aaf6bb09 100644 (file)
@@ -118,26 +118,6 @@ ZEND_API zval* zend_get_closure_this_ptr(zval *obj TSRMLS_DC) /* {{{ */
 }
 /* }}} */
 
-ZEND_API zval* zend_closure_copy(zval *closure_obj, zval *this_ptr TSRMLS_DC) /* {{{ */
-{
-       zend_closure *closure;
-
-       zval_copy_ctor(closure_obj);
-       closure = (zend_closure *)zend_object_store_get_object(closure_obj TSRMLS_CC);
-       if (closure->this_ptr) {
-               zval_ptr_dtor(&closure->this_ptr);
-       }
-       closure->this_ptr = this_ptr;
-       if (this_ptr) {
-               Z_ADDREF_P(this_ptr);
-               closure->func.common.scope = Z_OBJCE_P(this_ptr);
-       } else {
-               closure->func.common.scope = NULL;
-       }
-       return closure_obj;
-}
-/* }}} */
-
 static zend_function *zend_closure_get_method(zval **object_ptr, char *method_name, int method_len TSRMLS_DC) /* {{{ */
 {
        char *lc_name;
index 006af0667146a17d7b12912fd11e90489eb87e0d..c326e329c4739e2acb10f2d48d0f6008360a6efe 100644 (file)
@@ -35,7 +35,6 @@ ZEND_API int zend_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_functio
 ZEND_API zend_function *zend_get_closure_invoke_method(zval *obj TSRMLS_DC);
 ZEND_API const zend_function *zend_get_closure_method_def(zval *obj TSRMLS_DC);
 ZEND_API zval* zend_get_closure_this_ptr(zval *obj TSRMLS_DC);
-ZEND_API zval* zend_closure_copy(zval *closure, zval *this_ptr TSRMLS_DC);
 
 END_EXTERN_C()
 
index 584eeb1df1439fbb96aa011fcf330af9e994065b..7050dfeca9627e55d4ff2283008b40a13bd78cce 100644 (file)
@@ -405,10 +405,6 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM
                member = tmp_member;
        }
 
-       if (value && Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == zend_ce_closure && zend_get_closure_this_ptr(value TSRMLS_CC) != object) {
-               value = zend_closure_copy(value, object TSRMLS_CC);
-       }
-
        property_info = zend_get_property_info(zobj->ce, member, (zobj->ce->__set != NULL) TSRMLS_CC);
 
        if (property_info && zend_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &variable_ptr) == SUCCESS) {