$buffer =
fopen('php://memory', 'r+b'
);
if ('' !==
$this->header
) { fwrite($buffer,
$this->header
);
if ("\n" !==
substr($this->header, -1, 1
)) { fwrite($buffer, "\n"
);
} } if (0 !==
count($diff)) { $this->
writeDiffHunks($buffer,
$diff);
} $diff =
stream_get_contents($buffer, -1, 0
);
fclose($buffer);
// If the diff is non-empty and last char is not a linebreak: add it.
// This might happen when both the `from` and `to` do not have a trailing linebreak
$last =
substr($diff, -1
);
return 0 !==
strlen($diff) && "\n" !==
$last && "\r" !==
$last ?