cvs: ZendEngine2 / zend_operators.c /tests bug33999.phpt php-src NEWS

From: Date: Fri, 05 Aug 2005 09:02:15 +0000
Subject: cvs: ZendEngine2 / zend_operators.c /tests bug33999.phpt php-src NEWS
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-3974@lists.php.net to get a copy of this message
dmitry Fri Aug 5 05:02:15 2005 EDT Added files: /ZendEngine2/tests bug33999.phpt Modified files: /php-src NEWS /ZendEngine2 zend_operators.c Log: Fixed bug #33999 (object remains object when cast to int) http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2019&r2=1.2020&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.2019 php-src/NEWS:1.2020 --- php-src/NEWS:1.2019 Thu Aug 4 06:34:37 2005 +++ php-src/NEWS Fri Aug 5 05:02:08 2005 @@ -1,6 +1,7 @@ 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) http://cvs.php.net/diff.php/ZendEngine2/zend_operators.c?r1=1.207&r2=1.208&ty=u Index: ZendEngine2/zend_operators.c diff -u ZendEngine2/zend_operators.c:1.207 ZendEngine2/zend_operators.c:1.208 --- ZendEngine2/zend_operators.c:1.207 Wed Aug 3 09:30:56 2005 +++ ZendEngine2/zend_operators.c Fri Aug 5 05:02:14 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_operators.c,v 1.207 2005/08/03 13:30:56 sniper Exp $ */ +/* $Id: zend_operators.c,v 1.208 2005/08/05 09:02:14 dmitry Exp $ */ #include <ctype.h> @@ -338,13 +338,12 @@ 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"); @@ -1319,7 +1318,7 @@ 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); http://cvs.php.net/co.php/ZendEngine2/tests/bug33999.phpt?r=1.1&p=1 Index: ZendEngine2/tests/bug33999.phpt +++ ZendEngine2/tests/bug33999.phpt --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)

« previous php.zend-engine.cvs (#3974) next »