#39392 [Opn->Bgs]: __toString back compatibility

From: Date: Mon, 06 Nov 2006 14:26:08 +0000
Subject: #39392 [Opn->Bgs]: __toString back compatibility
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-104467@lists.php.net to get a copy of this message
ID: 39392 Updated by: helly@php.net Reported By: marcos dot neves at gmail dot com -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: ANY PHP Version: 5.2.0 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php See upgrade info Previous Comments: ------------------------------------------------------------------------ [2006-11-05 23:23:27] marcos dot neves at gmail dot com Description: ------------ Object that do not implement __toString, now stop the script with "PHP Catchable fatal error: Object of class {className} could not be converted to string in ..." But for backward compatibility, if __toString is not implemented, it should return the old object id value, or the name of class of the object for example. I agree that nobody can rely on old ObjectId string, but there´s thousand scripts that stringfy data for logging, like this: function log($vars) { foreach($vars as $var) echo $var; } function test($a, $b) { log(func_get_args()); } Reproduce code: --------------- class Foo { } echo new Foo; Expected result: ---------------- Old behavior of conversion from object to string Actual result: -------------- Catchable fatal error: Object of class Foo could not be converted to string in ... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39392&edit=1

« previous php.bugs (#104467) next »