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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
26 - 1 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC