Req #69106 [NEW]: Sortable interface
From: thomas at gielfeldt dot dk
Operating system: OSX
PHP version: Irrelevant
Package: SPL related
Bug Type: Feature/Change Request
Bug description:Sortable interface
Description:
------------
A new interface "Sortable" and implementation of it on ArrayObject and
ArrayIterator.
I could only get 5.6.3 to compile on my setup, so I hope someone can
"port" it to 5.6. I've also made some unit tests for the new feature.
I'm not sure if my implementation is "the best solution" (tm), but I
hope that I've at least done some footwork.
Test script:
---------------
$o = new ArrayObject(array(3,2,1));
var_dump($o);
sort($o);
var_dump($o);
Expected result:
----------------
object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(3) {
[0]=>
int(3)
[1]=>
int(2)
[2]=>
int(1)
}
}
object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
}
Actual result:
--------------
class ArrayObject#1 (1) {
private $storage =>
array(3) {
[0] =>
int(3)
[1] =>
int(2)
[2] =>
int(1)
}
}
Warning: sort() expects parameter 1 to be array, object given in
/Users/thomas/develop/php-src/mytest.php on line 6
Call Stack:
0.0010 226384 1. {main}()
/Users/thomas/develop/php-src/mytest.php:0
0.0030 228384 2. sort()
/Users/thomas/develop/php-src/mytest.php:6
class ArrayObject#1 (1) {
private $storage =>
array(3) {
[0] =>
int(3)
[1] =>
int(2)
[2] =>
int(1)
}
}
--
Edit bug report at https://bugs.php.net/bug.php?id=69106&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69106&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69106&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69106&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69106&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69106&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69106&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69106&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69106&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69106&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69106&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69106&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69106&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69106&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69106&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69106&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69106&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69106&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69106&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69106&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69106&r=mysqlcfg
Thread (7 messages)
- thomas at gielfeldt dot dk