Skip to content

Commit

Permalink
Fix Hash::get($data, '0')
Browse files Browse the repository at this point in the history
Fixes #3555
  • Loading branch information
markstory committed Jan 22, 2013
1 parent efadf3d commit 7549570
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/Cake/Test/Case/Utility/HashTest.php
Expand Up @@ -170,6 +170,14 @@ public static function userData() {
* 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');
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/Hash.php
Expand Up @@ -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)) {
Expand Down

0 comments on commit 7549570

Please sign in to comment.