DifferInterface
API reference › Diff › DifferInterface
Implemented by 1 type
Computes a line-by-line edit script between two multi-line strings.
Implementations split both inputs on "\n" with explode(), so an empty string is one empty line and a
trailing newline yields a trailing empty line. Every input line appears exactly once in the returned script, tagged
as kept (DiffOp::Context), removed from the old input (DiffOp::Remove) or added from the new input
(DiffOp::Add).
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
diff() abstract | Returns the edit script that transforms $old into $new. | DifferInterface |
Method details
Section titled “Method details”diff()
Section titled “diff() ”abstract public function diff(string $old, string $new): list<PHPForge\Diff\DiffLine>Returns the edit script that transforms $old into $new.
Parameters
| Parameter | Type | Description |
|---|---|---|
$old | string | Original input, split into lines on "\. |
$new | string | Target input, split into lines on "\. |
Returns
list<DiffLine>: Edit script; its Context and Remove lines in order reproduce the lines of $old, and its Context and Add lines in order reproduce the lines of $new.