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

 ID:                 64963
 Updated by:         larue...@php.net
 Reported by:        alasdair at softhome dot net
 Summary:            ReflectionClass::getMethods does not identify traits
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Reflection related
 Operating System:   Debian Wheezy
 PHP Version:        5.4.15
 Block user comment: N
 Private report:     N

 New Comment:

the methods of traits are copied into class.

so, in theory, there is nothing wrong.


Previous Comments:
------------------------------------------------------------------------
[2013-06-03 13:57:33] alasdair at softhome dot net

Description:
------------
Specific PHP version PHP 5.4.15-1~dotdeb.2

Executing ReflectionClass::getMethods on a class using traits does not 
differentiate between methods within the class or methods within the trait 
being 
used, whereas calling ReflectionMethod::getDeclaringClass on the class with the 
method identifies it as coming from the trait.

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

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

Class c {
    use t;

    function f2() {
        //do stuff
    }
}

$class = new ReflectionClass('c');
print_r($class->getMethods());
?>

Expected result:
----------------
Array
(
    [0] => ReflectionMethod Object
        (
            [name] => f2
            [class] => c
        )

    [1] => ReflectionMethod Object
        (
            [name] => f
            [class] => t
        )

)

or

Array
(
    [0] => ReflectionMethod Object
        (
            [name] => f2
            [class] => c
        )

    [1] => ReflectionMethod Object
        (
            [name] => f
            [trait] => t
        )

)

Actual result:
--------------
Array
(
    [0] => ReflectionMethod Object
        (
            [name] => f2
            [class] => c
        )

    [1] => ReflectionMethod Object
        (
            [name] => f
            [class] => c
        )

)


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



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

Reply via email to