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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sun Nov 24 02:01:28 2024 UTC