#34157 [Opn->Bgs]: Abstract methods in interfaces break class-relations
| From: | tony2001@php.net | Date: | Tue, 16 Aug 2005 20:05:31 +0000 |
| Subject: | #34157 [Opn->Bgs]: Abstract methods in interfaces break class-relations | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-83665@lists.php.net to get a copy of this message | ||
ID: 34157
Updated by: tony2001@php.net
Reported By: jami dot pekkanen at ateco dot fi
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Linux
PHP Version: 5.0.4
New Comment:
Actually it has nothing to do with methods, abstract etc.
You get the result you get because 'BrokenImplementor' doesn't have
parent classes at all, so it can't be a "subclass" of another
class/interface.
But 'WorkingImplementor' is a subclass of class that implements the
interface, so it works in this case.
Anyway, you should use 'instanceof' operator instead - it'd work in
both cases, as it operates differently.
Previous Comments:
------------------------------------------------------------------------
[2005-08-16 21:07:58] jami dot pekkanen at ateco dot fi
Description:
------------
If interface contains abstract method, direct implementor isn't
reported as subclass of the interface. However, if one has abstract
class in the inheritance hierarchy, implementing classes are reported
as subclasses of the interface.
Should abstract methods in interfaces even exist?
Reproduce code:
---------------
<?php
interface SomeInterface
{
abstract public function Foo();
}
class BrokenImplementor implements SomeInterface
{
public function Foo() {}
}
abstract class DummyParent implements SomeInterface {}
class WorkingImplementor extends DummyParent
{
public function Foo() {}
}
var_dump(is_subclass_of('WorkingImplementor', 'SomeInterface'));
var_dump(is_subclass_of('BrokenImplementor', 'SomeInterface'));
?>
Expected result:
----------------
bool(true)
bool(true)
Actual result:
--------------
bool(true)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34157&edit=1