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
$d = $nonstaticScoped->bindTo(new A, 'A'); $d(); echo "\n";
echo "Done.\n";
---EXPECT--
+--EXPECTF--
Before binding
bool(false)
bool(false)
bool(false)
bool(false)
+
+Deprecated: Unbinding $this of closure is deprecated in %s on line %d
bool(false)
bool(false)
bool(true)
bool(false)
+
+Deprecated: Unbinding $this of closure is deprecated in %s on line %d
bool(true)
bool(false)
$d = $nonstaticScoped->bindTo(new B, "static"); $d(); echo "\n";
echo "Done.\n";
---EXPECT--
+--EXPECTF--
Before binding
bool(false)
bool(false)
bool(false)
bool(false)
+
+Deprecated: Unbinding $this of closure is deprecated in %s on line %d
bool(true)
bool(false)
}
$f = (new A)->f();
-var_dump($f->bindTo(null, 'B')());
+var_dump($f->bindTo(new B, 'B')());
?>
--EXPECT--
} 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) {