Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_API.c
| From: | Andi Gutmans | Date: | Mon, 01 Dec 2003 16:46:20 +0000 |
| Subject: | Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_API.c | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-5907@lists.php.net to get a copy of this message | ||
What's the chance of having a __toString() in an external object model (note the two underscores :)
Andi
At 02:26 PM 12/1/2003 +0000, Wez Furlong wrote:
I favour a), if you mean that (string)$com_object will work. I'm not so bothered with userspace objects. b) is just wrong for overloaded objects; if we do some magic and either hide an existing __toString() method, or call one with the wrong parameters (it might implement one differently to the way that we expect), then we end up in trouble. --Wez. I think there are two options: a) Revert the cast operator patch and don't support automatic string conversion by PHP objects (i.e. allowing overloading extensions to support it). But you still shouldn't expect automagical conversions when passing COM objects to functions which accept strings as a parameter. b) Add a __toString() C API function and make $obj->__toString() call that. It would mean that your COM example would look like serialize($com_object->__toString()). Personally, I prefer (b) but I think I can live with both. Note: In both cases you won't have automatic conversions. Andi