Negative numbers and other stringy forms of numbers should be accepted. The name Hash::numeric implies is_numeric which it now uses. Fixes #2478
@@ -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));
}
/**
@@ -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');