php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
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 commitsRelated reports
 [2006-08-28 10:26 UTC] tony2001@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC