summaryrefslogtreecommitdiff
path: root/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt')
-rw-r--r--ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt33
1 files changed, 33 insertions, 0 deletions
diff --git a/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt b/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt
new file mode 100644
index 0000000..1932dbf
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt
@@ -0,0 +1,33 @@
+--TEST--
+ReflectionClass::newInstanceWithoutConstructor()
+--CREDITS--
+Sebastian Bergmann <sebastian@php.net>
+--FILE--
+<?php
+class Foo
+{
+ public function __construct()
+ {
+ print __METHOD__;
+ }
+}
+
+$class = new ReflectionClass('Foo');
+var_dump($class->newInstanceWithoutConstructor());
+
+$class = new ReflectionClass('StdClass');
+var_dump($class->newInstanceWithoutConstructor());
+
+$class = new ReflectionClass('DateTime');
+var_dump($class->newInstanceWithoutConstructor());
+--EXPECTF--
+object(Foo)#%d (0) {
+}
+object(stdClass)#%d (0) {
+}
+
+Fatal error: Uncaught exception 'ReflectionException' with message 'Class DateTime is an internal class that cannot be instantiated without invoking its constructor' in %sReflectionClass_newInstanceWithoutConstructor.php:%d
+Stack trace:
+#0 %sReflectionClass_newInstanceWithoutConstructor.php(%d): ReflectionClass->newInstanceWithoutConstructor()
+#1 {main}
+ thrown in %sReflectionClass_newInstanceWithoutConstructor.php on line %d