#43545 [NEW]: Object cast to int failure, multiple versions
| From: | mark at dynom dot nl | Date: | Sun, 09 Dec 2007 14:49:30 +0000 |
| Subject: | #43545 [NEW]: Object cast to int failure, multiple versions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-120495@lists.php.net to get a copy of this message | ||
From: mark at dynom dot nl
Operating system: Linux
PHP version: 5.2.5
PHP Bug Type: Unknown/Other Function
Bug description: Object cast to int failure, multiple versions
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 bug report at http://bugs.php.net/?id=43545&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43545&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43545&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43545&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43545&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43545&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=43545&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43545&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43545&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43545&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43545&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43545&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=43545&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=43545&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43545&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43545&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43545&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43545&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43545&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43545&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43545&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43545&r=mysqlcfg