On Sun, 05 Jun 2011 15:58:06 +0100, Manu Robledo <moli...@mopot.de> wrote:

I came a cross some problems, which were caused by PHPTAS relying on the __toString() magic method, when converting objects to strings.

First problem: Exceptions can´t be thrown within __toString(), see:

That's the contract of __toString, so you shouldn't even try to throw exceptions from this method, even if you can get away with it sometimes.

Is there a strong use-case for throwing exceptions at point of conversion to string?

Second problem: __toString() is not correctly implemented in PHP < 5.2.0, so that on a test server with an older PHP version, the output is just "Object".

5.2.0 has been released in 2006! I'd rather not support software even older than that.

Here is, how I extended the phptal_tostring() and phptal_escape() functions to implement this workaround (3 small changes):


Thanks. You bring very good point about implicit cast in implode(). I'll fix that one.

regards, Kornel Lesiński

PHPTAL mailing list

Reply via email to