ID:               31578
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mgkimsal at conduit dot com
-Status:           Open
+Status:           Wont fix
-Bug Type:         *General Issues
+Bug Type:         Feature/Change Request
 Operating System: all
 PHP Version:      5.0.2
 New Comment:

We decided in the past that this should be a fatal error, and not
catchable. If you want to make sure your objects are the correct class,
you have to test that before you call the method with the type hint.


Previous Comments:
------------------------------------------------------------------------

[2005-01-17 02:25:17] mgkimsal at conduit dot com

Description:
------------
http://us3.php.net/manual/en/language.oop5.typehinting.php  
states that "Failing to satisfy the type hint results in a  
fatal error."  
  
This seems relatively useless compared to having PHP5  
throw an exception.  This would make it a recoverable  
situation that could be handled gracefully rather than yet  
another fatal error which PHP can't deal with.   
 
http://bugs.php.net/bug.php?id=28001&edit=2 had a response 
from Derick stating that someone should just write their 
own custom error handler to catch this and deal with it, 
but it's a fatal error - my php5.0.2 can not catch fatal 
errors, and I'm not seeing anything in the docs that says 
we should be able to handle fatal errors with user-defined 
code. 
 
I *DID* see an example file that caught a FATAL error 
*when it was invoked by trigger_error()* but it doesn't 
work in the code below.  

Reproduce code:
---------------
<?php
set_error_handler("myfunc");
error_reporting(E_ALL);

function myfunc($errno, $errstr, $errfile, $errline)  {
        echo "err=$errono";
        print_r(debug_backtrace());
}

class bar { }
class foo {
        function me(bar $b) {
                print_r($b);
        }
}

$b = new bar;
$f = new foo();
$f->me("fff");
?>


Expected result:
----------------
I would expect a backtrace() dump on the screen. 

Actual result:
--------------
PHP Fatal error:  Argument 1 must be an object of class 
bar in /var/www/html/v5/er.php on line 12 
 
Fatal error: Argument 1 must be an object of class bar 
in /var/www/html/v5/er.php on line 12 
 


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31578&edit=1

Reply via email to