Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ public function implode($value, $glue = null)

$first = $this->first();

if (is_array($first) || (is_object($first) && ! $first instanceof Stringable)) {
if (is_array($first) || (is_object($first) && ! $first instanceof \Stringable)) {
return implode($glue ?? '', $this->pluck($value)->all());
}

Expand Down
8 changes: 8 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use stdClass;
use Symfony\Component\String\ByteString;
use Symfony\Component\VarDumper\VarDumper;
use Traversable;
use UnexpectedValueException;
Expand Down Expand Up @@ -2331,6 +2332,13 @@ public function testImplode($collection)
$this->assertSame('taylor-foo,dayle-bar', $data->implode(fn ($user) => $user['name'].'-'.$user['email'], ','));
}

#[DataProvider('collectionClassProvider')]
public function testImplodeStringable($collection)
{
$data = new $collection([new ByteString('taylor'), new ByteString('dayle')]);
$this->assertSame('taylordayle', $data->implode(''));
}

#[DataProvider('collectionClassProvider')]
public function testTake($collection)
{
Expand Down
Loading