1--TEST--
2Testing ReflectionClass::isCloneable()
3--EXTENSIONS--
4simplexml
5xmlwriter
6--FILE--
7<?php
8
9class foo {
10}
11$foo = new foo;
12
13print "User class\n";
14$obj = new ReflectionClass($foo);
15var_dump($obj->isCloneable());
16$obj = new ReflectionObject($foo);
17var_dump($obj->isCloneable());
18$h = clone $foo;
19
20class bar {
21    private function __clone() {
22    }
23}
24$bar = new bar;
25print "User class - private __clone\n";
26$obj = new ReflectionClass($bar);
27var_dump($obj->isCloneable());
28$obj = new ReflectionObject($bar);
29var_dump($obj->isCloneable());
30$h = clone $foo;
31
32print "Closure\n";
33$closure = function () { };
34$obj = new ReflectionClass($closure);
35var_dump($obj->isCloneable());
36$obj = new ReflectionObject($closure);
37var_dump($obj->isCloneable());
38$h = clone $closure;
39
40print "Internal class - SimpleXMLElement\n";
41$obj = new ReflectionClass('simplexmlelement');
42var_dump($obj->isCloneable());
43$obj = new ReflectionObject(new simplexmlelement('<test></test>'));
44var_dump($obj->isCloneable());
45$h = clone new simplexmlelement('<test></test>');
46
47print "Internal class - XMLWriter\n";
48$obj = new ReflectionClass('xmlwriter');
49var_dump($obj->isCloneable());
50$obj = new ReflectionObject(new XMLWriter);
51var_dump($obj->isCloneable());
52$h = clone new xmlwriter;
53
54?>
55--EXPECTF--
56User class
57bool(true)
58bool(true)
59User class - private __clone
60bool(false)
61bool(false)
62Closure
63bool(true)
64bool(true)
65Internal class - SimpleXMLElement
66bool(true)
67bool(true)
68Internal class - XMLWriter
69bool(false)
70bool(false)
71
72Fatal error: Uncaught Error: Trying to clone an uncloneable object of class XMLWriter in %s:%d
73Stack trace:
74#0 {main}
75  thrown in %s on line %d
76