Re: [PATCH] __toString()

From: Date: Fri, 27 Jan 2006 15:17:39 +0000
Subject: Re: [PATCH] __toString()
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-21702@lists.php.net to get a copy of this message
Marcus Boerger wrote: > Hello Jeremy, > > it is supposed to work everywhere in head and will be available in 5.2. > Is there a generic way (for extensions, of course) to override the operators between objects implementing __toString()? See, I have two objects: $o1 = new QString("php"); $o2 = new QString("-internals"); Now I could do: $result = $o1->operator+=($o2); better would be: $result = $o1 .= $o2; should result in "php-internals" Can I modify the object structure in any way to register my own operator functions which can be called by the engines execution unit? I found only hard-wired implementations of that if I looked into the 'zend execute' code or maybe I'm wrong. Ideally there would be something like a pointer in every zval which points to a struct or table of 'operator-function pointers'. In this case I could override it and point to another operator-function pointer table. Ok, I can dream ;-) In the current implementation (php 5.1) a function zend_make_printable' is called, and there zend_std_cast_object_tostring. This means that the objects __toString() result will be passed to the underlying system, and there is no unicode support yet. What I would prefer is calling overidden operators before __toString() is called. Am I wrong? Can anybody help me please? Thanks, Thomas

« previous php.internals (#21702) next »