com php-src: Added test for unbound_scoped: Zend/tests/cl osure_bind_unbound_scoped.phpt
| From: | Tjerk Anne Meesters | Date: | Tue, 29 Jul 2014 18:08:21 +0000 |
| Subject: | com php-src: Added test for unbound_scoped: Zend/tests/cl osure_bind_unbound_scoped.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81166@lists.php.net to get a copy of this message | ||
Commit: d67ec70a4c11b8da9b579ef79825f905629f305c
Author: Andrea Faulds <ajf@ajf.me> Tue, 29 Jul 2014 19:08:21 +0100
Parents: ded5b3fda44a76b010242a2c57dab4ad9f48e1bd
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d67ec70a4c11b8da9b579ef79825f905629f305c
Log:
Added test for unbound_scoped
Changed paths:
A Zend/tests/closure_bind_unbound_scoped.phpt
Diff:
diff --git a/Zend/tests/closure_bind_unbound_scoped.phpt
b/Zend/tests/closure_bind_unbound_scoped.phpt
new file mode 100644
index 0000000..a8347f8
--- /dev/null
+++ b/Zend/tests/closure_bind_unbound_scoped.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Closure::bind and ::bindTo unbound_scoped parameter
+--FILE--
+<?php
+class FooBar {
+ private $x = 3;
+}
+$foo = function () {
+ var_dump($this->x);
+};
+
+// This should create a closure scoped to FooBar but unbound, not static
+$foo = $foo->bindTo(NULL, "FooBar", true);
+
+// As it is unbound, not static, this will work
+$foo->apply(new FooBar);
+
+$foo = function () {
+ var_dump($this->x);
+};
+$foo = Closure::bind($foo, NULL, "FooBar", true);
+$foo->apply(new FooBar);
+?>
+--EXPECT--
+int(3)
+int(3)
\ No newline at end of file