php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66376 ReflectionClass::getPrototype returns ReflectionMethod which does not exist
Submitted: 2013-12-31 12:53 UTC Modified: 2017-10-24 03:07 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: rudgergravestein at gmail dot com Assigned: yohgaki (profile)
Status: Assigned Package: Reflection related
PHP Version: 5.4.23 OS: Ubuntu 12.04.2 LTS
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-12-31 12:53 UTC] rudgergravestein at gmail dot com
Description:
------------
Specific PHP version: PHP 5.4.23-1+sury.org~precise+1

ReflectionMethod::getPrototype — Gets the method prototype (if there is one).

Executing ReflectionClass::getPrototype on class methods, with the class using traits, returns a ReflectionClass with reference to non-existing class methods (these are trait methods).



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

trait t {
    function f() {
        //do stuff
    }

}

class a {
    function f() {
        // do stuff
    }
}

class c extends a {
    use t;

}

$class = new ReflectionClass('c');

foreach ($class->getMethods() as $method) {

    try {
        printf('method %s::%s%s', $method->class, $method->name, PHP_EOL);
        $prototype = $method->getPrototype();
        printf('prototype %s::%s%s', $prototype->class, $prototype->name, PHP_EOL);
    } catch (\ReflectionException $e) {
        printf('%s%s', $e->getMessage(), PHP_EOL);
    }

}


Expected result:
----------------
Two possible expected results:

method c::f
prototype a::f

or

method c::f
Method c::f does not have a prototype


Actual result:
--------------
method c::f
prototype c::f


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-13 23:03 UTC] yohgaki@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: yohgaki
 [2014-07-13 23:03 UTC] yohgaki@php.net
Fixed
http://3v4l.org/EGPiQ
 [2014-07-13 23:05 UTC] yohgaki@php.net
-Status: Closed +Status: Re-Opened
 [2014-07-13 23:05 UTC] yohgaki@php.net
Oops. Master is fine, but it's still broken 5.4.11 - 5.6.0RC2.
 [2017-10-24 03:07 UTC] kalle@php.net
-Status: Re-Opened +Status: Assigned
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC