|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
25 - 22 = ?
Subscribe to this entry?

 [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: Fri Apr 12 20:01:30 2024 UTC