From 7700a0261bd2ffd1805be6e7b8d4f6060cb56845 Mon Sep 17 00:00:00 2001 From: Ceeram Date: Wed, 4 Apr 2012 18:21:52 +0200 Subject: [PATCH] only use and test SORT_NATURAL on PHP 5.4 --- lib/Cake/Test/Case/Utility/HashTest.php | 3 +++ lib/Cake/Utility/Hash.php | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index a8233137e..9f7e528da 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -1043,6 +1043,9 @@ class HashTest extends CakeTestCase { * @return void */ public function testSortNatural() { + if (version_compare(PHP_VERSION, '5.4.0', '<')) { + $this->markTestSkipped('SORT_NATURAL is available since PHP 5.4.'); + } $items = array( array('Item' => array('image' => 'img1.jpg')), array('Item' => array('image' => 'img99.jpg')), diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index b29eb8641..6b278159b 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -379,7 +379,7 @@ class Hash { /** * Returns a formated series of values extracted from `$data`, using * `$format` as the format and `$paths` as the values to extract. - * + * * Usage: * * {{{ @@ -486,7 +486,7 @@ class Hash { * Recursively filters a data set. * * @param array $data Either an array to filter, or value when in callback - * @param callable $callback A function to filter the data with. Defaults to + * @param callable $callback A function to filter the data with. Defaults to * `self::_filter()` Which strips out all non-zero empty values. * @return array Filtered array * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::filter @@ -756,6 +756,9 @@ class Hash { $dir = strtolower($dir); $type = strtolower($type); + if ($type == 'natural' && version_compare(PHP_VERSION, '5.4.0', '<')) { + $type == 'regular'; + } if ($dir === 'asc') { $dir = SORT_ASC; } else {