|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchessortable_interface (last revision 2015-02-22 21:36 UTC by thomas at gielfeldt dot dk)Pull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2015-02-23 00:35 UTC] requinix@php.net
[2015-02-23 06:29 UTC] thomas at gielfeldt dot dk
[2015-02-23 06:57 UTC] requinix@php.net
[2015-02-23 15:13 UTC] thomas at gielfeldt dot dk
[2015-02-24 20:10 UTC] requinix@php.net
[2020-11-17 12:59 UTC] cmb@php.net
-Status: Open
+Status: Suspended
[2020-11-17 12:59 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
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) } }