Symfony\Component\Process\Process::buildCallback PHP Method

buildCallback() protected method

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