1--TEST--
2ReflectionClass::newInstanceWithoutConstructor()
3--CREDITS--
4Sebastian Bergmann <sebastian@php.net>
5--FILE--
6<?php
7class Foo
8{
9    public function __construct()
10    {
11        print __METHOD__;
12    }
13}
14
15$class = new ReflectionClass('Foo');
16var_dump($class->newInstanceWithoutConstructor());
17
18$class = new ReflectionClass('StdClass');
19var_dump($class->newInstanceWithoutConstructor());
20
21$class = new ReflectionClass('DateTime');
22var_dump($class->newInstanceWithoutConstructor());
23
24$class = new ReflectionClass('Generator');
25try {
26    var_dump($class->newInstanceWithoutConstructor());
27} catch (ReflectionException $e) {
28    echo $e->getMessage(), "\n";
29}
30
31final class Bar extends ArrayObject {
32}
33
34$class = new ReflectionClass('Bar');
35var_dump($class->newInstanceWithoutConstructor());
36
37?>
38--EXPECTF--
39object(Foo)#%d (0) {
40}
41object(stdClass)#%d (0) {
42}
43object(DateTime)#%d (0) {
44}
45Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor
46object(Bar)#%d (1) {
47  ["storage":"ArrayObject":private]=>
48  array(0) {
49  }
50}
51