php-diff icon indicating copy to clipboard operation
php-diff copied to clipboard

Return associative php array in DiffHelper::calculate

Open maxiirs opened this issue 1 year ago • 1 comments

Currently, one has to use json_decode() to access diff properties. This approach is cumbersome and adds unnecessary complexity to the code. It would be helpful to have an option to directly retrieve the diffs as an associative array, simplifying access and improving processing efficiency.

maxiirs avatar Dec 02 '24 14:12 maxiirs

Currently, one has to use json_decode() to access diff properties.

Because it's not a design goal. If you want that rather than rendered diff, you probably just use https://github.com/jfcherng/php-sequence-matcher . This lib is based on that too.


I don't have an idea how it could be done beautifully, since a renderer is required to return a string by design.

You may use the getChanges() method of any HTML renderer to get the diff in php array.

jfcherng avatar Dec 02 '24 15:12 jfcherng