#37811 [NEW]: define not using toString on objects
| From: | php at trancer dot nl | Date: | Thu, 15 Jun 2006 00:27:15 +0000 |
| Subject: | #37811 [NEW]: define not using toString on objects | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-98381@lists.php.net to get a copy of this message | ||
From: php at trancer dot nl
Operating system: Any
PHP version: 5.1.4
PHP Bug Type: Scripting Engine problem
Bug description: define not using toString on objects
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 bug report at http://bugs.php.net/?id=37811&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37811&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37811&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37811&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37811&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37811&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37811&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37811&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37811&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37811&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37811&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37811&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37811&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37811&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37811&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37811&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37811&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37811&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37811&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37811&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37811&r=mysqlcfg