Lines Matching defs:callback
54 private $callback;
230 * The callback receives the type of output (out or err) and
237 * @param callable|null $callback A PHP callback to run whenever there is some
246 * @throws LogicException In case a callback is provided and output has been disabled
250 public function run(callable $callback = null, array $env = []): int
252 $this->start($callback, $env);
269 public function mustRun(callable $callback = null, array $env = []): self
271 if (0 !== $this->run($callback, $env)) {
286 * The callback receives the type of output (out or err) and some bytes from
290 * @param callable|null $callback A PHP callback to run whenever there is some
295 * @throws LogicException In case a callback is provided and output has been disabled
297 public function start(callable $callback = null, array $env = [])
305 $this->callback = $this->buildCallback($callback);
306 $this->hasCallback = null !== $callback;
376 * @param callable|null $callback A PHP callback to run whenever there is some
388 public function restart(callable $callback = null, array $env = []): self
395 $process->start($callback, $env);
403 * The callback receives the type of output (out or err) and some bytes
407 * @param callable|null $callback A valid PHP callback
415 public function wait(callable $callback = null)
421 if (null !== $callback) {
424 throw new LogicException('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::wait".');
426 $this->callback = $this->buildCallback($callback);
448 * Waits until the callback returns true.
450 * The callback receives the type of output (out or err) and some bytes
458 public function waitUntil(callable $callback): bool
465 throw new LogicException('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::waitUntil".');
467 $callback = $this->buildCallback($callback);
477 $ready = $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data) || $ready;
635 while (null !== $this->callback || ($yieldOut && !feof($this->stdout)) || ($yieldErr && !feof($this->stderr))) {
1304 * Builds up the callback used by wait().
1307 * the user callback (if present) with the received output.
1309 * @param callable|null $callback The user defined PHP callback
1313 protected function buildCallback(callable $callback = null)
1316 return function ($type, $data) use ($callback): bool {
1317 return null !== $callback && $callback($type, $data);
1323 return function ($type, $data) use ($callback, $out): bool {
1330 return null !== $callback && $callback($type, $data);
1418 * Reads pipes, executes callback.
1427 $callback = $this->callback;
1430 $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
1461 // Free memory from self-reference callback created by buildCallback
1463 // Now pipes are closed, so the callback is no longer necessary
1464 $this->callback = null;
1475 $this->callback = null;