|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2016-04-16 13:52 UTC] nikic@php.net
 
-Status: Open
+Status: Not a bug
  [2016-04-16 13:52 UTC] nikic@php.net
 | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 07:00:01 2025 UTC | 
Description: ------------ 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 method..."). Test script: --------------- <?php 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(); $b->doA(); $b->doB(); $refA = new \ReflectionClass('A'); $refDoA = $refA->getMethod('doA'); $refDoA->invoke($b); $refIB = new \ReflectionClass('IB'); $refDoB = $refIB->getMethod('doB'); $refDoB->invoke($b); ?> 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 ...:..