vendredi 5 juin 2015

PHP Reflection: How to know if a method/property/constant is inherited from trait?

I want to exclude all inherited methods from trait(s) from the list that are not overriden in a class So how to know if a class member is inherited from trait?

Yes, I can check it like this:

    if ($trait->hasMethod($methodName)
        || $ref->getTraitAliases($methodName) !== null)
    {
        //
    }

But what if the trait method is overriden in a class? How to know it? One way is to check if method bodies are similar, if so, i may exclude it, but is there a better way to achieve this?





Aucun commentaire:

Enregistrer un commentaire