You are here: Re: [PHP] php 5 interfaces « PHP « IT news, forums, messages
Re: [PHP] php 5 interfaces

Posted by Richard Lynch on 01/20/05 21:13

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация