summaryrefslogtreecommitdiff
path: root/Zend/tests/closure_007.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/tests/closure_007.phpt')
-rw-r--r--Zend/tests/closure_007.phpt38
1 files changed, 38 insertions, 0 deletions
diff --git a/Zend/tests/closure_007.phpt b/Zend/tests/closure_007.phpt
new file mode 100644
index 0000000..89cd06d
--- /dev/null
+++ b/Zend/tests/closure_007.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Closure 007: Nested lambdas in classes
+--FILE--
+<?php
+
+class A {
+ private $x = 0;
+
+ function getClosureGetter () {
+ return function () {
+ return function () {
+ $this->x++;
+ };
+ };
+ }
+
+ function printX () {
+ echo $this->x."\n";
+ }
+}
+
+$a = new A;
+$a->printX();
+$getClosure = $a->getClosureGetter();
+$a->printX();
+$closure = $getClosure();
+$a->printX();
+$closure();
+$a->printX();
+
+echo "Done\n";
+?>
+--EXPECT--
+0
+0
+0
+1
+Done