Req #76011 [Dup->Nab]: Sub class should be allowed to change the specificity of return type
| From: | krakjoe@php.net | Date: | Mon, 26 Feb 2018 11:55:24 +0000 |
| Subject: | Req #76011 [Dup->Nab]: 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-214113@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: krakjoe@php.net
Reported by: ramouixn at pokemail dot net
Summary: Sub class should be allowed to change the
specificity of return type
-Status: Duplicate
+Status: Not a bug
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 7.2.2
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2018-02-26 11:53:49] kelunik@php.net
Stupid bug tracker doesn't detect conflicts on changes...
------------------------------------------------------------------------
[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