mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
44 lines
504 B
PHP
Executable File
44 lines
504 B
PHP
Executable File
--TEST--
|
|
Catching an exception in a constructor inside a static method
|
|
--FILE--
|
|
<?php
|
|
|
|
class MyObject
|
|
{
|
|
function fail()
|
|
{
|
|
throw new Exception();
|
|
}
|
|
|
|
function __construct()
|
|
{
|
|
self::fail();
|
|
echo __METHOD__ . "() Must not be reached\n";
|
|
}
|
|
|
|
function __destruct()
|
|
{
|
|
echo __METHOD__ . "() Must not be called\n";
|
|
}
|
|
|
|
static function test()
|
|
{
|
|
try
|
|
{
|
|
new MyObject();
|
|
}
|
|
catch(Exception $e)
|
|
{
|
|
echo "Caught\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
MyObject::test();
|
|
|
|
?>
|
|
===DONE===
|
|
--EXPECT--
|
|
Caught
|
|
===DONE===
|