php-src/Zend/tests/bug70685.phpt
Christoph M. Becker 78773890f6 Fix #74558: Can't rebind closure returned by Closure::fromCallable()
Failure to rebind such closures is not necessarily related to them
being created by `ReflectionFunctionAbstract::getClosure()`, so we fix
the error message.

Closes GH-6424.
2020-11-16 14:31:06 +01:00

23 lines
565 B
PHP

--TEST--
Bug #70685: Segfault for getClosure() internal method rebind with invalid $this
--FILE--
<?php
class cls {}
$c = (new ReflectionMethod('SplStack', 'count'))->getClosure(new SplStack);
$c = $c->bindTo(new cls);
var_dump($c);
$c = (new ReflectionMethod('SplStack', 'count'))->getClosure(new SplStack);
$c = $c->bindTo(new SplStack, 'cls');
var_dump($c);
?>
--EXPECTF--
Warning: Cannot bind method SplDoublyLinkedList::count() to object of class cls in %s on line %d
NULL
Warning: Cannot rebind scope of closure created from method in %s on line %d
NULL