diff --git a/src/Psalm/Internal/Codebase/Analyzer.php b/src/Psalm/Internal/Codebase/Analyzer.php index a0dfac7f9..e32f6010b 100644 --- a/src/Psalm/Internal/Codebase/Analyzer.php +++ b/src/Psalm/Internal/Codebase/Analyzer.php @@ -420,7 +420,7 @@ class Analyzer } /** - * @param array> $diff_map + * @param array> $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; diff --git a/src/Psalm/Internal/Stubs/CoreGenericClasses.php b/src/Psalm/Internal/Stubs/CoreGenericClasses.php index dfe58d31f..99295dd90 100644 --- a/src/Psalm/Internal/Stubs/CoreGenericClasses.php +++ b/src/Psalm/Internal/Stubs/CoreGenericClasses.php @@ -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 A copy of the array, or array of public properties * if ArrayIterator refers to an object. * @since 5.0.0 */ diff --git a/tests/FileUpdates/TemporaryUpdateTest.php b/tests/FileUpdates/TemporaryUpdateTest.php index fe0049443..ad6f069d9 100644 --- a/tests/FileUpdates/TemporaryUpdateTest.php +++ b/tests/FileUpdates/TemporaryUpdateTest.php @@ -1123,6 +1123,44 @@ class TemporaryUpdateTest extends \Psalm\Tests\TestCase ], 'error_positions' => [[306], [306, 452]], ], + 'addPropertyDocblock' => [ + [ + [ + getcwd() . DIRECTORY_SEPARATOR . 'A.php' => ' ' + */ + private $bar = []; + private $baz = []; + + public static function get() : A + { + return new A(); + } + }', + ], + ], + 'error_positions' => [[152, 203], [337]], + ], ]; } } diff --git a/tests/Template/TemplateExtendsTest.php b/tests/Template/TemplateExtendsTest.php index ef3c85541..e2b8b2276 100644 --- a/tests/Template/TemplateExtendsTest.php +++ b/tests/Template/TemplateExtendsTest.php @@ -1135,6 +1135,26 @@ class TemplateExtendsTest extends TestCase } }', ], + 'useGenericParentMethod' => [ + ' + */ + 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; + } + } + }', + ], ]; }