phpBB API Documentation
Class

diff3

class diff3 extends diff

A class for computing three way diffs.

Properties

array $_edits Array of changes.
integer $_conflicting_blocks Conflict counter.

Methods

diff($from_content, $to_content, $preserve_cr = true)

Computes diffs between sequences of strings.

from diff
get_diff()

Returns the array of differences.

from diff
integer count_added_lines()

returns the number of new (added) lines in a given diff.

from diff
integer count_deleted_lines()

Returns the number of deleted (removed) lines in a given diff.

from diff
diff reverse()

Computes a reversed diff.

from diff
boolean is_empty()

Checks for an empty diff.

from diff
integer lcs()

Computes the length of the Longest Common Subsequence (LCS).

from diff
array get_original()

Gets the original set of lines.

from diff
array get_final()

Gets the final set of lines.

from diff
trim_newlines(string $line, integer $key)

Removes trailing newlines from a line of text.

from diff
_check($from_lines, $to_lines)

Checks a diff for validity.

from diff
diff3($orig, $final1, $final2, $preserve_cr = true)

Computes diff between 3 sequences of strings.

get_num_conflicts()

Return number of conflicts

mixed get_conflicts_content(string $label1 = 'CURRENT_FILE', string $label2 = 'NEW_FILE', string $label_sep = 'DIFF_SEP_EXPLAIN')

Get conflicts content for download.

mixed merged_output()

Return merged output (used by the renderer)

merged_new_output()

Merge the output and use the new file code for conflicts

merged_orig_output()

Merge the output and use the original file code for conflicts

get_conflicts()

Get conflicting block(s)

_diff3($edits1, $edits2)

Details

in diff at line 49
public diff($from_content, $to_content, $preserve_cr = true)

Computes diffs between sequences of strings.

Parameters

$from_content
$to_content
$preserve_cr

in diff at line 58
public get_diff()

Returns the array of differences.

in diff at line 70
public integer count_added_lines()

returns the number of new (added) lines in a given diff.

Return Value

integer The number of new lines

in diff at line 93
public integer count_deleted_lines()

Returns the number of deleted (removed) lines in a given diff.

Return Value

integer The number of deleted lines

in diff at line 122
public diff reverse()

Computes a reversed diff.

Example: $diff = new diff($lines1, $lines2); $rev = $diff->reverse();

Return Value

diff A Diff object representing the inverse of the original diff. Note that we purposely don't return a reference here, since this essentially is a clone() method.

in diff at line 149
public boolean is_empty()

Checks for an empty diff.

Return Value

boolean True if two sequences were identical.

in diff at line 191
public integer lcs()

Computes the length of the Longest Common Subsequence (LCS).

This is mostly for diagnostic purposes.

Return Value

integer The length of the LCS.

in diff at line 214
public array get_original()

Gets the original set of lines.

This reconstructs the $from_lines parameter passed to the constructor.

Return Value

array The original sequence of strings.

in diff at line 237
public array get_final()

Gets the final set of lines.

This reconstructs the $to_lines parameter passed to the constructor.

Return Value

array The sequence of strings.

in diff at line 259
public trim_newlines(string $line, integer $key)

Removes trailing newlines from a line of text.

This is meant to be used with array_walk().

Parameters

string $line The line to trim.
integer $key The index of the line in the array. Not used.

in diff at line 269
public _check($from_lines, $to_lines)

Checks a diff for validity.

This is here only for debugging purposes.

Parameters

$from_lines
$to_lines

at line 495
public diff3($orig, $final1, $final2, $preserve_cr = true)

Computes diff between 3 sequences of strings.

Parameters

$orig
$final1
$final2
$preserve_cr

at line 510
public get_num_conflicts()

Return number of conflicts

at line 537
public 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.

Parameters

string $label1 the cvs file version/label from the original set of lines
string $label2 the cvs file version/label from the new set of lines
string $label_sep the explanation between label1 and label2 - more of a helper for the user

Return Value

mixed the merged output

at line 575
public mixed merged_output()

Return merged output (used by the renderer)

Return Value

mixed the merged output

at line 583
public merged_new_output()

Merge the output and use the new file code for conflicts

at line 607
public merged_orig_output()

Merge the output and use the original file code for conflicts

at line 631
public get_conflicts()

Get conflicting block(s)

at line 651
public _diff3($edits1, $edits2)

Parameters

$edits1
$edits2