PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2005, PHP 5.1
+- Fixed bug #33999 (object remains object when cast to int). (Dmitry)
- Fixed bug #33989 (extract($GLOBALS,EXTR_REFS) crashes PHP). (Dmitry)
- Fixed bug #33967 (misuse of Exception constructor doesn't display errorfile).
(Jani)
--- /dev/null
+--TEST--
+Bug #33999 (object remains object when cast to int)
+--INI--
+error_reporting=4095
+--FILE--
+<?php
+class Foo {
+ public $bar = "bat";
+}
+
+$foo = new Foo;
+var_dump($foo);
+
+$bar = (int)$foo;
+var_dump($bar);
+
+$baz = (float)$foo;
+var_dump($baz);
+?>
+--EXPECTF--
+object(Foo)#1 (1) {
+ ["bar"]=>
+ string(3) "bat"
+}
+
+Notice: Object of class Foo could not be converted to int in %sbug33999.php on line 9
+int(1)
+
+Notice: Object of class Foo could not be converted to double in %sbug33999.php on line 12
+float(1)
if (ht) {
retval = (zend_hash_num_elements(ht)?1:0);
}
- zval_dtor(op);
- ZVAL_LONG(op, retval);
- return;
} else {
- /* we cannot convert it to long */
- return;
+ zend_error(E_NOTICE, "Object of class %s could not be converted to int", Z_OBJCE_P(op)->name);
}
+ zval_dtor(op);
+ ZVAL_LONG(op, retval);
+ return;
}
default:
zend_error(E_WARNING, "Cannot convert to ordinal value");
zendi_smart_strcmp(result, op1, op2);
COMPARE_RETURN_AND_FREE(SUCCESS);
}
-
+
if (op1->type == IS_BOOL || op2->type == IS_BOOL
|| op1->type == IS_NULL || op2->type == IS_NULL) {
zendi_convert_to_boolean(op1, op1_copy, result);