Bug #72948 [Opn]: Uncatchable "Catchable" fatal error for class to string conversions

From: Date: Fri, 26 Aug 2016 13:48:54 +0000
Subject: Bug #72948 [Opn]: Uncatchable "Catchable" fatal error for class to string conversions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203582@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72948&edit=1

 ID:                 72948
 User updated by:    fredrik at neam dot se
 Reported by:        fredrik at neam dot se
 Summary:            Uncatchable "Catchable" fatal error for class to
                     string conversions
 Status:             Open
 Type:               Bug
 Package:            *Programming Data Structures
-Operating System:   linux
+Operating System:   
 PHP Version:        7.1.0beta3
 Block user comment: N
 Private report:     N

 New Comment:

Removed operating system value since this is likely not OS-specific


Previous Comments:
------------------------------------------------------------------------
[2016-08-26 13:44:29] fredrik at neam dot se

Description:
------------
When attempting to convert a class to a string, the resulting "Catchable" fatal error is
not being caught.

This results in confusion regarding whether or not PHP7's new ability to catch these fatal
errors work or not. It turns out that some catchable fatal errors indeed can be caught, while some
don't, like the one being reported here. 

This has been confirmed using the below test script against all active php and hhvm versions: 
https://3v4l.org/GeNpF

Test script:
---------------
<?php

echo "PHP Version: " . PHP_VERSION . "\n";

try {

    $v = new DateTime();
    $v = (string) $v;

} catch (Error $e) {

    echo "Caught 'Catchable fatal error' with message: " . $e->getMessage();
    die();

}

echo "Did not catch 'Catchable fatal error'";


Expected result:
----------------
The Catchable fatal error should be caught

Actual result:
--------------
The Catchable fatal error is acting like a non-catchable fatal error


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



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


Thread (7 messages)

« previous php.bugs (#203582) next »