mirror of
https://github.com/php/php-src.git
synced 2024-12-21 16:00:18 +08:00
75af8150f5
This prohibits binding closures returned by ReflectionMethod::getClosure() to a $this, which is not an instance of the method scope. This restriction was already in place for internal methods, now it is extended to user methods. ML discussion: http://markmail.org/message/zepnhdyr3kij6di6
23 lines
597 B
PHP
23 lines
597 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 by ReflectionFunctionAbstract::getClosure() in %s on line %d
|
|
NULL
|