From f8c225c57655b9e00ed6db6435afda5dca5ad694 Mon Sep 17 00:00:00 2001 From: ging-dev Date: Sat, 30 Sep 2023 10:36:21 +0700 Subject: [PATCH 1/2] fix: #10239 --- src/Psalm/Internal/Diff/FileStatementsDiffer.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Diff/FileStatementsDiffer.php b/src/Psalm/Internal/Diff/FileStatementsDiffer.php index 797b6f73012..665cb47cafd 100644 --- a/src/Psalm/Internal/Diff/FileStatementsDiffer.php +++ b/src/Psalm/Internal/Diff/FileStatementsDiffer.php @@ -115,7 +115,11 @@ static function ( $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]]; From c312c760503c4695331ee4893d0f81bce6f8e646 Mon Sep 17 00:00:00 2001 From: ging-dev Date: Sat, 30 Sep 2023 17:33:50 +0700 Subject: [PATCH 2/2] chore: add test --- tests/Cache/CacheTest.php | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/Cache/CacheTest.php b/tests/Cache/CacheTest.php index 0efce1c6876..04f44eda644 100644 --- a/tests/Cache/CacheTest.php +++ b/tests/Cache/CacheTest.php @@ -199,5 +199,54 @@ class B { ], ], ]; + + 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", + ], + ], + ], + ], + ]; } }