Download the PHP package facebook/difflib without Composer
On this page you can find all versions of the php package facebook/difflib. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package difflib
DiffLib
DiffLib is a Hack library for creating and parsing diffs. Diffs can be created between any two sequences of items. Additional helpers (such as support for unified diffs, and colored diffs) are provided for string diffs.
Diffs are represented as a sequence of DiffOp
operations; these can 'keep' an
element (i.e. it's unchanged in both sequences), insert an element, or delete an
element. For example, in a unified diff, these would be:
String diffs are typically represented as a sequence of lines, but can also be represented as a sequence of characters, allowing intra-line diffs.
Diff output formats
difflib can create standard unified diffs:
difflib can also create colored diffs, with intra-line edits highlighted:
A concrete implementation is provided for standard CLI terminals, and an abstract base class for other implementations, such as HTML or XHP.
Examples
dump_int_diff(vec[1, 3, 9], vec[1, 4, 9])
will produce this output:
Requirements
- The current release version of HHVM
Installing DiffLib
How DiffLib works
Diffs are created using Myers' diff algorithm: Myers, E.W. Algorithmica (1986) 1: 251. https://doi.org/10.1007/BF01840446
For more details, see the commented implementation.
Full documentation
DiffLib\Diff
: abstract base class. Needs to be subclassed to operate on any particular type.DiffLib\StringDiff
: final class for diffing strings, and adds support for creating unified diffsDiffLib\ColoredUnifiedDiff
: abstract class for rendering unified diffs. Output may be any type - for example, strings or XHP.DiffLib\CLIColoredUnifiedDiff
: abstract final class for rendering unified diffs to a terminal that supports color escape sequences. Provides intra-line highlighting.DiffLib\DiffOp
: abstract class for a diff operation. Sealed toDiffInsertOp
,DiffKeepOp
, andDiffDeleteOp
.DiffLib\cluster()
: utility function to group together sequential operations of the same kind. Convertsvec<DiffOp<T>>
to a generally shorter number ofvec<DiffOp<vec<T>>>
License
DiffLib is MIT licensed, as found in the LICENSE file.