From:             dagguh at gmail dot com
Operating system: Irrelevant
PHP version:      5.3.18
Package:          Class/Object related
Bug Type:         Bug
Bug description:Cannot override an abstract method with an abstract method

Description:
------------
It is impossible to override an abstract method with another abstract
method.
This is useful if you are trying to indicate (to both IDE and other
developers) 
that the overriden method returns type is expected to be a subclass of the

inherited method return type.

PS. Java allows it and it is generally a more restrictive language than
PHP.

Test script:
---------------
abstract class RuntimeExceptionReporter extends ExceptionReporter {

    /**
     * @return RuntimeException
     */
    public abstract function getExceptionToReport();

    // ... some operations specific to RuntimeException

}

abstract class ExceptionReporter {

    /**
     * @return Exception
     */
    public abstract function getExceptionToReport();

    // ... some operations on an Exception

}

Expected result:
----------------
Correct inheritance

Actual result:
--------------
Fatal error: Can't inherit abstract function 
ExceptionReporter::getExceptionToReport() (previously declared abstract in

RuntimeExceptionReporter) in xxx on line yyy

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63384&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63384&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63384&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63384&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63384&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63384&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63384&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63384&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63384&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63384&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63384&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63384&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63384&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63384&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63384&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63384&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63384&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63384&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63384&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63384&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63384&r=mysqlcfg

Reply via email to