php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47045 Bug when comparing SplObjectStorage instances
Submitted: 2009-01-09 10:21 UTC Modified: 2009-01-14 15:53 UTC
From: karsten at typo3 dot org Assigned: colder (profile)
Status: Closed Package: SPL related
PHP Version: 5.3.0alpha3 OS: Mac OS X 10.5.6
Private report: No CVE-ID: None
 [2009-01-09 10:21 UTC] karsten at typo3 dot org
Description:
------------
Two instances of SplObjectStorage should be considered equal only if 
they contain the same objects, when using == for comparison.

Reproduce code:
---------------
<?php
$someObject = new \stdClass();

$objectStorage = new \SplObjectStorage();
$objectStorage1 = new \SplObjectStorage();

var_dump($objectStorage === $objectStorage1); // FALSE, fine
var_dump($objectStorage == $objectStorage1); // TRUE, fine

$objectStorage->attach($someObject);

var_dump($objectStorage === $objectStorage1); // FALSE, fine
var_dump($objectStorage == $objectStorage1); // TRUE, huh?

$objectStorage1->attach($someObject);

var_dump($objectStorage === $objectStorage1); // FALSE, fine
var_dump($objectStorage == $objectStorage1); // TRUE, fine

?>


Expected result:
----------------
bool(false)
bool(true)
bool(false)
bool(false)
bool(false)
bool(true)


Actual result:
--------------
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-14 15:53 UTC] colder@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 09:01:30 2024 UTC