sebastianbergmann / diff

Diff implementation
BSD 3-Clause "New" or "Revised" License
7.58k stars 85 forks source link

Fatal when diffing integers #25

Closed mathiasverraes closed 9 years ago

mathiasverraes commented 9 years ago
<?php
use SebastianBergmann\Diff\Differ;
$differ = new Differ;
print $differ->diff(1, 2);

results in

PHP Catchable fatal error:  Argument 1 passed to 
SebastianBergmann\Diff\Differ::selectLcsImplementation() 
must be of the type array, integer given, called in src/Differ.php 
on line 198 and defined in src/Differ.php on line 254

diff('foo', 'bar') (with string arguments) works as expected. A workaround is to to cast the arguments to string.

sebastianbergmann commented 9 years ago

Thanks for the report, I will look into this. But why would you want to diff non-strings? Just curious.

mathiasverraes commented 9 years ago

I don't know what the type of the values will be. I guess I could check the types at runtime, but I think that job is better left to Diff.

— Mathias Verraes Software Consultant Value Object Comm.V http://value-object.com Blog http://verraes.net/ - Email mathias@verraes.net - Twitter http://twitter.com/mathiasverraes - LinkedIn https://www.linkedin.com/in/mathiasverraes

On 22 February 2015 at 16:00, Sebastian Bergmann notifications@github.com wrote:

Thanks for the report, I will look into this. But why would you want to diff non-strings? Just curious.

— Reply to this email directly or view it on GitHub https://github.com/sebastianbergmann/diff/issues/25#issuecomment-75439193 .