Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_API.c

From: Date: Mon, 01 Dec 2003 12:49:15 +0000
Subject: Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_API.c
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-5866@lists.php.net to get a copy of this message
I'm talking about (string)$obj calling the cast handler in overloaded objects; COM does not have a __toString() method, and we shouldn't be cluttering up the "method-space" for overloaded objects - what if the underlying object has a __toString() method? I'm not particularly worried about __toString() for regular user-defined objects, but for overloaded objects, we need that (string) cast stuff to work so that people can serialize() things like variant dates, integer values etc. // Perfect $v = new variant("12/01/03", VT_DATE); serialize((string)$v); // this cannot work- VT_DATE has no methods serialize($v->__toString()); // PHP string cast gets in the way of // the real __toString() call. $v = new COM("Object.With.toString.Method"); serialize($v->__toString()); --Wez. > I don't think casting an object to a string should work. > I don't see why this is any better than the more verbose $obj->__toString(). > > Can you please explain in what situation you need __toString() to be called > for SimpleXML and COM automatically and we can try and think of a solution > together. A possible solution is to remove the comment I put and to remove > the __toString > () call in the std objects cast handler.

« previous php.internals (#5866) next »