Test coverage does not mark unserialized closures as covered
I am using laravel's Bus batch to dispatch jobs, and they use closures that get serialized and un-serialized
https://laravel.com/docs/11.x/queues#dispatching-batches
Example: https://github.com/laravel/framework/blob/46ac7829eba556031fa5f540f3771d52fa4117a2/src/Illuminate/Bus/PendingBatch.php#L173
public function then($callback)
{
$this->options['then'][] = $callback instanceof Closure
? new SerializableClosure($callback)
: $callback;
return $this;
}
This results in the code coverage marking the then closure as not covered. Is there any workaround to cover such code blocks that get serialized and un-serialized and then are executed?
Maybe the path mapping feature of XDebug 3.5 (currently in alpha releases) could be used by serializable-closure to map the code generated for the unserialized closure to equivalent locations in the original code.
Edit: this won't work as path mapping in XDebug 3.5 is only for debugger breakpoints. Using that feature for code coverage is listed in the future scopes instead.