Skip to content

Commit

Permalink
only use and test SORT_NATURAL on PHP 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ceeram committed Apr 4, 2012
1 parent e5ca80b commit 7700a02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/Cake/Test/Case/Utility/HashTest.php
Expand Up @@ -1043,6 +1043,9 @@ public function testSortNumeric() {
* @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')),
Expand Down
7 changes: 5 additions & 2 deletions lib/Cake/Utility/Hash.php
Expand Up @@ -379,7 +379,7 @@ public static function combine(array $data, $keyPath, $valuePath = null, $groupP
/**
* Returns a formated series of values extracted from `$data`, using
* `$format` as the format and `$paths` as the values to extract.
*
*
* Usage:
*
* {{{
Expand Down Expand Up @@ -486,7 +486,7 @@ public static function check(array $data, $path) {
* 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
Expand Down Expand Up @@ -756,6 +756,9 @@ public static function sort(array $data, $path, $dir, $type = 'regular') {

$dir = strtolower($dir);
$type = strtolower($type);
if ($type == 'natural' && version_compare(PHP_VERSION, '5.4.0', '<')) {
$type == 'regular';

This comment has been minimized.

Copy link
@ceeram

ceeram Jan 25, 2013

Author Contributor

oops

}
if ($dir === 'asc') {
$dir = SORT_ASC;
} else {
Expand Down

0 comments on commit 7700a02

Please sign in to comment.