mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
parent
f250592fee
commit
889c1ebc09
4 changed files with 12 additions and 0 deletions
|
@ -928,6 +928,9 @@ class HashTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testSort() {
|
||||
$result = Hash::sort(array(), '{n}.name', 'asc');
|
||||
$this->assertEquals(array(), $result);
|
||||
|
||||
$a = array(
|
||||
0 => array(
|
||||
'Person' => array('name' => 'Jeff'),
|
||||
|
|
|
@ -225,6 +225,9 @@ class SetTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testSort() {
|
||||
$result = Set::sort(array(), '{n}.name', 'asc');
|
||||
$this->assertEquals(array(), $result);
|
||||
|
||||
$a = array(
|
||||
0 => array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))),
|
||||
1 => array('Person' => array('name' => 'Tracy'),'Friend' => array(array('name' => 'Lindsay')))
|
||||
|
|
|
@ -730,6 +730,9 @@ class Hash {
|
|||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::sort
|
||||
*/
|
||||
public static function sort(array $data, $path, $dir, $type = 'regular') {
|
||||
if (empty($data)) {
|
||||
return array();
|
||||
}
|
||||
$originalKeys = array_keys($data);
|
||||
$numeric = is_numeric(implode('', $originalKeys));
|
||||
if ($numeric) {
|
||||
|
|
|
@ -956,6 +956,9 @@ class Set {
|
|||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::sort
|
||||
*/
|
||||
public static function sort($data, $path, $dir) {
|
||||
if (empty($data)) {
|
||||
return $data;
|
||||
}
|
||||
$originalKeys = array_keys($data);
|
||||
$numeric = false;
|
||||
if (is_numeric(implode('', $originalKeys))) {
|
||||
|
|
Loading…
Reference in a new issue