http://www.geocrawler.com/mail/thread.php3?subject=%5BPHP-DEV%5D+__string_value%28%29++crashes+with+return&list=5
First of all I suggest everyone catches up on the reading :) Thies and I
were against it. Zeev wanted to keep it and most of the rest that replied
seemed to be against too.
Personally I don't have a problem with _to_string() *if* it works well and
as expected. There are two main issues:
a) Make all of PHP work this way consistently.
b) Make the patch itself work well.
(a) shouldn't be much of a problem. I think as most string conversions use
convert_to_string() there probably aren't too many exceptions. The main
problem is (b). What if _to_string() returns a different object which is
for example an error object. We would all like this error object to be in
turn converted to a string. However, if we make the code general then we
could risk having an infinite loop. What Jeremy's patch does to solve this
is only call the _to_string() method once and if it returns an object then
the result is "Object" like it is today. I guess it's OK but it would be
nicer to have it work recursively. But then again that could lead to
infinite loops. (It might be something we can live with).
Anyway, so on a whole I don't really mind having such functionality but
let's just be sure what kind of behavior we want and if we can make it
behave consistently across PHP.
Andi
At 11:53 AM 8/22/2001 -0500, Andrei Zmievski wrote:
>On Wed, 22 Aug 2001, Jeremy Bettis wrote:
> > I changed php (current CVS) to add another magic method to Objects,
> > __toString(). Whenever an object needs to be converted to a string,
> then it
> > will first try to call __toString() and if it can't, then it will just
> > return "Object" like now.
>
>Good luck trying to get this in.
>
>-Andrei
>* George Orwell was an optimist. *
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]