Bug #41145 [Com]: Interface, Abstract Class & Methods

From: Date: Thu, 02 Feb 2012 22:02:49 +0000
Subject: Bug #41145 [Com]: Interface, Abstract Class & Methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-167074@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=41145&edit=1

 ID:                 41145
 Comment by:         lsmith@php.net
 Reported by:        gerald at copix dot org
 Summary:            Interface, Abstract Class & Methods
 Status:             Not a bug
 Type:               Bug
 Package:            Class/Object related
 Operating System:   Linux
 PHP Version:        5.2.1
 Block user comment: N
 Private report:     N

 New Comment:

see #43200


Previous Comments:
------------------------------------------------------------------------
[2007-04-21 20:56:07] 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

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.

------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=41145&edit=1


Thread (3 messages)

« previous php.bugs (#167074) next »