Skip to content

Commit

Permalink
[10.x] Make ComponentAttributeBag JsonSerializable (#48338)
Browse files Browse the repository at this point in the history
* [10.x] Make ComponentAttributeBag JsonSerializable

* Fix return type

* Explicit mixed return type

* Update ComponentAttributeBag.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
iamgergo and taylorotwell authored Sep 8, 2023
1 parent 3caca4c commit 00894b8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Illuminate/View/ComponentAttributeBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
use Illuminate\Support\Traits\Conditionable;
use Illuminate\Support\Traits\Macroable;
use IteratorAggregate;
use JsonSerializable;
use Traversable;

class ComponentAttributeBag implements ArrayAccess, Htmlable, IteratorAggregate
class ComponentAttributeBag implements ArrayAccess, IteratorAggregate, JsonSerializable, Htmlable
{
use Conditionable, Macroable;

Expand Down Expand Up @@ -455,6 +456,16 @@ public function getIterator(): Traversable
return new ArrayIterator($this->attributes);
}

/**
* Convert the object into a JSON serializable form.
*
* @return mixed
*/
public function jsonSerialize(): mixed
{
return $this->attributes;
}

/**
* Implode the attributes into a single HTML ready string.
*
Expand Down

0 comments on commit 00894b8

Please sign in to comment.