File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -1073,7 +1073,7 @@ function __flatten($results, $key = null) {
1073
1073
if (!is_null ($ key )) {
1074
1074
$ id = $ key ;
1075
1075
}
1076
- if (is_array ($ r )) {
1076
+ if (is_array ($ r ) && count ( $ r ) ) {
1077
1077
$ stack = array_merge ($ stack , Set::__flatten ($ r , $ id ));
1078
1078
} else {
1079
1079
$ stack [] = array ('id ' => $ id , 'value ' => $ r );
Original file line number Diff line number Diff line change @@ -336,6 +336,21 @@ function testSort() {
336
336
);
337
337
$ a = Set::sort ($ a , '{n}.Person.name ' , 'ASC ' );
338
338
$ this ->assertIdentical ($ a , $ b );
339
+
340
+ $ names = array (
341
+ array ('employees ' => array (array ('name ' => array ('first ' => 'John ' , 'last ' => 'Doe ' )))),
342
+ array ('employees ' => array (array ('name ' => array ('first ' => 'Jane ' , 'last ' => 'Doe ' )))),
343
+ array ('employees ' => array (array ('name ' => array ()))),
344
+ array ('employees ' => array (array ('name ' => array ())))
345
+ );
346
+ $ result = Set::sort ($ names , '{n}.employees.0.name ' , 'asc ' , 1 );
347
+ $ expected = array (
348
+ array ('employees ' => array (array ('name ' => array ('first ' => 'John ' , 'last ' => 'Doe ' )))),
349
+ array ('employees ' => array (array ('name ' => array ('first ' => 'Jane ' , 'last ' => 'Doe ' )))),
350
+ array ('employees ' => array (array ('name ' => array ()))),
351
+ array ('employees ' => array (array ('name ' => array ())))
352
+ );
353
+ $ this ->assertEqual ($ result , $ expected );
339
354
}
340
355
/**
341
356
* testExtract method
You can’t perform that action at this time.
0 commit comments