PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Question on PHP 6 and static calls to instance methods.
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Question on PHP 6 and static calls to instance methods.

Réponse
 
LinkBack Outils de la discussion
Vieux 03/05/2008, 23h02   #1
Adam Richardson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Question on PHP 6 and static calls to instance methods.

I have a quick question on what's coming in PHP 6.

I've incorporated use of the ability to call instance methods through
static calls, allowing for me to mimic multiple inheritance without
having to make edits to classes that are already working because of
the behavior of '$this' when instance methods are called statically.

As stated on in the basics section on classes and objects:

"$this is a reference to the calling object (usually the object to
which the method belongs, but can be another object, if the method is
called statically from the context of a secondary object)."

I've made great use of that functionality in my framework. However,
It sounds like this is going to cause a fatal error in PHP6. Is this
in fact true? And, if the behavior is going to change, can somebody
explain what the impetus for this change was?

Thank you very much for your time,

Adam

Adam Richardson
Envision Internet Consulting, LLC
Phone: (517)623-0485

Services and insight for building effective, user-oriented websites.




  Réponse avec citation
Vieux 05/05/2008, 03h10   #2
Nathan Nobbe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Question on PHP 6 and static calls to instance methods.

On 5/3/08, Adam Richardson <adam@envisionic.com> wrote:
>
> I have a quick question on what's coming in PHP 6.
>
> I've incorporated use of the ability to call instance methods through
> static calls, allowing for me to mimic multiple inheritance without having
> to make edits to classes that are already working because of the behavior of
> '$this' when instance methods are called statically.
>
> As stated on in the basics section on classes and objects:
>
> "$this is a reference to the calling object (usually the object to which
> the method belongs, but can be another object, if the method is called
> statically from the context of a secondary object)."
>
> I've made great use of that functionality in my framework. However, It
> sounds like this is going to cause a fatal error in PHP6. Is this in fact
> true? And, if the behavior is going to change, can somebody explain what
> the impetus for this change was?
>


this is an interesting feature; i was not previously aware of it. its
something akin to javascripts concept of the execution context and the
apply(), call() methods. i think it would be better if the class that used
the $this keyword whereby it was made to refer to the instance of the
caller, have access to the protected members of the other class. i think
this would be reasonable because the client has to invoke the method on the
class that intends to use the $this keyword in the context of its caller;
essentially sanctioning access to protected members. i think the feature
would be quite awesome if that were the case and i can imagine instances
where i would use it.

-nathan

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 20h00.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08490 seconds with 10 queries