Make Hash::numeric() accept more numeric things.

Negative numbers and other stringy forms of numbers should be accepted.
The name Hash::numeric implies is_numeric which it now uses.

Fixes #2478
This commit is contained in:
mark_story 2013-12-12 17:41:38 -05:00
parent fc6edf4d9c
commit 79701af501
2 changed files with 4 additions and 3 deletions

View file

@ -665,6 +665,9 @@ class HashTest extends CakeTestCase {
$data = array('one', 2 => 'two', 3 => 'three', 4 => 'four', 'a' => 'five');
$this->assertFalse(Hash::numeric(array_keys($data)));
$data = array(2.4, 1, 0, -1, -2);
$this->assertTrue(Hash::numeric($data));
}
/**

View file

@ -626,9 +626,7 @@ class Hash {
if (empty($data)) {
return false;
}
$values = array_values($data);
$str = implode('', $values);
return (bool)ctype_digit($str);
return $data === array_filter($data, 'is_numeric');
}
/**