php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62976 Notice: could not be converted to int when comparing some builtin classes
Submitted: 2012-08-30 13:16 UTC Modified: 2012-08-31 03:23 UTC
From: ladislav at marek dot su Assigned: laruence (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.4Git-2012-08-30 (Git) OS: Linux
Private report: No CVE-ID: None
 [2012-08-30 13:16 UTC] ladislav at marek dot su
Description:
------------
Comparing instance of some builtin class with instance of different class issues 
notice: "Object of class ArrayObject could not be converted to int".


Test script:
---------------
new stdClass == new ArrayObject;
// but "new stdClass == new Exception" works without notice


Actual result:
--------------
Notice: Object of class ArrayObject could not be converted to int in Command line 
code on line 1

Notice: Object of class stdClass could not be converted to int in Command line 
code on line 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-30 16:13 UTC] laruence@php.net
Arrayobject is share the same object handlers as stdClass, but exception does.

anyway, I think there is a room to improve..
 [2012-08-30 17:40 UTC] reeze dot xia at gmail dot com
After the fix for #61326 ArrayObject have different compare_objects handler:
http://git.php.net/?p=php-
src.git;a=commit;h=23e65a9dcc71cf11ee5ec82c256588626545d4db

There is an test case the same as bug report:
https://github.com/php/php-src/blob/master/tests/lang/compare_objects_basic2.phpt

I agree with @laruence that it could be improved.
if both of the object couldn't be cast to compare. they ARE not equal.
 [2012-08-30 17:58 UTC] reeze dot xia at gmail dot com
Hi,
   I proposed a patch for this:
https://github.com/php/php-src/pull/179
 [2012-08-31 03:22 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5dc2cef370885c552c20f3ff44bccd402850de9e
Log: Fixed bug #62976 (Notice: could not be converted to int when comparing some builtin classes)
 [2012-08-31 03:23 UTC] laruence@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-08-31 03:23 UTC] laruence@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence
 [2012-08-31 03:24 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5dc2cef370885c552c20f3ff44bccd402850de9e
Log: Fixed bug #62976 (Notice: could not be converted to int when comparing some builtin classes)
 [2012-08-31 03:25 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5dc2cef370885c552c20f3ff44bccd402850de9e
Log: Fixed bug #62976 (Notice: could not be converted to int when comparing some builtin classes)
 [2014-10-07 23:22 UTC] stas@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=5dc2cef370885c552c20f3ff44bccd402850de9e
Log: Fixed bug #62976 (Notice: could not be converted to int when comparing some builtin classes)
 [2014-10-07 23:33 UTC] stas@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=5dc2cef370885c552c20f3ff44bccd402850de9e
Log: Fixed bug #62976 (Notice: could not be converted to int when comparing some builtin classes)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC