diff --git a/src/Psalm/Internal/Codebase/ClassLikes.php b/src/Psalm/Internal/Codebase/ClassLikes.php index 887220acb..61cd57daf 100644 --- a/src/Psalm/Internal/Codebase/ClassLikes.php +++ b/src/Psalm/Internal/Codebase/ClassLikes.php @@ -778,7 +778,7 @@ class ClassLikes $method_id = $classlike_storage->name . '::' . $method_storage->cased_name; - if ($method_storage->visibility === ClassLikeAnalyzer::VISIBILITY_PUBLIC) { + if ($method_storage->visibility !== ClassLikeAnalyzer::VISIBILITY_PRIVATE) { $method_name_lc = strtolower($method_name); $has_parent_references = false; diff --git a/tests/UnusedCodeTest.php b/tests/UnusedCodeTest.php index a592faecd..8b3944c52 100644 --- a/tests/UnusedCodeTest.php +++ b/tests/UnusedCodeTest.php @@ -322,6 +322,25 @@ class UnusedCodeTest extends TestCase new A();', ], + 'abstractMethodImplementerCoveredByParentCall' => [ + 'inner(); + } + + abstract protected function inner(): void; + } + + class MyFooBar extends Foobar { + protected function inner(): void { + // Do nothing + } + } + + $myFooBar = new MyFooBar(); + $myFooBar->doIt();', + ], ]; }