php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69110 Abstract method inheritance behaves differently from concrete inheritance
Submitted: 2015-02-23 17:14 UTC Modified: 2016-04-16 13:39 UTC
From: draconyster at gmai dot com Assigned:
Status: Duplicate Package: Scripting Engine problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: draconyster at gmai dot com
New email:
PHP Version: OS:

 

 [2015-02-23 17:14 UTC] draconyster at gmai dot com
Description:
------------
When extending abstract classes you are not allowed to change an abstract method's signature to a compatible one. This works perfectly fine for concrete classes though.

Test script:
---------------
//This code works:

class A { 
    public function a () {}
} 

class B extends A { 
    public function a ($t = false) {}
}

//this code throws an error:

abstract class A { 
    abstract public function a ();
} 

abstract class B extends A { 
    abstract public function a ($t = false);
} 

Expected result:
----------------
Extending an abstract method should behaves consistently with extending concrete methods

Actual result:
--------------
Fatal error:  Can't inherit abstract function A::a() (previously declared abstract in B)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-16 13:39 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2016-04-16 13:39 UTC] nikic@php.net
Duplicate of bug #63384.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Apr 03 02:01:23 2020 UTC