xref: /PHP-8.0/Zend/tests/bug74862.phpt (revision dba5a798)
1--TEST--
2Bug #74862 (Unable to clone instance when private __clone defined)
3--FILE--
4<?php
5
6class a {
7    private function __clone()
8    {
9
10    }
11
12    private function __construct()
13    {
14
15    }
16
17    public static function getInstance()
18    {
19        return new static();
20    }
21
22    public function cloneIt()
23    {
24        $a = clone $this;
25
26        return $a;
27    }
28}
29
30class c extends a {
31
32}
33
34// private constructor
35$d = c::getInstance();
36
37// private clone
38$e = $d->cloneIt();
39var_dump($e);
40?>
41--EXPECT--
42object(c)#2 (0) {
43}
44