From 3ac0bce203e71ff5ac966e74a2afd554a7c691b4 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 12 Oct 2022 11:24:42 +0200 Subject: [PATCH] Fix #8569 --- .../Reflector/FunctionLikeNodeScanner.php | 2 +- tests/CloneTest.php | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php index 5583040e62b..ddfe0d33e96 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php @@ -557,7 +557,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal = $classlike_storage->appearing_method_ids[$method_name_lc] = $method_id; - if (!$stmt->isPrivate() || $method_name_lc === '__construct' || $classlike_storage->is_trait) { + if (!$stmt->isPrivate() || $method_name_lc === '__construct' || $method_name_lc === '__clone' || $classlike_storage->is_trait) { $classlike_storage->inheritable_method_ids[$method_name_lc] = $method_id; } diff --git a/tests/CloneTest.php b/tests/CloneTest.php index de2fa5bda3a..6afe54b5afc 100644 --- a/tests/CloneTest.php +++ b/tests/CloneTest.php @@ -82,6 +82,28 @@ private function __clone() {} clone $a;', 'error_message' => 'InvalidClone', ], + 'notVisibleCloneMethodSubClass' => [ + 'code' => ' 'InvalidClone', + ], + 'notVisibleCloneMethodTrait' => [ + 'code' => ' 'InvalidClone', + ], 'invalidGenericClone' => [ 'code' => '