mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Closure::fromCallable(): Use fake closures
This commit is contained in:
parent
03fbc27f07
commit
e395b62c51
2 changed files with 22 additions and 2 deletions
20
Zend/tests/closures/closure_from_callable_rebinding.phpt
Normal file
20
Zend/tests/closures/closure_from_callable_rebinding.phpt
Normal file
|
@ -0,0 +1,20 @@
|
|||
--TEST--
|
||||
Testing Closure::fromCallable() functionality: Rebinding
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class A {
|
||||
public function method() {
|
||||
var_dump($this);
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
}
|
||||
|
||||
$fn = Closure::fromCallable([new A, 'method']);
|
||||
$fn->call(new B);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Cannot bind method A::method() to object of class B in %s on line %d
|
|
@ -295,9 +295,9 @@ static int zend_create_closure_from_callable(zval *return_value, zval *callable,
|
|||
|
||||
if (fcc.object) {
|
||||
ZVAL_OBJ(&instance, fcc.object);
|
||||
zend_create_closure(return_value, mptr, mptr->common.scope, fcc.object->ce, &instance);
|
||||
zend_create_fake_closure(return_value, mptr, mptr->common.scope, fcc.object->ce, &instance);
|
||||
} else {
|
||||
zend_create_closure(return_value, mptr, mptr->common.scope, NULL, NULL);
|
||||
zend_create_fake_closure(return_value, mptr, mptr->common.scope, NULL, NULL);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue