Fix Hash::get($data, '0')

Fixes #3555
This commit is contained in:
mark_story 2013-01-21 20:50:46 -05:00
parent efadf3dcd3
commit 75495705a6
2 changed files with 9 additions and 1 deletions

View file

@ -170,6 +170,14 @@ class HashTest extends CakeTestCase {
* return void
*/
public function testGet() {
$data = array('abc', 'def');
$result = Hash::get($data, '0');
$this->assertEquals('abc', $result);
$result = Hash::get($data, '1');
$this->assertEquals('def', $result);
$data = self::articleData();
$result = Hash::get(array(), '1.Article.title');

View file

@ -39,7 +39,7 @@ class Hash {
* @return mixed The value fetched from the array, or null.
*/
public static function get(array $data, $path) {
if (empty($data) || empty($path)) {
if (empty($data)) {
return null;
}
if (is_string($path)) {