mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Deprecate unbinding $this from non-static closure
This commit is contained in:
@@ -80,6 +80,8 @@ scoped to A: bool(false)
|
||||
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
|
||||
After binding, with same-class instance for the bound ones
|
||||
|
||||
@@ -38,7 +38,7 @@ $d = $nonstaticUnscoped->bindTo(new A, 'A'); $d(); echo "\n";
|
||||
$d = $nonstaticScoped->bindTo(new A, 'A'); $d(); echo "\n";
|
||||
|
||||
echo "Done.\n";
|
||||
--EXPECT--
|
||||
--EXPECTF--
|
||||
Before binding
|
||||
bool(false)
|
||||
bool(false)
|
||||
@@ -50,6 +50,8 @@ After binding, null scope, no instance
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
|
||||
Deprecated: Unbinding $this of closure is deprecated in %s on line %d
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
@@ -64,6 +66,8 @@ After binding, with scope, no instance
|
||||
bool(true)
|
||||
bool(false)
|
||||
|
||||
|
||||
Deprecated: Unbinding $this of closure is deprecated in %s on line %d
|
||||
bool(true)
|
||||
bool(false)
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ echo "After binding, with different instance for the bound one", "\n";
|
||||
$d = $nonstaticScoped->bindTo(new B, "static"); $d(); echo "\n";
|
||||
|
||||
echo "Done.\n";
|
||||
--EXPECT--
|
||||
--EXPECTF--
|
||||
Before binding
|
||||
bool(false)
|
||||
bool(false)
|
||||
@@ -50,6 +50,8 @@ After binding, no instance
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
|
||||
Deprecated: Unbinding $this of closure is deprecated in %s on line %d
|
||||
bool(true)
|
||||
bool(false)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class B {
|
||||
}
|
||||
|
||||
$f = (new A)->f();
|
||||
var_dump($f->bindTo(null, 'B')());
|
||||
var_dump($f->bindTo(new B, 'B')());
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
||||
@@ -90,6 +90,9 @@ static zend_bool zend_valid_closure_binding(
|
||||
} else {
|
||||
zend_error(E_DEPRECATED, "Unbinding $this of a method is deprecated");
|
||||
}
|
||||
} else if (!is_fake_closure && !Z_ISUNDEF(closure->this_ptr)) {
|
||||
// TODO: Only deprecate if it had $this *originally*?
|
||||
zend_error(E_DEPRECATED, "Unbinding $this of closure is deprecated");
|
||||
}
|
||||
|
||||
if (scope && scope != func->common.scope && scope->type == ZEND_INTERNAL_CLASS) {
|
||||
|
||||
Reference in New Issue
Block a user