php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35057 abstract method inheritance and interface implementation problem
Submitted: 2005-11-01 21:12 UTC Modified: 2005-11-01 21:53 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: antonsub at pochtamt dot ru Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.1.0RC4 OS: Linux
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: antonsub at pochtamt dot ru
New email:
PHP Version: OS:

 

 [2005-11-01 21:12 UTC] antonsub at pochtamt dot ru
Description:
------------
Code given produces fatal error:
Can't inherit abstract function A::foo() (previously declared abstract in B) in foo.php on line 20

Reproduce code:
---------------
<?php
interface A
{
    public function foo($id);
}

abstract class B
{
    abstract public function foo($id);
}

class C extends B
{
    public function foo($id)
    {
        echo "foo\n";
    }
}

class D extends C implements A {}

var_dump(new D);
?>


Expected result:
----------------
But is expected to run cleanly.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-01 21:53 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

B::foo is not A::foo, so when C inherits B it gets B::foo and when it implements A it gets A:foo, obviously A::foo and B::foo are different. That\'s what the error tells you.
 [2012-02-02 22:02 UTC] lsmith@php.net
see #43200
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 26 20:01:33 2024 UTC