Cannot rebind scope of closure created from method
Description
When a closure is build from a method and an existing object, it is not possible to rebind it to another object.
Example
<?php
class X {
function method () {}
}
class Y {}
$x = new X;
$fn = $x->method(...);
$ret = $fn->bindTo($x, Y::class);
?>
Alternatives
- To be rebound, the closure must be build from within the class.
Related error messages
- cannot-rebind-scope-of-closure-created-from-method,-this-will-be-an-error-in-php-9
- cannot-rebind-scope-of-closure-created-from-function,-this-will-be-an-error-in-php-9
In more recent PHP versions, this error message is now :ref:cannot-rebind-scope-of-closure-created-from-method,-this-will-be-an-error-in-php-9.