|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-09-23 18:08 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2016-09-23 18:08 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 14:00:01 2025 UTC |
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 } }