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