Forty lines of proc_open wrapping, written in 2018, replaced by four — and the part that mattered was the testing.
// before: proc_open, three stream handles, a select loop,
// and a timeout implemented with a clock check
// after
$result = Process::timeout(30)->run('git rev-parse HEAD');
if (! $result->successful()) {
throw new RuntimeException($result->errorOutput());
}
// and in a test
Process::fake(['git *' => Process::result('abc123')]);
The wrapper had been correct and nobody wanted to touch it, which is the usual state of code that deals with process streams. Being able to fake the process in a test is the genuine improvement: the four call sites had previously been tested by shelling out to echo, which tested the wrapper and not the code using it.