|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73152 Hint of return type in PHP works unexpected way.
Submitted: 2016-09-23 16:02 UTC Modified: 2016-09-23 18:08 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: roman at litgroup dot ru Assigned: cmb (profile)
Status: Duplicate Package: *General Issues
PHP Version: 7.0.11 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: roman at litgroup dot ru
New email:
PHP Version: OS:


 [2016-09-23 16:02 UTC] roman at litgroup dot ru
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-23 18:08 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2016-09-23 18:08 UTC]
Duplicate of feature request #72442.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 22 19:01:31 2024 UTC