php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68438 Can not inherit abstract function to extend its syntax
Submitted: 2014-11-17 19:06 UTC Modified: 2016-04-16 13:41 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: someone dot wanted dot to dot be dot unknown at gmail dot com Assigned:
Status: Duplicate Package: Reproducible crash
PHP Version: Irrelevant OS: Linux
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: someone dot wanted dot to dot be dot unknown at gmail dot com
New email:
PHP Version: OS:

 

 [2014-11-17 19:06 UTC] someone dot wanted dot to dot be dot unknown at gmail dot com
Description:
------------
My code class A, that defined abstract method `method` with one argument.
After that class B extends A. In this place I can not extend signature of `method` (for example, add new required arguments).
Code is following.
That's strange and non-intuitive behavior.
This bug is appearing on PHP 5.0.0 - 5.6.3.

Test script:
---------------
abstract class A {
    abstract function method($a);
}

abstract class B extends A {
    abstract function method($a, $b);
}

Expected result:
----------------
none printable result

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-17 19:08 UTC] someone dot wanted dot to dot be dot unknown at gmail dot com
I saw previously reported bugs, but this is NOT about inheriting method in interfaces, but in classes. It is not fix for now.
http://3v4l.org/rj5AF
 [2016-04-16 13:41 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2016-04-16 13:41 UTC] nikic@php.net
This will certainly not be allowed, as it violates LSP. I'm closing this as a duplicate of bug #63384 to track the unhelpful error message (it should be complaining about the signature mismatch instead).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 16:01:29 2024 UTC