Skip to content

Commit

Permalink
Merge pull request #8570 from Nicelocal/fix_8569
Browse files Browse the repository at this point in the history
Fix #8569
  • Loading branch information
orklah committed Oct 12, 2022
2 parents 8d874aa + e43c6c1 commit bb9aabe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Expand Up @@ -557,7 +557,11 @@ 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;
}

Expand Down
22 changes: 22 additions & 0 deletions tests/CloneTest.php
Expand Up @@ -82,6 +82,28 @@ private function __clone() {}
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
/**
Expand Down

0 comments on commit bb9aabe

Please sign in to comment.