]> granicus.if.org Git - php/commitdiff
Closure binding and trait binding to anonymous class tests.
authorStanislav Malyshev <stas@php.net>
Sun, 18 Oct 2015 22:39:34 +0000 (15:39 -0700)
committerStanislav Malyshev <stas@php.net>
Sun, 18 Oct 2015 22:39:34 +0000 (15:39 -0700)
Zend/tests/anon/013.phpt [new file with mode: 0644]
Zend/tests/anon/014.phpt [new file with mode: 0644]

diff --git a/Zend/tests/anon/013.phpt b/Zend/tests/anon/013.phpt
new file mode 100644 (file)
index 0000000..72ba3d6
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+closure binding to anonymous class
+--FILE--
+<?php
+$class = new class {};
+$foo = function() {
+    return $this;
+};
+
+$closure = Closure::bind($foo, $class, $class);
+var_dump($closure());
+?>
+--EXPECTF--
+object(class@anonymous)#1 (0) {
+}
diff --git a/Zend/tests/anon/014.phpt b/Zend/tests/anon/014.phpt
new file mode 100644 (file)
index 0000000..cacac47
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+anonymous class trait binding
+--FILE--
+<?php
+trait TaskTrait {
+    function run() {
+        return 'Running...';
+    }
+}
+$class = new class() {
+  use TaskTrait;
+};
+var_dump($class->run());
+?>
+--EXPECTF--
+string(10) "Running..."