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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 16:01:29 2024 UTC