0

What are the consequences of implementing the same interface through two different routes in PHP, are there any?

What I mean, is something like this:

interface baseInterface {}

abstract class baseClass implements baseInterface { }

interface myInterface extends baseInterface {}

class myClass extends baseClass implements myInterface {}

In this case myClass implements baseInterface from two different parents - myInterface and baseClass. Are there any consequences to this? My instinct is that PHP should handle this fine, but I just want to make sure. What exactly does PHP do in this case? Does it just check to see that the necessary functions are implemented for the interface each time it discovers it and call it a day or does it do something more?

Daniel Bingham
  • 12,414
  • 18
  • 67
  • 93
  • Have you tried running a simple example, or are you slightly concerned that PHP might crash your server/computer? – Finbarr Apr 19 '10 at 22:48
  • @Finbarr More that I prefer to have this stuff documented, and that's part of what StackOverflow is for ;) – Daniel Bingham Apr 19 '10 at 22:54
  • @Finbarr Plus, if there is some weird consequence in doing it - not unheard of - simply running a test run to see if it will "compile" as it were won't necessarily reveal that. – Daniel Bingham Apr 19 '10 at 22:55
  • I know, I was half joking as PHP takes a beating and some people would have you believe it will cause your computer to explode when something goes wrong. Just a comment, not a suggestion or answer ;) – Finbarr Apr 19 '10 at 23:07

1 Answers1

2

That will all work fine. You'll still have to keep them all straight in your head and documentation though :)

In other words, there are no technical concerns.

Scott Saunders
  • 29,840
  • 14
  • 57
  • 64