Diviner

Class LinesOfALargeExecFuture

Definedsrc/filesystem/linesofalarge/LinesOfALargeExecFuture.php:26
GroupFilesystem
ExtendsLinesOfALarge

Read the output stream of an ExecFuture one line at a time. This abstraction allows you to process large inputs without holding them in memory. If you know your inputs fit in memory, it is generally more efficient (and certainly simpler) to read the entire input and explode() it. For more information, see LinesOfALarge. See also LinesOfALargeFile for a similar abstraction that works on files.

$future = new ExecFuture('hg log ...');
foreach (new LinesOfALargeExecFuture($future) as $line) {
  // ...
}

If the subprocess exits with an error, a CommandException will be thrown.

On destruction, this class terminates the subprocess if it has not already exited.

Tasks

Construction

Internals

Methods

public this __construct(ExecFuture $future)

parametersExecFuture$futureFuture to wrap.
returnthis

To construct, pass an ExecFuture.

public void __destruct()

returnvoid

On destruction, we terminate the subprocess if it hasn't exited already.

protected string readMore()

returnstringBytes read from stdout.

Read more data from the subprocess.

protected void willRewind()

returnvoid

The PHP foreach() construct calls rewind() once, so we allow the first rewind(), without effect. Subsequent rewinds mean misuse.