forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa09c70
commit a702406
Showing
3 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--TEST-- | ||
ReflectionClass::newInstanceWithoutConstructor() | ||
--CREDITS-- | ||
Sebastian Bergmann <[email protected]> | ||
--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 %s/tests/ReflectionClass_newInstanceWithoutConstructor.php:%d | ||
Stack trace: | ||
#0 %s/ReflectionClass_newInstanceWithoutConstructor.php(%d): ReflectionClass->newInstanceWithoutConstructor() | ||
#1 {main} | ||
thrown in %s/ReflectionClass_newInstanceWithoutConstructor.php on line %d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters