ID:               37537
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Verified
 Bug Type:         Documentation problem
 Operating System: Any
 PHP Version:      PHP5.2.0
 New Comment:

I don't think it's *that* clear.

Consider that when you pass a "string" to %d guess what -> it works,
the string is converted to an int. But in case of an object, it does
not work this way automatically. If you would write (string)$obj it
again would work.

I don't consider this as clear as blue sky. :)


Previous Comments:
------------------------------------------------------------------------

[2006-05-29 11:52:53] [EMAIL PROTECTED]

No you shouldn't.
IMO it's quite clear that __toString wouldn't be called 
with %i or %e or anything else than %s. But I guess there 
is no harm in documenting that too..

------------------------------------------------------------------------

[2006-05-29 06:01:08] [EMAIL PROTECTED]

I had a small conversation with the autor on internals@ and it is very
important, because you gave the printf example, that __toString() will
only be called if an stirng modified %s is encountered. If it's %d for
integer, __toString() is not called.

This may or may not be expected, but it's the current implementation.
Should I file another report for it?

------------------------------------------------------------------------

[2006-05-26 12:13:46] [EMAIL PROTECTED]

http://php.net/oop5.magic#language.oop5.magic.tostring 
needs an updated before 5.2.0.

#1 Can't throw exceptions anymore
#2 Is called 'wherever it's appropriate' (e. 
printf("__toString: %s", $obj))

If language.exceptions will be updated to note where 
exceptions can't be thrown it'll need to note lot more then 
just __toString()

------------------------------------------------------------------------

[2006-05-21 05:27:56] [EMAIL PROTECTED]

Description:
------------
>From zend_object_handlers.c:

zend_error(E_ERROR, "Method %v::__toString() must not throw an
exception", ce->name);

This is due the recent changes that from now on __toString will be
called everywhere an object is used in a string context.

Good page candidates are:
http://de.php.net/manual/en/language.exceptions.php
http://de.php.net/manual/en/language.oop5.magic.php



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37537&edit=1

Reply via email to