Strange warning when throwing an exception from a __set method.
| Bug #38624 | Strange warning when throwing an exception from a __set method. | ||||
|---|---|---|---|---|---|
| Submitted: | 2006-08-28 09:59 UTC | Modified: | 2006-08-28 10:26 UTC | ||
| From: | derick@php.net | Assigned: | |||
| Status: | Closed | Package: | Scripting Engine problem | ||
| PHP Version: | 5CVS-2006-08-28 (CVS) | OS: | * | ||
| Private report: | No | CVE-ID: | None | ||
[2006-08-28 09:59 UTC] derick@php.net
Description:
------------
When throwing an exception from a __set() method a strange fatal error is shown. I would expect to see the uncaught exception error. Even if I put a try/catch around the $impl = new impl() line the same error is thrown. It seems like you can not throw exceptions if __set() is used through the constructor.
Reproduce code:
---------------
<?php
abstract class abs
{
private $properties = array();
public function __set( $name, $value )
{
throw new Exception( "doesn't work" );
}
public function __get( $name )
{
throw new Exception( "doesn't work" );
}
}
class impl extends abs
{
public function __construct()
{
$this->counter++;
}
}
$impl = new impl();
?>
Expected result:
----------------
The uncaught exception fatal error.
Actual result:
--------------
Fatal error: Couldn't execute method impl::__set in Unknown on line 0
Call Stack:
2.6910 262144 1. {main}() /home/derick/-:0
2.6911 262144 2. impl->__construct() /home/derick/-:25
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2006-08-28 10:26 UTC] tony2001@php.net