php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69991 Fatal error
Submitted: 2015-07-03 19:46 UTC Modified: 2017-09-12 10:56 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: dievartg at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Reflection related
PHP Version: 7.0.0alpha2 OS: linux
Private report: No CVE-ID: None
 [2015-07-03 19:46 UTC] dievartg at gmail dot com
Description:
------------
Hello,

a fatal error (no catchable) is thrown when I attempt to call the mehod getReturnType from a class inheriting of ReflectionFunctionAbstract

Do you think it's a normal behavior ?

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

class MockReflectionMethod extends ReflectionFunctionAbstract
{
    public static function export() {}
    public function __toString() {}
}


try {
    (new MockReflectionMethod)->isStatic();    
} catch(Throwable $e) {
    echo $e->getMessage();
}

try {
    (new MockReflectionMethod)->getReturnType();
} catch(Throwable $e) {
    echo $e->getMessage();
}

// output:
// Call to undefined method MockReflectionMethod::isStatic()
// Fatal error: ReflectionFunctionAbstract::getReturnType(): Internal error: Failed to retrieve the reflection object

Actual result:
--------------
http://3v4l.org/7LjRK

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-04 00:52 UTC] requinix@php.net
-Status: Open +Status: Verified
 [2015-07-04 00:52 UTC] requinix@php.net
Yes, it is raising an error rather than throwing an exception.
http://3v4l.org/f20S1#v700alpha2

Note that it doesn't make sense to extend ReflectionFunctionAbstract because you can't provide the "reflection object" which the error is talking about.
 [2015-07-04 05:50 UTC] dievartg at gmail dot com
ReflectionFunctionAbstract is extended to test a mock generator, for a unit testing framework.
 [2015-07-04 10:26 UTC] kalle@php.net
So did this used to work on 5.x series, or?
 [2015-07-04 13:15 UTC] cmb@php.net
No, this is not supposed to work (neither with 5 nor 7).

However, as Damian already pointed out, ::getReturnType() raises a
fatal error instead of an exception (<http://3v4l.org/f20S1>),
what seems to be undesired behavior for PHP 7.
 [2015-07-09 06:22 UTC] trowski@php.net
This will be addressed eventually by the PR I added, but it likely will not be merged until 7.1.
 [2017-09-12 10:56 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2017-09-12 10:56 UTC] cmb@php.net
Indeed, fixed as of PHP 7.1.0.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 16:01:28 2024 UTC