Bug #63384 [Com]: Cannot override an abstract method with an abstract method

From: Date: Sat, 03 Jan 2015 16:17:57 +0000
Subject: Bug #63384 [Com]: Cannot override an abstract method with an abstract method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189628@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63384&edit=1 ID: 63384 Comment by: kassner@php.net Reported by: dagguh at gmail dot com Summary: Cannot override an abstract method with an abstract method Status: Open Type: Bug Package: Class/Object related Operating System: Irrelevant PHP Version: 5.3.18 Block user comment: N Private report: N New Comment: Reproducible on PHP 5.5.20. Previous Comments: ------------------------------------------------------------------------ [2012-10-29 11:23:12] dagguh at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=63384&edit=1

« previous php.bugs (#189628) next »