Skip to content

Instantly share code, notes, and snippets.

@gonzaloserrano
Created March 3, 2015 17:19
Show Gist options
  • Save gonzaloserrano/d74bbbf452f745b91a0f to your computer and use it in GitHub Desktop.
Save gonzaloserrano/d74bbbf452f745b91a0f to your computer and use it in GitHub Desktop.
daff-php broken diff
<?php
require_once 'vendor/autoload.php';
$localTable = [
['col1', 'col2', 'col3', 'col4', 'col5'],
[0, 0, 0, 0, 0]
];
$remoteTable = [
['col1', 'col2', 'col3', 'col4', 'col5'],
['xxx', 0, 0, 0, 0]
];
$localTableView = new \coopy_PhpTableView($localTable);
$remoteTableView = new \coopy_PhpTableView($remoteTable);
$compareView = \coopy_Coopy::compareTables($localTableView, $remoteTableView);
// compute aligment
$alignment = $compareView->align();
// produce the diff
$tableDiffData = [];
$tableDiffView = new \coopy_PhpTableView($tableDiffData);
$flags = new \coopy_CompareFlags();
$flags->always_show_order = true;
$flags->never_show_order = false;
$highlighter = new \coopy_TableDiff($alignment, $flags);
$highlighter->hilite($tableDiffView);
print_r($tableDiffView->getData());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment