Re: Fwd: Re: [PHP-DEV] Assigning to $this

From: Date: Wed, 04 Feb 2004 19:37:33 +0000
Subject: Re: Fwd: Re: [PHP-DEV] Assigning to $this
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-25502@lists.php.net to get a copy of this message
On Wed, 04 Feb 2004 19:57:30 +0100, Lukas Smith wrote: > Jan Schneider wrote: >> Zitat von Lorenzo Alberton <l.alberton@quipo.it>: >> FYI: >> read the mail below, from php.internals newsgroup. >> There are > 10 packages in PEAR that use the >> "$this = $sth_else;" hack. >> >> Since it will not be supported in PHP5 anymore, >> has anyone a viable alternative to it? > > Yes. Don't use it. > Jan. thanks for the useful comment. > move everything that could create errors in a separat method. if > you have a factory method you can call this method from there after > the object has been instanciated. unfortunately this is not always possible. Being able to assign a new class to $this meant having an easy delegator, perfect for its task. Of course a factory method would make it not necessary anymore, but if the class has no factory method already in place, then maintaining BC is almost impossible. The only viable alternative (in my POV) is making the original class a proxy for the child class ==> lots of functions whose only reason to exists is to proxy the call, as said. *grunt* The better alternative would be this one: http://marc.theaimsgroup.com/?t=107394584300002&r=1&w=2 but it's not in PEAR yet, and who knows when it will be. Best regards, Lorenzo

« previous php.pear.dev (#25502) next »