Skip to content

Commit 455b343

Browse files
authored
Fix the dump method for LazyCollection (#33944)
1 parent 28f847f commit 455b343

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/Illuminate/Support/Traits/EnumeratesValues.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ public function dd(...$args)
181181
*/
182182
public function dump()
183183
{
184-
(new static(func_get_args()))
185-
->push($this)
184+
(new Collection(func_get_args()))
185+
->push($this->all())
186186
->each(function ($item) {
187187
VarDumper::dump($item);
188188
});

tests/Support/SupportCollectionTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPUnit\Framework\TestCase;
1919
use ReflectionClass;
2020
use stdClass;
21+
use Symfony\Component\VarDumper\VarDumper;
2122

2223
class SupportCollectionTest extends TestCase
2324
{
@@ -3419,6 +3420,24 @@ public function testConcatWithCollection($collection)
34193420
$this->assertSame($expected, $actual);
34203421
}
34213422

3423+
/**
3424+
* @dataProvider collectionClassProvider
3425+
*/
3426+
public function testDump($collection)
3427+
{
3428+
$log = new Collection();
3429+
3430+
VarDumper::setHandler(function ($value) use ($log) {
3431+
$log->add($value);
3432+
});
3433+
3434+
(new $collection([1, 2, 3]))->dump('one', 'two');
3435+
3436+
$this->assertSame(['one', 'two', [1, 2, 3]], $log->all());
3437+
3438+
VarDumper::setHandler(null);
3439+
}
3440+
34223441
/**
34233442
* @dataProvider collectionClassProvider
34243443
*/

0 commit comments

Comments
 (0)