On 23/08/2016 14:20, Alexander Lisachenko wrote:

2016-08-23 16:13 GMT+03:00 Julien Pauli <jpa...@php.net
<mailto:jpa...@php.net>>:


    No, How can this be ?  B extends A , not A extends B ...
    In this case, B'sfoo() will be called , which is the equivalent to
    having a reflectionMethod from B , so useless to me.



Ok, how can I invoke Parent::whoami() with reflection and get exactly
"Child" as an output?


I've no idea why you'd want to, but note that using get_class($this), you can actually get that for a non-static method: https://3v4l.org/Rc7Dk

class MyParent {
    public function whoami() {
        echo get_class($this);
    }
}

class MyChild extends MyParent {
    public function whoami() {
        echo "Don't call me now!";
        parent::whoami();
    }
}

$m = new reflectionMethod('MyParent', 'whoami');
$m->invoke(new MyChild);


So there is a gap in functionality between static and non-static methods here. I'm not sure reinterpreting a parameter which has always been ignored is the best way to solve it though.

Regards,
--
Rowan Collins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to