#41145 [Opn->Bgs]: Interface, Abstract Class & Methods
| From: | helly@php.net | Date: | Sat, 21 Apr 2007 20:56:08 +0000 |
| Subject: | #41145 [Opn->Bgs]: Interface, Abstract Class & Methods | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-111770@lists.php.net to get a copy of this message | ||
ID: 41145
Updated by: helly@php.net
Reported By: gerald at copix dot org
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Linux
PHP Version: 5.2.1
New Comment:
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
This kind of inhereitance trickery is only useful and working in
languages that support MI and there you need to have the leave class
reimplement the method or explicitly use one of the base class'
implementation regardless of whether you provide new code or not. This
is the case because both the abstract class and the interface are two
independant origins of the method. Thus they are considered different.
What you can do instead is having a basic interface that only contains
the shared method. Doing so is absolutely correct because as you say
they are the same protocol entity. And if you were not able to ürovide a
shared base for them, than indeed the methods are different.
Previous Comments:
------------------------------------------------------------------------
[2007-04-20 08:00:05] gerald at copix dot org
Description:
------------
When we want to implement an interface in a child class that extends an
abstract class that contains an abstract method that is in the
interface, we get an error.
This kind of bug has already been submited in #35057 and was marked as
bogus because AClasse::show obviously is not the same as IClasse::show.
But in the code we only say that IClasse::show is the same as
AClasseConcrete::show.
To me, the IClasse should not care how AClasseConcrete manage to
implements the interface. The important thing is that
AClasseConcrete::show IS the same as IClasse::show.
I've checked the documentation and was not able to find this exact case
and I've try this concept in other langages (like Java) with success.
I think at least it should be discussed.
If it has been discussed already, I'm really sorry for the time I made
you spent on this.
Greatings
Reproduce code:
---------------
interface IClasse {
public function show ();
}
abstract class AClasse {
abstract public function show ();
}
class AClasseConcrete extends AClasse implements IClasse {
public function show (){
echo "Everything is ok";
}
}
$classe = new AClasseConcrete ();
$classe->show ();
Expected result:
----------------
"Everything is ok"
Actual result:
--------------
Fatal error: Can't inherit abstract function IClasse::show()
(previously declared abstract in AClasse) in
/home/geraldc/workspace/Copix_3/www/syntax_playground.php
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41145&edit=1