1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Only move issue once

This commit is contained in:
Matthew Brown 2019-02-07 18:47:50 -05:00
parent 0bca8db561
commit 6d0e78540a
4 changed files with 64 additions and 3 deletions

View File

@ -420,7 +420,7 @@ class Analyzer
}
/**
* @param array<string, array<int, array{0: int, 1: int, 2: int, 3: int}>> $diff_map
* @param array<string, array<int, array{int, int, int, int}>> $diff_map
* @return void
*/
public function shiftFileOffsets(array $diff_map)
@ -449,7 +449,10 @@ class Analyzer
$matched = false;
foreach ($file_diff_map as list($from, $to, $file_offset, $line_offset)) {
if ($issue_data['from'] >= $from && $issue_data['from'] <= $to) {
if ($issue_data['from'] >= $from
&& $issue_data['from'] <= $to
&& !$matched
) {
$issue_data['from'] += $file_offset;
$issue_data['to'] += $file_offset;
$issue_data['snippet_from'] += $file_offset;

View File

@ -547,7 +547,7 @@ class ArrayIterator implements SeekableIterator, ArrayAccess, Serializable, Coun
/**
* Get array copy
* @link http://php.net/manual/en/arrayiterator.getarraycopy.php
* @return array A copy of the array, or array of public properties
* @return array<TKey, TValue> A copy of the array, or array of public properties
* if ArrayIterator refers to an object.
* @since 5.0.0
*/

View File

@ -1123,6 +1123,44 @@ class TemporaryUpdateTest extends \Psalm\Tests\TestCase
],
'error_positions' => [[306], [306, 452]],
],
'addPropertyDocblock' => [
[
[
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
class A {}
class B
{
private $bar = [];
private $baz = [];
public static function get() : A
{
return new A();
}
}',
],
[
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
class A {}
class B
{
/**
* @var array<string, string>
*/
private $bar = [];
private $baz = [];
public static function get() : A
{
return new A();
}
}',
],
],
'error_positions' => [[152, 203], [337]],
],
];
}
}

View File

@ -1135,6 +1135,26 @@ class TemplateExtendsTest extends TestCase
}
}',
],
'useGenericParentMethod' => [
'<?php
/**
* @template-extends ArrayObject<string, string>
*/
class Foo extends ArrayObject
{
public function bar() : void {
$c = $this->getArrayCopy();
foreach ($c as $d) {
echo $d;
}
$c = parent::getArrayCopy();
foreach ($c as $d) {
echo $d;
}
}
}',
],
];
}