Bug->Req #63384 [Opn->Csd]: Cannot override an abstract method with an abstract method
| From: | nikic@php.net | Date: | Wed, 24 May 2017 15:44:55 +0000 |
| Subject: | Bug->Req #63384 [Opn->Csd]: Cannot override an abstract method with an abstract method | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209255@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
Updated by: nikic@php.net
Reported by: dagguh at gmail dot com
Summary: Cannot override an abstract method with an abstract
method
-Status: Open
+Status: Closed
-Type: Bug
+Type: Feature/Change Request
Package: Class/Object related
Operating System: Irrelevant
PHP Version: 5.3.18
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Resolved by RFC https://wiki.php.net/rfc/allow-abstract-function-override,
implemented with https://github.com/php/php-src/commit/a5eb57c96e8e851793d419cd4a4b4815a2cb44cb.
Previous Comments:
------------------------------------------------------------------------
[2016-04-16 13:41:03] nikic@php.net
Related To: Bug #68438
------------------------------------------------------------------------
[2016-04-16 13:39:30] nikic@php.net
Related To: Bug #69110
------------------------------------------------------------------------
[2015-01-03 16:17:56] kassner@php.net
Reproducible on PHP 5.5.20.
------------------------------------------------------------------------
[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