Bug #73152 [Opn->Dup]: Hint of return type in PHP works unexpected way.
| From: | cmb@php.net | Date: | Fri, 23 Sep 2016 18:08:53 +0000 |
| Subject: | Bug #73152 [Opn->Dup]: Hint of return type in PHP works unexpected way. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204217@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73152&edit=1
ID: 73152
Updated by: cmb@php.net
Reported by: roman at litgroup dot ru
Summary: Hint of return type in PHP works unexpected way.
-Status: Open
+Status: Duplicate
Type: Bug
Package: *General Issues
Operating System: Linux
PHP Version: 7.0.11
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Duplicate of feature request #72442.
Previous Comments:
------------------------------------------------------------------------
[2016-09-23 16:02:47] roman at litgroup dot ru
Description:
------------
Hint of return type in PHP works unexpected way.
It's not possible to change hint of return type to a more concrete subtype.
Test script:
---------------
interface Person {/* _ */}
interface PersonFactory
{
public function createPerson(): Person;
}
class Customer implements Person {/* _ */}
class CustomerFactory implements PersonFactory
{
public function createPerson(): Customer // PHP Fatal error:
{ // Declaration of CustomerFactory::createPerson():
Customer
return new Customer(); // must be compatible with
PersonFactory::createPerson(): Person
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73152&edit=1