From:             oliver dot graetz at gmx dot de
Operating system: Windows XP
PHP version:      Irrelevant
PHP Bug Type:     Documentation problem
Bug description:  PHP violates type casting rules

Description:
------------
In the documentation under

http://php.net/manual/en/language.types.string.php#language.types.string.casting

it reads

"Objects are always converted to the string "Object"."

This is not true:

php -r "echo PHP_VERSION;echo new StdClass;"
5.2.2RC3-dev
Catchable fatal error: Object of class stdClass could not be converted to
string in Command line code on line 1

The documentation should be changed to:

"Objects are not converted to anything unless you define a __toString()
method. If you can't because you are using an engine internal class then
you are busted. This is especially annoying with functions like implode()
that stop working when their arguments contain such objects. Sorry for this
inconvenience but we refuse to listen to any bug report about this and
blindly change any complaint to BOGUS."

Of course the real fix would be providing the documented "Object" as
fallback instead of raising a recoverable error. But as my documentation
suggestion states: You are not listening. In my opinion the current
behaviour is a real showstopper.

For further nagging read http://bugs.php.net/bug.php?id=40799


Reproduce code:
---------------
echo new StdClass;


Expected result:
----------------
Object

Actual result:
--------------
Catchable fatal error: Object of class stdClass could not be converted to
string in Command line code on line 1

-- 
Edit bug report at http://bugs.php.net/?id=41221&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41221&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41221&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41221&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41221&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41221&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41221&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41221&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41221&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41221&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41221&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41221&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41221&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41221&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41221&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41221&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41221&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41221&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41221&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41221&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41221&r=mysqlcfg

Reply via email to