|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63196 ReflectionMethod::invoke() on non-abstract ancestor
Submitted: 2012-10-02 08:36 UTC Modified: 2016-04-16 13:52 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: php dot net at vdachev dot net Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 5.4.7 OS: Ubuntu Quantal
Private report: No CVE-ID: None
 [2012-10-02 08:36 UTC] php dot net at vdachev dot net
Consider a situation when an abstract class (or an interface) is defined and a 
concrete class that extends it. If we get instantiate a ReferenceClass object for 
the abstract class (or the interface), we can then get an ReferenceMethod instance 
for the abstract method.

Unfortunately, calling the ReferenceMethod::invoke() method for an instance of the 
concrete class throws a ReflectionException ("Trying to invoke abstract 

Test script:
abstract class A
        public abstract function doA();

interface IB
        function doB();

class B extends A implements IB
        public function doA()
                echo 'A is done.';

        public function doB()
                echo 'B is done.';

$b = new B();

$refA = new \ReflectionClass('A');
$refDoA = $refA->getMethod('doA');

$refIB = new \ReflectionClass('IB');
$refDoB = $refIB->getMethod('doB');

Expected result:
The invocation of the method on an instance of the concrete class should succeed.

Actual result:
PHP Fatal error:  Uncaught exception 'ReflectionException' with message 'Trying to 
invoke abstract method ...()' in ...:..


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-16 13:52 UTC]
-Status: Open +Status: Not a bug
 [2016-04-16 13:52 UTC]
This is working as intended. ReflectionMethods refer to concrete methods, not to some concept of "this methods or the most specific applicable override".
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 02 19:01:27 2023 UTC