Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_API.c
| From: | Andi Gutmans | Date: | Mon, 01 Dec 2003 10:58:25 +0000 |
| Subject: | Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_API.c | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-5858@lists.php.net to get a copy of this message | ||
At 07:54 AM 12/1/2003 +0100, Marcus Boerger wrote:
Hello Andi, Sunday, November 30, 2003, 12:08:33 AM, you wrote: At 11:59 AM 11/28/2003 -0500, Adam Maccabee Trachtenberg wrote:No. You would get print toupper($obj->__toString()). I am not sure (string) cast on objects should work. AndiWrong. __toString() isn't supposed to work in every case the engine expects a string. You'd probably also want $obj[3] to work as a string offset? In this case, maybe we should rename __toString to __toPrintable, because I think Marcus' patch is asking for trouble. I guess you're right that it doesn not make sense in all places but even if you rename it to printable it should work with all printing functions and hence you are causing confusing trouble and confusion in disallowing it. And if at all we drop the auto-conversion then what we get is: print toupper((string)$obj); Wow, no more elegant php - no more typeless php.On Fri, 28 Nov 2003, Andrei Zmievski wrote:On Thu, 27 Nov 2003, Marcus Boerger wrote:Convert objects to string if string is required by newer parameter parsing since we do this for older parameter parsing does so too.Do you really think this is necessary? I can see the automatic object->string casting being useful for things like print(), but when a extension author expects a string, would it make sense to make the object convert itself? I mean the result will most likely be some internal object info represented as a string, and not something meaningful.This is needed for SimpleXML. It's an object pretending to be a set of strings. You've got to be able to things like: htmlentities($xml->element); You can't do that currently because htmlentities() complains that you're passing in an object. As far as I'm concerned, if you don't want your object to be auomatically cast to a string, you shouldn't provide a __toString() method.