|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34157 Abstract methods in interfaces break class-relations
Submitted: 2005-08-16 21:07 UTC Modified: 2005-08-16 22:05 UTC
From: jami dot pekkanen at ateco dot fi Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.4 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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: jami dot pekkanen at ateco dot fi
New email:
PHP Version: OS:


 [2005-08-16 21:07 UTC] jami dot pekkanen at ateco dot fi
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:
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:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-16 22:05 UTC]
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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 17:01:31 2024 UTC