com php-src: Remove ability to unbind $this of closures if used: UPGRADING Zend/tests/closure_041.phpt Zend/tests/closure_ 044.phpt
Zend/tests/closure_046.phpt Zend /tests/closure_062.phpt Zend/zend_closures.c
| From: | Nikita Popov | Date: | Mon, 28 Oct 2019 12:24:07 +0000 |
| Subject: | com php-src: Remove ability to unbind $this of closures if used: UPGRADING Zend/tests/closure_041.phpt Zend/tests/closure_ 044.phpt Zend/tests/closure_046.phpt Zend /tests/closure_062.phpt Zend/zend_closures.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-109091@lists.php.net to get a copy of this message | ||
Commit: 87fefd165a29091c3cb462431529107189c12d55
Author: Nikita Popov <nikita.ppv@gmail.com> Mon, 28 Oct 2019 13:24:07 +0100
Parents: 26579db403bbcbb96634bf59dd168a4916f172f5
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=87fefd165a29091c3cb462431529107189c12d55
Log:
Remove ability to unbind $this of closures if used
This was deprecated in PHP 7.4, removing it for PHP 8.0.
Changed paths:
M UPGRADING
M Zend/tests/closure_041.phpt
M Zend/tests/closure_044.phpt
M Zend/tests/closure_046.phpt
M Zend/tests/closure_062.phpt
M Zend/zend_closures.c
Diff:
diff --git a/UPGRADING b/UPGRADING
index 8ef0d141179..ba32d55eef9 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -39,6 +39,8 @@ PHP 8.0 UPGRADE NOTES
. 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().
+ . Also removed ability to unbind $this from proper closures that contain uses
+ of $this.
. Any array that has a number n as its first numeric key will use n+1 for
its next implicit key. Even if n is negative.
RFC: https://wiki.php.net/rfc/negative_array_index
diff --git a/Zend/tests/closure_041.phpt b/Zend/tests/closure_041.phpt
index cfe4f9487f6..42fc55dfe77 100644
--- a/Zend/tests/closure_041.phpt
+++ b/Zend/tests/closure_041.phpt
@@ -48,9 +48,7 @@ echo "After binding, no instance", "\n";
$d = $staticUnscoped->bindTo(null); $d(); echo "\n";
$d = $nonstaticUnscoped->bindTo(null); $d(); echo "\n";
$d = $staticScoped->bindTo(null); $d(); echo "\n";
-$d = $nonstaticScoped->bindTo(null); $d(); echo "\n";
-// $d is still non-static
-$d->bindTo($d);
+$d = $nonstaticScoped->bindTo(null); var_dump($d); echo "\n";
echo "After binding, with same-class instance for the bound ones", "\n";
$d = $staticUnscoped->bindTo(new A);
@@ -81,9 +79,9 @@ bound: no
scoped to A: bool(true)
bound: no
-Deprecated: Unbinding $this of closure is deprecated in %s on line %d
-scoped to A: bool(true)
-bound: no
+Warning: Cannot unbind $this of closure using $this in %s on line %d
+NULL
+
After binding, with same-class instance for the bound ones
Warning: Cannot bind an instance to a static closure in %s on line %d
diff --git a/Zend/tests/closure_044.phpt b/Zend/tests/closure_044..phpt
index 225d7540d2a..a848c0b17aa 100644
--- a/Zend/tests/closure_044.phpt
+++ b/Zend/tests/closure_044.phpt
@@ -23,7 +23,7 @@ $nonstaticScoped(); echo "\n";
echo "After binding, null scope, no instance", "\n";
$d = $nonstaticUnscoped->bindTo(null, null); $d(); echo "\n";
-$d = $nonstaticScoped->bindTo(null, null); $d(); echo "\n";
+$d = $nonstaticScoped->bindTo(null, null); var_dump($d); echo "\n";
echo "After binding, null scope, with instance", "\n";
$d = $nonstaticUnscoped->bindTo(new A, null); $d(); echo "\n";
@@ -31,7 +31,7 @@ $d = $nonstaticScoped->bindTo(new A, null); $d(); echo "\n";
echo "After binding, with scope, no instance", "\n";
$d = $nonstaticUnscoped->bindTo(null, 'A'); $d(); echo "\n";
-$d = $nonstaticScoped->bindTo(null, 'A'); $d(); echo "\n";
+$d = $nonstaticScoped->bindTo(null, 'A'); var_dump($d); echo "\n";
echo "After binding, with scope, with instance", "\n";
$d = $nonstaticUnscoped->bindTo(new A, 'A'); $d(); echo "\n";
@@ -51,9 +51,8 @@ bool(false)
bool(false)
-Deprecated: Unbinding $this of closure is deprecated in %s on line %d
-bool(false)
-bool(false)
+Warning: Cannot unbind $this of closure using $this in %s on line %d
+NULL
After binding, null scope, with instance
bool(false)
@@ -67,9 +66,8 @@ bool(true)
bool(false)
-Deprecated: Unbinding $this of closure is deprecated in %s on line %d
-bool(true)
-bool(false)
+Warning: Cannot unbind $this of closure using $this in %s on line %d
+NULL
After binding, with scope, with instance
bool(true)
diff --git a/Zend/tests/closure_046.phpt b/Zend/tests/closure_046.phpt
index e10cc1b57e7..7d94df33b63 100644
--- a/Zend/tests/closure_046.phpt
+++ b/Zend/tests/closure_046.phpt
@@ -26,9 +26,7 @@ $nonstaticScoped(); echo "\n";
echo "After binding, no instance", "\n";
$d = $nonstaticUnscoped->bindTo(null, "static"); $d(); echo "\n";
-$d = $nonstaticScoped->bindTo(null, "static"); $d(); echo "\n";
-// $d is still non-static
-$d->bindTo($d);
+$d = $nonstaticScoped->bindTo(null, "static"); var_dump($d); echo "\n";
echo "After binding, with same-class instance for the bound one", "\n";
$d = $nonstaticUnscoped->bindTo(new A, "static"); $d(); echo "\n";
@@ -51,9 +49,8 @@ bool(false)
bool(false)
-Deprecated: Unbinding $this of closure is deprecated in %s on line %d
-bool(true)
-bool(false)
+Warning: Cannot unbind $this of closure using $this in %s on line %d
+NULL
After binding, with same-class instance for the bound one
bool(false)
diff --git a/Zend/tests/closure_062.phpt b/Zend/tests/closure_062.phpt
index d56b4f06637..b8c0a981be5 100644
--- a/Zend/tests/closure_062.phpt
+++ b/Zend/tests/closure_062.phpt
@@ -48,7 +48,7 @@ Test::staticMethod();
--EXPECTF--
instance scoped, non-static, $this used
-Deprecated: Unbinding $this of closure is deprecated in %s on line %d
+Warning: Cannot unbind $this of closure using $this in %s on line %d
instance scoped, static, $this used
instance scoped, non-static, $this not used
static scoped, non-static, $this used
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index 26184d3d359..dfd6a06dfce 100644
--- a/Zend/zend_closures.c
+++ b/Zend/zend_closures.c
@@ -89,8 +89,8 @@ static zend_bool zend_valid_closure_binding(
return 0;
} else if (!is_fake_closure && !Z_ISUNDEF(closure->this_ptr)
&& (func->common.fn_flags & ZEND_ACC_USES_THIS)) {
- // TODO: Only deprecate if it had $this *originally*?
- zend_error(E_DEPRECATED, "Unbinding $this of closure is deprecated");
+ zend_error(E_WARNING, "Cannot unbind $this of closure using $this");
+ return 0;
}
if (scope && scope != func->common.scope && scope->type ==
ZEND_INTERNAL_CLASS) {