At 02:46 PM 10/12/2004 +0200, Jochem Maas wrote:
>Wez Furlong wrote:
>
>>An interface is a *public* contract by definition; PPP specifiers just
>>don't make sense there.
>
>out of curiosity:
>would that be a definition at the PHP level (i.e. decided by php-devs) or
>is that definition more widely acknowledged (for want of a better word)
>(e.g. php-devs used the definition as used in C).
>
>anyway...thanks for knowledge-boost!
This is widely accepted practice. We just have to enforce it in the engine now.
>>Neither does static, since interfaces are instance based.
>
>where as the argument for PPP is wholly understandable, I can't see the
>logic in saying that interfaces are per-definition instance based. It is
>the class that implements the interface, but assuming that indeed
>interface should be instance based then would it not be correct to assume
>that interface implementation should only be checked if and when a class
>is initialized (i.e. so a class is used _only_ statically any interfaces
>it implements should be ignored), as per the following example (which only
>works if the 'abstract' is uncommented):
>
><?php
>
>interface Foo { function foofoo(); }
>
>/* abstract */ class Bar implements Foo
>{
> public static function barbar()
> {
> echo "bar bar black sheep";
> }
>}
>
>Bar::barbar();
>
>?>
>
>I can understand that interfaces more naturally lean towards use with
>instances rather than static classes - but it seems to me that forcing
>that is a case of telling users how they must program (I have always had
>the impression that PHP tried never to force a particular way of doing
>things) - not that its a big deal, because in the end a non-static method
>can be called statically if the user/programmer wishes (and then its his
>problem to make sure the method in question can handle being called that
>way, i.e. no refs to $this).
>
>Anyway, thanks very much for taking the time to broaden (at least) my
>knowledge of PHP.
I tend to agree with Wez here. Interfaces mainly exist so that you can have
more instanceof relationships for objects than just one (OK that's an
oversimplification but I think it's very much down to earth). That said,
there could be instances where it might be useful (such as a Singleton
interface) but I don't think it's worth adding such a feature for edge
cases. I am very much for simplicity.
Andi