php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76000 Unable to annotate more specific return types in PHP 7.1
Submitted: 2018-02-23 17:05 UTC Modified: 2018-02-23 17:22 UTC
From: bexomixog at 69postix dot info Assigned: cmb (profile)
Status: Duplicate Package: *General Issues
PHP Version: 7.1.14 OS:
Private report: No CVE-ID: None
 [2018-02-23 17:05 UTC] bexomixog at 69postix dot info
Description:
------------
Good evening. I think the following code should be allowed.

Test script:
---------------
<?php

class ParentClass
{
    
}

class ChildClass extends ParentClass
{
    
}

class A
{
    public function test() : ParentClass{}    
}

class B extends A
{
    public function test() : ChildClass{}    
}

Expected result:
----------------
No error.

Actual result:
--------------
Fatal error: Declaration of B::test(): ChildClass must be compatible with A::test(): ParentClass

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-23 17:15 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2018-02-23 17:15 UTC] cmb@php.net
Duplicate of feature request #72442.
 [2018-02-23 17:22 UTC] cmb@php.net
-Status: Closed +Status: Duplicate
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Mar 23 11:01:26 2019 UTC