diff3
class diff3 extends diff
A class for computing three way diffs.
Properties
array | $_edits | Array of changes. |
from diff |
int | $_conflicting_blocks | Conflict counter. |
Methods
Computes diff between 3 sequences of strings.
Removes trailing newlines from a line of text. This is meant to be used with array_walk().
Return number of conflicts
Get conflicts content for download. This is generally a merged file, but preserving conflicts and adding explanations to it.
Return merged output (used by the renderer)
Merge the output and use the new file code for conflicts
Merge the output and use the original file code for conflicts
Get conflicting block(s)
Details
at line 507
__construct(array $orig, array $final1, array $final2, bool $preserve_cr = true)
Computes diff between 3 sequences of strings.
in
diff at line 62
get_diff()
Returns the array of differences.
in
diff at line 74
int
count_added_lines()
returns the number of new (added) lines in a given diff.
in
diff at line 97
int
count_deleted_lines()
Returns the number of deleted (removed) lines in a given diff.
in
diff at line 126
diff
reverse()
Computes a reversed diff.
Example:
$diff = new diff($lines1, $lines2);
$rev = $diff->reverse();
in
diff at line 153
bool
is_empty()
Checks for an empty diff.
in
diff at line 201
int
lcs()
Computes the length of the Longest Common Subsequence (LCS).
This is mostly for diagnostic purposes.
in
diff at line 224
array
get_original()
Gets the original set of lines.
This reconstructs the $from_lines parameter passed to the constructor.
in
diff at line 247
array
get_final()
Gets the final set of lines.
This reconstructs the $to_lines parameter passed to the constructor.
in
diff at line 269
trim_newlines(string $line, int $key)
Removes trailing newlines from a line of text. This is meant to be used with array_walk().
in
diff at line 279
_check($from_lines, $to_lines)
Checks a diff for validity.
This is here only for debugging purposes.
at line 522
get_num_conflicts()
Return number of conflicts
at line 549
mixed
get_conflicts_content(string $label1 = 'CURRENT_FILE', string $label2 = 'NEW_FILE', string $label_sep = 'DIFF_SEP_EXPLAIN')
Get conflicts content for download. This is generally a merged file, but preserving conflicts and adding explanations to it.
A user could then go through this file, search for the conflicts and changes the code accordingly.
at line 587
mixed
merged_output()
Return merged output (used by the renderer)
at line 595
merged_new_output()
Merge the output and use the new file code for conflicts
at line 619
merged_orig_output()
Merge the output and use the original file code for conflicts
at line 643
get_conflicts()
Get conflicting block(s)