summaryrefslogtreecommitdiff
path: root/Zend/tests/closure_call.phpt
diff options
context:
space:
mode:
authorAndrea Faulds <ajf@ajf.me>2014-07-30 01:26:53 +0100
committerAndrea Faulds <ajf@ajf.me>2014-07-30 01:26:53 +0100
commitf65bdda469dfc30bd28652a6aa94d369eac1b6b2 (patch)
treeefd000590d7503d330e6463365ae88b967576959 /Zend/tests/closure_call.phpt
parentd67ec70a4c11b8da9b579ef79825f905629f305c (diff)
downloadphp-git-f65bdda469dfc30bd28652a6aa94d369eac1b6b2.tar.gz
Rename ::apply to ::call for the sake of JS consistency
Diffstat (limited to 'Zend/tests/closure_call.phpt')
-rw-r--r--Zend/tests/closure_call.phpt48
1 files changed, 48 insertions, 0 deletions
diff --git a/Zend/tests/closure_call.phpt b/Zend/tests/closure_call.phpt
new file mode 100644
index 0000000000..7a65817189
--- /dev/null
+++ b/Zend/tests/closure_call.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Closure::call
+--FILE--
+<?php
+
+class Foo {
+ public $x = 0;
+ function bar() {
+ return function () {
+ return $this->x;
+ };
+ }
+}
+
+$foo = new Foo;
+$qux = $foo->bar();
+
+$foobar = new Foo;
+$foobar->x = 3;
+
+var_dump($qux());
+var_dump($qux->call($foo));
+var_dump($qux->call($foobar));
+
+
+$bar = function () {
+ return $this->x;
+};
+
+$elePHPant = new StdClass;
+$elePHPant->x = 7;
+
+var_dump($bar->call($elePHPant));
+
+
+$beta = function ($z) {
+ return $this->x * $z;
+};
+
+var_dump($beta->call($elePHPant, 3));
+
+?>
+--EXPECT--
+int(0)
+int(0)
+int(3)
+int(7)
+int(21) \ No newline at end of file