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');
25var_dump($class->newInstanceWithoutConstructor());
26--EXPECTF--
27object(Foo)#%d (0) {
28}
29object(stdClass)#%d (0) {
30}
31object(DateTime)#%d (0) {
32}
33
34Fatal error: Uncaught ReflectionException: Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor in %sReflectionClass_newInstanceWithoutConstructor.php:%d
35Stack trace:
36#0 %sReflectionClass_newInstanceWithoutConstructor.php(%d): ReflectionClass->newInstanceWithoutConstructor()
37#1 {main}
38  thrown in %sReflectionClass_newInstanceWithoutConstructor.php on line %d
39