Git Product home page Git Product logo

daff-php's Introduction

daff-php

This contains the haxe-generated php code for daff.

Tests

Tests require the use of PHPUnit which can be installed via composer. To install PHPUnit to run the tests use the following command.

composer update --dev

Tests are located in the ./test directory, to run all tests simply use the following command

vendor/phpunit/phpunit/phpunit --bootstrap test/bootstrap.php test

Similarly you can run a single test using the following command. (eg: running the SomeFileTest.php test case)

vendor/phpunit/phpunit/phpunit --bootstrap test/bootstrap.php test/SomeFileTest

daff-php's People

Contributors

dogmatic69 avatar paulfitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

daff-php's Issues

TableDiff file number question

Hi,

I've got a question about the TableDiff. Imagine that i make some versions of a spreadsheet and when comparing them i get something like this:

alt text

What i'm trying to know is how would the coordinate of a cell in this view would be in the final merged table. Because i already have the column name on the top i can know the "x" part of the coordinate, but i don't what would be the "y".

I need this because i want to "undo" certain changes shown in the diff view, e.g don't modify certain cell or undo a column removing or similar.

Thanks!

PSR-0 / PSR-4 autoloader

Continue from #5 as that was initially something else.

PSR-0 examples

\Doctrine\Common\IsolatedClassLoader => /path/to/project/lib/vendor/Doctrine/Common/IsolatedClassLoader.php
\Symfony\Core\Request => /path/to/project/lib/vendor/Symfony/Core/Request.php
\Zend\Acl => /path/to/project/lib/vendor/Zend/Acl.php
\Zend\Mail\Message => /path/to/project/lib/vendor/Zend/Mail/Message.php

Or skip to PSR-4

Fully Qualified Class Name Namespace Prefix Base Directory Resulting File Path
\Acme\Log\Writer\File_Writer Acme\Log\Writer ./acme-log-writer/lib/ ./acme-log-writer/lib/File_Writer.php
\Aura\Web\Response\Status Aura\Web /path/to/aura-web/src/ /path/to/aura-web/src/Response/Status.php
\Symfony\Core\Request Symfony\Core ./vendor/Symfony/Core/ ./vendor/Symfony/Core/Request.php
\Zend\Acl Zend /usr/includes/Zend/ /usr/includes/Zend/Acl.php

Problem patching simple tables

Hi,

I have the following code: https://gist.github.com/gonzaloserrano/07948738bd3abc91545b

I'm trying to patch this table:

$remoteTable = [
    ['col1', 'col2', 'col3', 'col4', 'col5', 'col6'],
    [0, 0, 0, 0, 2, 0]
];

into this one:

$localTable = [
    ['col1', 'col2', 'col3', 'col4', 'col5', 'col6'],
    [0, 0, 0, 0, 1, 0]
];

And i have errors similar to:

PHP Notice:  Undefined offset: 3 in /Users/gonzalo/dev/sp/config-manager-backend/vendor/paulfitz/daff-php/gen/lib/coopy/PhpTableView.class.php on line 131

Notice: Undefined offset: 3 in /Users/gonzalo/dev/sp/config-manager-backend/vendor/paulfitz/daff-php/gen/lib/coopy/PhpTableView.class.php on line 131
PHP Notice:  Undefined offset: 3 in /Users/gonzalo/dev/sp/config-manager-backend/vendor/paulfitz/daff-php/gen/lib/coopy/PhpTableView.class.php on line 132

Notice: Undefined offset: 3 in /Users/gonzalo/dev/sp/config-manager-backend/vendor/paulfitz/daff-php/gen/lib/coopy/PhpTableView.class.php on line 132
PHP Notice:  Undefined offset: 3 in /Users/gonzalo/dev/sp/config-manager-backend/vendor/paulfitz/daff-php/gen/lib/coopy/PhpTableView.class.php on line 133

If you remove ANY column from the tables except the 5th (which is the one which has the change) it works flawlessly, but like its found in the gist it gives those errors.

I'm using last master version which has the 1.2.4 commit message on it.

Thanks!

include some tests in the php lib

either hand coded PHPUnit tests or something generated from the main libs?

hand coded will allow people making bugs to include failing tests quite easily. They can also run them to make sure all is well on their platform

Unexpected log "Ordering took too long..."

The log message is being generated here:
https://github.com/paulfitz/daff-php/blob/master/gen/lib/coopy/Alignment.class.php#L159

We're comparing the following tables:

Array
(
    [0] => Array
        (
            [0] => lorem
            [1] => ipsum
        )

    [1] => Array
        (
            [0] => 1
            [1] => value
        )

    [2] => Array
        (
            [0] => 2
            [1] => value
        )

)
Array()

Result:

Alignment.hx:153: Ordering took too long, something went wrong
[["@:@",null,"0:-","1:-"],[null,"!","---","---"],[null,"@@","lorem","ipsum"],["1:-","---",1,"value"],["2:-","---",2,"value"]]

The diff generated is completely correct, but the log message being generated is printed to output and the resulting page is wrong.

Optimize diff case (was: Problem diffing simple tables)

Hi,

There you are another bug report, this time when diffing files: https://gist.github.com/gonzaloserrano/d74bbbf452f745b91a0f

$localTable = [
    ['col1', 'col2', 'col3', 'col4', 'col5'],
    [0, 0, 0, 0, 0]
];

against

$remoteTable = [
    ['col1', 'col2', 'col3', 'col4', 'col5'],
    ['xxx', 0, 0, 0, 0]
];

With this data it does generate an "empty" diff, but I noticed that changing 'xxx' by 1 generates diff data but says NULL->1 when i think it should be 0->1.

Thanks a lot for your time!

Error when patching a table if removed a duplicate row

Hi,

I think there is a bug when apply a patch over a table, I created a gist with an example.
https://gist.github.com/sp-ruben-simon/f049beb378851bdfba80

Seems that if you delete a row and there is an identical row then the patcher doesn't have a good behaviour.

In the above example if you have these tables:

$localTable = [
    ['A', 'B'],
    [2, 2],
    [2, 2],
    [3, 8]
];

$remoteTable = [
    ['A', 'B'],
    [2, 2],
    [3, 8]
];

The result should be that:

$resultTable = [
    ['A', 'B'],
    [2, 2],
    [3, 8]
];

But returned a table full of nulls.

What do you think?

Another error diffing simple tables

Gist: https://gist.github.com/gonzaloserrano/f7aaa84f69dbb80d701e

$localTable = [
["fd", "df"],
["fd", "fd"],
[null, "fd"],
["fd", null],
];

against

$remoteTable = [
["A", "new_column_2"],
[null, null],
["fd", "df"],
["fd", "fd"],
];

shoots

Notice: Trying to get property of non-object in /Users/gonzalo/daff-test/vendor/paulfitz/daff-php/gen/lib/coopy/TableDiff.class.php on line 347
<table>
<thead>
<tr class="index"><td class="index">@:@</td><td></td><td>0:0</td><td>1:1</td></tr>
<tr class="spec"><td class="index"></td><td>!</td><td>(fd)</td><td>(df)</td></tr>
<tr class="header"><th class="index"></th><th>@@</th><th>A</th><th>new_column_2</th></tr>
</thead>
<tbody>
<tr class="add"><td class="index">-:1</td><td>+++</td><td></td><td></td></tr>
<tr><td class="index">0:2</td><td></td><td>fd</td><td>df</td></tr>
<tr><td class="index">1:3</td><td></td><td>fd</td><td>fd</td></tr>
<tr class="remove"><td class="index">2:-</td><td>---</td><td></td><td>fd</td></tr>
</tbody>
</table>

Edit: interestingly, if you remove last row from both tables, you get a Alignment.hx:277: Ordering took too long, something went wrong.

Thanks!

[php] problem aligning compare table with floats

Hi,

Testing last version i got an error when aligning a compare table which has floats.

E.g: the first row with a 2.5 value in a cell fails with:

{"success":false,"message":"Warning: array_key_exists(): The first argument should be either a string or an integer in /Users/gonzalo/dev/config-manager/vendor/paulfitz/daff-php/gen/lib/haxe/ds/StringMap.class.php line 21"}

edit: introduced in 1.1.14, 1.1.13 works fine

Thanks

Error handler is invasive

I dont know if there is any value in having a custom error handler in a package that does not specifically deal with handling errors.

EG: I am using Cake which does a decent job of handling errors. Until daff is included. For example I have a custom error handler that emails issues to a bug tracker, spits them out in syslog which is then sent to 'the cloud' as the application is across a number of servers.

Other users that are not using a framework, my be including some package to specifically handle errors.

Daff is not adding value here, just being annoying. Big unformatted error. I would vote that error handling is removed (or at the very lest configurable with default off)

Autoload

Figured I would make a new ticket here so it does not block up the other repo.

While it can now install and work with composer, there needs to be some auto loading going on so users don't need to manually include files.

I have not found the exact config just yet, will need to make a fork and test it out as the code is not psr-4 compatible. Should be a case of telling composer about the Boot.class.php file and all should be fine.

[php] diff view data column ordering

Hi,

I think there is a bug in the way the diff view is generated.

If i do a diff between two tables where i remove a cell from the remote version i have an html version like this one, which looks great:

screenshot 2014-10-20 17 18 05

But if i don't do the html version an do a $diffTableView->getData() i get this:

Array
(
    [0] => Array
        (
            [0] => @:@
            [1] => 
            [2] => 0:0
        )

    [1] => Array
        (
            [1] => @@
            [2] => A
            [0] => 
        )

    [2] => Array
        (
            [1] => ...
            [2] => ...
            [0] => 
        )

    [3] => Array
        (
            [1] => 
            [2] => zzz
            [0] => 3:3
        )

    [4] => Array
        (
            [1] => ---
            [2] => kkk
            [0] => 4:-
        )

)

Notice 0 row is fine but the 1-4 rows content order should be 0, 1, 2 not 1, 2, 0. They are different data structures, the first one is an integer indexed array in php but the second one is a hashmap, check this out:

php > $good = [0 => '4:-', 1 => '---', 2 => 'kkk'];
php > $bad  = [1 => '---', 2 => 'kkk', 0 => '4:-'];
php > echo json_encode($good);
["4:-","---","kkk"]
php > echo json_encode($bad);
{"1":"---","2":"kkk","0":"4:-"}

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.