Hello Melvyn,
Wednesday, July 16, 2003, 1:27:52 AM, you wrote:
MS> Hi Marcus,
MS> On Wednesday 16 July 2003 00:11, Marcus Börger wrote:
Wednesday, July 16, 2003, 12:08:29 AM, you wrote:
GB> Hi,
GB> I've heard rumors that there are plans to take away the ability to
GB> assign to $this in php 5. If this is true, I would like to place a
vote GB> to keep it, as it can be very useful in conjunction with
GB> __call()/__get()/__set() to implement run-time aggregation seamlessly
Why do you want to trick yourself and the engine? Can't you find a correct
solution?
MS> I'm not farmiliar with the example Greg is getting at, but the following bit
MS> me recently:
MS> class DomFromString extends DomDocument
MS> {
MS> function DomFromString($string)
MS> {
MS> $this = domxml_open_mem($string);
MS> }
This should be a factory patter...static function ...return domxml_open...
MS> function foo()
MS> {
MS> echo('foo');
MS> }
MS> }
MS> $doc = new DomFromString($xml);
$Root = $doc->>document_element();
MS> var_dump($doc, $Root);
echo($doc->>foo()); // call to undefined function
MS> I'm farmiliar with the trick-element of this code and why it won't work, but
MS> the way to do something similar now, is to *not* extend the extension
MS> provided class, use a $this->real_instance and provide methods that re-route
MS> the already existing methods to $this->real_instance.
MS> Unless there's something I'm missing, I find the latter solution has a much
MS> larger trick element and adds a lot of unnecessary typing.
MS> Note that the goal here, is to extend a class of which may not have the source
MS> (or the time/ability to modify it) AND override it's constructor or the
MS> constructor is provided by a function, rather than 'new' principle.
You can of course overwrite the constructor in a derived class and all. So you
are missing the possibility to exchange the contants of a dom clas, that's all
you do this tricky stuff for?
Best regards,
Marcus mailto:helly@php.net