diff --git a/src/Psalm/Internal/Diff/FileStatementsDiffer.php b/src/Psalm/Internal/Diff/FileStatementsDiffer.php index 797b6f730..665cb47ca 100644 --- a/src/Psalm/Internal/Diff/FileStatementsDiffer.php +++ b/src/Psalm/Internal/Diff/FileStatementsDiffer.php @@ -115,7 +115,11 @@ class FileStatementsDiffer extends AstDiffer $b_code, ); - $keep = [...$keep, ...$class_keep[0]]; + if ($diff_elem->old->getDocComment() === $diff_elem->new->getDocComment()) { + $keep = [...$keep, ...$class_keep[0]]; + } else { + $keep_signature = [...$keep_signature, ...$class_keep[0]]; + } $keep_signature = [...$keep_signature, ...$class_keep[1]]; $add_or_delete = [...$add_or_delete, ...$class_keep[2]]; $diff_map = [...$diff_map, ...$class_keep[3]]; diff --git a/tests/Cache/CacheTest.php b/tests/Cache/CacheTest.php index 0efce1c68..04f44eda6 100644 --- a/tests/Cache/CacheTest.php +++ b/tests/Cache/CacheTest.php @@ -199,5 +199,54 @@ class CacheTest extends TestCase ], ], ]; + + yield 'classDocblockChange' => [ + [ + [ + 'files' => [ + '/src/A.php' => <<<'PHP' + [], + ], + [ + 'files' => [ + '/src/A.php' => <<<'PHP' + [ + '/src/A.php' => [ + "UndefinedDocblockClass: Docblock-defined class, interface or enum named T does not exist", + ], + ], + ], + ], + ]; } }