Bug #76011 [Opn->Dup]: Sub class should be allowed to change the specificity of return type

From: Date: Mon, 26 Feb 2018 11:52:48 +0000
Subject: Bug #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-214110@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: requinix@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: Bug Package: Scripting Engine problem PHP Version: 7.2.2 Block user comment: N Private report: N New Comment: It is allowed by LSP but PHP does not support it yet because of technical limitations. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#214110) next »