1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Merge pull request #8570 from Nicelocal/fix_8569

Fix #8569
This commit is contained in:
orklah 2022-10-12 20:59:04 +02:00 committed by GitHub
commit bb9aabe5b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -557,7 +557,11 @@ class FunctionLikeNodeScanner
= $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;
}

View File

@ -82,6 +82,28 @@ class CloneTest extends TestCase
clone $a;',
'error_message' => 'InvalidClone',
],
'notVisibleCloneMethodSubClass' => [
'code' => '<?php
class a {
private function __clone() {}
}
class b extends a {}
clone new b;',
'error_message' => 'InvalidClone',
],
'notVisibleCloneMethodTrait' => [
'code' => '<?php
trait a {
private function __clone() {}
}
class b {
use a;
}
clone new b;',
'error_message' => 'InvalidClone',
],
'invalidGenericClone' => [
'code' => '<?php
/**