#44444 [NEW]: Error in array_unique when objects are values
| From: | pawel dot jacek dot matysiak at gmail dot com | Date: | Sun, 16 Mar 2008 12:33:29 +0000 |
| Subject: | #44444 [NEW]: Error in array_unique when objects are values | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-123345@lists.php.net to get a copy of this message | ||
From: pawel dot jacek dot matysiak at gmail dot com
Operating system: Windows XP
PHP version: 5.2.5
PHP Bug Type: Arrays related
Bug description: Error in array_unique when objects are values
Description:
------------
I've encountered a problem when working with array of objects and using
mentioned library function array_unique. It just doesn't work.
Reproduce code:
---------------
<?php
class Test
{
public $x;
public function __construct($x)
{
$this->x = $x;
}
}
$temp[] = new Test(1);
$temp[] = new Test(1);
var_dump($temp);
$temp2 = array_unique($temp);
var_dump($temp2);
?>
Expected result:
----------------
I expected the function to return the array with only one object. It could
return unchanged array but I think it would not make any sense.
Actual result:
--------------
error: Catchable fatal error: Object of class Test could not be converted
to string in test.php on line 13
--
Edit bug report at http://bugs.php.net/?id=44444&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44444&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44444&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44444&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44444&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=44444&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44444&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44444&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44444&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44444&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44444&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=44444&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=44444&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44444&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44444&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44444&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44444&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44444&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44444&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44444&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44444&r=mysqlcfg