com php-src: Closure::fromCallable(): Use fake closures: Zend/tests/closures/closure_from_callable_rebinding.php t Zend/zend_closures.c

From: Date: Tue, 05 Jul 2016 13:13:51 +0000
Subject: com php-src: Closure::fromCallable(): Use fake closures: Zend/tests/closures/closure_from_callable_rebinding.php t Zend/zend_closures.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92799@lists.php.net to get a copy of this message
Commit: e395b62c51524427b225323f827efdc46eb0b9b0 Author: Nikita Popov <nikic@php.net> Tue, 5 Jul 2016 15:13:36 +0200 Parents: 03fbc27f07777432b8f9f60be2c39611668b47ec Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e395b62c51524427b225323f827efdc46eb0b9b0 Log: Closure::fromCallable(): Use fake closures Changed paths: A Zend/tests/closures/closure_from_callable_rebinding.phpt M Zend/zend_closures.c Diff: diff --git a/Zend/tests/closures/closure_from_callable_rebinding.phpt b/Zend/tests/closures/closure_from_callable_rebinding.phpt new file mode 100644 index 0000000..6fb5c6f --- /dev/null +++ b/Zend/tests/closures/closure_from_callable_rebinding.phpt @@ -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 diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 5c5e8a6..6185c21 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -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;

« previous php.cvs (#92799) next »