Annotation of embedaddon/php/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: ReflectionClass::newInstanceWithoutConstructor()
                      3: --CREDITS--
                      4: Sebastian Bergmann <sebastian@php.net>
                      5: --FILE--
                      6: <?php
                      7: class Foo
                      8: {
                      9:     public function __construct()
                     10:     {
                     11:         print __METHOD__;
                     12:     }
                     13: }
                     14: 
                     15: $class = new ReflectionClass('Foo');
                     16: var_dump($class->newInstanceWithoutConstructor());
                     17: 
                     18: $class = new ReflectionClass('StdClass');
                     19: var_dump($class->newInstanceWithoutConstructor());
                     20: 
                     21: $class = new ReflectionClass('DateTime');
                     22: var_dump($class->newInstanceWithoutConstructor());
                     23: --EXPECTF--
                     24: object(Foo)#%d (0) {
                     25: }
                     26: object(stdClass)#%d (0) {
                     27: }
                     28: 
                     29: 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
                     30: Stack trace:
                     31: #0 %sReflectionClass_newInstanceWithoutConstructor.php(%d): ReflectionClass->newInstanceWithoutConstructor()
                     32: #1 {main}
                     33:   thrown in %sReflectionClass_newInstanceWithoutConstructor.php on line %d

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>