com php-src: Forbid unbinding $this from methods: UPGRADING Zend/tests/bug70681.phpt Zend/tests/closure_061.phpt Zend/zend_closures.c
| From: | Nikita Popov | Date: | Wed, 30 Jan 2019 08:19:02 +0000 |
| Subject: | com php-src: Forbid unbinding $this from methods: UPGRADING Zend/tests/bug70681.phpt Zend/tests/closure_061.phpt Zend/zend_closures.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104393@lists.php.net to get a copy of this message | ||
Commit: 4eb5db2c68ecab4fd50a5e1950fdd6eb3703b899
Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 29 Jan 2019 15:16:51 +0100
Parents: 23a5be3696f4d92e1b18fd59f3ac63c6a15ea12a
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4eb5db2c68ecab4fd50a5e1950fdd6eb3703b899
Log:
Forbid unbinding $this from methods
Changed paths:
M UPGRADING
M Zend/tests/bug70681.phpt
M Zend/tests/closure_061.phpt
M Zend/zend_closures.c
Diff:
diff --git a/UPGRADING b/UPGRADING
index 0f2b9a5..d3bf768 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -30,6 +30,8 @@ PHP 8.0 UPGRADE NOTES
argument to define() may no longer be true.
. Removed create_function(). Anonymous functions may be used instead.
. Removed each(). foreach or ArrayIterator should be used instead.
+ . Removed ability to unbind $this from closures that were created from a
+ method, using Closure::fromCallable() or ReflectionMethod::getClosure().
- Filter:
. The FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED flags for the
diff --git a/Zend/tests/bug70681.phpt b/Zend/tests/bug70681.phpt
index 9dd09b0..d0cc952 100644
--- a/Zend/tests/bug70681.phpt
+++ b/Zend/tests/bug70681.phpt
@@ -12,5 +12,5 @@ var_dump($c("foo"));
?>
--EXPECTF--
-Warning: Cannot unbind $this of internal method in %s on line %d
+Warning: Cannot unbind $this of method in %s on line %d
int(3)
diff --git a/Zend/tests/closure_061.phpt b/Zend/tests/closure_061.phpt
index f01e393..2c574c4 100644
--- a/Zend/tests/closure_061.phpt
+++ b/Zend/tests/closure_061.phpt
@@ -175,9 +175,7 @@ Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure
-------------------
bindTo(null, Cls::class):
-Unbinding $this of a method is deprecated
-
-Success!
+Cannot unbind $this of method
bindTo(new Cls, Cls::class):
Success!
@@ -210,10 +208,10 @@ bindTo(new ClsUnrelated, SplDoublyLinkedList::class):
Cannot bind method SplDoublyLinkedList::count() to object of class ClsUnrelated
bindTo(null, null):
-Cannot unbind $this of internal method
+Cannot unbind $this of method
bindTo(null, SplDoublyLinkedList::class):
-Cannot unbind $this of internal method
+Cannot unbind $this of method
bindTo(new SplDoublyLinkedList, null):
Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure()
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index c3dbf14..ac95108 100644
--- a/Zend/zend_closures.c
+++ b/Zend/zend_closures.c
@@ -84,12 +84,8 @@ static zend_bool zend_valid_closure_binding(
}
} else if (is_fake_closure && func->common.scope
&& !(func->common.fn_flags & ZEND_ACC_STATIC)) {
- if (func->type == ZEND_INTERNAL_FUNCTION) {
- zend_error(E_WARNING, "Cannot unbind $this of internal method");
- return 0;
- } else {
- zend_error(E_DEPRECATED, "Unbinding $this of a method is deprecated");
- }
+ zend_error(E_WARNING, "Cannot unbind $this of method");
+ return 0;
}
if (scope && scope != func->common.scope && scope->type ==
ZEND_INTERNAL_CLASS) {