diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-11-16 14:33:45 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-11-16 14:34:28 +0100 |
commit | c351768e4f6f7061669723fee83c085e631f30d5 (patch) | |
tree | 74dd0e490e4c0a97961c12821297b3ae6682113a /Zend | |
parent | e3c63de05b938c1adedbcfe169abc1b46f7f1e93 (diff) | |
parent | 78773890f6b0d82b29e0b869f3f3b22174cea217 (diff) | |
download | php-git-c351768e4f6f7061669723fee83c085e631f30d5.tar.gz |
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
Fix #74558: Can't rebind closure returned by Closure::fromCallable()
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/bug70630.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/bug70685.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/closure_061.phpt | 24 | ||||
-rw-r--r-- | Zend/zend_closures.c | 6 |
4 files changed, 19 insertions, 15 deletions
diff --git a/Zend/tests/bug70630.phpt b/Zend/tests/bug70630.phpt index d78ee62c6a..0e9e544975 100644 --- a/Zend/tests/bug70630.phpt +++ b/Zend/tests/bug70630.phpt @@ -7,4 +7,4 @@ $x = (new ReflectionFunction("substr"))->getClosure(); $x->call(new a); ?> --EXPECTF-- -Warning: Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() in %s on line %d +Warning: Cannot rebind scope of closure created from function in %s on line %d diff --git a/Zend/tests/bug70685.phpt b/Zend/tests/bug70685.phpt index 8ae97f1bf0..737b4469fd 100644 --- a/Zend/tests/bug70685.phpt +++ b/Zend/tests/bug70685.phpt @@ -18,5 +18,5 @@ var_dump($c); 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 +Warning: Cannot rebind scope of closure created from method in %s on line %d NULL diff --git a/Zend/tests/closure_061.phpt b/Zend/tests/closure_061.phpt index 2c574c49c0..240f22e036 100644 --- a/Zend/tests/closure_061.phpt +++ b/Zend/tests/closure_061.phpt @@ -118,10 +118,10 @@ bindTo(new Cls, null): Success! bindTo(new Cls, Cls::class): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from function bindTo(null, Cls::class): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from function bindTo(null, stdClass::class): Cannot bind closure to scope of internal class stdClass @@ -139,10 +139,10 @@ bindTo(new Cls, null): Success! bindTo(new Cls, Cls::class): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from function bindTo(null, Cls::class): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from function bindTo(null, stdClass::class): Cannot bind closure to scope of internal class stdClass @@ -163,13 +163,13 @@ bindTo(new Cls, Cls::class): Cannot bind an instance to a static closure bindTo(null, null): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from method bindTo(null, ClsChild::class): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from method bindTo(null, ClsUnrelated::class): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from method (new Cls)->method() ------------------- @@ -187,13 +187,13 @@ bindTo(new ClsUnrelated, Cls::class): Cannot bind method Cls::method() to object of class ClsUnrelated bindTo(new Cls, null): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from method bindTo(new Cls, ClsUnrelated::class): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from method bindTo(new Cls, ClsChild::class): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from method (new SplDoublyLinkedList)->count() ---------------------------------- @@ -214,10 +214,10 @@ bindTo(null, SplDoublyLinkedList::class): Cannot unbind $this of method bindTo(new SplDoublyLinkedList, null): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from method bindTo(new SplDoublyLinkedList, ClsUnrelated::class): -Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() +Cannot rebind scope of closure created from method (function() {})() ----------------- diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 034b0d2d07..e7777c58cf 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -107,7 +107,11 @@ static zend_bool zend_valid_closure_binding( } if (is_fake_closure && scope != func->common.scope) { - zend_error(E_WARNING, "Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure()"); + if (func->common.scope == NULL) { + zend_error(E_WARNING, "Cannot rebind scope of closure created from function"); + } else { + zend_error(E_WARNING, "Cannot rebind scope of closure created from method"); + } return 0; } |