#43545 [Opn->Bgs]: Object cast to int failure, multiple versions
| From: | tony2001@php.net | Date: | Tue, 29 Jan 2008 00:46:11 +0000 |
| Subject: | #43545 [Opn->Bgs]: Object cast to int failure, multiple versions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-121686@lists.php.net to get a copy of this message | ||
ID: 43545
Updated by: tony2001@php.net
Reported By: mark at dynom dot nl
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Linux
PHP Version: 5.2.5
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2007-12-09 14:49:30] mark at dynom dot nl
Description:
------------
When comparing objects with integer types the notice:
"PHP Notice: Object of class Foo could not be converted to int in
Command line code on line 1"
is raised, this only happens when not using strict checks (== vs ===)
It has been tested on multiple builds 5.1.6, 5.2.2, 5.2.4 and 5.2.5.
Reproduce code:
---------------
FAILS
php -r 'error_reporting( E_ALL ); class Foo { } $foo = new Foo;
var_dump( in_array($foo, array(0)) );'
WORKS
php -r 'error_reporting( E_ALL ); class Foo { } $foo = new Foo;
var_dump( in_array($foo, array("foo")) );'
// More examples: http://pasteosaurus.com/44812
Expected result:
----------------
I exepected to get: bool(false)
Actual result:
--------------
$ php -r 'error_reporting( E_ALL ); class Foo { } $foo = new Foo; if
($foo == 1) {}';
Notice: Object of class Foo could not be converted to int in Command
line code on line 1
Call Stack:
0.0001 68456 1. {main}() Command line code:0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43545&edit=1