Skip to content

Commit 619c25a

Browse files
authored
Revert "Support iterables objects on data_get nested arrays (#37443)"
This reverts commit 32ac02a.
1 parent 32ac02a commit 619c25a

File tree

2 files changed

+1
-26
lines changed

2 files changed

+1
-26
lines changed

src/Illuminate/Collections/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function data_get($target, $key, $default = null)
5858
if ($segment === '*') {
5959
if ($target instanceof Collection) {
6060
$target = $target->all();
61-
} elseif (! is_iterable($target)) {
61+
} elseif (! is_array($target)) {
6262
return value($default);
6363
}
6464

tests/Support/SupportHelpersTest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
namespace Illuminate\Tests\Support;
44

55
use ArrayAccess;
6-
use ArrayIterator;
76
use Illuminate\Contracts\Support\Htmlable;
87
use Illuminate\Support\Env;
98
use Illuminate\Support\Optional;
10-
use IteratorAggregate;
119
use LogicException;
1210
use Mockery as m;
1311
use PHPUnit\Framework\TestCase;
@@ -89,18 +87,10 @@ public function testDataGetWithNestedArrays()
8987
['name' => 'abigail'],
9088
['name' => 'dayle'],
9189
];
92-
$arrayIterable = new SupportTestArrayIterable([
93-
['name' => 'taylor', 'email' => 'taylorotwell@gmail.com'],
94-
['name' => 'abigail'],
95-
['name' => 'dayle'],
96-
]);
9790

9891
$this->assertEquals(['taylor', 'abigail', 'dayle'], data_get($array, '*.name'));
9992
$this->assertEquals(['taylorotwell@gmail.com', null, null], data_get($array, '*.email', 'irrelevant'));
10093

101-
$this->assertEquals(['taylor', 'abigail', 'dayle'], data_get($arrayIterable, '*.name'));
102-
$this->assertEquals(['taylorotwell@gmail.com', null, null], data_get($arrayIterable, '*.email', 'irrelevant'));
103-
10494
$array = [
10595
'users' => [
10696
['first' => 'taylor', 'last' => 'otwell', 'email' => 'taylorotwell@gmail.com'],
@@ -802,18 +792,3 @@ public function offsetUnset($offset)
802792
unset($this->attributes[$offset]);
803793
}
804794
}
805-
806-
class SupportTestArrayIterable implements IteratorAggregate
807-
{
808-
protected $items = [];
809-
810-
public function __construct($items = [])
811-
{
812-
$this->items = $items;
813-
}
814-
815-
public function getIterator()
816-
{
817-
return new ArrayIterator($this->items);
818-
}
819-
}

0 commit comments

Comments
 (0)