diff-match-patch
diff-match-patch copied to clipboard
Double call to mb_string
Hi there!
There's an issue in DiffToolkit
where it's calling mb_strlen(mb_strlen($longtext))
this produces an error on newer php versions (using declare(strict_types=1)
) because mb_strlen
must receive a string as an argument.
After changing it all tests keep passing
https://github.com/yetanotherape/diff-match-patch/blob/463b635e734775ff5e38c2e2edc4f676ea1c3da2/src/DiffToolkit.php#L175
Here's the previous phpunit log
PhpUnit Log
fede@desktop ~/Codes/diff-match-patch ~ $ vendor/phpunit/phpunit/phpunit
//PHPUnit 9.1.3 by Sebastian Bergmann and contributors.
Runtime: PHP 7.4.5
Configuration: /home/fede/Codes/diff-match-patch/phpunit.xml.dist
.E.......EEE..........E.............EEEE.Elapsed time: 0.008
Memory usage: 0.144
.Elapsed time: 0.158
Memory usage: 0
.. 44 / 44 (100%)
Time: 00:00.315, Memory: 8.00 MB
There were 9 errors:
1) DiffMatchPatch\DiffMatchPatchTest::testDiffMain
TypeError: Argument 4 passed to DiffMatchPatch\Diff::compute() must be of the type int, float given, called in /home/fede/Codes/diff-match-patch/src/Diff.php on line 991
/home/fede/Codes/diff-match-patch/src/Diff.php:1029
/home/fede/Codes/diff-match-patch/src/Diff.php:991
/home/fede/Codes/diff-match-patch/src/DiffMatchPatch.php:174
/home/fede/Codes/diff-match-patch/tests/DiffMatchPatchTest.php:79
2) DiffMatchPatch\DiffMatchPatchTest::testPatchMake
TypeError: Argument 4 passed to DiffMatchPatch\Diff::compute() must be of the type int, float given, called in /home/fede/Codes/diff-match-patch/src/Diff.php on line 991
/home/fede/Codes/diff-match-patch/src/Diff.php:1029
/home/fede/Codes/diff-match-patch/src/Diff.php:991
/home/fede/Codes/diff-match-patch/src/Patch.php:293
/home/fede/Codes/diff-match-patch/src/DiffMatchPatch.php:262
/home/fede/Codes/diff-match-patch/tests/DiffMatchPatchTest.php:164
3) DiffMatchPatch\DiffMatchPatchTest::testPatchApply
TypeError: Argument 4 passed to DiffMatchPatch\Diff::compute() must be of the type int, float given, called in /home/fede/Codes/diff-match-patch/src/Diff.php on line 991
/home/fede/Codes/diff-match-patch/src/Diff.php:1029
/home/fede/Codes/diff-match-patch/src/Diff.php:991
/home/fede/Codes/diff-match-patch/src/Patch.php:293
/home/fede/Codes/diff-match-patch/src/DiffMatchPatch.php:262
/home/fede/Codes/diff-match-patch/tests/DiffMatchPatchTest.php:176
/home/fede/Codes/diff-match-patch/tests/DiffMatchPatchTest.php:188
4) DiffMatchPatch\DiffMatchPatchTest::testPatchApply_2
TypeError: Argument 4 passed to DiffMatchPatch\Diff::compute() must be of the type int, float given, called in /home/fede/Codes/diff-match-patch/src/Diff.php on line 991
/home/fede/Codes/diff-match-patch/src/Diff.php:1029
/home/fede/Codes/diff-match-patch/src/Diff.php:991
/home/fede/Codes/diff-match-patch/src/Patch.php:293
/home/fede/Codes/diff-match-patch/src/DiffMatchPatch.php:262
/home/fede/Codes/diff-match-patch/tests/DiffMatchPatchTest.php:176
/home/fede/Codes/diff-match-patch/tests/DiffMatchPatchTest.php:196
5) DiffMatchPatch\DiffTest::testMain
TypeError: Argument 4 passed to DiffMatchPatch\Diff::compute() must be of the type int, float given, called in /home/fede/Codes/diff-match-patch/src/Diff.php on line 991
/home/fede/Codes/diff-match-patch/src/Diff.php:1029
/home/fede/Codes/diff-match-patch/src/Diff.php:991
/home/fede/Codes/diff-match-patch/tests/DiffTest.php:729
6) DiffMatchPatch\PatchTest::testMake
TypeError: Argument 4 passed to DiffMatchPatch\Diff::compute() must be of the type int, float given, called in /home/fede/Codes/diff-match-patch/src/Diff.php on line 991
/home/fede/Codes/diff-match-patch/src/Diff.php:1029
/home/fede/Codes/diff-match-patch/src/Diff.php:991
/home/fede/Codes/diff-match-patch/src/Patch.php:293
/home/fede/Codes/diff-match-patch/tests/PatchTest.php:157
7) DiffMatchPatch\PatchTest::testSplitMax
TypeError: Argument 4 passed to DiffMatchPatch\Diff::compute() must be of the type int, float given, called in /home/fede/Codes/diff-match-patch/src/Diff.php on line 991
/home/fede/Codes/diff-match-patch/src/Diff.php:1029
/home/fede/Codes/diff-match-patch/src/Diff.php:991
/home/fede/Codes/diff-match-patch/src/Patch.php:293
/home/fede/Codes/diff-match-patch/tests/PatchTest.php:214
8) DiffMatchPatch\PatchTest::testAddPadding
TypeError: Argument 4 passed to DiffMatchPatch\Diff::compute() must be of the type int, float given, called in /home/fede/Codes/diff-match-patch/src/Diff.php on line 991
/home/fede/Codes/diff-match-patch/src/Diff.php:1029
/home/fede/Codes/diff-match-patch/src/Diff.php:991
/home/fede/Codes/diff-match-patch/src/Patch.php:293
/home/fede/Codes/diff-match-patch/tests/PatchTest.php:247
9) DiffMatchPatch\PatchTest::testApply
TypeError: Argument 4 passed to DiffMatchPatch\Diff::compute() must be of the type int, float given, called in /home/fede/Codes/diff-match-patch/src/Diff.php on line 991
/home/fede/Codes/diff-match-patch/src/Diff.php:1029
/home/fede/Codes/diff-match-patch/src/Diff.php:991
/home/fede/Codes/diff-match-patch/src/Patch.php:293
/home/fede/Codes/diff-match-patch/tests/PatchTest.php:288
Regards!