From af36f26dad805a8d866555c979e92a9e0e1fa8ea Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 18 Jan 2018 07:27:12 -0600 Subject: [PATCH] revert --- src/Illuminate/Support/Collection.php | 6 +++++- tests/Support/SupportCollectionTest.php | 21 --------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/Illuminate/Support/Collection.php b/src/Illuminate/Support/Collection.php index b30b18b57ab6..ea584fc0de85 100644 --- a/src/Illuminate/Support/Collection.php +++ b/src/Illuminate/Support/Collection.php @@ -644,7 +644,11 @@ public function forget($keys) */ public function get($key, $default = null) { - return is_null($key) ? null : Arr::get($this->items, $key, $default); + if ($this->offsetExists($key)) { + return $this->items[$key]; + } + + return value($default); } /** diff --git a/tests/Support/SupportCollectionTest.php b/tests/Support/SupportCollectionTest.php index 362126143190..0bb8c632b5b9 100755 --- a/tests/Support/SupportCollectionTest.php +++ b/tests/Support/SupportCollectionTest.php @@ -2465,27 +2465,6 @@ public function testUnlessDefault() $this->assertSame(['michael', 'tom', 'taylor'], $collection->toArray()); } - public function testGetNestedValue() - { - $collection = new Collection([ - 'foo' => [ - 'bar' => 'baz', - 'books' => [ - 'Book 1', - 'Book 2', - ], - 'todos' => [ - 'first' => 'Todo 1', - 'second' => 'Todo 2', - ], - ], - ]); - - $this->assertEquals('baz', $collection->get('foo.bar')); - $this->assertEquals('Book 1', $collection->get('foo.books.0')); - $this->assertEquals('Todo 2', $collection->get('foo.todos.second')); - } - public function testGetWithNullReturnsNull() { $collection = new Collection([1, 2, 3]);