vendredi 29 septembre 2017

Php, ReflectionClass, getConstructor() bumpts into a trait's constructor, how to dodge it?

so far I have this:

class A
{
    public function __construct($v1,$v2) {}
}

class B extends A
{
}

class C extends B
{
}

echo (new \ReflectionClass('C'))->getConstructor()->class;

this works like a charm, it produces A as expected. So far so good. But then a trait came into my way:

trait X
{
    public function __construct($fake) {}
}

class A
{
    public function __construct($v1,$v2) {}
}

class B extends A
{
    use X;
}

class C extends B
{
}

echo (new \ReflectionClass('C'))->getConstructor()->class;

it now produces B ! But I want to know the parameters of A::constructor, not X::constructor! How to dodge it?





Aucun commentaire:

Enregistrer un commentaire