php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71485 Return typehint on interanal func causes Fatal error when it throws exception
Submitted: 2016-01-29 20:14 UTC Modified: -
From: zaq178miami at gmail dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: master-Git-2016-01-29 (Git) OS: Debian GNU/Linux 8.2 (jessie)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zaq178miami at gmail dot com
New email:
PHP Version: OS:

 

 [2016-01-29 20:14 UTC] zaq178miami at gmail dot com
Description:
------------
In debug mode, when we define return type info as object and specify class for it, e.g.

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(test_arginfo, ZEND_RETURN_VALUE, 0, IS_OBJECT, "ClassName", 0)
ZEND_END_ARG_INFO()

and then throw exception from function, e.g.

PHP_FUNCTION(test) {
    if (zend_parse_parameters_none() == FAILURE) {
        return;
    }
    
    zend_throw_exception(zend_exception_get_default(), "Test exception", 0);
}

we have fatal error "Fatal error: Return value of test() must be an instance of ClassName, null returned in Unknown on line 0"

While allow_null set to 1 fixes this problem, it is clearly a bug, while after exception thrown, method returned value not used, so no type check after exception should be performed (debug mode affected only).





Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-30 06:06 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e0627594011364e6d75d86a87c6c3a9219e704d1
Log: Fixed bug #71485 (Return typehint on interanal func causes Fatal error when it throws exception).
 [2016-01-30 06:06 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2016-07-20 11:33 UTC] davey@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e0627594011364e6d75d86a87c6c3a9219e704d1
Log: Fixed bug #71485 (Return typehint on interanal func causes Fatal error when it throws exception).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC