Re: php 5 interfaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sergio Gorelyshev wrote:
Hi all.

Situation:

interface MyInterface {
 public static myMethod();
}

class MyClass implements MyInterface {
  public static myMethod() {}
}

This sample will crash with message Fatal error: Access type for interface method MyInterface::myMethod() must be omitted in somefile.php on line NN

Why I'm not able to clarify call's type (static) for methods in interface? I'm predict closely that method myMethod() in all classes which implements  MyInterface must be called statically. A little trick allowed to me to resolve this problem, but my question  more ideological than practical.

Thanks
it's not the static part, it's the public part. You can't make non-public static methods. It's simply impossible by the definition of protected and private (both allow only the object itself to access it, or (in case of protected) a descendent).

So, removing the public part should work out fine.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux