From:             crywolf at kyndimarion dot net
Operating system: Linux
PHP version:      5.0.3
PHP Bug Type:     Class/Object related
Bug description:  object remains object when cast to int

Description:
------------
When attempting to cast an object to an int, it remains untouched.  No
warnings or errors are displayed.  The results are the same for (int),
intval(), and settype().  float, bool, string, and array all seem to work
correctly.  I get the same results in both 5.0.3 and 5.1.0b3.  In 4.3.11,
an object can be cast to int.


Reproduce code:
---------------
<?php
error_reporting(E_ALL);

class Foo {
var $bar = "bat";
}

$foo = new Foo;
var_dump($foo);

$bar = (int)$foo;
var_dump($bar);

$baz = (float)$foo;
var_dump($baz);

?>


Expected result:
----------------
object(Foo)#1 (1) {
  ["bar"]=>
  string(3) "bat"
}
int(1)
float(1)

Actual result:
--------------
object(Foo)#1 (1) {
  ["bar"]=>
  string(3) "bat"
}
object(Foo)#1 (1) {
  ["bar"]=>
  string(3) "bat"
}

Notice: Object of class Foo could not be converted to double in
/home/crywolf/Test/cast_object.php on line 14
float(1)

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

Reply via email to