#37811 [Asn->Csd]: define not using toString on objects
| From: | helly@php.net | Date: | Sun, 09 Jul 2006 22:45:47 +0000 |
| Subject: | #37811 [Asn->Csd]: define not using toString on objects | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-99258@lists.php.net to get a copy of this message | ||
ID: 37811
Updated by: helly@php.net
Reported By: php at trancer dot nl
-Status: Assigned
+Status: Closed
Bug Type: Scripting Engine problem
-Operating System: Any
+Operating System: *
-PHP Version: 5.1.4
+PHP Version: 5.1.*
Assigned To: helly
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2006-06-15 00:27:15] php at trancer dot nl
Description:
------------
PHP is using toString on most places to cast objects to string. However
define is not doing this. This seems somewhat of an oddity as objects
are casted in other functions aswell.
Possible fix to this problem was provided by bjori:
http://php.is/bugs/toString/define.call.toString.patch.txt
Reproduce code:
---------------
<?php
class foo
{
function __toString()
{
return "bar";
}
}
$foo = new foo();
define('COWBELL', $foo);
?>
Expected result:
----------------
It being properly defined using the toString function.
Actual result:
--------------
Warning: Constants may only evaluate to scalar values in test.php on
line 15
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37811&edit=1