Builds up the callback used by wait().
The callbacks adds all occurred output to the specific buffer and calls the user callback (if present) with the received output.
mixed $callback The user defined PHP callback:
mixed A PHP callable
protected function buildCallback($callback) {
$that = $this;
$out = self::OUT;
$err = self::ERR;
$callback = function ($type, $data) use ($that, $callback, $out, $err) {
if ($out == $type) {
$that
->addOutput($data);
}
else {
$that
->addErrorOutput($data);
}
if (null !== $callback) {
call_user_func($callback, $type, $data);
}
};
return $callback;
}