#38624 [Opn->Csd]: Strange warning when throwing an exception from a __set method.

From: Date: Mon, 28 Aug 2006 10:26:58 +0000
Subject: #38624 [Opn->Csd]: Strange warning when throwing an exception from a __set method.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-101427@lists.php.net to get a copy of this message
ID: 38624 Updated by: tony2001@php.net Reported By: derick@php.net -Status: Open +Status: Closed Bug Type: Scripting Engine problem Operating System: * PHP Version: 5CVS-2006-08-28 (CVS) New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2006-08-28 09:59:59] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38624&edit=1

« previous php.bugs (#101427) next »