mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
fc6edf4d9c
commit
79701af501
2 changed files with 4 additions and 3 deletions
|
@ -665,6 +665,9 @@ class HashTest extends CakeTestCase {
|
||||||
|
|
||||||
$data = array('one', 2 => 'two', 3 => 'three', 4 => 'four', 'a' => 'five');
|
$data = array('one', 2 => 'two', 3 => 'three', 4 => 'four', 'a' => 'five');
|
||||||
$this->assertFalse(Hash::numeric(array_keys($data)));
|
$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)) {
|
if (empty($data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$values = array_values($data);
|
return $data === array_filter($data, 'is_numeric');
|
||||||
$str = implode('', $values);
|
|
||||||
return (bool)ctype_digit($str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue