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.

As I understand it, an 'interface' is, by definition, never gonna have an
actualy object instantiated.

Thus, there can never *BE* an object for which private/public/protected
have any meaning.

You can only use the private/public/protected on the 'class' definitions.

Even if you *KNOW* that all class definitions *should* for this to be
'public' it just doesn't make sense from the strictly technical
stand-point of what an 'interface' is to declare it there.

Maybe somewhere over on php-dev you could make the case for the PHP Dev
Team to implement something good/interesting when public/protected/private
is used there, but currently it's semanticly undefined to have it there,
so it can't be there.

Disclaimer: I could easily be 100% wrong in this entire post. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
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