From: jason at amp-design dot net Operating system: CentOS PHP version: 5.0.4 PHP Bug Type: Zend Engine 2 problem Bug description: objects cast as string explictly require a __toString when __call is defined
Description: ------------ This produces an error that should not happen. Instead, when you cast an object to a string that has no __toString defined, it should produce the objects internal ID. Oddly enough, the behaviour is inconsistent as ... class A { public function __call($name, $args) {echo $name;} } echo (new A); seems to work as expected. I can't see how this should behave differently from dereferencing from a variable. I guess the behaviour of string casting is undefined for objects that do not have __toString() defined, so I guess it is debateable if this is really a bug, or a querky language "feature" ;-) Note that this will work if one returns a value for __call(). Reproduce code: --------------- <?php class A { public function __call($name, $args) {echo $name;} } $a = new A; echo $a; ?> Expected result: ---------------- Object id #insert_number_here Actual result: -------------- __tostring Fatal error: Method A::__toString() must return a string value in /data/test.php on line 21 -- Edit bug report at http://bugs.php.net/?id=32638&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32638&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32638&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32638&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32638&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32638&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32638&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32638&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32638&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32638&r=support Expected behavior: http://bugs.php.net/fix.php?id=32638&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32638&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32638&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32638&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32638&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32638&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32638&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32638&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32638&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32638&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32638&r=mysqlcfg