Using php's 8.1 first class callable method leaves an xdebug in limbo
tschallacka opened this issue · comments
Tschallacka commented
When a closure is passed via a first class callable method xdebug doesn't know where it is.
<?php
namespace Foo;
include_once '/path/to/laravel/vendor/autoload.php';
use Laravel\SerializableClosure\SerializableClosure;
class Bar {
public function __construct(public int $x = 0) {
}
public function foo(int $a) {
$y = $a + $this->x;
xdebug_break();
}
}
$bar = new Bar();
$closure = new SerializableClosure($bar->foo(...));
$x = serialize($closure);
echo $x;
$z = unserialize($x);
$z->getClosure()(2);
When a closure is passed via a first class callable method, maybe serialize the given class, then call the method on the deserialized class?
Currently we need to use string references instead of these first class callable features we have now available.
Dries Vints commented
Please recreate this issue with a filled out issue template. Thanks