1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix issue in file diff offset

This commit is contained in:
Brown 2018-11-01 19:11:00 -04:00
parent df8b0a1fc5
commit ef671a14cc
2 changed files with 79 additions and 5 deletions

View File

@ -202,8 +202,8 @@ class FileDiffer
$max_same_count = min($old_text_length, $new_text_length);
for ($i = 0; $i < $max_same_count; $i++) {
if ($old_diff_text[$i] !== $new_diff_text[$i]) {
for ($j = 0; $j < $max_same_count; $j++) {
if ($old_diff_text[$j] !== $new_diff_text[$j]) {
break;
}
@ -213,10 +213,10 @@ class FileDiffer
$new_text_length--;
}
$old_diff_text = substr($old_diff_text, $i);
$new_diff_text = substr($new_diff_text, $i);
$old_diff_text = substr($old_diff_text, $j);
$new_diff_text = substr($new_diff_text, $j);
if ($last_change === null || $i) {
if ($last_change === null || $j) {
$i++;
$last_change = [
$a_offset,

View File

@ -1602,6 +1602,80 @@ class FileDiffTest extends TestCase
[],
[]
],
'diffMultipleBadDocblocks' => [
'<?php
namespace Foo;
class A
{
/**
* @param string $s
* @param string $t
* @return Database
*/
public static function foo()
{
return D::eep();
}
/**
* @param string $s
* @param string $t
* @return bool
*/
public static function bar()
{
return 2;
}
/**
* @return C|null
*/
public static function bat()
{
return 1;
}
}
',
'<?php
namespace Foo;
class A
{
/**
* @param string $s
* @param string
* @return Database
*/
public static function foo()
{
return D::eep();
}
/**
* @param string $s
* @param string
* @return bool
*/
public static function bar()
{
return 2;
}
/**
* @return C|null
*/
public static function bat()
{
return 1;
}
}
',
['foo\a::bat'],
[],
['foo\a::foo', 'foo\a::bar', 'foo\a::foo', 'foo\a::bar'],
[[-6, 0]]
],
];
}
}