Bug #80009 [NEW]: Fatal Error is not caught with Throwable

From: Date: Sat, 22 Aug 2020 18:04:44 +0000
Subject: Bug #80009 [NEW]: Fatal Error is not caught with Throwable
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228710@lists.php.net to get a copy of this message
From:             brucekwells at gmail dot com
Operating system: Windows 10.0 build 19041 AMD64
PHP version:      7.4.9
Package:          Compile Failure
Bug Type:         Bug
Bug description:Fatal Error is not caught with Throwable

Description:
------------
Some Fatal Errors are caught in this script and some are not.

Comment out the "extends TestBase" of the TestExtended class, and this
example will catch the error: Return value of
TestExtended::returnString() must be of the type int, string returned

Or change the class in the new statement to an undefined class.  Or
change the method call.  Both are fatal errors, both caught.

But as written, this script does not catch the fatal error.

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

try
	{
	class TestBase
		{

		public function returnString() : string
			{
			return __METHOD__;
			}

		}

	class TestExtended extends TestBase
		{

		public function returnString() : int
			{
			return __METHOD__;
			}

		}

	$test = new TestExtended();
	echo $test->returnString();
	}
catch (\Throwable $e)
	{
	echo 'Caught error: ' . $e->getMessage();
	}
phpinfo();



Expected result:
----------------
'Caught error: ' followed by PHP error message is printed, followed by
phpinfo() output.

Actual result:
--------------
Fatal error message is printed the standard PHP error handler and is not
prefixed by 'Caught error: '.  phpinfo() is also not printed.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=80009&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=80009&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=80009&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=80009&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=80009&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=80009&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=80009&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=80009&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=80009&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=80009&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=80009&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80009&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=80009&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=80009&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=80009&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=80009&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=80009&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=80009&r=mysqlcfg


Thread (6 messages)

« previous php.bugs (#228710) next »