diff options
author | Bob Weinand <bobwei9@hotmail.com> | 2015-10-14 12:07:04 +0200 |
---|---|---|
committer | Bob Weinand <bobwei9@hotmail.com> | 2015-10-14 12:07:33 +0200 |
commit | 60b4355168cf3185f87d902be3396265132c045f (patch) | |
tree | d059b7875a5c0b3eeabd2158642299f276d28d6b /Zend/tests/closure_061.phpt | |
parent | 5649b0ccba49a3e1bfb1c1f8f86e42e64f55b362 (diff) | |
download | php-git-60b4355168cf3185f87d902be3396265132c045f.tar.gz |
Do not create a fake Closure for real Closures
That is solved by just returning the Closure as is, which is safe due to Closures being immutable objects
Diffstat (limited to 'Zend/tests/closure_061.phpt')
-rw-r--r-- | Zend/tests/closure_061.phpt | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Zend/tests/closure_061.phpt b/Zend/tests/closure_061.phpt index a87303498e..83ad16d2e1 100644 --- a/Zend/tests/closure_061.phpt +++ b/Zend/tests/closure_061.phpt @@ -64,6 +64,15 @@ $tests = [ [new DLL, null], [new DLL, ClsUnrelated::class], ]], + + [function() {}, [ + [null, null], + [new Cls, null], + [new Cls, 'Cls'], + [null, 'Cls'], + [null, 'stdClass'], + [new stdClass, null], + ]], ]; set_error_handler(function($errno, $errstr) { @@ -79,6 +88,9 @@ foreach ($tests as list($fn, $bindings)) { $c = (new ReflectionFunction($fn))->getClosure(); $fnStr = $fn; } + if ($fn instanceof Closure) { + $fnStr = "(function() {})"; + } echo "$fnStr()\n" . str_repeat('-', strlen($fnStr) + 2), "\n\n"; @@ -206,3 +218,24 @@ Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure bindTo(new SplDoublyLinkedList, ClsUnrelated::class): Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() + +(function() {})() +----------------- + +bindTo(null, null): +Success! + +bindTo(new Cls, null): +Success! + +bindTo(new Cls, Cls::class): +Success! + +bindTo(null, Cls::class): +Success! + +bindTo(null, stdClass::class): +Cannot bind closure to scope of internal class stdClass + +bindTo(new stdClass, null): +Success! |