Skip to content

Instantly share code, notes, and snippets.

@sp-ruben-simon
Last active August 29, 2015 14:24
Show Gist options
  • Save sp-ruben-simon/f049beb378851bdfba80 to your computer and use it in GitHub Desktop.
Save sp-ruben-simon/f049beb378851bdfba80 to your computer and use it in GitHub Desktop.
daff-php patch error when remove a duplicate row
<?php
require_once 'vendor/autoload.php';
$localTable = [
['A', 'B'],
[2, 2],
[2, 2],
[3, 8]
];
$remoteTable = [
['A', 'B'],
[2, 2],
[3, 8]
];
$localTableView = new \coopy_PhpTableView($localTable);
$remoteTableView = new \coopy_PhpTableView($remoteTable);
$compareView = \coopy_Coopy::compareTables($localTableView, $remoteTableView);
$alignment = $compareView->align();
// produce the diff
$tableDiffData = [];
$tableDiffView = new \coopy_PhpTableView($tableDiffData);
$flags = new \coopy_CompareFlags();
$highlighter = new \coopy_TableDiff($alignment, $flags);
$highlighter->hilite($tableDiffView);
print_r("Diff Table");
print_r($tableDiffView->getData());
$patch = new coopy_HighlightPatch(
$localTableView,
$tableDiffView
);
$patch->apply();
$patchedData = $localTableView->getData();
print_r("Patched Table");
print_r($patchedData);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment