function Process::buildCallback
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.
Parameters
callable|null $callback The user defined PHP callback:
3 calls to Process::buildCallback()
- Process::start in vendor/
symfony/ process/ Process.php - Starts the process and returns after writing the input to STDIN.
- Process::wait in vendor/
symfony/ process/ Process.php - Waits for the process to terminate.
- Process::waitUntil in vendor/
symfony/ process/ Process.php - Waits until the callback returns true.
File
-
vendor/
symfony/ process/ Process.php, line 1297
Class
- Process
- Process is a thin wrapper around proc_* functions to easily start independent PHP processes.
Namespace
Symfony\Component\ProcessCode
protected function buildCallback(?callable $callback = null) : \Closure {
if ($this->outputDisabled) {
return fn($type, $data): bool => null !== $callback && $callback($type, $data);
}
$out = self::OUT;
return function ($type, $data) use ($callback, $out) : bool {
if ($out == $type) {
$this->addOutput($data);
}
else {
$this->addErrorOutput($data);
}
return null !== $callback && $callback($type, $data);
};
}