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
>
>
>

-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to