Req #76011 [Opn->Dup]: Sub class should be allowed to change the specificity of return type
| From: | kelunik@php.net | Date: | Mon, 26 Feb 2018 11:53:50 +0000 |
| Subject: | Req #76011 [Opn->Dup]: Sub class should be allowed to change the specificity of return type | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214112@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76011&edit=1
ID: 76011
Updated by: kelunik@php.net
Reported by: ramouixn at pokemail dot net
Summary: Sub class should be allowed to change the
specificity of return type
-Status: Open
+Status: Duplicate
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 7.2.2
Block user comment: N
Private report: N
New Comment:
Stupid bug tracker doesn't detect conflicts on changes...
Previous Comments:
------------------------------------------------------------------------
[2018-02-26 11:52:46] requinix@php.net
It is allowed by LSP but PHP does not support it yet because of technical limitations.
------------------------------------------------------------------------
[2018-02-26 11:48:40] ramouixn at pokemail dot net
Description:
------------
Greetings,
I believe the following should be allowed.
class Animal {}
class Cat extends Animal {}
class My1 {
public function getAnimal () : Animal {}
}
class My2 extends My1 {
public function getAnimal () : Cat {}
}
Because Cat is a Animal and thus compatible with the inherited signature.
Thanks in advance.
Expected result:
----------------
No errors
Actual result:
--------------
Compile error
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76011&edit=1