This was deprecated in PHP 7.4, removing it for PHP 8.0.
. 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
$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);
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
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";
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";
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)
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)
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";
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)
--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
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) {