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