Skip to content
This repository was archived by the owner on Oct 26, 2024. It is now read-only.

Commit 3c26811

Browse files
lerua83maschmann
authored andcommitted
checking mutable $data variable on loop (#7)
Add fix for data not being an array
1 parent 8585ea1 commit 3c26811

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/Data/DataTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ private static function searchArray(array $args, array $data, $default = false)
256256
}
257257

258258
foreach ($args as $key) {
259-
if (array_key_exists($key, $data)) {
259+
if ((is_array($data)) && (array_key_exists($key, $data))) {
260260
$data = $data[$key];
261261
} else {
262262
$data = $default;

tests/Data/DataTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ public function testGet(Data $data)
113113

114114
// multi dimension array single value getter
115115
$mixResult = $data->get('testKey2', 'sub_test', 'subsubtest');
116-
117116
$this->assertEquals('subvalue', $mixResult);
118117

119118
// non existent keys
120119
$this->assertFalse($data->get('nothing'));
121120
$this->assertFalse($data->get('testKey2', 'nothing'));
121+
$this->assertFalse($data->get('testKey2', 'test', 'nothing'));
122122
$this->assertFalse($data->get('testKey2', 'sub_test', 'nothing'));
123123
$this->assertTrue(is_array($data->get('testKey2', 'sub_test', '')));
124124

0 commit comments

Comments
 (0)