Hi Andi,
Quick question -
Andi Gutmans wrote:Marcus and rest,
Zeev and I took a long look at the whole __toString() issue. There is a problem today that make_printabl_zval() is being called in many places, some of which can't cope with a user-land __toString() being called. In order to support this we will have to do a complete restructuring of the opcodes something we don't want to do pre-5.0.0.
Just to clarify, this is only for internal classes like Exception, right? Userland __toString() will continue to be invoked when an explicit (string) cast (or concat, etc.) is used, correct?
Wrong. The only time userland __toString() will be invoked will be in print/eval. We found that all the places where this happened automaticall were buggy due to the way our opcode mechanism works. It's not a quick fix to support this and is not something I would like to do before 5.0.0. You're going to have to explicitly call __toString() in anything except for print/eval.
Internal classes which support the cast_object() callback (such as SimpleXML) will always be called.
Sorry but it's the right way to go for now. Once we release 5.0.0 we should discuss exactly in which additional cases it should be called.
Andi
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php